Are there any looking ahead options in pine script v5?

46 Views Asked by At

So what Im trying to do is that i want a long or short position to open after two conditions have been met. Once the first condition is met then the second condition would have to be met within the next ten bars or the order wont be placed.

For Example:

The market is currently in a downward trend and hits a level of support and rejects off of it, then in 5 bars after the rejection two EMA’s cross over signaling a reversal.

Is there anything in pine script that will allow me to do this?

Ive looked around the user manual and couldnt find anything that could help

1

There are 1 best solutions below

0
On

Sure, you can use ta.barssince().

Counts the number of bars since the last time the condition was true.

ta.barssince(condition) → series int