Hello, I'm trying to add a label that dynamically changes its text and color depending on a condition being met. My code below:
Essentially I have this working to the point where it displays HIGHER or LOWER. What I want it to do is if MA_1_closeType > MA_2_closeType then display HIGHER and color the label green, and if it MA_1_closeType < MA_2_closeType then display LOWER and color the label red.
Thank you for your help.
Code:
#EMA3vsEMA9
#Checks if the previous day's closing EMA3 is higher or lower than the previous days closing EMA9
input MA_1_length = 3; #exponential
input MA_2_length = 9; #exponential
input MA_1_closeType = ohlc4;
input MA_2_closeType = ohlc4;
AddLabel(yes, if MA_1_closeType > MA_2_closeType then "HIGHER" else "LOWER");
Essentially I have this working to the point where it displays HIGHER or LOWER. What I want it to do is if MA_1_closeType > MA_2_closeType then display HIGHER and color the label green, and if it MA_1_closeType < MA_2_closeType then display LOWER and color the label red.
Thank you for your help.