Magic number problem (in the tester at least)

 

We've made a last minute decision to enter the competition. We've been working over the weekend to port one of our MT4 EAs, and we've hit a problem.

The EA Magic Number is not being applied to any of the closing deals, only to the opening deals. Here's an extract from a log:

RO      0       GurooEx02 (EURUSD,M1)   18:46:20        2010.09.13 01:58:12   Position flat at 2010.09.13 01:58:12
DQ      0       GurooEx02 (EURUSD,M1)   18:46:20        2010.09.13 01:58:12   Found 3 deals
GI      0       GurooEx02 (EURUSD,M1)   18:46:20        2010.09.13 01:58:12   Found deal 3, Symbol = EURUSD, Magic = 0, Profit = -51.7
OO      0       GurooEx02 (EURUSD,M1)   18:46:20        2010.09.13 01:58:12   Found deal 2, Symbol = EURUSD, Magic = 12345, Profit = 0
JN      0       GurooEx02 (EURUSD,M1)   18:46:20        2010.09.13 01:58:12   Found deal 1, Symbol = , Magic = 0, Profit = 10000

Deal 1 is just the opening balance in the tester. The markets are closed at the moment, but in a few hours we'll discover whether the problem applies trading a demo account too. Whether it does or not, we'd still like to able to test our converted EA before submitting it!

Can anyone suggest what the problem is, and a way around it. I guess just not bothering to check the magic number at all would get us going in the short term, but that's definitely not a good long term solution!

Jim

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
 

I believe you can use the following algorithm:

1. Find opening deal with correct magic.

2. Remember DEAL_POSITION_ID.

3. Select all deals of this position with HistorySelectByPosition( pos_id ) .

4. Continue working in accordance to your algorithm, knowing for sure that all deals you have selected belong to correct position. 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Deal Properties - Documentation on MQL5
 
Hi hasayama,
hasayama:

I believe you can use the following algorithm:


Thanks very much for what certainly looks as though it will be the answer to all our problems.

Cheers,

Jim