TraderJane
New member
I am creating a Zero lag 3 EMA strategy. I have ZLEMA as fast, ZLEMAa as medium, and ZLEMAb as slow.
I am trying to get buy signal when ZLEMA crosses above ZLEMAa and ZLEMAb. (Preferably would like to have ZLEMAb below ZLEMAa as an optional condition) and a Sell Signal when ZLEMAb Crosses above ZLEMA and ZLEMAa (Preferably would like to have ZLEMA below ZLEMAa as an optional condition.
I am trying to get an exit signal when the ZLEMAa crosses ZLEMAb.
I am trying to get buy signal when ZLEMA crosses above ZLEMAa and ZLEMAb. (Preferably would like to have ZLEMAb below ZLEMAa as an optional condition) and a Sell Signal when ZLEMAb Crosses above ZLEMA and ZLEMAa (Preferably would like to have ZLEMA below ZLEMAa as an optional condition.
I am trying to get an exit signal when the ZLEMAa crosses ZLEMAb.
Code:
# ZLEMA Strategy
input Period = 20;
input src = close;
input Period2 = 40;
input src2 = close;
input Period3 = 60;
input src3 = close;
def EMA341 = ExpAverage(src, Period);
def EMA342 = ExpAverage(EMA341, Period);
def Difference34 = EMA341 - EMA342;
def ZeroLagEMA34 = EMA341 + Difference34;
plot ZLEMA = ZeroLagEMA34;
ZLEMA.SetDefaultColor(Color.green);
def EMA341a = ExpAverage(src2, Period2);
def EMA342a = ExpAverage(EMA341, Period2);
def Difference34a = EMA341a - EMA342a;
def ZeroLagEMA34a = EMA341a + Difference34a;
plot ZLEMAa = ZeroLagEMA34a;
ZLEMAa.SetDefaultColor(Color.red);
def EMA341b = ExpAverage(src3, Period3);
def EMA342b = ExpAverage(EMA341b, Period3);
def Difference34b = EMA341b - EMA342b;
def ZeroLagEMA34b = EMA341b + Difference34b;
plot ZLEMAb = ZeroLagEMA34b;
ZLEMAb.SetDefaultColor(Color.blue);
# Buy signal
def buySignal = ZLEMA crosses above ZLEMAa and ZLEMAb is less than or equal to ZLEMAa;
plot buySignalPlot = buySignal;
buySignalPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buySignalPlot.SetDefaultColor(Color.green);
# Sell signal
def sellSignal = ZLEMAb crosses above ZLEMA and ZLEMA is less than or equal to ZLEMAa;
plot sellSignalPlot = sellSignal;
sellSignalPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sellSignalPlot.SetDefaultColor(Color.red);
# Buy exit signal
def buyExitSignal = ZLEMAb crosses above ZLEMAa;
plot buyExitSignalPlot = buyExitSignal;
buyExitSignalPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
buyExitSignalPlot.SetDefaultColor(Color.yellow);
# Sell exit signal
def sellExitSignal = ZLEMAb crosses above ZLEMA or ZLEMA crosses Above ZLEMAb;
plot sellExitSignalPlot = sellExitSignal;
sellExitSignalPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
sellExitSignalPlot.SetDefaultColor(Color.yellow);
# Alerts
alert(buySignal, "Buy signal", Alert.BAR, Sound.Bell);
alert(sellSignal, "Sell signal", Alert.BAR, Sound.Chimes);
#alert(buyExitSignal, "Buy exit signal", Alert.BAR, Sound.Bell);
alert(sellExitSignal, "Sell exit signal", Alert.BAR, Sound.Chimes);
def ExitSignal = ZLEMAb crosses Above ZLEMA;
plot ExitSignalplot = ExitSignal;
ExitSignalplot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
sellExitSignalPlot.SetDefaultColor(Color.yellow);