Strategy Tester Returning Wrong Tick Value

 

In an EA that I am developing in MQL5, I use the function SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE) to get the tick value of pairs that I am trading.

It gives me the correct tick value when I run the EA normally. However, when I run it on the strategy tester the function returns wrong tick values.

To illustrate my problem, I have created a simple EA which is attached here to. Results from that EA are also given below.

Can someone help me resolve this issue please.

Please note that I have posted this query elsewhere in the Forum earlier but couldn’t find an answer to the problem.

Results when the EA is run:

2021.11.06 07:16:56.028 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: NZDCAD- Tick Value; 0.80
2021.11.06 07:16:58.035 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: AUDCHF- Tick Value; 1.10
2021.11.06 07:17:00.036 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: EURJPY- Tick Value; 0.88
2021.11.06 07:17:02.036 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: AUDUSD- Tick Value; 1.00
2021.11.06 07:17:04.052 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: CHFJPY- Tick Value; 0.88
2021.11.06 07:17:06.052 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: EURUSD- Tick Value; 1.00
2021.11.06 07:17:08.053 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: NZDJPY- Tick Value; 0.88
2021.11.06 07:17:10.054 Tick Value (Multi Pair) (AUDJPY,H1)     Alert: AUDJPY- Tick Value; 0.88
Results from the strategy tester:

2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:01   Alert: NZDCAD- Tick Value; 1.00
2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:03   Alert: AUDCHF- Tick Value; 1.00
2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:05   Alert: EURJPY- Tick Value; 100.00
2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:07   Alert: AUDUSD- Tick Value; 1.00
2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:09   Alert: CHFJPY- Tick Value; 100.00
2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:11   Alert: EURUSD- Tick Value; 1.00
2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:13   Alert: NZDJPY- Tick Value; 100.00
2021.11.06 06:54:43.769 Core 1  2011.07.29 20:24:15   Alert: AUDJPY- Tick Value; 100.00
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You don't listen to anyone and you keep making the same mistakes.

1. You must provide information about the terminal and operating system. Example:

Forum on trading, automated trading systems and testing trading strategies

Very Glitchy MetaTrader

Vladimir Karputov, 2021.03.16 04:20

If you have a question, first of all you should show the first three lines from the 'Journal' tab


(select these lines, copy to the clipboard and paste into the message using the button Code). It should look like this:

2021.03.16 05:13:07.133 Terminal        MetaTrader 5 x64 build 3003 started for MetaQuotes Software Corp.
2021.03.16 05:13:07.134 Terminal        Windows 10 build 19042, Intel Core i7-9750H  @ 2.60GHz, 26 / 31 Gb memory, 842 / 947 Gb disk, IE 11, UAC, GMT+2
2021.03.16 05:13:07.134 Terminal        C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

