Download MetaTrader 5

iBarShift is not working in backtest

To add comments, please log in or register
Ahmed Sabry Bakry
10
Ahmed Sabry Bakry  

Please find the below code and here's the problem:

datetime fromDT ="00:00",

           toDT ="07:00";

int      fromBar = iBarShift(NULL, 60, fromDT),

           toBar = iBarShift(NULL, 60,   toDT),

          length = fromBar - toBar + 1,

           HHbar = iHighest(NULL,60, MODE_HIGH, length, toBar),

           LLbar =  iLowest(NULL,60, MODE_LOW,  length, toBar);

double     HH    = iHigh(NULL,60, HHbar),

           LL    = iLow(NULL,60, LLbar); 

 the problem is in backtesting HH and LL are returning the open price of the current bar only.

 

Any help please?

whroeder1
16108
whroeder1  
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. datetime fromDT ="00:00"
    A string is not a datetime. StringToTime - Conversion Functions - MQL4 Reference
  3. "00:00" is not valid to StringToTime.



Vasyl Nosal
19305
Vasyl Nosal  

Maybe helps you.

 https://www.mql5.com/en/code/viewcode/14322/86819/time_trading.mq4

Carl Schreiber
7364
Carl Schreiber  
eevviill:

Maybe helps you.

 https://www.mql5.com/en/code/viewcode/14322/86819/time_trading.mq4

Your link is dead (error 404).
Vasyl Nosal
19305
Vasyl Nosal  
gooly:
Your link is dead (error 404).
https://www.mql5.com/en/code/viewcode/14244/82456/time_trading__7.mq4
To add comments, please log in or register