自己写的ATR不能实时更新
#property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DeepSkyBlue #property indicator_color2 Gold #property indicator_width1 1 #property indicator_width2 2 extern int periods = 14; double TR[]; double ATR[]; int init() { IndicatorDigits(Digits+1); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,TR); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ATR); IndicatorShortName("MyATR"); SetIndexLabel(0,"TR"); SetIndexLabel(1,"ATR"); return(0); } int start() { int counted_bars = IndicatorCounted(); if(counted_bars > 0) counted_bars--; int remanent_bars = Bars - counted_bars; int i; for(i = 0; i < remanent_bars; i++) TR[i] = MAX(High[i] - Low[i], High[i] - Close[i + 1], Close[i + 1] - Low[i]); for(i = 0; i < remanent_bars; i++) ATR[i] = iMAonArray(TR,Bars,periods,0,MODE_SMA,i); return(0); } double MAX(double x, double y, double z) { if(x < y) x = y; if(x < z) x = z; return(x); } 有两个问题: 1. 指标只能在加载的时候执行一次,不能随新K线的出现一起更新。 2. 图表上只有波幅TR,没有均线ATR[]。 请问该怎么修改? |
打赏
最新创建圈子
- 新闻EA运行效果图圈 2019-05-05
圈主:admin 帖子:1