The problem is that you have not kept track. So do it.
- I move the SL to BE before doing the partial close. Therefor don't need to remember which orders have been reduced.
- Otherwise, remember the ticket numbers in persistent storage (files, global variables w/flush)
Hi
I'm making an account manager. this EA closes 50 percent of volume of every trade which has more than 20 pips in profit.
But the problem is that I cannot keep track of which trade was partially close so that the EA doesn't close the entire volume.
I tried using ticket number but every time you close an order partially the ticket is going to change in MQL4. in MQL5 the circumstances is a lot worse. because of orders positions and ....!
this EA does not place any order and only closes the user manually placed orders, so I cannot benefit from Magic number!
The problem is that you have not kept track. So do it.
- I move the SL to BE before doing the partial close. Therefor don't need to remember which orders have been reduced.
- Otherwise, remember the ticket numbers in persistent storage (files, global variables w/flush)
I DID keep track of them, but as I said the ticket numbers changes every time you close partially so its useless(in MQL4)
I'm sorry, I don't understand "SL to BE". what do they mean?
Use a global variable like a switch on/off… set on when opening a trade and off after partial close… put a filter to partial close only trades with the switch in On position … 😁
But how do I differentiate between positions?
I wrote something similar with ticket number. but ticket number changes after partial close so you will lost track of trades!
maybe I should use positions start time because those are unique for every position I guess!
Before posting consider first searching the forum for similar questions and reading the answers: https://www.mql5.com/en/search#!keyword=partial%20close%20ticket%20number&module=mql5_module_forum
Here is thread entry that seems to answer your question: Partial OrderClose — https://www.mql5.com/en/forum/144565
EDIT: But also read the other threads to make sure of the information
Before posting consider first searching the forum for similar questions and reading the answers: https://www.mql5.com/en/search#!keyword=partial%20close%20ticket%20number&module=mql5_module_forum
Here is thread entry that seems to answer your question: Partial OrderClose — https://www.mql5.com/en/forum/144565
EDIT: But also read the other threads to make sure of the information
I'm sorry
thanks a lot
I finally found what I needed in those threads
I DID keep track of them, but as I said the ticket numbers changes every time you close partially so its useless(in MQL4)
I'm sorry, I don't understand "SL to BE". what do they mean?
- Move the Stop Loss to Break Even before the partial close. That can be checked before trying another one.
- You don't remember the existing ticket number, that is unless. When you partially close an order, you get a new ticket number. That will be the highest number in the pool. Find it and remember it.
But how do I differentiate between positions?
I wrote something similar with ticket number. but ticket number changes after partial close so you will lost track of trades!
maybe I should use positions start time because those are unique for every position I guess!

- 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
I'm making an account manager. this EA closes 50 percent of volume of every trade which has more than 20 pips in profit.
But the problem is that I cannot keep track of which trade was partially close so that the EA doesn't close the entire volume.
I tried using ticket number but every time you close an order partially the ticket is going to change in MQL4. in MQL5 the circumstances is a lot worse. because of orders positions and ....!
this EA does not place any order and only closes the user manually placed orders, so I cannot benefit from Magic number!