need code for ATR (Average True Range) to use with Reactive State Engine

Hi, I have tried coding ATR but did not have success. I have code for TR (as trueRange can not be used with Reactive State Engine).

@state
def tr(high, low, close) {
	cp=prev(close)
	return rowMax(abs(high-low),abs(high-cp),abs(low-cp))
}

I am calculating ATR based on  https://school.stockcharts.com/doku.php?id=technical_indicators:average_true_range_atr

check their excel file for formula  https://school.stockcharts.com/lib/exe/fetch.php?media=technical_indicators:average_true_range_atr:cs-atr.xls

please provide me code to use with Reactive State Engine.

请先 登录 后评论

1 个回答

Shena Mao

Sorry for late response.

I want to confirm whether your ATR is always based on daily market price? Because if it's not based on a high-frequency market data, I don't think you need to use reactive State Engine to realize ATR.

According to the formula you refered, it was difficult to deal with streaming data. 

For now, I suggest that you calculate ATR based on historical data if you do not need to use high-frequency streaming data.

请先 登录 后评论
  • 1 关注
  • 0 收藏,996 浏览
  • Vishvesh Upadhyay 提出于 2021-09-16 22:17

相似问题