Download MetaTrader 5

I want to know what is the difference between two sections of codes in Indicator

To add comments, please log in or register
Fa Cao
1141
Fa Cao  

The below codes are in Indicator, and I want to know the difference when I change a little

About this Indicator, I don't want to draw any indicator in Terminal, I just want to select some points in Indicator and call this indicator in EA by iCustom();

Below codes include two case: one case is just as the below codes, another case is delete all "//" in the below codes; I test the two cases, very different, in the fact I want to know why? In indicator, " int Counted_Bars=IndicatorCounted();" must be used?

extern int Seek_Period=15,Mini_Swing=60,Trade_Range=90;
double Call[1];         

int init()
{
   SetIndexBuffer(0,Call);
   return(0);
}
int deinit()
{
   return(0);
}

int start()
{  
   if(Bars<=Seek_Period) return(0);
  // int Counted_Bars=IndicatorCounted();
  // if(Counted_Bars==0) Counted_Bars--;
  // int Limit=Bars-Counted_Bars;
   ArrayInitialize(Call,0.0);
  // for(int i=Limit-1;i>0;i--)
 // {
  int P_CNT=Seek_Period;
   int G_i=iHighest(NULL,0,MODE_HIGH,P_CNT,0); /* the second case: the last 0 of this line should be i;*/
    double High_Refer_P=High[iHighest(NULL,0,MODE_HIGH,10,G_i-5)],Low_Refer_P=Low[iLowest(NULL,0,MODE_LOW,G_i,0)];
    double HL_Current_P=High[iHighest(NULL,0,MODE_HIGH,3,0)]; 
    if(
       G_i>=5&&MathAbs(High_Refer_P-High[G_i])<Point&&High[G_i]-Low_Refer_P>=Mini_Swing*Point&&HL_Current_P!=High[0]
      &&HL_Current_P>=High[G_i]-Trade_Range*Point/2&&HL_Current_P<=High[G_i]+Trade_Range*Point&&Close[0]<Low[1]  
        )  {Call[0]=High[G_i];}
 //  }

   return(0);
}
Ubzen
5394
Ubzen  

vx0532: In indicator, " int Counted_Bars=IndicatorCounted();" must be used?

You do-not have to use IndictorCounted() if you do-not want. Do you understand the reason IndicatorCounted() is used?
Ian Venner
2584
Ian Venner  
vx0532:

Below codes include two case: one case is just as the below codes, another case is delete all "//" in the below codes; I test the two cases, very different, in the fact I want to know why? In indicator, " int Counted_Bars=IndicatorCounted();" must be used?

Of course its very different, if you took the back off your tv and pulled out some random parts without having first learned what they do would you expect the tv to work the same as before ?

I recommend you read Creation of Custom Indicators. There is a section all about IndicatorCounted().

okwh
1637
okwh  

why is come from how to change with time changing.

suggest to read https://book.mql4.com/samples/icustom to understand the relation between of time and index i

Fa Cao
1141
Fa Cao  
Thanks all.
To add comments, please log in or register