Prevent multiple orders on same bar.

 

Hello, I'm working on an EA that uses envelope conditions (tick based) when to open a long/short position. 

Do describe my problem better I'll explain the goal;
(5 MIN chart)
Whenever the price is below/above the channel it will open a position. This is tick based so the order wont be placed on the bar close (could be anytime (as it crosses the channel roof or floor)).
However let's say that the following 5min bar meets the condition again and if so it will open another order in the same direction as the previous. 

Problem:
It opens unlimited orders on the same bar due to the tick condition (which the EA need for calculation and entry point). 
Therefore, is there a way to prevent it open several orders on the same bar?

Thanks for help.

Envelopes - Trend Indicators - MetaTrader 5 Help
Envelopes - Trend Indicators - MetaTrader 5 Help
  • www.metatrader5.com
Envelopes Technical Indicator is formed with two Moving Averages , one of which is shifted upward and another one is shifted downward. The...
 
Biskop: , is there a way to prevent it open several orders on the same bar?

Remember the bar time and check it.

 
IWilliam Roeder #:

Remember the bar time and check it.

I use MT4, is it the same? Can it be done under OnTick?
 
We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem
Reason: