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.
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 the same thing, Normal close partially or with pending
It's only possible on a netting account. On an hedging account, it will always result in a new position.
It seems complicated to me Alain, I can affect my current position by "deal" orders even on a hedge account with giving my current position ticket value to MqlTradeRequest.position but when it comes to "pending" orders, I can't affect my position by them even when I give value to "Position" variable in MqlTradeRequest structure.
It's not complicated it's how it works, you will have to deal with it.
On an hedging account, you can :
- open new positions (with market or pending orders)
- close existing position (fully or partially) with market orders, not with pending orders.
- you can not add to an existing position, only open a new one.
So if you want a partial close you have 2 solutions :
- Monitor the price and send a market order to partially close your position with the needed volume.
- Open 2 positions (0.9 and 0.1) instead of one, and set your sl/tp accordingly.
In all cases, pending orders can't be used for that purpose.
It's not complicated it's how it works, you will have to deal with it.
On an hedging account, you can :
- open new positions (with market or pending orders)
- close existing position (fully or partially) with market orders, not with pending orders.
- you can not add to an existing position, only open a new one.
So if you want a partial close you have 2 solutions :
- Monitor the price and send a market order to partially close your position with the needed volume.
- Open 2 positions (0.9 and 0.1) instead of one, and set your sl/tp accordingly.
In all cases, pending orders can't be used for that purpose.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.
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.