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.
MqlTradeRequest PrimaryPendingRequest; MqlTradeResult PrimaryPendingResult; ZeroMemory(PrimaryPendingRequest); ZeroMemory(PrimaryPendingResult); 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; OrderSend(PrimaryPendingRequest, PrimaryPendingResult);
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.