“Value never assgined to” error


Category:
0
0

Getting “Value never assgined to” on  my variables vSignalCandleClose and vSignalCandleStop. What am I doing wrong?

#—–MyIndicator–

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 – 1;
    vSignalCandleClose = close;
} else {
    #
}
if   (closeBelowEMA) {
    vSignalCandleStop = high + 1;
    vSignalCandleClose = close;
} else {
#
}
#
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)  );

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on April 3, 2021 6:30 pm
33 views
0
Private answer

Screenshot below explains what your code is missing.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 3, 2021 7:11 pm
0
Pete, Based on your feedback, changed it a bit! The error is now gone. Thank you! . ##--------- if (closeAboveEMA) { vSignalCandleStop = low - .25; vSignalCandleClose = close; } else { if (closeBelowEMA) { vSignalCandleStop = high + .25; vSignalCandleClose = close; } else { vSignalCandleStop = vSignalCandleStop; vSignalCandleClose = vSignalCandleClose; } } # 1. How to get open time of the SignalCandle? 2. How to hilight the signal candle? Can I put a marker on the signal candle?
( at April 4, 2021 11:26 am)
0
Strangely the code is not working. The labels and alerts are not firing!
( at April 4, 2021 3:35 pm)