Parabolic1
Parabolic1

Reputation: 17

Adding 1 bar delay (pine script)

I want the conditions "buyDB" and "sellDB" to trigger 1 bar after the bar of the close, ie. 1 bar after the crossover/crossunder. What would I add to this script for that? Thanks in advance!:

buyDB = crossover(close, TopBox)
sellDB = crossunder(close, BottomBox)

Upvotes: 0

Views: 437

Answers (1)

Bjorgum
Bjorgum

Reputation: 2310

Try using a historical operator on your condition. eg.

buyDB = (crossover(close, TopBox))[1] sellDB = (crossunder(close, BottomBox)[1]

or you could add it in later if you have other conditions:

long = condition and buyDB[1]

Cheers and best of luck with your trading and coding!

Upvotes: 1

Related Questions