script sma {
input period = AggregationPeriod.DAY;
def varhigh = high(period = period);
def varlow = low(period = period);
plot SMAH = SimpleMovingAvg(varhigh, 20);
SMAH.AssignValueColor(Color.GREEN);
plot SMAL = SimpleMovingAvg(varlow, 20);
SMAL.AssignValueColor(Color.RED);
}
DefineGlobalColor("H", Color.GREEN);
DefineGlobalColor("L", Color.RED);
plot sma1h = sma(period = "MIN");
plot sma1l = sma(period = "MIN").SMAL;
plot sma5h = sma(period = "FIVE_MIN");
plot sma5l = sma(period = "FIVE_MIN").SMAL;
plot sma15h = sma(period = "FIFTEEN_MIN");
plot sma15l = sma(period = "FIFTEEN_MIN").SMAL;
sma1h.SetDefaultColor(GlobalColor("H"));
sma1l.SetDefaultColor(GlobalColor("L"));
sma5h.SetDefaultColor(GlobalColor("H"));
sma5l.SetDefaultColor(GlobalColor("L"));
sma15h.SetDefaultColor(GlobalColor("H"));
sma15l.SetDefaultColor(GlobalColor("L"));
input showbubbles = yes;
input bubblemover = 3;
def bm = bubblemover;
def bm1 = bm + 1;
AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), sma1h[bm1], "1m", GlobalColor("H"));
AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), sma1l[bm1], "1m", GlobalColor("L"));
AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), sma5h[bm1], "5m", GlobalColor("H"));
AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), sma5l[bm1], "5m", GlobalColor("L"));
AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), sma15h[bm1], "15m", GlobalColor("H"));
AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), sma15l[bm1], "15m", GlobalColor("L"));