In the Internet, across many boards one can read that it is impossible to make use of MarketInfo()
function in the Strategy Tester. It's the limitation of the platform.
I haven't found on the web any workaround for this. However, since the need is the mother of invention, and my need was to make USDJPY
market decisions with EA that depends on the state of EURUSD
market I've found the workaround ( which is good enough for me ). I use iMA()
with a period of one, and M1
resolution.
iMA( "EURUSD", PERIOD_M1, 1, 0, MODE_SMA, PRICE_MEDIAN, i )
The question is:
since MetaTrader is able to calculate Moving Average for another currency ( which is surely based on the actual price of the pair! ),Q1:
why can't one has access to the current value : directly?
And a follow-up question:Q2:
Is there any other ( more accurate ) workaround for this limitation?
REASON: The reason to that question is because of "Tick". Because a "tick" in one currency happens independently from the "tick" of another currency, it is not possible to accurately determine the Price of another currency basing on the current "Tick" of one currency. The iMA
is calculated using the OHLC of the M1 candle, and not the actual "Tick" (which is not the same as "Tick" data).
Rephrase: Let's say we are on USDJPY, and this "tick" happens at 12:00:00.210 (12mid-night at the 210th millisecond). When that "tick" happens, the start()
event gets triggered. In that function, we look for Bid of EURUSD. However, there is no "Tick" for EURUSD as of that time (the USDJPY and EURUSD do not "tick" at the same time), thus it is not possible to determine the exact price of EURUSD at-that-point-in-time.
There is no workaround because it is impossible to determine the price on the "Tick" level because MQL4's datetime
variable is an integer
and accurate only to the seconds, and the HistoryCenter>Export are OHLC only.
Your iMA()
is as good as it gets.