NexusFi: Find Your Edge


Home Menu

 





2 conditions IF statement ?


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one kblaine123 with 2 posts (1 thanks)
    2. looks_two wldman with 1 posts (0 thanks)
    3. looks_3 halcyonguy with 1 posts (0 thanks)
    4. looks_4 kareem40 with 1 posts (1 thanks)
    1. trending_up 5,089 views
    2. thumb_up 4 thanks given
    3. group 6 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
kblaine123
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


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hormuz Completely Closed: US Strikes Day 2, Iran Shoots …
Traders Hideout
Thanks Mike. Godspeed.
The Elite Circle
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
CME Expands 24/7 Trading to WTI Crude Oil and Gold -- We …
Commodities
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 
wldman's Avatar
 wldman 
Chicago Illinois USA
Legendary Market Wizard
 
Experience: Advanced
Broker: IB, ToS
Trading: /ES, US Equities/Options
Frequency: Several times daily
Duration: Hours
Posts: 3,585 since Aug 2011
Thanks Given: 2,095
Thanks Received: 9,704

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


Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
kblaine123
houston
 
Posts: 9 since Feb 2018
Thanks Given: 2
Thanks Received: 1



kblaine123 View Post
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);


Reply With Quote
Thanked by:
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

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 View Post
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);


Follow me on X Reply With Quote
Thanked by:
  #5 (permalink)
halcyonguy
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;


Reply With Quote
  #6 (permalink)
 
kareem40's Avatar
 kareem40 
Dallas, TX
Legendary Trade Garlic
 
Experience: Intermediate
Platform: NT, TS
Broker: IB, Oanda
Trading: ES, MES, MNQ, MYM
Posts: 745 since May 2010
Thanks Given: 1,950
Thanks Received: 934


halcyonguy View Post
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


Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
Nube
Minneapolis Minnesota
 
Posts: 24 since Jul 2019
Thanks Given: 0
Thanks Received: 13


kblaine123 View Post
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;


Reply With Quote




Last Updated on August 17, 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