EA positions only : Closed ones , Profit/Loss

 

Ok, here i'm stuck on any idea on how to do this procedure. [not looking for codes, you see. just any help on how-to]

----------------------------------------------------------------------------------------------------------------------------------
Short version of the question :

How to count number of closed EA-positions, in the last day (or week or so) ?
I know how to populate History list, and search through deals (through a desired time, say last 24 hrs), find the positions that were opened by EA.
BUT, how to detect if a closed position was originally opened by my EA ? (since all closed positions I checked, have magic number = 0)


----------------------------------------------------------------------------------------------------------------------------------
Long version of the question :

Inside the chart-analyzer part of my EA, there's a variable to assess short-term success/fail rate of EA on recent trades.
one thing is to set a bool to true on some-conditions. (PRUDENT_MODE = true) , this variable affects behavior of EA on next signals/patterns it finds.

In order to set this bool, I need to count the positions that were opened by my EA, in last 24 hours, and check the profit/loss ratio of the last 20 positions.
i.e : (assuming I've already checked all error-raiser flags...)

bool PRUDENT_MODE = false; //global variable

OnTrade() :
int ALL_TRADES = 0;     // positions that were opened by this EA, in last 24 hrs. (<<< No problem coding this one)
int LOST_TRADES = 0;    // among the above positions, the ones that are closed with negative profit. (<<< HOW ?)

// count these two...

PRUDENT_MODE = (LOST_TRADES/ALL_TRADES > 0.33);
 
The opening of a position is linked to the first deal of this position. So check the magic of this deal.
 
Alain Verleyen:
The opening of a position is linked to the first deal of this position. So check the magic of this deal.
the positions i'm considering are closed. (so i'm only watching for the deals that are of type DEAL_TYPE_OUT).

so the question is :
is there a way to find the ticket of the deal, that is the DEAL_TYPE_IN linked to the DEAL_TYPE_OUT one i'm currently considering ?
 
Code2219 or probably 2319:
the positions i'm considering are closed. (so i'm only watching for the deals that are of type DEAL_TYPE_OUT).

so the question is :
is there a way to find the ticket of the deal, that is the DEAL_TYPE_IN linked to the DEAL_TYPE_OUT one i'm currently considering ?
Yes, each deal has a DEAL_POSITION_ID property, with it you can find all deals related to a position, and from there find the first one.
 
Alain Verleyen:
Yes, each deal has a DEAL_POSITION_ID property, with it you can find all deals related to a position, and from there find the first one.

BIG THANKS, and my EA will be complete soon.

Reason: