Can't find the corresponding reactive state function for sequence sensitive function mmad

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) 

 }

请先 登录 后评论

2 个回答

YcHan韩迎春

Confirmed your promble, We will handle it as soon as possible.

请先 登录 后评论
naxi

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.

acs-cci.csv



请先 登录 后评论
  • 2 关注
  • 0 收藏,1185 浏览
  • Vishvesh Upadhyay 提出于 2021-10-05 20:13

相似问题