Hi guys, I have faced a problem which I really worked on but I couldn't solve it.
I want to partially close a position by pending order, the reason I want to use pending order is I want it as an SL but Partial SL.
I wrote the code below but pending order results new position an doesn't affect the active position.
PrimaryPendingRequest.action = TRADE_ACTION_PENDING;
PrimaryPendingRequest.magic = 1998;
PrimaryPendingRequest.symbol = _Symbol;
PrimaryPendingRequest.volume = 0.9;
PrimaryPendingRequest.price = NormalizeDouble(PrimaryTradeResult.price + 0.00005, 5);
PrimaryPendingRequest.type = ORDER_TYPE_BUY_STOP;
PrimaryPendingRequest.type_filling = ORDER_FILLING_FOK;
PrimaryPendingRequest.position = PrimaryTradeResult.order;
I want this pending to close 0.9 lot of the active position which is 1 lot and make it 0.1 lot position but it opens a new position and I will have 1 lot position + 0.9 lot position.
I thought it's broker problem and check it with 3 brokers but the result was the same.
It's only possible on a netting account. On an hedging account, it will always result in a new position.
It's not complicated it's how it works, you will have to deal with it.
On an hedging account, you can :
So if you want a partial close you have 2 solutions :
In all cases, pending orders can't be used for that purpose.