numbers of bars since a past date

 
I would like to know how to calculate the number of bars since the last time my 2 ema crossed.

What to use, iBarShift ? and how ?
 
If you have the time when they crossed you can use iBarShift. It will give you the index of the bar at certain time.
If you don't then you need to count bars in a loop from 0 upwards until ema cross.
 
irusoh1 wrote:
If you have the time when they crossed you can use iBarShift. It will give you the index of the bar at certain time.
If you don't then you need to count bars in a loop from 0 upwards until ema cross.

thanks, do you have an example of code that loop from 0 upwards until ema cross ?
Reason: