may i get "Execute on bar open" scripts ?

 

i tried this code :

extern bool CheckOncePerBar = true;
datetime CurrentTimeStamp;
                if(CheckOncePerBar == true)
                        {
                                int BarShift = 1;
                                if(CurrentTimeStamp != Time[0]) 
                                        {
                                                CurrentTimeStamp = Time[0];
                                                bool NewBar = true;
                                        }
                                else NewBar = false;
                        }
                else 
                        {
                                NewBar = true;
                                BarShift = 0;
                        }

 i dunno why but it's execute on the second bar since the pattern show . 

thanks !  

 
Is CurrentTimeStamp global?
 
yes, i toghut thats mabye the problem came from "BarShift".
 
vushel:
yes, i toghut thats mabye the problem came from "BarShift".
No idea,  we don't know what you are doing with   NewBar  or  BarShift . . . .
 

if (  signalbuy==1 && (Time[0] > last_time|| CheckOncePerBar==false) )
{ OrderSend( Symbol(),OP_BUY,Ask, ........................ ) ; 
last_time = Time[0]; 
}

	          
 
WDholic:
Time[0] > last_time|| ...
Use Time[0] != last_time. A post several years ago, reported the the broker messed up server time (current time, wrong date). When the fixed it, the EA stopped trading for several days.
 
WHRoeder:
Use Time[0] != last_time. A post several years ago, reported the the broker messed up server time (current time, wrong date). When the fixed it, the EA stopped trading for several days.

thanks..  i never know that a broker can  messed up server time.. :-)