#Daily Simple Moving Averages with Identifying Bubbles
#Pensar
#Simple Moving Averages
input avg_1 = 20;
input avg_2 = 50;
input avg_3 = 200;
input avg_type = AverageType.SIMPLE;
def c = close(period = AggregationPeriod.DAY);
plot ma1 = MovingAverage(avg_type,c,avg_1);
ma1.SetDefaultColor(Color.YELLOW);
plot ma2 = MovingAverage(avg_type,c,avg_2);
ma2.SetDefaultColor(Color.DARK_ORANGE);
plot ma3 = MovingAverage(avg_type,c,avg_3);
ma3.SetDefaultColor(Color.GREEN);
#Bubbles
input show_bubbles = yes;
def x = !IsNaN(close[-25]) and IsNaN(close[-26]);
AddChartBubble(show_bubbles and x, ma1, avg_1 + " MA", Color.YELLOW, if ma1 > c then yes else no);
AddChartBubble(show_bubbles and x, ma2, avg_2 + " MA", Color.DARK_ORANGE, if ma2 > c then yes else no);
AddChartBubble(show_bubbles and x, ma3, avg_3 + " MA", Color.GREEN, if ma3 > c then yes else no);
#end code