need help in counting bars - page 2

 
05121981:


 yes i know but this is only for testing ea. i use it on M1 & M5. thank for informing. 

 Deviation*Point   is 100 * Point in those timeframes most candels are not that big

 
deVries:

 Deviation*Point   is 100 * Point in those timeframes most candels are not that big

 


  i use it for margin in case the prices is still going up or going down..  as you can see when the Close[0] in my code is above valHigh they will convert it to valLow from that point if Close[0] is still going up and reach the margin  buy signal will be true (this is only on my prediction), so that if the prices is still going up only buy signal is true & vice versa to the other side.
 
05121981:

  i use it for margin in case the prices is still going up or going down..  as you can see when the Close[0] in my code is above valHigh they will convert it to valLow from that point if Close[0] is still going up and reach the margin  buy signal will be true (this is only on my prediction), so that if the prices is still going up only buy signal is true & vice versa to the other side.

deVries:

 Deviation*Point   is 100 * Point in those timeframes most candels are not that big

 


  thanks for your time guys i found solution to my problem.. 

  int PrevBars;

  int int()  PrevBars=Bars;

  int start()

 {  if(Bars-Prevbars>0) i++;

  .. then my code here... 

  PrevBars=Bars; 

   }

 
05121981:


  thanks for your time guys i found solution to my problem.. 

  int PrevBars;

  int int()  PrevBars=Bars;

  int start()

 {  if(Bars-Prevbars>0) i++;

  .. then my code here... 

  PrevBars=Bars; 

   }

Use   SRC   button for displaying code
Bars can reach its maximum so its not reliable

search for  "once per bar"   as WHRoeder suggested for other way once per bar 

 
05121981:



Please edit your posts and use SRC button as already asked !
 
deVries:

Use   SRC   button for displaying code
Bars can reach its maximum so its not reliable

search for  "once per bar"   as WHRoeder suggested for other way once per bar 

 

 


  i found this code... i think this is more reliable..
int start()
  {
//----
   if(Fun_New_Bar() == true)
   {
      NewBar++;
      Print("New Bar ",NewBar);
   }
   return(0);
  }

// Identify new bars
   bool Fun_New_Bar()
      {
      static datetime New_Time = 0;
      bool New_Bar = false;
      if (New_Time!= Time[0])
         {
         New_Time = Time[0];
         New_Bar = true;
         }
      return(New_Bar);
      }
 
05121981:

  i found this code... i think this is more reliable..


It is....   might be you still have to do i++;  in your code

at position  

      NewBar++;
      Print("New Bar ",NewBar);
 
deVries:


It is....   might be you still have to do i++;  in your code

at position  

 


   yes i still need to count the bars.. i want to put additional condition on the certain count.. but first i need to adjust my codes..   thanks guys for the advice.
Reason: