How correctly does the strategy tester work when depositing not in USD?

How correctly does the strategy tester work when depositing not in USD?

23 September 2018, 06:28
Natalja Romancheva
0
146

The post was created based on the results of the discussion in the branch: https://www.mql5.com/ru/forum/279476

Main questions:

There are a number of Russian brokers with a deposit in rubles, many other brokers can open deposits in EUR, AUD and other currencies.

Actually from here two basic questions:

1. How correctly the strategy tester works with such deposits?

2. How correctly does the tester work, if for example the deposit is in rubles, and in the tester as the currency the euro is chosen?

What are the subtleties and pitfalls in these situations?

How much is the tester multicurrency in terms of deposit currencies?

-------------------

With deposits not in the dollar, the tester tries to load a lot of related tools. There are fears that there will be numerous inconsistencies.

Тестер001

For example, when testing the simplest EA on the EURGBP tool, 5 tools are loaded on the ruble deposit and not all of them are successful.

The screenshot shows that the EURUSD tool appeared in the market review, but there are no quotes for it.


The main answer.

Vitaly Muzichenko 2018.09.16 23:00   RU
Natalja Romancheva:

Which tools are loaded - this is understandable and does not cause any questions.

Questions arise about the correctness of the loading of quotations required for conversion or even their non-loading at all.

Yes, it happens, and quite often.

I at myself in OnInit () registered here such design, and now the history always boots correctly:

  // We touch the symbol in the tester, otherwise it does not load the history
  if(TESTER) iClose(SymbTrade[i],PERIOD_CURRENT,1);

How to use it in your case - you need to think, I have the characters spelled out in the array

Implementation.

Function for interrogation of instruments associated with the tested through USD and the currency of the deposit.
//=== v4.304 ================================================================================== MQL5 ===
// iCloseCallSymbol() - Interrogation related tools on iClose()
//------------------------------------------------------------------------------------------------------
void iCloseCallSymbol(string  iSymbol,
                      string  iDepoCurrency,
                      string  iSuffix)
{
   //Define the type of the instrument (with the USDXXX quotation, the reverse quote of ZZZUSD, the cross-rate of ZZZXXX) and interrogate the corresponding tools on iClose()
   {switch(CheckSymbolQuotaType(iSymbol))
   {
      case QUOTA_TYPE_FORWARD://USDXXX депо ZZZ
         {
            //USDXXX
            iClose(iSymbol,PERIOD_CURRENT,1);
            //USDZZZ
            {if(iDepoCurrency!="USD")
            {
               {if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
               {
                  iClose(iDepoCurrency+"USD"+iSuffix,PERIOD_CURRENT,1);
               }}//if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
            }}//if(iDepoCurrency!="USD")
            break;
         }
      case QUOTA_TYPE_BACKWARD://XXXUSD депо ZZZ
         {
            //XXXUSD
            iClose(iSymbol,PERIOD_CURRENT,1);
            //USDZZZ
            {if(iDepoCurrency!="USD")
            {
               {if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
               {
                  iClose(iDepoCurrency+"USD"+iSuffix,PERIOD_CURRENT,1);
               }}//if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
            }}//if(iDepoCurrency!="USD")
            break;
         }
      case QUOTA_TYPE_CROSS://XXXYYY депо ZZZ
         {
            //XXXYYY  
            iClose(iSymbol,PERIOD_CURRENT,1);
            //YYYUSD или USDYYY
            {if(iClose(StringSubstr(iSymbol,3,3)+"USD"+iSuffix,PERIOD_CURRENT,1)<=0)
            {
               iClose("USD"+StringSubstr(iSymbol,3,3)+iSuffix,PERIOD_CURRENT,1);
            }}//if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
            //XXXUSD или USDXXX
            {if(iClose(StringSubstr(iSymbol,0,3)+"USD"+iSuffix,PERIOD_CURRENT,1)<=0)
            {
               iClose("USD"+StringSubstr(iSymbol,0,3)+iSuffix,PERIOD_CURRENT,1);
            }}//if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
            {if(iDepoCurrency!="USD")
            {
               //XXXZZZ или ZZZXXX
               {if(iClose(StringSubstr(iSymbol,0,3)+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
               {
                  iClose(iDepoCurrency+StringSubstr(iSymbol,0,3)+iSuffix,PERIOD_CURRENT,1);
               }}//if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
               //USDZZZ или ZZZUSD
               iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1);
               {if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
               {
                  iClose(iDepoCurrency+"USD"+iSuffix,PERIOD_CURRENT,1);
               }}//if(iClose("USD"+iDepoCurrency+iSuffix,PERIOD_CURRENT,1)<=0)
            }}//if(iDepoCurrency!="USD")
            break;
         }   
      default:
         {
            break;
         }
   }}//switch(CheckSymbolQuotaType(iSymbol))
   return;
}//iCloseCallSymbol()

Function for determining the quotation of the instrument in relation to USD.

//=== v3.304 ================================================================================ MQL4/5 ===
// CheckSymbolQuotaType()
//------------------------------------------------------------------------------------------------------
ENUM_QUOTA_TYPE CheckSymbolQuotaType(  string   iSymbol)
{
   string
      BaseCurrency=StringSubstr(iSymbol,0,3),
      CotirCurrency=StringSubstr(iSymbol,3,3),
      OilCurrency=StringSubstr(iSymbol,2,3);
   {if(BaseCurrency=="USD")//USDYYY - Прямая котировка, Базовая валюта доллар США, стоимость лота $ContractSize
   {
      return(QUOTA_TYPE_FORWARD);
   }else{//if(BaseCurrency!="USD") Базовая валюта НЕ доллар США
      {if((CotirCurrency=="USD")||(OilCurrency=="Oil"))//XXXUSD или UxOil (фактически USOUSD) Обратная котировка, Валюта котировки доллар США, стоимость лота $ContractSize*PriceXXX
      {
         return(QUOTA_TYPE_BACKWARD);
      }else{//XXXYYY //if((CotirCurrency!="USD") Кросс-курс, Базовая валюта НЕ доллар США, Валюта котировки НЕ доллар США, стоимость лота $ContractSize*PriceXXXUSD
         return(QUOTA_TYPE_CROSS);
      }}//if((CotirCurrency=="USD")||(OilCurrency=="Oil"))
   }}//if(BaseCurrency=="USD")
   return(QUOTA_TYPE_CROSS);
}//CheckSymbolQuotaType()

It is advisable to place the function iCloseCallSymbol () in OnInit ().

I express my gratitude for possible constructive criticism.


Share it with friends: