ankit29030:
here is my code::-----
want this to be run only on start of new bar once....not on each tick of the 0th candle being formed..
Remember the time for bar 1
Check the time of bar 1 if is the same as the time you remembered it has not changed . . . if it is different you have a new bar, before you move on remember this new time for bar 1 . . . then do the stuff you wanted to do once per new bar.
ankit29030: want this to be run only on start of new bar once....
Use this and you would have found this (updated minutes ago)
int start() { static int insideflag=0; if(iTime(NULL,0, 1) != bartime) { if(High[1]<=High[2] && Low[1]>=Low[2]) { double ub=High[2]; double lb=Low[2]; insideflag=1; } if(Close[1]>ub && insideflag==1) { SendMail("UPPER BREAKOUT","UPPER BREAKOUT"); insideflag=0; } if(Close[1]<lb && insideflag==1) { SendMail("LOWER BREAKOUT","LOWER BREAKOUT"); insideflag=0; } if(Close[2]>=Open[2]&& Close[2]-Open[2]>0.0004 && Close[1]<=Open[2]) SendMail("bearish engulfing","bearish engulfing"); if(Close[2]<=Open[2] && Open[2]-Close[2]>0.0004 && Close[1]>=Open[2]) SendMail("bullish engulfing","bullish engulfing"); bartime = iTime(NULL, 0, 1); }it executes many times during current bar in H4...wanted to check cond on new H4 bar formation once...
ankit29030:
it executes many times during current bar in H4...wanted to check cond on new H4 bar formation once...
Bartime not defined. Bartime never updated. Of course it executes many times per bar. Read the link posted.
it executes many times during current bar in H4...wanted to check cond on new H4 bar formation once...
if(iTime(NULL,0, 1) != bartime)
WHRoeder:
Bartime not defined. Bartime never updated. Of course it executes many times per bar. Read the link posted.
Bartime not defined. Bartime never updated. Of course it executes many times per bar. Read the link posted.
no sir i have made it global
datetime bartime;
ankit29030:
no sir i have made it global
What timeframe chart are you running this code on ?
no sir i have made it global
datetime bartime;

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hello im making a inside bar breakout stratagy.
it check for inside bar before 0th candle...(latest candle being formed);
but how do i make sure it run code only single time in each 0th candle formation??
here is my code::-----
want this to be run only on start of new bar once....not on each tick of the 0th candle being formed..