Distance between two bars.

 

Hi. At first I would like to say hello to everyone as it is my firs post ;)

I have a question, which I can not find answer for few days already :(


Is there any way to obtain amount of bars between two bars. I mean something like iBarShift() function with two arguments.

Alternatively how to obtain "shift" value for x bar instead of 0 bar in a chart . Something like iBarShift() for 1,2,3,4 bar.

Thanks.

 

How do you identify your 2 bars? Maybe with timestamps?


datetime some_time1 = D'2004.03.21 12:00';
datetime some_time2 = D'2004.03.21 12:30';

int         shift_1 = iBarShift("EUROUSD",PERIOD_M1,some_time1);
int         shift_2 = iBarShift("EUROUSD",PERIOD_M1,some_time2);

int        distance = shift_1 - shift_2;
 

Worked great.

Thanks.