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)
2 conditions IF statement ?
Updated August 17, 2019
Top Posters
looks_one
kblaine123
with 2 posts (1 thanks)
looks_two
wldman
with 1 posts (0 thanks)
looks_3
halcyonguy
with 1 posts (0 thanks)
looks_4
kareem40
with 1 posts (1 thanks)
trending_up
3,802 views
thumb_up
4 thanks given
group
6 followers
forum
6 posts
attach_file
0 attachments
2 conditions IF statement ?
August 1st, 2019, 08:34 AM
houston
Posts: 9 since Feb 2018
Thanks Given: 2
Thanks Received: 1
I thought you could use 2 conditions within an If statement ?
Simple Example....RSI crossover signal
Plot crossover = if(rsi>50 and rsi[1[]<50,1,double.nan);
This does not work.....am I doing something wrong ? Or is it just not accepted, seems like I used it long ago but not working now.
Any help ? Thanks in advance
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
August 1st, 2019, 08:57 AM
Chicago Illinois USA
Legendary Market Wizard
Experience: Advanced
Broker: IB, ToS
Trading: /ES, US Equities/Options
Frequency: Several times daily
Duration: Hours
Posts: 3,534 since Aug 2011
Thanks Given: 2,069
Thanks Received: 9,556
that you can create both a hierarchy or a confluence. But I have no idea how. Back in the day we built a "scoring" that was based on a series of "if then" type statements.
Best of luck with this.
-Dan
August 1st, 2019, 09:05 AM
houston
Posts: 9 since Feb 2018
Thanks Given: 2
Thanks Received: 1
kblaine123
I thought you could use 2 conditions within an If statement ?
Simple Example....RSI crossover signal
Plot crossover = if(rsi>50 and rsi[1[]<50,1,double.nan);
This does not work.....am I doing something wrong ? Or is it just not accepted, seems like I used it long ago but not working now.
Any help ? Thanks in advance
Weird.....I tried again with the above and it did give me output, then I changed it to whats shown below and no signals at all !
Plot crossover = if(rsi>50 and rsi[1[]<50,1,double.nan);
Plot crossover2 = if(rsi<50 and rsi[1[]>50,1,double.nan);
August 1st, 2019, 09:59 AM
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629
kblaine123,
your code snippet "rsi[1[]" might set brackets incorrectly, but without seeing your full code it's hard to tell where the problem comes from exactly.
Apart from that you should also be able to check for a cross over using something along the lines of:
Code
plot Crossover = RSI(close, 14) crosses above 50;
plot Crossunder = RSI(close, 14) crosses under 50;
plot Cross = RSI(close, 14) crosses 50;
Regards,
ABCTG
kblaine123
Weird.....I tried again with the above and it did give me output, then I changed it to whats shown below and no signals at all !
Plot crossover = if(rsi>50 and rsi[1[]<50,1,double.nan);
Plot crossover2 = if(rsi<50 and rsi[1[]>50,1,double.nan);
August 12th, 2019, 08:43 PM
fertile
Posts: 2 since Aug 2019
Thanks Given: 1
Thanks Received: 0
i just saw this, it might be the problem
rsi[1[]
change to
rsi[1]
----------------------------
maybe if this
Plot crossover = if(rsi>50 and rsi[1[]<50,1,double.nan);
is changed to this 50)
Plot crossover = if((rsi>50 and rsi[1]<50),1,double.nan);
but i've never used commas in thinkscript. i would write it this way
Plot crossover = if (rsi>50 and rsi[1]<50 ) then 1 else double.nan;
August 12th, 2019, 09:12 PM
Dallas, TX
Legendary TradeTheBar
Experience: Intermediate
Platform: NT, TS
Broker: IB, Oanda
Trading: ES, MES, MNQ, MYM
Posts: 730 since May 2010
Thanks Given: 1,950
Thanks Received: 925
halcyonguy
i just saw this, it might be the problem
rsi[1[]
change to
rsi[1]
----------------------------
maybe if this
Plot crossover = if(rsi>50 and rsi[1[]<50,1,double.nan);
is changed to this 50)
Plot crossover = if((rsi>50 and rsi[1]<50),1,double.nan);
but i've never used commas in thinkscript. i would write it this way
Plot crossover = if (rsi>50 and rsi[1]<50 ) then 1 else double.nan;
Just noticed, its for your first post and its a help, nice
Welcome,
K
August 17th, 2019, 10:37 AM
Minneapolis Minnesota
Posts: 24 since Jul 2019
Thanks Given: 0
Thanks Received: 13
kblaine123
I thought you could use 2 conditions within an If statement ?
Simple Example....RSI crossover signal
Plot crossover = if(rsi>50 and rsi[1[]<50,1,double.nan);
This does not work.....am I doing something wrong ? Or is it just not accepted, seems like I used it long ago but not working now.
Any help ? Thanks in advance
That's sort of an awkward way to write a crossing condition in Thinkscript. The language provides a slightly more intuitive way.
Code
if rsi crosses above 50 then 1 else Double.NaN;
Last Updated on August 17, 2019