I do not know how to make a timer, so any wisdom on this, would be great.
One way is to check if OrderClosePrice() is nearer to OrderTakeProfit() or nearer to OrderStopLoss().
However, if you are manually closing orders that will present a problem, unless you move both TP and SL to 0 before closing (you could consider doing this by code, if suitable. For example, using a script or a button).
If you find an order has been closed by SL, then add one hour to OrderCloseTime() and don't open new orders until after this time.
Just thought; I use this OnTick:
if( OpenOrdersThisPair(Symbol()) == 0 && H1_Buy_Touch == "H1 Buy Touch" ...) ... OrderEntry(0);
H1_Buy_Touch is essentially the last check before the trade is placed (if no trades are open it will place a trade like above - Buy Stop).
If that is not "H1 Buy Touch" then no trades can physically be placed. If OpenOrdersThisPair(Symbol()) == 4 , I want a way to safely stop my EA when it goes from == 4 to == 0 for "x" amount of time. Is this possible?
Thanks for your reply.
Just thought; I use this OnTick:
H1_Buy_Touch is essentially the last check before the trade is placed (if no trades are open it will place a trade like above - Buy Stop).
If that is not "H1 Buy Touch" then no trades can physically be placed. If OpenOrdersThisPair(Symbol()) == 4 , I want a way to safely stop my EA when it goes from == 4 to == 0 for "x" amount of time. Is this possible?
Create a static datetime variable which you update when required (for example, when you have had an order closed by SL).
Then add a simple check that sufficient time has passed before placing an order.
static datetime NextOrder = 0; ... if(ClosedBySL) NextOrder = OrderCloseTime()+3600; ... if(TimeCurrent()>=NextOrder && OpenOrdersThisPair(Symbol()) == 0 && H1_Buy_Touch == "H1 Buy Touch" ...) ... OrderEntry(0);
I'll have a play tomorrow, cheers!
if(TimeCurrent()>=NextOrder... ...
How does TimeCurrent() work in this part and would I need to store in GlobalVariable for it to remember NextOrder if it were set to "3,600"?
If MT4 crashes or I shut it down during:
How does TimeCurrent() work in this part and would I need to store in GlobalVariable for it to remember NextOrder if it were set to "3,600"?
TimeCurrent() is the last known server time.
Personally, I wouldn't bother with global variables because you can easily recalculate the value with a loop through your order history.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
So I know when a stop loss was hit: what's the easiest way to halt trading for 1 hour when I know this?
I.e. OnTick fails on an equality statement every time for 1 hour after I discover a stop loss was hit?
cheers