Branch
Member
I would like one label (response) with the following criteria: price closes above or below Simple moving averages, on the following various times intervals.. The times intervals are 1 minute, 5 minute and 30 minute. When this is TRUE on ALL of those times intervals I want a label 'Buy' when condition meets or 'Sell' when conditions meets based on the def B and def S below.
# PRICE + MA
input price = close;
def SMA9 = MovingAverage(AverageType.SIMPLE, close, 9);
def SMA13 = MovingAverage(AverageType.SIMPLE, close, 13);
def SMA21 = MovingAverage(AverageType.SIMPLE, close, 21);
def SMA35 = MovingAverage(AverageType.SIMPLE, close, 35);
def PD = close < close [1];
def PU = close > close [1];
def PMS = PD and SMA9 < SMA13 and SMA13 < SMA21 and SMA21 < SMA35;
def PMB = PU and SMA9 > SMA13 and SMA13 > SMA21 and SMA21 > SMA35;
def UP = close > sma9 and sma13 and sma21 and sma35 ;
def DN = close < sma9 and sma13 and sma21 and sma35 ;
def B = UP ;
def S = DN ;
# Create the label
AddLabel(1, "" + (if B then "B" + "" else if S then "S" + "" else " X "),
if B then Color.GREEN else if S then Color.RED else Color.PLUM);
AssignBackgroundColor(if B then Color.BLACK else if S then Color.BLACK else Color.BLACK);
# PRICE + MA
input price = close;
def SMA9 = MovingAverage(AverageType.SIMPLE, close, 9);
def SMA13 = MovingAverage(AverageType.SIMPLE, close, 13);
def SMA21 = MovingAverage(AverageType.SIMPLE, close, 21);
def SMA35 = MovingAverage(AverageType.SIMPLE, close, 35);
def PD = close < close [1];
def PU = close > close [1];
def PMS = PD and SMA9 < SMA13 and SMA13 < SMA21 and SMA21 < SMA35;
def PMB = PU and SMA9 > SMA13 and SMA13 > SMA21 and SMA21 > SMA35;
def UP = close > sma9 and sma13 and sma21 and sma35 ;
def DN = close < sma9 and sma13 and sma21 and sma35 ;
def B = UP ;
def S = DN ;
# Create the label
AddLabel(1, "" + (if B then "B" + "" else if S then "S" + "" else " X "),
if B then Color.GREEN else if S then Color.RED else Color.PLUM);
AssignBackgroundColor(if B then Color.BLACK else if S then Color.BLACK else Color.BLACK);