The talib.ROCP()
function is used to calculate Rate of change Percentage: (price-prevPrice)/prevPrice (rate of price change).
The return value of the talib.ROCP()
function is: a one-dimensional array.
array
talib.ROCP(inReal) talib.ROCP(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.ROCP(records)
Log(ret)
}
import talib
def main():
records = exchange.GetRecords()
ret = talib.ROCP(records.Close)
Log(ret)
void main() {
auto records = exchange.GetRecords();
auto ret = talib.ROCP(records);
Log(ret);
}
The ROCP()
function is described in the talib library documentation as: ROCP(Records[Close],Time Period = 10) = Array(outReal)