def vSignalCandleClose;
def vSignalCandleStop;
def vEMA = MovingAverage(AverageType.EXPONENTIAL, close, 20);
def closeAboveEMA = close[1] < vEMA[1] and close > vEMA;
def closeBelowEMA = close[1] > vEMA[1] and close < vEMA;
#
##---------
if (closeAboveEMA) {
vSignalCandleStop = low - .25;
vSignalCandleClose = close;
} else {
if (closeBelowEMA) {
vSignalCandleStop = high + .25;
vSignalCandleClose = close;
} else {
vSignalCandleStop = vSignalCandleStop;
vSignalCandleClose = vSignalCandleClose;
}
}
#
Alert(closeAboveEMA, “NQ – Close Crossed Above EMA – BUY”, Alert.BAR, Sound.Chimes);
Alert(closeBelowEMA, “NQ – Close Crossed Below EMA – SELL”, Alert.BAR, Sound.Ding);
AddLabel (yes, “Close of Signal Candle” + (vSignalCandleClose) );
AddLabel (yes, “SuggestedStop” + (vSignalCandleStop) );