if (BarCount != Bars)
Bars is unreliable (max bars on chart) Volume is unreliable (you can miss ticks) Always use Timestatic datetime nextTrade; if (TimeCurrent() > nextTrade){ int ticket = OrderSend(...); if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else nextTrade = TimeCurrent() + 86400; }
Thanks Guys, great stuff. Just the answer i was looking for!

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
Hi,
I have a EA that I only want to trade once per day..... It puts a BuyStop in at a particluar level and if it doesnt get trigged by the end of a 24 hour period it expiires.
If it does get triggered though, i want to ensure that my code wont put the trade on again.
Normally i would just use a BarCount check like this
But the 24 hour period i want my order to exist in is staggered, as seen below so i cant use a daily bar count check.
Can anyone tell me the best way to get my order placement code to run only once in this period? I have thought about just telling the code to run in the first hour, but then if my order gets triggered in the first hour it would put in on again.......
I have also thought about just using a boolean that resets once the first minute of the new period passes but if my connection is down for that small period the boolean wont reset....... can anyone suggest an efficient way?
Thanks in advance for any help...