Bars in a row on logics are used to determine whether a condition has always occurred within the last few bars. This typically used with a combination of logics that do not necessarily occur at the same time (i.e on the same bar) and/or to validate that a certain logic was reinforced throughout the last few bars.
In this example we check for a cross over between two Exponential Moving Averages (EMA) at the current bar. At the same time we would like to check the price has been trending up by checking that the EMA 100 has been increasing for the last 5 bars using the bars in a row function. By checking the EMA with its previous bar (i.e. using the index function) and setting a bars in a row value of 5 this condition is automatically checked for the last n (i.e. 5) bars.
The equivalent logic using the Strategy Designer can be defined as follows:
In the following example two logics are created one for verifying moving average cross overs and checking whether the moving average has been above its previous value (using an index of 1 - see index function for more details) for the last 10 bars.
To create the bar in a row condition in the designer the following steps must be followed and the logic needs to be saved: