Help Retrieving Trade History Info

 
Hi. I am trying to pull up the sum in dollars of all closed orders in history that were from this single EA.

After #property link I have
extern string EAName = "MyEaName";
double closedProfit = 0;


somewhere after int init() I have

int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{OrderSelect(i, SELECT_BY_POS, MODE_HISTORY );
if ( OrderSymbol()==Symbol() && OrderComment() == EAName )
{closedProfit = closedProfit + OrderProfit();}
}

in the chart comments for my EA, I am using the closedProfit to pull up closed order profit from history but am getting a value of 0.

Any idea what I am doing wrong?

Thank you,
Jon 
 
OrderComment is "MyEaName          " ie space padded to 31 char. Use StringSubstr or StringFind functions
 
don't use comments to identify trades, use magic numbers.
 
I understand now. Thanks for making this clear!!