Awesome guys, thanks for all your help. I'm sure happy with this code, which I have completed:
Code:
#ChartAlert_SMA
#EvanEvans
#V1.0
input aggregationPeriod = AggregationPeriod.DAY;
input SMAPeriod = 20;
input SuperSMAPeriod = 50;
input averageType = AverageType.SIMPLE;
input AlertWhenPercentAboveSMA = 0.050;
input SuperAlertWhenPercentAboveSMA = 0.100;
def c = close(period = aggregationPeriod);
def sma = movingaverage(averageType,c,SMAperiod);
def SuperSMA = movingaverage(averageType,c,SuperSMAperiod);
DefineGlobalColor("SuperAbove",Color.Green);
DefineGlobalColor("Above",Color.Dark_Green);
DefineGlobalColor("Below",Color.Dark_Red);
DefineGlobalColor("SuperBelow",Color.Red);
DefineGlobalColor("default",Color.Current);
AssignBackgroundColor(if close > ((SuperAlertWhenPercentAboveSMA+1) * sma)
then GlobalColor("SuperAbove") else if close > ((AlertWhenPercentAboveSMA+1) * sma) then GlobalColor("Above")
else if close < SuperSMA then GlobalColor("SuperBelow") else if close < SMA then GlobalColor("Below") else GlobalColor("default"));
If price is 5% above the 20 sma chart changes to dark green
If price is 10% above the 20 sma chart changes to bright green
If price is below the 20 sma chart changes to dark red
If price is below the 50 sma chart changes to bright red
Example in action: