MQL4: MarketInfo returns Zero for EURUSD!

 

Hi All,

I'm trying to convert amounts from base currency to my deposit currency but i got stuck with MarketInfo that gives me zero when i use it like this:

MarketInfo("EURUSD", MODE_ASK);

I checked that the currency pair "EURUSD" is available in MarketWatch.

Thanks in advance for your help.

 
Zakaria O.:

Hi All,

I'm trying to convert amounts from base currency to my deposit currency but i got stuck with MarketInfo that gives me zero when i use it like this:

MarketInfo("EURUSD", MODE_ASK);

I checked that the currency pair "EURUSD" is available in MarketWatch.

Thanks in advance for your help.

How do you know that it returns zero?

Show your code that does this.

 
  1. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 2019.05.20

    On MT5: Unless the chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
              Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum
              Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
              Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum
              SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum 2019.09.03
              OnCalculate during weekend MT5 - General - MQL5 programming forum

  2. don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.