scale out of a position with a limit order
Something common, i am using latest metatrader 5, so i think its the last standard library , i want to create a limit order as soon as i create a trade to scale out half of position in 1:1. The problem i have its that everything is fine but for example if i am in a sell when it touches the buy limit order it just open a buy and the sell stays open the same, it doesnt close half of sell and let the other half run, as i want to. This is my code:
thank you in advance
It is necessary to understand the difference between a hedge and netting account. Example:
| Current state | Event | Netting | Hedge |
|---|---|---|---|
| USDCAD Sell 3.0 lot | USDCAD BuyLimit 1.0 lo triggered -> | USDCAD Sell 2.0 lot | USDCAD Sell 3.0 lot USDCAD Buy 1.0 lot |
I also highly recommend working with OnTradeTransaction.
Something common, i am using latest metatrader 5, so i think its the last standard library, i want to create a limit order as soon as i create a trade to scale out half of position in 1:1. The problem i have its that everything is fine but for example if i am in a sell when it touches the buy limit order it just open a buy and the sell stays open the same, it doesnt close half of sell and let the other half run, as i want to. This is my code:
thank you in advance