"OR" clause in NT strategy? - NinjaTrader Programming | futures io social day trading
futures io futures trading


"OR" clause in NT strategy?
Updated: Views / Replies:557 / 9
Created: by hawks67 Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

"OR" clause in NT strategy?

  #1 (permalink)
Elite Member
Chicago, IL
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AGN/Rithmic
Favorite Futures: CL
 
Posts: 22 since Apr 2010
Thanks: 14 given, 1 received

"OR" clause in NT strategy?

OK, this could just be me losing my mind...it's been a while since I donned my programmer's cap, and I just can't remember....

I am coding a strategy and one of my conditions really wants an OR clause:

"if the Stoch is here and either this CCI is here or this one is, then do this."

 
Code
if
((Stochastics(7, 14, 3).K[2] > 80)
&&
((CCI(3)[2] > 95) OR (CCI(3)[3] > 95)))
{ action };
(not my exact code, just a simplified example of what I'm trying to do)

But, of course, NT7 doesn't like that. It doesn't like anything close to that.

Is there a form of an OR clause? You know, like one that serves as the partner/opposite of the && clause? I'm kind of starting to use a bunch of nested if/else statements in place of a simple OR, but it's getting very messy...

Thanks in advance,
Gary

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received


In C#

&& = "and"
|| = "or"

|| Operator (C# Reference)

Reply With Quote
The following 3 users say Thank You to shodson for this post:
 
  #4 (permalink)
Elite Member
Chicago, IL
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AGN/Rithmic
Favorite Futures: CL
 
Posts: 22 since Apr 2010
Thanks: 14 given, 1 received

YES! Thank you! Either mybrain.full or mybrain.old.

Reply With Quote
 
  #5 (permalink)
Banned: trolling
Russia,Khabarovsk
 
Futures Experience: Beginner
Platform: NT
Favorite Futures: Gold
 
Cachevary's Avatar
 
Posts: 407 since Feb 2014
Thanks: 138 given, 78 received


shodson View Post
In C#

&& = "and"
|| = "or"

|| Operator (C# Reference)

@shodson,

Hello,

i`m also struggling to buils conditions using || operator.

I have this line to begin with:

 
Code
(this.super.Values[0][1] == this.super.Values[3][1] || this.super.Values[1][1] == this.super.Values[3][1] || this.super.Values[2][1] == this.super.Values[3][1])
that one i need for the Bar[1] to compare the equality of either of two :

this.super.Values[0][1]

this.super.Values[1][1]

this.super.Values[2][1]


to this one:

this.super.Values[3][1]


Now for the Bar[0] i need to know which set was greater or less(< or >) to the this.super.Values[3][1]


I try this:

&& this.super.Values[3][0] > (this.super.Values[0][0] || this.super.Values[0][1] || this.super.Values[0][2])

But,get compile error that says "Operator || cannot be applied to ''double"....

Can you please suggets a corrcet way to get those conditions,please?


Last edited by Cachevary; January 22nd, 2015 at 07:52 PM.
Reply With Quote
 
  #6 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received

|| is a boolean operator. It ORs two boolean expressions like true OR false OR true

you have align your logic into boolean expressions and to think of it like this:

 
Code
the sky is white OR the sky is blue OR the sky is black
not

 
Code
the sky is (white OR blue OR black)
because the things between the ORs are not boolean expressions, they are colors

so what you need to do is

 
Code
&& (this.super.Values[3][0] > this.super.Values[0][0] ||
    this.super.Values[3][0] > this.super.Values[0][1] ||
    this.super.Values[3][0] > this.super.Values[0][2])

Reply With Quote
The following 2 users say Thank You to shodson for this post:
 
  #7 (permalink)
Banned: trolling
Russia,Khabarovsk
 
Futures Experience: Beginner
Platform: NT
Favorite Futures: Gold
 
Cachevary's Avatar
 
Posts: 407 since Feb 2014
Thanks: 138 given, 78 received


shodson View Post
|| is a boolean operator. It ORs two boolean expressions like true OR false OR true

you have align your logic into boolean expressions and to think of it like this:

 
Code
the sky is white OR the sky is blue OR the sky is black
not

 
Code
the sky is (white OR blue OR black)
because the things between the ORs are not boolean expressions, they are colors

so what you need to do is

 
Code
&& (this.super.Values[3][0] > this.super.Values[0][0] ||
    this.super.Values[3][0] > this.super.Values[0][1] ||
    this.super.Values[3][0] > this.super.Values[0][2])

Seems working that way.

Thank you,sir!Appreciate your help and effort.

Have a fantastic weekend!

Reply With Quote
 
  #8 (permalink)
Banned: trolling
Russia,Khabarovsk
 
Futures Experience: Beginner
Platform: NT
Favorite Futures: Gold
 
Cachevary's Avatar
 
Posts: 407 since Feb 2014
Thanks: 138 given, 78 received

@shodson,

a little problem here.

Now that i have those conditions for the entry in place:

 
Code
If (this.super.Values[0][1] == this.super.Values[3][1] || this.super.Values[1][1] == this.super.Values[3][1] || this.super.Values[2][1] == this.super.Values[3][1])

&& (this.super.Values[3][0] > this.super.Values[0][0] ||  this.super.Values[3][0] > this.super.Values[0][1] || this.super.Values[3][0] > this.super.Values[0][2])
i often have the issue,depicted on the image attached.Could you please take a look and suggest what is happening?

Thank you!

Attached Thumbnails
&quot;OR&quot; clause in NT strategy?-entry-issue.png  
Reply With Quote
 
  #9 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,860 since Jun 2009
Thanks: 480 given, 3,255 received

It's hard for me to say what's wrong without seeing the entire code and knowing what the rules of the strategy are. I suggest you look for more significant help here or here. You really need more Ninjascript/C# programming training and experience.

Reply With Quote
The following user says Thank You to shodson for this post:
 
  #10 (permalink)
Banned: trolling
Russia,Khabarovsk
 
Futures Experience: Beginner
Platform: NT
Favorite Futures: Gold
 
Cachevary's Avatar
 
Posts: 407 since Feb 2014
Thanks: 138 given, 78 received



shodson View Post
|| is a boolean operator. It ORs two boolean expressions like true OR false OR true

you have align your logic into boolean expressions and to think of it like this:

 
Code
the sky is white OR the sky is blue OR the sky is black
not

 
Code
the sky is (white OR blue OR black)
because the things between the ORs are not boolean expressions, they are colors

so what you need to do is

 
Code
&& (this.super.Values[3][0] > this.super.Values[0][0] ||
    this.super.Values[3][0] > this.super.Values[0][1] ||
    this.super.Values[3][0] > this.super.Values[0][2])

@shodson,

and yet,it`s still not what i wanted.Sorry if i didn`t put it clear.

For the Bar[0], i need EXACTLY the comparison - <or> ,for the this.super.Values[3][0] and the ONE,that this exact this.super.Values[3][0] was matched at the Bar[1].For now,the conditions you`ve added just do an arbitrary comparison - which one is grater/lesser another,not for the particular set.

Reply With Quote

Reply



futures io > > > > > "OR" clause in NT strategy?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sal Starzun's Trading systems info on "Eclipse" and "Moon" Naples Trading Reviews and Vendors 2 January 7th, 2015 08:56 AM
Saxo Bank's 10 "Outrageous Predictions" For "2012: The Perfect Storm" Quick Summary News and Current Events 0 December 17th, 2011 08:10 PM
Fukushima: "China Syndrome Is Inevitable" ... "Huge Steam Explosions", or "Nuclear Bo Quick Summary News and Current Events 0 November 22nd, 2011 02:50 AM
How to change "Stop Loss" and "Take Profit" in "shElderImpulse" Strategy javed759 NinjaTrader 1 November 1st, 2011 11:44 PM
"mid", "buy", "sell" volumes lokgotkent Traders Hideout 6 September 30th, 2011 02:24 PM


All times are GMT -4. The time now is 11:24 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-17 in 0.13 seconds with 20 queries on phoenix via your IP 54.221.73.186