• Happy Independence Day! Take $40 off VIP Membership with code JULY4. Sign up here.

Need help with 200 SMA labels


New member
Green color Label= Candles over 20(SMA) and 20(SMA) over 200(SMA)

Red color Label = Candles under 20(SMA) and 20(SMA) under 200(SMA)

Labels appear as dot/circle on the top left corner of the chart and can work on all time frames.


Well-known member
2019 Donor
input Showlabels = yes;
input price = close;
input length = 20;
input displace = 0;

input length_200 = 200;

DEF SMA = Average(price[-displace], length);
DEF SMA_200 = Average(price[-displace], length);

def waveUP = SMA > SMA_200 and close > SMA;
def waveDN = SMA < SMA_200 and close < SMA;
def wavenet = !waveUP and !waveDN;

AddLabel(Showlabels and  waveUP, "SMA = Bullish", Color.GREEN);
AddLabel(Showlabels and  waveDN, "SMA = Bearish", Color.RED);
AddLabel(Showlabels and  wavenet, "SMA = Neutral", Color.YELLOW);
Last edited by a moderator:

Similar threads