Else If Help
Posted: Tue Dec 14, 2021 11:16 pm
Trying to figure out how to turn off the sell label when price is above the 200D MA
as well as turn off the buy label if price is below the 200D ma
indicator("Redlight-Greenlight", overlay=true)
GreenLightMA = ta.sma(close, 7)
RedLightEMA = ta.ema(close, 47)
BullMarket = ta.sma(close, 200)
plot(GreenLightMA, color = color.green)
plot(RedLightEMA, color = color.red)
plot(BullMarket, color = color.orange)
buy = ta.crossover(GreenLightMA, RedLightEMA)
sell = ta.crossover(RedLightEMA, GreenLightMA)
if (buy)
lbl = label.new(bar_index, low, "Buy")
label.set_color(lbl, color.green)
label.set_yloc(lbl, yloc.belowbar)
label.set_style(lbl, label.style_label_up)
if (sell)
lbl = label.new(bar_index, low, "Sell")
label.set_color(lbl, color.red)
label.set_yloc(lbl, yloc.abovebar)
label.set_style(lbl, label.style_label_down)
as well as turn off the buy label if price is below the 200D ma
indicator("Redlight-Greenlight", overlay=true)
GreenLightMA = ta.sma(close, 7)
RedLightEMA = ta.ema(close, 47)
BullMarket = ta.sma(close, 200)
plot(GreenLightMA, color = color.green)
plot(RedLightEMA, color = color.red)
plot(BullMarket, color = color.orange)
buy = ta.crossover(GreenLightMA, RedLightEMA)
sell = ta.crossover(RedLightEMA, GreenLightMA)
if (buy)
lbl = label.new(bar_index, low, "Buy")
label.set_color(lbl, color.green)
label.set_yloc(lbl, yloc.belowbar)
label.set_style(lbl, label.style_label_up)
if (sell)
lbl = label.new(bar_index, low, "Sell")
label.set_color(lbl, color.red)
label.set_yloc(lbl, yloc.abovebar)
label.set_style(lbl, label.style_label_down)