All I'm trying to do is determine the slope of the Hull Moving Average for different time frames, but my code doesn't generate any labels. I understand I have to set the chart period to something shorter than the periods I'm calculating.
Code:
#INPUTS
input malength = 9;
input averageType = AverageType.HULL;
input showlabels = yes; #show labels
input show1MIN = yes; #show ONE MINUTE label
input show2MIN = yes; #show TWO MINUTES label
input show3MIN = yes; #show THREE MINUTES label
#CORE
DefineGlobalColor("Bullish", Color.DARK_GREEN);
DefineGlobalColor("TurnBullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.DARK_RED);
DefineGlobalColor("TurnBearish", Color.RED);
DefineGlobalColor("Neutral", Color.GRAY);
# AGGREGATION 1 - ONE MINUTE
def aM1 = AggregationPeriod.MIN;
def closem1 = close(period = aM1);
def MaM1 = MovingAverage(averageType = averageType, closem1, malength);
def bullishM1 = MaM1[0] > MaM1[aM1];
def bearishM1 = MaM1[0] < MaM1[aM1];
AddLabel(showlabels and show1MIN, "1MIN",
if bullishM1[0] and bullishM1[1] then GlobalColor("Bullish")
else if bullishM1[0] and bearishM1[1] then GlobalColor("TurnBullish")
else if bearishM1[0] and bearishM1[1] then GlobalColor("Bearish")
else if bearishM1[0] and bullishM1[1] then GlobalColor("TurnBearish")
else GlobalColor("Neutral"));
# AGGREGATION 2 - TWO MINUTES
def am2 = AggregationPeriod.TWO_MIN;
def closem2 = close(period = am2);
def MaM2 = MovingAverage(averageType = averageType, closem2, malength);
def bullishM2 = MaM2[0] > MaM2[am2];
def bearishM2 = MaM2[0] < MaM2[am2];
AddLabel(showlabels and show2MIN, "2MIN",
if bullishM2[0] and bullishM2[1] then GlobalColor("Bullish")
else if bullishM2[0] and bearishM2[1] then GlobalColor("TurnBullish")
else if bearishM2[0] and bearishM2[1] then GlobalColor("Bearish")
else if bearishM2[0] and bullishM2[1] then GlobalColor("TurnBearish")
else GlobalColor("Neutral"));
# AGGREGATION 3 - THREE MINUTES
def am3 = AggregationPeriod.THREE_MIN;
def closem3 = close(period = am3);
def MaM3 = MovingAverage(averageType = averageType, closem3, malength);
def bullishM3 = MaM3[0] > MaM3[am3];
def bearishM3 = MaM3[0] < MaM3[am3];
AddLabel(showlabels and show3MIN, "3MIN",
if bullishM3[0] and bullishM3[1] then GlobalColor("Bullish")
else if bullishM3[0] and bearishM3[1] then GlobalColor("TurnBullish")
else if bearishM3[0] and bearishM3[1] then GlobalColor("Bearish")
else if bearishM3[0] and bullishM3[1] then GlobalColor("TurnBearish")
else GlobalColor("Neutral"));