MQL4 check please for closing half trade
What would be a way to stop it from closing out half of the next trade?
For example, I have alot of 0.10 open. It reaches a target profit of 50pips, so the code closes half the trade and resets the stop loss to +10 of openprice.
So, we now have a lot of 0.05. I want the code to leave this alone until I either close it out manually or it hits a stop loss.
if(OrderType()==OP_BUY && Ask-OrderOpenPrice() >= TP)
if(OrderType()==OP_BUY && Ask-OrderOpenPrice() >= TP&& OrderLots()>0.05)
Err not all the lots would be 0.05 or less with this method.
I might have a lot open at 0.07 cut down to 0.04 or
one at 0.16 cut down to 0.08 or
one open at 0.5 cut down to 0.25
- Do not set an initial TP. Once you close half, set the TP for the second.
- Open two orders each for half size. Set one with TP, one without.
- Use two different magic numbers
Will this EA monitor open trades for the chart and close half the trade on reaching a certain target profit and move the stop loss to plus 10 pips of the opening price?
Have I missed anything in the code?
How could I stop it acting on the half closed order the next time the tick runs?