input trailType = {default modified, unmodified}; input ATRPeriod = 9; input ATRFactor = 2.9; input firstTrade = {default long, short}; input averageType = AverageType.exPONENTIAL; def thisATR = ATRTrailingStop(trailType, ATRPeriod, ATRFactor, firstTrade, averageType).TrailingStop; rec countBullish = if close < thisATR then 0 else countBullish[1] + 1; rec countBearish = if close > thisATR then 0 else countBearish[1] + 1; plot data = if countBullish > 0 then countBullish else if countBearish < 0 then countBearish else 0; data.SetDefaultColor(Color.BLACK); AssignBackgroundColor(if countBullish == 1 then Color.cyan else if countBullish > 1 then color.green else if countBearish == -1 then Color.cyan else if countBearish < -1 then Color.RED else Color.red);