scott69
Active member
@acjtumio1987 Modify this to suit your purposes. Instead of "3 above 9" change the code so that it is "Price is Above or Below MA" Follow through the logic and you should be able to modify this to do what you want.
Code:
# SD_MARelationLabel
# Scott D
# Version: 01
# Original: November 17, 2020
# Last Mod: November 17, 2020
input MAshort = 3;
input MAlong = 9;
input MAtwenty = 20;
input MAfifty = 50;
def MA1 = movAvgExponential(close, MAshort);
def MA2 = movAvgExponential(close, MAlong);
def MA3 = movAvgExponential(close, MAtwenty);
def MA4 = movAvgExponential(close, MAfifty);
AddLabel(yes, if MA1 > MA1[1] then " 3 EMA RISING " else " 3 EMA FALLING ", if MA1 > MA1[1] then Color.GREEN else Color.RED);
AddLabel(yes, if MA2 > MA2[1] then " 9 EMA RISING " else " 9 EMA FALLING ", if MA2 > MA2[1] then Color.GREEN else Color.RED);
AddLabel(yes, if MA1 > MA2 then " 3 ABOVE 9 " else " 3 BELOW 9 ", if MA1 > MA2 then Color.GREEN else Color.RED);
AddLabel(yes, if MA3 > MA3[1] then " 20 EMA RISING " else " 20 EMA FALLING ", if MA3 > MA3[1] then Color.GREEN else Color.RED);
AddLabel(yes, if MA1 > MA3 then " 3 ABOVE 20 " else " 3 BELOW 20 ", if MA1 > MA3 then Color.GREEN else Color.RED);
AddLabel(yes, if MA4 > MA4[1] then " 50 EMA RISING " else " 50 EMA FALLING ", if MA4 > MA4[1] then Color.GREEN else Color.RED);
AddLabel(yes, if MA1 > MA4 then " 3 ABOVE 50 " else " 3 BELOW 50 ", if MA1 > MA4 then Color.GREEN else Color.RED);
### End Code ###