1

I get buy and sell signals from an indicator. Let's say I got a buy signal. Now I want to count the pivot highs after that signal. I can do this with the following code:

var countPivotHigh = 0
countPivotHigh := ta.barssince(buySignal) < ta.barssince(sellSignal) ? pivotHigh ? countPivotHigh + 1 : countPivotHigh : 0

This counter is only reset to zero when the indicator gives a sell signal.

The problem is, that the indicator can give several buy signals in a row and when that happens I also need to reset the counter of the pivot highs. So that with every new buy signal the counting starts at zero again.

But I don't know how to code this. Could anybody help me please?

0 Answers0