keeping track of trades

 

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!

 
Nima J: 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.

The problem is that you have not kept track. So do it.

  1. I move the SL to BE before doing the partial close. Therefor don't need to remember which orders have been reduced.
  2. Otherwise, remember the ticket numbers in persistent storage (files, global variables w/flush)

 
Nima J:

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!

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 … 😁
 
William Roeder #:

The problem is that you have not kept track. So do it.

  1. I move the SL to BE before doing the partial close. Therefor don't need to remember which orders have been reduced.
  2. 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?

 
Daniel Cioca #:
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!

 
Nima J #: 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

 
Fernando Carreiro #:

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

 
Nima J #:

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?

  1. Move the Stop Loss to Break Even before the partial close. That can be checked before trying another one.
  2. 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.
 
Nima J #:

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!

Start time will Change Also After parțial Close … variabile set in global area is very easy … you set int a = 0; in global area… after OrderSend function you place a=1… in the partial close function you add a condition… among others… if ( a==1) OrderClose() … after partial closing you set again a = 0… this way, you will close partial only once … or you can use GlobalVariable as well… instead of a variable placed in global area 
 
Daniel Cioca #:
Start time will Change Also After parțial Close …

Order open time does not change after a partial close.

Reason: