Zero divide error when backtesting historical but not in real time (demo) operation

 
Hi,

here the problem I've being fighting against.

The following code runs properly when the strategy is attached to a chart (GBPUSD pair)

    int risk = 1;
    int lot_price = 100000;
    double lots = 0.03;

    double pip_value;
    double max_stop:

    //Pip Value in EUR for the EURUSD pair (Attached to the GBPUSD chart)

    pip_value = (Point * lot_price) / (Ask * MarketInfo ("EURGBP", MODE_ASK)); 

    //Maximum StopLoss distance for a given lot number, account balance and risk

     max_stop = (AccountBalance() * risk / 100) / (pip_value * lots);

But when I bastest it, i receive the error Zero divide in the line:

    pip_value = (Point * lot_price) / (Ask * MarketInfo ("EURGBP", MODE_ASK)); 
because MarketInfo ("EURGBP", MODE_ASK) is equal to 0.

I've downloaded all historical data with no changes.

Any idea how to get access to this information from the GBPUSD chart in backtesting? Can MT do it anyway?

Thank you in advance
 
Profit_Warning:
The following code runs properly when the strategy is attached to a chart (GBPUSD pair)
But when I bastest it, i receive the error Zero divide in the line:
because MarketInfo ("EURGBP", MODE_ASK) is equal to 0.
Tester can be used for one symbol only -> https://www.mql5.com/en/articles/1512.
If all you need is the Ask price of another currency, you can have the expert search for it in the hst files (via File functions).
 
gordon:
Tester can be used for one symbol only -> https://www.mql5.com/en/articles/1512.
If all you need is the Ask price of another currency, you can have the expert search for it in the hst files (via File functions).


Thanks, gordon. Nerver heard about this topic. I'll try to solve it as you mention.
 
Also if the symbol does not end in your account currency then pip_value will not be in your account currency and the equation with AccountBalance() will be bogus.
 pip_value = MarketInfo( Symbol(), MODE_TICKVALUE );
Finally on a 5 digit broker a pip is NOT a point
//++++ These are adjusted for 5 digit brokers.
double  pips2points,    // slippage  3 pips    3=points    30=points
        pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int init() {
    if (Digits == 5 || Digits == 3) {   // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
 
WHRoeder:
Also if the symbol does not end in your account currency then pip_value will not be in your account currency and the equation with AccountBalance() will be bogus. Finally on a 5 digit broker a pip is NOT a point


Thanks WHRoeder,

My broker is Alpari UK, and Point = 0.00001 and Digit = 5, so, for them and for my purposes (calculate the maximum stop distance for a fixed risk of 1% of my balance) there's no real diference. I also think that the Point should be 0.0001, but in this case are the same.

My account is in EUR, so I had to operate a little bit. Point (=0.00001)*100.000/ASK(GBPUSD) give the the value of a point (a change of 1 lot in 0.00001) in GBP. To get the value in my account currency, EUR, I have to convert this value to EUR just dividing the previous value by the ASK(EURGBP).

And it's at that point, getting the ASK (EURGPB) value where I had problems.

Thans for your code.
Reason: