/* NRTR_ATR_STOP Coder: Nikolay Khrushchev MqlLab.ru */ #property copyright "MqlLab.ru" #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_color1 clrBlue #property indicator_color2 clrRed input int ATR = 20; input int Coeficient = 2; double Up[], Dn[]; string MODE; int atr_handle; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< int OnInit() { SetIndexBuffer(0, Up); PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE); PlotIndexSetInteger(0,PLOT_LINE_WIDTH,2); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(0,PLOT_LABEL,"Up"); SetIndexBuffer(1, Dn); PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_LINE); PlotIndexSetInteger(1,PLOT_LINE_WIDTH,2); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(1,PLOT_LABEL,"Dn"); atr_handle=iATR(Symbol(),0,ATR); //---- return(INIT_SUCCEEDED); } //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { double atr[]; int i, limit; double REZ; limit=prev_calculated-1; if(prev_calculated==0) { limit=ATR+1; CopyBuffer(atr_handle,0,rates_total-limit-1,1,atr); REZ = Coeficient*atr[0]; Up[limit]=low[limit]-REZ; Dn[limit]=0; MODE = "UP"; limit++; } for(i=limit;i Dn[i-1]) { Up[i-1] = low[i-1] - REZ; MODE = "UP"; } //---- if(MODE == "UP" && high[i-1] < Up[i-1]) { Dn[i-1] = high[i-1] + REZ; MODE = "DN"; } //---- if(MODE=="UP") { if(low[i-1] > Up[i-1] + REZ) { Up[i] = low[i-1] - REZ; Dn[i] = 0; }else{ Up[i] = Up[i-1]; Dn[i] = 0; } } //---- if(MODE=="DN") { if(high[i-1] < Dn[i-1] - REZ) { Dn[i] = high[i-1] + REZ; Up[i] = 0; }else{ Dn[i] = Dn[i-1]; Up[i] = 0; } } } return(rates_total); } //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<