//+------------------------------------------------------------------+ //| ATR_Ratio_v2.mq4 | //+------------------------------------------------------------------+ //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 LightSeaGreen #property indicator_color2 Purple #property indicator_level1 1 #property indicator_minimum 0.5 #property indicator_maximum 1.5 //---- indicator parameters extern int FastATR_Period = 5; extern int SlowATR_Period = 14; extern int ShowBars = 500; //---- indicator buffers double ATRFast[],ATRSlow[]; double ATR_Ratio_Buffer[]; double ATRFastDev[],ATRSlowDev[]; double ATRDev_Ratio_Buffer[]; int draw_begin0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- additional buffer used for counting. IndicatorBuffers(6); //---- drawing settings draw_begin0 = SlowATR_Period; SetIndexEmptyValue(0,0.0000); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1); SetIndexBuffer(0,ATR_Ratio_Buffer); SetIndexLabel(0,"ATRFast/ATRSlow"); SetIndexDrawBegin(0,draw_begin0); SetIndexEmptyValue(1,0.0000); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); SetIndexBuffer(1,ATRDev_Ratio_Buffer); SetIndexLabel(1,"ATRFastDev/ATRSlowDev"); SetIndexDrawBegin(1,draw_begin0); SetIndexStyle(2,DRAW_NONE); SetIndexBuffer(2,ATRFast); SetIndexStyle(3,DRAW_NONE); SetIndexBuffer(3,ATRSlow); SetIndexStyle(4,DRAW_NONE); SetIndexBuffer(4,ATRFastDev); SetIndexStyle(5,DRAW_NONE); SetIndexBuffer(5,ATRSlowDev); //---- name for DataWindow and indicator subwindow label IndicatorShortName("ATR_Ratio_v2"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int limit,i,shift; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<1) for(i=1;i<=draw_begin0;i++) ATRDev_Ratio_Buffer[Bars-i]=0; ATR_Ratio_Buffer[Bars-i]=0; //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; //limit=Bars-counted_bars; limit = ShowBars; if (ShowBars >= Bars) limit = Bars - 1; //----------------------------------------------------------------------------------------------------------------- //---- preadxbuffer for(i=0; i