marketinfo, me too needing help on getting info from beyond the connected chart

 

dear forum,

good morning from vienna, austria, europe

szenario:

i am tradinng a symbol and my accountcurrency is a different currency from the ones in the traded symbol

so i want to to do some computations from the quote currency to my accountcurrency

here some coding:

//...somewhere in the init function:

   BaseCurrency = StringSubstr(Symbol(), 0, 3);                        // the first 3 chars
   QuoteCurrency = StringSubstr(Symbol(), 3, 3);                       // the next 3
   SymbolSuffix = StringSubstr(Symbol(), 6, StringLen(Symbol())-6);    // incase there is something left (in my special case there is!)
   
// --- printout for my own security :-)
   Print(
         "Symbol is ", Symbol(),
         " => BaseCurrency is ", BaseCurrency,
         ", QuoteCurrency is ", QuoteCurrency,
         ", SymbolSuffix is ", SymbolSuffix
         );
   Print("Account currency is ", AccountCurrency());

// --- the purpose of the following lines is to prepare combinations of both ways of the
// --- conversion symbol to my account currencyfor instance GBPJPY and JPYGBP
// --- to check which one exists
   ConversionSymbol1 = StringConcatenate(QuoteCurrency,AccountCurrency(),SymbolSuffix);
   ConversionSymbol2 = StringConcatenate(AccountCurrency(),QuoteCurrency,SymbolSuffix);

// --- here i do the checkup by looking which of the two has a timecode not equal to zero
// --- first i print out because i am a control freak,
// --- and i convert to readable time to make it look nice and tidy
   Print("ConversionSymbol1: ", ConversionSymbol1,
         ", last Tick @ ", TimeToStr(MarketInfo(ConversionSymbol1,MODE_TIME),TIME_DATE),
         " ", TimeToStr(MarketInfo(ConversionSymbol1,MODE_TIME),TIME_SECONDS));
   Print("ConversionSymbol2: ", ConversionSymbol2,
         ", last Tick @ ", TimeToStr(MarketInfo(ConversionSymbol2,MODE_TIME),TIME_DATE),
         " ", TimeToStr(MarketInfo(ConversionSymbol2,MODE_TIME),TIME_SECONDS));

// --- here i check if i have to do the rest of this
   if (QuoteCurrency != AccountCurrency())
// --- yes i have to, so i check the first one
      if (MarketInfo(ConversionSymbol1,MODE_TIME) != 0)
         {
         ConversionSymbol = ConversionSymbol1;
         AccountCurrencyRole = "Quote";
         }
      else
         {
// --- and here i check the second one
         if (MarketInfo(ConversionSymbol2,MODE_TIME) != 0)
            {
            ConversionSymbol = ConversionSymbol2;
            AccountCurrencyRole = "Base";
            }
         else
            Print ("Could not find ConversionSymbol!");
         }   
   else            
      {
      ConversionSymbol = "";
      AccountCurrencyRole = "";
      }
            
// --- so when i know what i want to know i print it out again
   Print ("ConversionSymbol is ", ConversionSymbol);

...

until here everything works fine but later, somewhere in the start funktion, there occurs the problem that i do not get a quote for my correctly prepared conversionsymbol.

again some coding here:

// --- somewhere in the start function:

// ...

      if (ConversionSymbol != "")
// --- here i know that i have a conversion symbol
// --- there is a print again, that proofs i am in this part of the if
// --- it ALWAYS prints out 0 (zero) fo rthe conversion symbol
         {
         ConversionQuote = NormalizeDouble(MarketInfo(ConversionSymbol,MODE_BID),Digits);
         Print("ConversionQuote is: ", ConversionQuote);
         }
      else
         ConversionQuote = 0;
i have used this in the tester, not in letting it run on an account, should not the tester also deliver a quote for my conversion symbol?
what is wrong here? 
maybe it is not the best coding but i hope you get the general purpose.
thank you all for the help!
chz
 

I also perform money management across symbols which do not match the account currency, but have a much less complex way of achieving this.

Have a look at MarketInfo(Symbol(),MODE_TICKVALUE) and MarketInfo(Symbol(),MODE_TICKSIZE).


CB

 
cloudbreaker wrote >>

I also perform money management across symbols which do not match the account currency, but have a much less complex way of achieving this.

Have a look at MarketInfo(Symbol(),MODE_TICKVALUE) and MarketInfo(Symbol(),MODE_TICKSIZE).

CB

thank you very much. that helped :-)

Reason: