SymbolInfoString() problem on the tester

Eishin Maki  

I want to call SymbolInfoString () for another currency pair, but I'm having trouble onthe tester.

If EA call SymbolInfoString () for another currency pair, its currency pair will appear on MarketWatch.

However, its price is not displayed and but also cannot be used to calculate the profit and loss of positions.

error message: "no prices for symbol USDJPY (1970.01.01 00:00:00 0.00000, 0.00000)"


Please tell me the workaround.

I want to get a currency pair of account currency and  profit currency of current currency pair.


   string margin = AccountInfoString(ACCOUNT_CURRENCY);
   string profit = SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT);
   
   for(int i = SymbolsTotal(false); i >= 0; i--)
   {
      string sym = SymbolName(i, false);
      string otherBase = SymbolInfoString(sym, SYMBOL_CURRENCY_BASE);
      string otherProfit = SymbolInfoString(sym, SYMBOL_CURRENCY_PROFIT);
      
      if((otherBase == profit && otherProfit == margin) || (otherBase == margin && otherProfit == profit))
      {
         marginPair = sym; //Necessary information
      }
   }
Fabio Albano  
真 木 英 maki:

I want to call SymbolInfoString () for another currency pair, but I'm having trouble onthe tester.

You can't work with other symbols on the tester.
Which makes a demo of mine useless btw
Vladimir Karputov  
真 木 英 maki:


Please insert the code correctly: when editing a message, press the button    Codeand paste your code into the pop-up window.

Dominik Egert  
Load an indicator like iATR to make the environment load the data for you.
Vladimir Karputov  
真 木 英 maki :


Are you probably talking about an old terminal (MQ4)?

Eishin Maki  
Vladimir Karputov:

Are you probably talking about an old terminal (MQ4)?

Added the code.

This is MQL5.

Eishin Maki  
Dominik Egert:
Load an indicator like iATR to make the environment load the data for you.

I was able to get the information by adding iClose().

Thanks so much.

But I sigh...


   string account = AccountInfoString(ACCOUNT_CURRENCY);
   string margin = SymbolInfoString(_Symbol, SYMBOL_CURRENCY_MARGIN);
   string profit = SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT);
   string marginPair = "";
   
   for(int i = SymbolsTotal(false); i >= 0; i--)
   {
      string sym = SymbolName(i, false);
      string otherBase = SymbolInfoString(sym, SYMBOL_CURRENCY_BASE);
      string otherProfit = SymbolInfoString(sym, SYMBOL_CURRENCY_PROFIT);
      
      if((otherBase == profit && otherProfit == account) || (otherBase == account && otherProfit == profit))
      {
         accountPair = sym; //Necessary information
      }
      else if((otherBase == margin && otherProfit == account) || (otherBase == account && otherProfit == margin))
      {
         marginPair = sym;
      }
   }
   
   double close1 = iClose(accountPair, PERIOD_CURRENT, 1);
   double close2 = iClose(marginPair, PERIOD_CURRENT, 1);
Reason: