Confirmed your promble, We will handle it as soon as possible.
Hi, please help me. I want to define reactive state function for CCI (Commodity Channel Index). But I can not use function mmad in the definition. Please help me define it.
reference for CCI formula is from here. https://school.stockcharts.com/doku.php?id=technical_indicators:commodity_channel_index_cci
Code:
@state
def cci(high,low,close,timeP){
tp=rowAvg(high,low,close)
dev=mmad(tp,timeP)
sma=mavg(tp,timeP)
return (tp-sma)/(0.015* dev)
}
The function is:
def mmadas(tp,sma,timeP){
return moving(def(x,y)->avg(abs(x - y.last())), [tp, sma], timeP)
}
def cci(high,low,close,timeP){
tp=rowAvg(high,low,close)
sma=mavg(tp,timeP)
dev=mmadas(tp,sma,timeP)
return (tp-sma)/(0.015* dev)
}
Testing script is :
login(`admin,`123456)
dataFilePath = "D:/data/cs-cci.csv"
tmpTB = loadText(dataFilePath)
a = select Date, rowAvg(high,low,close) as tp,mavg(rowAvg(high,low,close),20) as sma from tmpTB
def mmadas(tp,sma,timeP){
return moving(def(x,y)->avg(abs(x - y.last())), [tp, sma], timeP)
}
select Date, mmadas(tp,sma,20) as dev from
The test data is in the attachment.