ERROR: Usage: ema(X, window). window must be at least 2

When I run this code it gives me error Usage: ema(X, window). window must be at least 2

version: 1.30.16

@state

defg atr1(high,low,close,atr_tp){

mf_atr = 2 * atr_tp - 1

tr = rowMax(abs(high-low),abs(high-prev(close)),abs(low-prev(close)))

atr_inc = ema(tr, (mf_atr))

return (atr_inc)

}

select *, atr(high,low,close,atr_tp) from tmp

tmp = table(100:0,`symbol`open`high`low`close,[SYMBOL,DOUBLE,DOUBLE,DOUBLE ,DOUBLE])

op1 = table(100:0,`symbol`atr,[SYMBOL,DOUBLE])

atr=createReactiveStateEngine(name="atr",metrics=<[atr1(high,low,close,7)]>,dummyTable =tmp,outputTable=op1,keyColumn=`symbol);


If I use ema( x, ( 2 * atr_tp - 1) instead of using mf_atr it sometimes work.
请先 登录 后评论

1 个回答

mhxiang

use mf_atr = int(2 * atr_tp - 1) instead of using mf_atr =2 * atr_tp - 1

请先 登录 后评论
  • 1 关注
  • 0 收藏,951 浏览
  • Vishvesh Upadhyay 提出于 2022-02-16 23:11

相似问题