Problem with OrdersHistoryTotal() and the Tester

 

I have some problem with OrdersHistoryTotal() and the tester.

I have used 2 different simple code (AAAAA and BBBBB) and i got correct value of print on terminal window when the EA is used with a live chart.

But when i use the tester with the same code, OrdersHistoryTotal()=0 (whatever the number of historical orders) and GetLastError()=4105 meaning NO_ORDER_SELECTED.

Any idea to help me ?

Thanks


//AAAAA

Print("OrdersHistoryTotal()= ", OrdersHistoryTotal());

Print("LastError= ", GetLastError());

//end AAAAA


//BBBBB

for(int pos=3; pos >= 0; pos--) if (

OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)

&& OrderMagicNumber() == magicNumber // my magic number

&& OrderSymbol() == Symbol() // and my pair.

){

Print(" Last Order Ticket = ",OrderTicket(), " OrderProfit()= ", OrderProfit());

//break;

}

Print("LastError= ", GetLastError());

//end BBBBB

 

  1. For large amounts of code, attach it
  2. Live chart has nothing to do with the tester. The only history in the tester is what your EA did in the tester.
 
WHRoeder:

  1. For large amounts of code, attach it
  2. Live chart has nothing to do with the tester. The only history in the tester is what your EA did in the tester.


May be i was not clear in my explanation. I just wanted to say that the EA runs correctly and gives correct values from OrdersHistoryTotal() except when you run it with the tester.

It's like OrdersHistoryTotal() is not compatible with the tester.


Does someone can run the code with the Tester and tell me what is the value coming from OrdersHistoryTotal() ?

 

I understand. If you could please add a new message to this post containing your code in this format...

int value1;int value2;

if (value1>value2) {int value3=value1+value2;}

You can add code to a new message in this format by clicking the "SRC" button located at the top left corner of a new message.

I would be more than happy to help you. Other MQL4 coders would also be happy to help.

Thank you.

 
georges75:


May be i was not clear in my explanation. I just wanted to say that the EA runs correctly and gives correct values from OrdersHistoryTotal() except when you run it with the tester.

It's like OrdersHistoryTotal() is not compatible with the tester.


Does someone can run the code with the Tester and tell me what is the value coming from OrdersHistoryTotal() ?


It will be zero . . your code does not place any trades.

The Strategy Tester has it's own set of Order History and current Orders . . . when you use OrderHistoryTotal() it is referencing the Strategy Tester Order History . . not the Order History from your Demo/Live account . . .

Reason: