wrong value of SYMBOL_TRADE_MODE in tester

 
I checked with several brokers and found that, in cases where a broker offers both something like EURUSD and EURUSD.m (it can be any symbol that has two versions in a broker) and only the second symbol has full trading access while the first one is disabled However, the tester incorrectly returns a SYMBOL_TRADE_MODE value of 4 (which indicates full access) for the first symbol, which is incorrect:

Udpate: i checked and any symbol that has trading disabled has the same issue.

//+------------------------------------------------------------------+
//|                                                       test 3.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   int symb_mod = SymbolInfoInteger("EURUSD", SYMBOL_TRADE_MODE) ;
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+


1 2
 
Khuman Bakhramirad: I checked with several brokers and found that, in cases where a broker offers both something like EURUSD and EURUSD.m (it can be any symbol that has two versions in a broker) and only the second symbol has full trading access while the first one is disabled However, the tester incorrectly returns a SYMBOL_TRADE_MODE value of 4 (which indicates full access) for the first symbol, which is incorrect:

Udpate: i checked and any symbol that has trading disabled has the same issue.

This is just my opinion, but I suspect it to be a reasonable explanation for the issue:

The express aim of the Strategy Tester is to back-test EAs, so it would not make sense for it not to be able to do so if a symbol prevented that.

So, when the trading mode is set to "Disabled", it forcibly treats it as "Full access" to allow the back-testing to be carried out anyway.

The other modes, like "Long only" or "Short only" do work correctly, and I have used them quite often to force "closed source" EAs to only carry out longs or shorts during back-testing.

The "Close only" options also works correctly, resulting in no trading, given that there are no pre-existing open positions to close in a back-test.

By the way, you can change this mode by editing that field in symbol's specifications in the Strategy Tester.


 
Fernando Carreiro #:

This is just my opinion, but I suspect it to be a reasonable explanation for the issue:

The express aim of the Strategy Tester is to back-test EAs, so it would not make sense for it not to be able to do so if a symbol prevented that.

So, when the trading mode is set to "Disabled", it forcibly treats it as "Full access" to allow the back-testing to be carried out anyway.

The other modes, like "Long only" or "Short only" do work correctly, and I have used them quite often to force "closed source" EAs to only carry out longs or shorts during back-testing.

The "Close only" options also works correctly, resulting in no trading, given that there are no pre-existing open positions to close in a back-test.

By the way, you can change this mode by editing that field in symbol's specifications in the Strategy Tester.


yes but when an EA tries to automatically find the correct symbol to trade on backtest it causes issues, this seems like a bug right?

 
Khuman Bakhramirad #:yes but when an EA tries to automatically find the correct symbol to trade on backtest it causes issues, this seems like a bug right?

I consider it an implementation choice made by the developers, and not a bug.

Simply add code logic to your EA to consider the differences between a "live" environment and a "back-test" environment.