The BARSTRUE function calculates how many times a condition is true over a given lookback period. In this example, we want to know when the low price has crossed the 13period EMA for the first time in 10 days. To do this we can create 2 variables, one for the crossover and one for the barstrue lookback, and then return the result when both are true:

c1 = LOW() CrossesBelow MA(BARS=13, STYLE=Exponential); c2 = BARSTRUE(LOW()[1] > MA(BARS=13, STYLE=Exponential)[1], LOOKBACK=10) == 10; c1 and c2

In the c2 condition we’re looking at 10 bars prior to the crossover (c1) where the low is above the 13EMA every day, so == 10 (remember to use the ‘==’ for equality).

If you wanted to look back 20 days and know when any 15 days out of the 20 are above the 13EMA you would use the following for c2:

c2 = BARSTRUE(LOW()[1] > MA(BARS=13, STYLE=Exponential)[1], LOOKBACK=20) == 15;