Can I use a DataSeries as part of an 'if' statement? - futures io
futures io futures trading

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

Discussion in NinjaTrader

Updated by jeremytang
      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.0 thanks per post
    2. looks_two ShruggedAtlas with 1.0 thanks per post
    3. looks_3 Big Mike with 1.0 thanks per post
    4. looks_4 jeremytang with 1.0 thanks per post
    1. trending_up 2,658 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 11 replies
    2. attach_file 0 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

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

Thread Tools Search this Thread

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

  #11 (permalink)
Site Administrator
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Big Mike's Avatar
Posts: 48,718 since Jun 2009
Thanks: 31,454 given, 93,969 received

ShruggedAtlas View Post
if (cond1 == 1)

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

if (cond1[0] == 1)


We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:

Can you help answer these questions
from other members on futures io?
Convert NinjaTrader NT7 indicator to Tradestation EasyLanguage and RADARSCREEN
Platforms and Indicators
Issue meeting order entry conditions
Elite Automated NinjaTrader Trading
Last 5 minutes Label
Moving average with Lag reduction
Best Threads (Most Thanked)
in the last 7 days on futures io
Spoo-nalysis ES e-mini futures S&P 500
442 thanks
VWAP for stock index futures trading?
48 thanks
Want your NinjaTrader indicator created, free?
46 thanks
Is Amp at risk of going under?
24 thanks
Risk of trading micro futures
19 thanks
  #12 (permalink)
Calgary, AB
Experience: Intermediate
Platform: NinjaTrader
Trading: futures, forex
jeremytang's Avatar
Posts: 13 since Aug 2010
Thanks: 1 given, 48 received


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:


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

cond1[0] = 1;


Reply With Quote
The following user says Thank You to jeremytang for this post:

futures io Trading Community Platforms and Indicators NinjaTrader > Can I use a DataSeries as part of an 'if' statement?

Upcoming Webinars and Events


May 28

Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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