The talib.ROCR()
function is used to calculate the Rate of change ratio: (price/prevPrice) (price change ratio).
The return value of the talib.ROCR()
function is a one-dimensional array.
array
talib.ROCR(inReal) talib.ROCR(inReal, optInTimePeriod)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The optInTimePeriod
parameter is used to set the period, the default value is 10.
optInTimePeriod
false
number
function main() {
var records = exchange.GetRecords()
var ret = talib.ROCR(records)
Log(ret)
}
import talib
def main():
records = exchange.GetRecords()
ret = talib.ROCR(records.Close)
Log(ret)
void main() {
auto records = exchange.GetRecords();
auto ret = talib.ROCR(records);
Log(ret);
}
The ROCR()
function is described in the talib library documentation as: ROCR(Records[Close],Time Period = 10) = Array(outReal)