mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-17 10:08:05 +00:00
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
31 lines
852 B
Plaintext
31 lines
852 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Rate of Change Ratio (ROCR)", "ROCR", overlay=false)
|
|
|
|
//@function Calculates ratio between current price and N periods ago
|
|
//@param source Source price series
|
|
//@param length Lookback period
|
|
//@returns Price ratio value
|
|
rocr(series float source, simple int length)=>
|
|
if length<=0
|
|
runtime.error("Length must be greater than 0")
|
|
var int count = 0
|
|
float ratio = na
|
|
if not na(source[count]) and source[count] != 0
|
|
ratio := source / source[count]
|
|
count := math.min(count + 1, length)
|
|
ratio
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input.source(close, "Source")
|
|
i_length = input.int(9, "Length", minval=1)
|
|
|
|
// Calculate ROCR
|
|
float rocr_val = rocr(i_source, i_length)
|
|
|
|
// Plot
|
|
plot(rocr_val, "ROCR", color=color.yellow, linewidth=2)
|