Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
need help with switch statement error
Updated March 22, 2022
trending_up
2,088 views
thumb_up
2 thanks given
group
2 followers
forum
2 posts
attach_file
1 attachments
need help with switch statement error
March 21st, 2022, 03:25 PM
Las Vegas, Nevada
Posts: 2 since Mar 2022
Thanks Given: 1
Thanks Received: 1
Hello, I keep getting an "invalid statement: switch at 31:1" error (picture attached below) and I don't know how to fix it. If anyone can help, it would be super appreciated!
declare lower;
input display = {default NYSE , All_Exchanges, NASDAQ , AMEX};
def uvolny = close("$UVOL");
def dvolny = close("$DVOL");
def uvolq = close("$UVOL/Q");
def dvolq = close("$DVOL/Q");
def uvola = close("$UVOA");
def dvola = close("$DVOA");
def tvolq = close("$TVOL/Q");
def tvola = close("$TVOA");
def tvolny = close("$TVOL");
def unchy = tvolny - uvolny - dvolny;
def unchq = tvolq - uvolq - dvolq;
def uncha = tvola - dvola - uvola;
def tvolall = tvolny + tvolq + tvola;
def uvol = uvolny + uvolq + uvola;
def dvol = dvolny + dvolq + dvola;
#
# Define the plots:
#
plot VolRatio;
switch (display){
case All_Exchanges:
VolRatio = if (uvol >= dvol,(uvol / tvolall)*100, -(dvol / tvolall)*100);
case NYSE:
Volratio = if (uvolny >= dvolny, ((uvolny / tvolny)*100), - ((dvolny / tvolny)*100));
case NASDAQ:
Volratio = if (uvolq >= dvolq, (uvolq / dvolq)*100, - (dvolq / tvolq)*100);
case AMEX:
Volratio = if (uvola >= dvola, (uvola / tvola)*100, - (dvola / tvola)*100);
}
#
# Formatting:
#
VolRatio.SetDefaultColor(color.cyan);
VolRatio.SetLineWeight(1);
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
March 21st, 2022, 04:05 PM
Monte Carlo, Monaco
Legendary Market Wizard
Experience: Advanced
Platform: NinjaTrader 8
Broker: NinjaTrader Brokerage
Trading: Futures
Posts: 647 since May 2012
Thanks Given: 799
Thanks Received: 1,193
You can try with quotes:
switch (display){
case "All_Exchanges":
VolRatio = if (uvol >= dvol,(uvol / tvolall)*100, -(dvol / tvolall)*100);
case "NYSE ":
Volratio = if (uvolny >= dvolny, ((uvolny / tvolny)*100), - ((dvolny / tvolny)*100));
case "NASDAQ ":
Volratio = if (uvolq >= dvolq, (uvolq / dvolq)*100, - (dvolq / tvolq)*100);
case "AMEX":
Volratio = if (uvola >= dvola, (uvola / tvola)*100, - (dvola / tvola)*100);
}
March 22nd, 2022, 12:17 AM
Las Vegas, Nevada
Posts: 2 since Mar 2022
Thanks Given: 1
Thanks Received: 1
Mich62
You can try with quotes:
switch (display){
case "All_Exchanges":
VolRatio = if (uvol >= dvol,(uvol / tvolall)*100, -(dvol / tvolall)*100);
case "
NYSE ":
Volratio = if (uvolny >= dvolny, ((uvolny / tvolny)*100), - ((dvolny / tvolny)*100));
case "
NASDAQ ":
Volratio = if (uvolq >= dvolq, (uvolq / dvolq)*100, - (dvolq / tvolq)*100);
case "AMEX":
Volratio = if (uvola >= dvola, (uvola / tvola)*100, - (dvola / tvola)*100);
}
thank you!
Last Updated on March 22, 2022