2. You must change your code. (read help: Enable Required Symbols in Market Watch for Multi-Currency Expert Advisors #)

//+------------------------------------------------------------------+
//|                                                     Expert 1.mq5 |
//|                              Copyright © 2021, Vladimir Karputov |
//|                      https://www.mql5.com/en/users/barabashkakvn |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2021, Vladimir Karputov"
#property link      "https://www.mql5.com/en/users/barabashkakvn"
#property version   "1.00"
//--- input parameters
input int      Input1=9;
//---
string array_symbols[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create a timer with a 5 second period
   EventSetTimer(5);
   ArrayResize(array_symbols,8);
   array_symbols[0] = "NZDCAD";
   array_symbols[1] = "AUDCHF";
   array_symbols[2] = "EURJPY";
   array_symbols[3] = "AUDUSD";
   array_symbols[4] = "CHFJPY";
   array_symbols[5] = "EURUSD";
   array_symbols[6] = "NZDJPY";
   array_symbols[7] = "AUDJPY";
   int size=ArraySize(array_symbols);
   for(int i=0; i<size; i++)
      SymbolSelect(array_symbols[i],true);
   Print(AccountInfoString(ACCOUNT_SERVER));
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   int size=ArraySize(array_symbols);
   for(int i=0; i<size; i++)
     {
      double tick_value=SymbolInfoDouble(array_symbols[i],SYMBOL_TRADE_TICK_VALUE);
      int digits=(int)SymbolInfoInteger(array_symbols[i],SYMBOL_DIGITS);
      Print(array_symbols[i]+" Tick Value: "+DoubleToString(tick_value,digits));
     }
  }
//+------------------------------------------------------------------+

3. You should test the 'Expert 1' advisor on the 'MetaQuotes-Demo' server.

4. Testing mode - every tick


Result:

Server Online Tetster (Every Tick)

MetaQuotes-Demo
NZDCAD Tick Value: 0.80276
AUDCHF Tick Value: 1.09624
EURJPY Tick Value: 0.882
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.882
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.882
AUDJPY Tick Value: 0.882
NZDCAD Tick Value: 0.80276
AUDCHF Tick Value: 1.09624
EURJPY Tick Value: 0.882
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.882
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.882
AUDJPY Tick Value: 0.882


NZDCAD Tick Value: 0.80261
AUDCHF Tick Value: 1.09583
EURJPY Tick Value: 0.879
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.879
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.879
AUDJPY Tick Value: 0.879
NZDCAD Tick Value: 0.80259
AUDCHF Tick Value: 1.09584
EURJPY Tick Value: 0.879
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.879
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.879
AUDJPY Tick Value: 0.879




RoboForex-ECN
NZDCAD Tick Value: 0.80263
AUDCHF Tick Value: 0.00000
EURJPY Tick Value: 0.882
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.882
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.882
AUDJPY Tick Value: 0.882
NZDCAD Tick Value: 0.80263
AUDCHF Tick Value: 1.09527
EURJPY Tick Value: 0.882
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.882
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.882
AUDJPY Tick Value: 0.882

NZDCAD Tick Value: 0.80261
AUDCHF Tick Value: 1.09570
EURJPY Tick Value: 0.879
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.879
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.879
AUDJPY Tick Value: 0.879
NZDCAD Tick Value: 0.80261
AUDCHF Tick Value: 1.09570
EURJPY Tick Value: 0.879
AUDUSD Tick Value: 1.00000
CHFJPY Tick Value: 0.879
EURUSD Tick Value: 1.00000
NZDJPY Tick Value: 0.879
AUDJPY Tick Value: 0.879



Alpari-Demo03
NZDCAD Tick Value: 0.69396
AUDCHF Tick Value: 0.94772
EURJPY Tick Value: 0.762
AUDUSD Tick Value: 0.86451
CHFJPY Tick Value: 0.762
EURUSD Tick Value: 0.86451
NZDJPY Tick Value: 0.762
AUDJPY Tick Value: 0.762
NZDCAD Tick Value: 0.69396
AUDCHF Tick Value: 0.94772
EURJPY Tick Value: 0.762
AUDUSD Tick Value: 0.86451
CHFJPY Tick Value: 0.762
EURUSD Tick Value: 0.86451
NZDJPY Tick Value: 0.762
AUDJPY Tick Value: 0.762


NZDCAD Tick Value: 0.69467
AUDCHF Tick Value: 0.94833
EURJPY Tick Value: 0.761
AUDUSD Tick Value: 0.86549
CHFJPY Tick Value: 0.761
EURUSD Tick Value: 0.86549
NZDJPY Tick Value: 0.761
AUDJPY Tick Value: 0.761
NZDCAD Tick Value: 0.69467
AUDCHF Tick Value: 0.94830
EURJPY Tick Value: 0.761
AUDUSD Tick Value: 0.86552
CHFJPY Tick Value: 0.761
EURUSD Tick Value: 0.86552
NZDJPY Tick Value: 0.761
AUDJPY Tick Value: 0.761










Please note: all symbols on all servers are Forex symbols!

Strategy Testing - Algorithmic Trading, Trading Robots - MetaTrader 5 Help
Strategy Testing - Algorithmic Trading, Trading Robots - MetaTrader 5 Help
  • www.metatrader5.com
The Strategy Tester allows you to test and optimize trading strategies ( Expert Advisors ) before using them for live trading. During testing, an...
Files:
Expert_1.mq5  5 kb
 
Vladimir Karputov #:

You don't listen to anyone and you keep making the same mistakes.

1. You must provide information about the terminal and operating system. Example:


2. You must change your code. (read help: Enable Required Symbols in Market Watch for Multi-Currency Expert Advisors #)

3. You should test the 'Expert 1' advisor on the 'MetaQuotes-Demo' server.

4. Testing mode - every tick


Result:

Server Online Tetster (Every Tick)

MetaQuotes-Demo





RoboForex-ECN



Alpari-Demo03











Please note: all symbols on all servers are Forex symbols!

Thank you Vladimir. Running the strategy tester on Metaquotes-Demo did the trick.   So it must be a problem with my broker. In fact I tried two brokers and both of them did the same thing. Would you recommend that I do all my strategy testing on MetqQuotes-Demo without a broker?

 

I would recommend taking a close look at this picture:

 
Vladimir Karputov #:

I would recommend taking a close look at this picture:

Thanks Vladimir.

Initially I ran it with exactly the same settings as what you have shown. Still my broker's server gave the wrong results.

However, when running on MetaQuotes server it gave the correct results. I then changed the Time frame to H4 and Modelling to "Open Price Only" which is how I would like my other EA to run. Tick Values remained the same with these changes

 

Hello! Apologies that Im little off this topic, but is still in regards with strategy tester


During the strategy testing, the times recorded for the trades are computer time or market time?! Some strange things is happening since we changed clocks for winter time...before changing clocks, the tester was running fine on my EA, taking trades on Set Timer, which is from 01:00 to 01:20 everyday. And I was testing my EA since 2017 to present. But since we changed to winter time, the strategy tester is only taking trades after 06/06/2021...nothing from before...if I set the EA trade Timer to 02:00 to 02:20, it will take the trades normally...Anyone can explain this phenomenon? Thanks   

Reason: