Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1192

 
Artem Mordvinkin:


It's written in plain English that the symbols are automatically connected to the test

When you access them.
 
Artem Mordvinkin:


Yes, it is written in Russian that symbols are automatically connected during testing

To create an indicator, you must first connect a symbol in Market Watch (in your case in Market Watch of the tester).

 
Artyom Trishkin:
Request any data from each desired symbol.

They by SymbolSelect() are missing - not selected

Dear Sirs Before referring me to publications (for which I thank you) check - whether your multicurrencies work in the tester And if they do, it makes sense

 
Artem Mordvinkin:

They by SymbolSelect() are missing - not selected

Dear Sirs Before referring me to publications (for which I thank you) check - whether your multicurrencies work in the tester And if they do, it makes sense

They work. On the latest build. No problems at all.
 
Artyom Trishkin:
It works. On the latest build. No problems at all.

How did you connect them (symbols) - can you tell me which function?

 
Artem Mordvinkin:

How did you connect them (symbols) - can you tell me which function?

SymbolSelect(character name,true);

 
Vladimir Karputov:

SymbolSelect(character name,true);

I do the same.

SymbolSelect(EURUSD_inst, true);
  SymbolSelect(GBPUSD_inst, true);
  SymbolSelect(USDJPY_inst, true);
  SymbolSelect(AUDUSD_inst, true);


I get it like this

2020.03.09 19:19:45.766 symbol EURUSDrfd does not exist

2020.03.09 19:19:45.766 symbol USDJPYrfd does not exist

2020.03.09 19:19:45.766 symbol AUDUSDrfd does not exist


The cable does not give an error as it is selected in the tester.

The symbol names are correct.


UPD seems to me that it needs to do something in the terminal settings itself. If everything was working before last build, it has nothing to do with code. Tester can't see the symbols.

 
Artem Mordvinkin:


2020.03.09 19:19:45.766 symbol EURUSDrfd does not exist

2020.03.09 19:19:45.766 symbol USDJPYrfd does not exist

2020.03.09 19:19:45.766 symbol AUDUSDrfd does not exist


Cable does not give an error as it is selected in the tester

What is it? Where is the code? How do you get it? Especially you are selecting completely different characters.

 
Vladimir Karputov:

What is it? Where is the code? How do you get it? Especially since you're choosing completely different characters.

Got it, let's go like this.

Given (name of characters)


Code (fragments)

//----------------------------название инструмента
string EURUSD_inst = "EURUSDrfd";
string GBPUSD_inst = "GBPUSDrfd";
string AUDUSD_inst = "AUDUSDrfd";
string USDJPY_inst = "USDJPYrfd";


void OnTick()
  {
  SymbolSelect(EURUSD_inst, true);
  SymbolSelect(GBPUSD_inst, true);
  SymbolSelect(USDJPY_inst, true);
  SymbolSelect(AUDUSD_inst, true);
}

Let's select the cable in the tester as an example.


Run it and

2020.03.09 19:19:45.766 symbol EURUSDrfd does not exist

2020.03.09 19:19:45.766 symbol USDJPYrfd does not exist

2020.03.09 19:19:45.766 symbol AUDUSDrfd does not exist

There is no error on the cable - it is selected by default in the tester

And just in case, I will say that this problem is only in the tester. And that the owl is several years old and the error is 2 days old and that this is the case with all my multi-currency owls.
 

Example of creating an iMA indicator on 'USDJPY' symbol, with the tester running on 'EURUSD'.

//+------------------------------------------------------------------+
//|                                        iMA Values on a Chart.mq5 |
//|                              Copyright © 2019, Vladimir Karputov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2019, Vladimir Karputov"
#property version   "1.001"
//--- input parameters
input  string              Inp_MA_symbol        = "USDJPY";    // MA: symbol name
input ENUM_TIMEFRAMES      Inp_MA_period        = PERIOD_D1;   // MA: timeframe
input int                  Inp_MA_ma_period     = 12;          // MA: averaging period
input int                  Inp_MA_ma_shift      = 5;           // MA: horizontal shift
input ENUM_MA_METHOD       Inp_MA_ma_method     = MODE_SMA;    // MA: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_applied_price = PRICE_CLOSE; // MA: type of price
//---
int    handle_iMA;                           // variable for storing the handle of the iMA indicator
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(!SymbolSelect(Inp_MA_symbol,true))
     {
      PrintFormat("Failed select symbol %s",
                  Inp_MA_symbol);
      return(INIT_FAILED);
     }
//--- create handle of the indicator iMA
   handle_iMA=iMA(Inp_MA_symbol,Inp_MA_period,Inp_MA_ma_period,Inp_MA_ma_shift,
                  Inp_MA_ma_method,Inp_MA_applied_price);
//--- if the handle is not created
   if(handle_iMA==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d",
                  Inp_MA_symbol,
                  EnumToString(Inp_MA_period),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double array_ma[];
   ArraySetAsSeries(array_ma,true);
   int start_pos=0,count=3;
   if(!iGetArray(handle_iMA,0,start_pos,count,array_ma))
      return;

   string text="";
   for(int i=0; i<count; i++)
      text=text+IntegerToString(i)+": "+DoubleToString(array_ma[i],Digits()+1)+"\n";
//---
   Comment(text);
  }
//+------------------------------------------------------------------+
//| Get value of buffers                                             |
//+------------------------------------------------------------------+
bool iGetArray(const int handle,const int buffer,const int start_pos,
               const int count,double &arr_buffer[])
  {
   bool result=true;
   if(!ArrayIsDynamic(arr_buffer))
     {
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);
      return(false);
     }
   ArrayFree(arr_buffer);
//--- reset error code
   ResetLastError();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer);
   if(copied!=count)
     {
      //--- if the copying fails, tell the error code
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",
                  __FILE__,__FUNCTION__,count,copied,GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
   return(result);
  }
//+------------------------------------------------------------------+

The result is correct. First the symbol is selected and then the indicator is created using it.


Reason: