0

I'm looking for a way to compare the highest high of a current event to the highest high to the previous event but i can't figure out how to look for this since i can only find ways to use bars as a lookback period instead of the previous event.

this is as far as i could get.

var float HH = 0.00
var float LL = 0.00
var float HHprevious = 0.00
var float LLprevious = 0.00

if signalLong or signalShort
    HHprevious := HH
    LLprevious := LL
    HH := ta.highest(high, ta.barssince(signalLong[1]) + 1)
    LL := ta.lowest(low, ta.barssince(signalLong[1]) + 1)
Pitt
  • 13
  • 5

1 Answers1

1

you might try this

var float LL = 0.00
var float HHprevious = 0.00
var float LLprevious = 0.00

highest_marker =ta.highest(high, ta.barssince(signalLong)[1] + 1)
lowest_marker = ta.lowest(low, ta.barssince(signalLong)[1] + 1)
if signalLong or signalShort
    HHprevious := HH
    LLprevious := LL
    HH := highest_marker
    LL := lowest_marker
John Baron
  • 291
  • 2
  • 8
  • 1
    Great solution! Improvement suggestion for the length parameter you may consider: math.max(nz(ta.barssince(signalLong)[1] + 1), 1) – elod008 Nov 01 '22 at 18:45