Backtesting different pair not correct data?

 

Hi all

Im backtesting GBPUSD but with data from EURUSD


I get the correct value from double high_1 && double low_1

But the double high && double low i will get the open price on current bar not the high and the low? What am i doing wrong?

double high_1 = iHigh("EURUSD", 0, 1);
Print("high_1 is ", DoubleToStr(high_1,5)); 

double low_1 = iLow("EURUSD", 0,  1);
Print("low_1 is ", DoubleToStr(low_1,5)); 


double high = iHigh("EURUSD", 0, 0);
Print("high is ", DoubleToStr(high,5)); 

double low = iLow("EURUSD", 0,  0);
Print("low is ", DoubleToStr(low,5)); 
 
pontuso:

Hi all

Im backtesting GBPUSD but with data from EURUSD


I get the correct value from double high_1 && double low_1

But the double high && double low i will get the open price on current bar not the high and the low? What am i doing wrong?

It tells you here: Testing Features and Limits in MetaTrader 4

"Zero bar of another timeframe for the same symbol under test is modeled approximately

  • Open = correct Open, Close = correct Close, Low = min (Open,Close), High = max (Open,Close), Volume = final Volume (false)"

 

Great thanx.


But if i trade with the EA Live, i do not use

*Low = min (Open,Close), High = max (Open,Close)


Correct??

 
pontuso:

Great thanx.


But if i trade with the EA Live, i do not use

*Low = min (Open,Close), High = max (Open,Close)


Correct??

Live you will get the correct values for OHLC, bear in mind Close[0] == Bid and High[0] and Low[0] can change while the bar is forming . . .
 
RaptorUK: "Zero bar of another timeframe for the same symbol under test is modeled approximatel
No longer true. There's a post 6 months back where someone tested it. OHLC, Current symbol, PERIOD_D1, bar 0 was correct.
pontuso: Im backtesting GBPUSD but with data from EURUSD What am i doing wrong?

your chart pair is modeled (bar zero) is the current price. You are assuming that the other chart is also. It's not. (tested on build 445)

You have to find the correct shift [iBarShift(otherPair,otherTF, Time[0])].

The other pair is also constrained by max Bars in chart. Make sure you have enough bars to cover your tester start date.

 
WHRoeder:
No longer true. There's a post 6 months back where someone tested it. Current symbol is now fine.

Now you mention it . . . I do recall it, the OP would seem to disagree. Perhaps I should find out for myself . . .

This thread: https://www.mql5.com/en/forum/142100

 

I was looking for a URL on the problem, (I hadn't saved any.) Found it: I posted a comment at the bottom of the article, with two links: Is no longer correct, per Tester in the Terminal MetaTrader 4: It Should Be Known - MQL4 Articles and in EA testing The "someone tested it" was me! LOL

 
WHRoeder:
No longer true. There's a post 6 months back where someone tested it. OHLC, Current symbol, PERIOD_D1, bar 0 was correct.

your chart pair is modeled (bar zero) is the current price. You are assuming that the other chart is also. It's not. (tested on build 445)

You have to find the correct shift [iBarShift(otherPair,otherTF, Time[0])].

The other pair is also constrained by max Bars in chart. Make sure you have enough bars to cover your tester start date.

Dosent work how shall i code to get the last high for different symbol in strategy tester

double high = iHigh("EURUSD", 60, 0);  //Not correct i understand

double high = iHigh("EURUSD", 60,iBarShift("EURUSD",60, Time[0]); // does not work
 

"Doesn't work" is a meaning less expression - there are no mind readers here.

Print out your variables, what is iBarShift, value what is iBars("EURUSD",60)

 
pontuso:

Dosent work how shall i code to get the last high for different symbol in strategy tester

Have you confirmed that you have H1 EURUSD data for the period covering Time[0] ?
Reason: