Error: Value never assigned?


Category:
0
0
Hi Pete,

I am having an issue with "Value never assigned". Please see attached for a screenshot of the error
<pre>input mode = {default Value, Avg, Signal};
input mode_ma = {default Simple, Exponential, Weighted, Wilders, Hull, EHMA, THMA};
input ma_length = 55; #Length(180-200 for floating S/R , 55 for swing entry)

def MACD_Value;
def MACD_Avg;
def EMA_Signal;

switch (mode) {
case Value:
    MACD_Value = g(length = fastLength) - g(length = slowLength);
case Avg:
    MACD_Avg = g(price = Value, length = MACDLength);
case Signal:
    EMA_Signal = EMA – AA * RE8;
}

def avg_MACD_Value;
def avg_MACD_Avg;
def avg_EMA_Signal;

switch (mode_ma) {
case Simple:
                avg_MACD_Value = average(MACD_Value, ma_length);
                avg_MACD_Avg = average(MACD_Avg, ma_length);
                avg_EMA_Signal = average(EMA_Signal, ma_length);
             
case Exponential:
                avg_MACD_Value = expaverage(MACD_Value, ma_length);
                avg_MACD_Avg = expaverage(MACD_Avg, ma_length);
                avg_EMA_Signal = expaverage(EMA_Signal, ma_length);
             
case Weighted:
                avg_MACD_Value = wma(MACD_Value, ma_length);
                avg_MACD_Avg = wma(MACD_Avg, ma_length);
                avg_EMA_Signal = wma(EMA_Signal, ma_length);
             
case Wilders:
                avg_MACD_Value = wildersaverage(MACD_Value, ma_length);
                avg_MACD_Avg = wildersaverage(MACD_Avg, ma_length);
                avg_EMA_Signal = wildersaverage(EMA_Signal, ma_length);
             
case Hull:
                avg_MACD_Value = wma(2 * wma(MACD_Value, ma_length / 2) - wma(MACD_Value, ma_length), round(sqrt(ma_length)));
                avg_MACD_Avg = wma(2 * wma(MACD_Avg, ma_length / 2) - wma(MACD_Avg, ma_length), round(sqrt(ma_length)));
                avg_EMA_Signal = wma(2 * wma(EMA_Signal, ma_length / 2) - wma(EMA_Signal, ma_length), round(sqrt(ma_length)));
             
case EHMA:
                avg_MACD_Value = expaverage(2 * expaverage(MACD_Value, ma_length / 2) - expaverage(MACD_Value, ma_length), round(sqrt(ma_length)));
                avg_MACD_Avg = expaverage(2 * expaverage(MACD_Avg, ma_length / 2) - expaverage(MACD_Avg, ma_length), round(sqrt(ma_length)));
                avg_EMA_Signal = expaverage(2 * expaverage(EMA_Signal, ma_length / 2) - expaverage(EMA_Signal, ma_length), round(sqrt(ma_length)));
             
case THMA:
                avg_MACD_Value = wma(wma(MACD_Value,(ma_length/2) / 3) * 3 - wma(MACD_Value, (ma_length/2) / 2) - wma(MACD_Value, (ma_length/2)), (ma_length/2));
                avg_MACD_Avg = wma(wma(MACD_Avg,(ma_length/2) / 3) * 3 - wma(MACD_Avg, (ma_length/2) / 2) - wma(MACD_Avg, (ma_length/2)), (ma_length/2));
                avg_EMA_Signal = wma(wma(EMA_Signal,(ma_length/2) / 3) * 3 - wma(EMA_Signal, (ma_length/2) / 2) - wma(EMA_Signal, (ma_length/2)), (ma_length/2));
}
;</pre>

Below is the previous code I was trying...The compiler didn't complain, but the code didn't interact with the studies either:
<pre>input modeswitch = {default "Value", "Avg", "Diff", "Signal", "EMA"};

input modeSwitch_ma = {default "Simple", "Exponential", "Weighted", "Wilders", "Hull", "EHMA", "THMA"};

input ma_length = 55; #Length(180-200 for floating S/R , 55 for swing entry)


def ma_calc;

switch (modeSwitch) {

case "Value":
ma_calc = g(length = fastLength) - g(length = slowLength);

case "Avg":
ma_calc = g(price = Value, length = MACDLength);

case "Diff":
ma_calc = Value - Avg;

case "Signal":
ma_calc = EMA – AA * RE8;

case "EMA":
ma_calc = AA * Close + CC * EMA[1];

}
;


def multi_ma;

switch (modeSwitch_ma) {

case "Simple":
multi_ma = average(ma_calc, ma_length);

case "Exponential":
multi_ma = expaverage(ma_calc, ma_length);

case "Weighted":
multi_ma = wma(ma_calc, ma_length);

case "Wilders":
multi_ma = wildersaverage(ma_calc, ma_length);

case "Hull":
multi_ma = wma(2 * wma(ma_calc, ma_length / 2) - wma(ma_calc, ma_length), round(sqrt(ma_length)));

case "EHMA":
multi_ma = expaverage(2 * expaverage(ma_calc, ma_length / 2) - expaverage(ma_calc, ma_length), round(sqrt(ma_length)));

case "THMA":
multi_ma = wma(wma(ma_calc,(ma_length/2) / 3) * 3 - wma(ma_calc, (ma_length/2) / 2) - wma(ma_calc, (ma_length/2)), (ma_length/2));

}
;</pre>
I've tried everything I can think of, searched 
here and across the internet, but I can't find the answer...Any 
help/pointers in the right direction would be greatly appreciated...
Thanks in advance...

I hope this question finds you feeling much better, Pete :)

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on November 2, 2019 4:31 pm
58 views
0
Private answer

In the future, when you have code with more than a dozen or so lines it's best to attach it as a plain text document rather than including it in the body of your question. There is a limit to how many characters you can include.

In your switch/case structure. You must assign a value to each of your three variables for each case in the switch/case structure. You have an example of this in the switch/case structure immediately below the one that is causing all those errors.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 2, 2019 4:55 pm
0
Hi Pete, Thank you for the swift response :) Sorry for the code posting. I will make sure to send text files in the future...
( at November 2, 2019 5:49 pm)