Navigation´╝ÜHome > Content >

NRTR_ATR_STOP.mq4

Time: 2013-12-14 | Download file:NRTR_ATR_STOP.mq4

//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers  2
#property indicator_color1 Blue
#property indicator_color2 Red

extern int ATR=50;
extern int Coeficient=3;

double Up[],Dn[];
//+------------------------------------------------------------------+
int init()
{
  SetIndexBuffer(0,Up);
  SetIndexStyle (0,DRAW_LINE);
  SetIndexEmptyValue(0,0.0);
  SetIndexLabel (0,"Up");

  SetIndexBuffer(1,Dn);
  SetIndexStyle (1,DRAW_LINE);
  SetIndexEmptyValue(1,0.0);
  SetIndexLabel (1,"Dn");

  return(0);
}
int deinit() { return(0); }
//+------------------------------------------------------------------+
int start()
{
  int i,limit;
  double REZ;
  string MODE="UP";

  limit=Bars-ATR;
  for(i=limit; i>=0; i--)
  {
    Dn[i]=0; Up[i]=0;
    REZ=Coeficient*iATR(NULL,0,ATR,i);
    if(MODE=="DOWN" &&  Low[i]>Dn[i+1]) { Up[i+1]= Low[i+1]-REZ; MODE="UP";   }
    if(MODE=="UP"   && High[i]Up[i+1]+REZ) Up[i]=Low[i+1]-REZ;
		  else Up[i]=Up[i+1];
		}

    if(MODE=="DOWN")
    {
     	if(High[i+1]        

Recommend