NexusFi: Find Your Edge


Home Menu

 





Can I use a DataSeries as part of an 'if' statement?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one magnumdbl with 4 posts (0 thanks)
    2. looks_two cory with 2 posts (2 thanks)
    3. looks_3 ShruggedAtlas with 2 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
      Best Posters
    1. looks_one cory with 1 thanks per post
    2. looks_two ShruggedAtlas with 1 thanks per post
    3. looks_3 Big Mike with 1 thanks per post
    4. looks_4 jeremytang with 1 thanks per post
    1. trending_up 4,481 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Can I use a DataSeries as part of an 'if' statement?

  #11 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,461 since Jun 2009
Thanks Given: 33,235
Thanks Received: 101,657


ShruggedAtlas View Post
O
if (cond1 == 1)

but that won't work if cond1 is a series. You'd get an error I think

if (cond1[0] == 1)

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Quant vue
Trading Reviews and Vendors
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
76 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
37 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
17 thanks
  #12 (permalink)
 
jeremytang's Avatar
 jeremytang  SharkIndicators is an official Site Sponsor
Site Sponsor

Web: SharkIndicators
AMA: Ask Me Anything
Webinars: SharkIndicators Webinars
Elite offer: Click here
 
Posts: 16 since Aug 2010
Thanks Given: 4
Thanks Received: 53

magnumdbl,

To elaborate on BigMike's solution,

your cond1 is a dataseries that is indexed. This means (when you reference it from OnBarUpdate):

cond1[0] refers to the value you set cond1 to on the current bar.
cond1[1] refers to the value you set cond1 to 1 bar ago.
cond1[2] refers to the value you set cond1 to 2 bars ago.

When you call:

cond1.Set(1)

that is actually the equivalent to setting the current value of cond1, thus it's a shortcut for:

cond1[0] = 1;

Jeremy

Reply With Quote
Thanked by:




Last Updated on February 11, 2012


© 2024 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 - Privacy Policy - Downloads - Top
no new posts