NexusFi: Find Your Edge


Home Menu

 





Error: Value never assigned...


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,534 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
netarchitech
NY, NY
 
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19

Given the following:




Here is the code:

 
Code
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));
}
;

Below is the previous code I was trying...The compiler didn't complain, but the code didn't interact with the studies either:

 
Code
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));

}
;

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...


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Warsh Opens Today, Hormuz June 19 -- WTI Below $80, Fran …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
S&P 500 Holds the Line: No Fast Track for SpaceX, Op …
Stocks and ETFs
Six Days to Kickoff: World Cup Prediction Markets Hit $1 …
Prediction Markets & Event Contracts
 
  #2 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79

there are several mistakes in switch cases when you assignnig values to variables MACD_Value and MACD_Avg. There must be expressions, not equations. Also what is g()? Is it some function with name "g"?


Follow me on X Reply With Quote




Last Updated on December 21, 2019


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts