I have a code I wrote and i dunno if its working they way I want to to. I was hoping to have a stock that maintains its self above the 9 ema and or 20 ema for 4 or more bars (within a range of consolidation (maybe 1% or 2%), just before a breakout. Think you could help?
def openchange = close; plot x = openchange; input ema1_len = 9; input ema2_len = 20; input averageType = AverageType.EXPONENTIAL; def ema1 = MovAvgExponential(length=ema1_len); def ema2 = MovAvgExponential (length=ema2_len); AssignBackgroundColor( if openchange >= ema1 within 4 bars and openchange >= ema2 within 5 bars then color.white else color.Current); x.AssignValueColor ( if openchange >= ema1 within 4 bars and openchange >= ema2 within 5 bars then color.Black else color.Current);
Last edited by a moderator: