SymbolInfoString() problem on the tester

 

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
      }
   }
 
真 木 英 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
 
真 木 英 maki:


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

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


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

 
Vladimir Karputov:

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

Added the code.

This is MQL5.

 

Added an MQ5 file.

The pair used is EURUSD, and account currency is JPY.

In my environment, just having follow code causes a similar error.

string profit = SymbolInfoString("USDJPY", SYMBOL_CURRENCY_PROFIT);


If the code is valid, there is no profit.

SymbolInfoString() is valid


If the code is invalid, there is profit.

SymbolInfoString() is invalid

Files:
E-Test1.mq5  3 kb
 
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);
 
Try to find your answer in this code.



Define Margin per open Position
Define Margin per open Position
  • 2021.05.04
  • www.mql5.com
Hello everyone. I really hope to get some hints where to dig further...
 
Dominik Egert: Try to find your answer in this code. https://www.mql5.com/en/forum/368609#comment_2218808

Just a friendly reminder to use the Link tool (Ctrl-K) when adding links so that they clickable. Otherwise we have to copy/paste them into the address bar.

 
Thank you. I usually use my mobile and it does not provide these features. Neither on the site, nor by keyboard.

Very annoyed.

Also I cannot reply to people on mobile. Another disadvantage of the rather exotic forum software in use.


Reason: