Hey guys, I'm baffled that I cannot get this simple ATR trailing stop attempt working correctly. I just want to setup a basic ATR trailing stop that stays on the intended side of a trade (as opposed to the built-in indicator that flips sides depending on price action). For some reason, though, if you plot the following code the plot does not obey the Max or Min functions and will decrease (if max used) or increase (if min used) with price action. Anyone know what I'm doing wrong?
input ATRPeriod = 5; input ATRFactor = 3.5; def loss = ATRFactor * atr(atrperiod); def traillong = close - loss; def trailshort = close + loss; plot atrtraillong = Max(traillong, traillong); plot atrtrailshort = Min(trailshort, trailshort);