I am trying to make a plot for higher crossovers or lower crossovers. So for example if I have a HMA and a displaced HMA cross up I want to return the low of that bar. Then I want to return the next low that it crosses above it, same with crossing below returning the high of that bar as a variable. I can't seem to make it work, I think I am missing a bar variable.
input Value = close; input Length = 55; def HMA = MovingAverage(AverageType.HULL, Value, length); def HMADisplaced = MovingAverage(AverageType.HULL, Value, length); def cu = Crosses(HMA, HMADisplaced, CrossingDirection.ABOVE); def cd = Crosses(HMA, HMADisplaced, CrossingDirection.BELOW); def Sell = if cd then high else Double.NEGATIVE_INFINITY; def Buy = if cu then low else Double.POSITIVE_INFINITY; plot uptrend = Sell > Sell and Buy > Buy; plot dntrend = Sell < Sell and Buy < Buy;