Question about: MarketInfo(X, MODE_LOTSIZE)

 

Hello,

I am running the tester tool against the CADJPY tool.

When I call MarketInfo("CADJPY", MODE_LOTSIZE) I get "100000".

When I call MarketInfo("USDJPY", MODE_LOTSIZE) I get 0. I fact, I get 0 for any pair other than CADJPY.

I tried also downloading the history for USDCAD, USDJPY, but I still get the issue.

When I run my EA on a live chart, it works fine and I can call MarketInfo for any pair and get the proper results.

So my question is, what am I doing wrong? How can I get the market info of a different pair when using the testing tool?

Thanks!

 
Ricotter:

[...] How can I get the market info of a different pair when using the testing tool?

You can save the required MarketInfo() data to file and read from that file during testing (file functions work fine during testing). More details can be found in the article "Break Through The Strategy Tester Limit On Testing Hedge EA".
 

See my last post in this thread: https://www.mql5.com/en/forum/129652

The code will do multiple things for you, it is symbol() agnostic, and it will compute the max lotsize to take for a position based on the equity you are willing to risk and the stoploss price. Once you have that lotsize value it can also compute for you the profit potential based on your takeprofit price.

It computes the crosses correctly as well, which is what you were after...however you need to be aware that you cannot correctly backtest on crosses because of a fundamental design limitation of MT4's backtester which prevents your EA from accessing the historical price data for other currency pairs during the backtest. In practice what this means is that all monetary valuations that come from trading cross-pairs in a backtest are fundamentally wrong, meaning the profit/loss of the trades themselves when converted into the account's currency by the backtester are simply wrong.

The code I linked to computes them correctly, analytically, no shortcuts taken. But they can't be used in backtesting on crosses because the code will try and calculate market valuations correctly and the backtester will prevent it from doing so and as such the code will simply return error alerts (as it would in real-life forward testing if the broker somehow broke their currency definitions).

Reason: