Buy orders should be closed by Bid.
Replace
OrderOpenPrice()+SL
to
OrderOpenPrice()+SL*Point
and
TP to TP*Point
SanMiguel:
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.
Replace
if(OrderType()==OP_BUY && Ask-OrderOpenPrice() >= TP)
to
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
The problem is not with the closed half, but the other half. Once you close the first, how do you know not to close the second half again.
- 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
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
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?