Dang, that was quick. Thank you for your help. I have been trying to do this for hours and haven't got it to work. LOL I was no where near that code. If the 8 ema goes above the 3 MA does the color go to red? And does this get affected by timeframes? Can I also have the number represent how many bars it has crossed?try this and adjust t he way you want.
CSS:def FastMA = ExpAverage(close, 3); def SlowMA = ExpAverage(close, 8); def Condition = FastMA>SlowMA; def barssince = if Condition then barssince[1] + 1 else 0; def bar = if barssince>0 then barssince else Double.NaN; plot scan = bar within 3 bars; scan.SetDefaultColor(Color.BLACK); AssignBackgroundColor(if bar >= 10 then color.CYAN else if bar >= 3 then color.GREEN else if bar > 0 then color.YELLOW else color.LIGHT_RED);
@samer800 I just tested using OnDemand. It does show colors but they are way off on bar timing. For instance, I waited for the 3MA to cross over the 8MA. It was below it for at least 20 bars on the 1 min and the watch list was already showing a green colored box. When it did cross over, nothing actually changed. What I was hoping to achieve, was to have the box turn green when the 3 ma crosses over the 8 ma for at least 3 bars and then go to red when the 8 ma crosses over the 3 ma for at least 3 bars anything outside of 3 bars can be yellow/gray/or no color. No need for the number of bars displayed as mentioned above.
Last edited by a moderator: