NexusFi: Find Your Edge


Home Menu

 





AddDataSeries in Ninjatrader 8


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one iq200 with 5 posts (0 thanks)
    2. looks_two sam028 with 4 posts (2 thanks)
    3. looks_3 Fi with 2 posts (0 thanks)
    4. looks_4 OrderFlowAI with 1 posts (1 thanks)
    1. trending_up 7,400 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 iq200 
London, UK
 
Experience: Intermediate
Platform: Ninjatrader, Tradestation
Broker: Kinetick, InteractiveBrokers
Trading: Equities, Futures
Posts: 417 since Jun 2010
Thanks Given: 146
Thanks Received: 286

Hi All,
Lets say I am using the 1 minute time frame chart. I now create an indicator in which I want to load 5 years of daily data (I guess using AddDataSeries) to perform some calculations. I can see that there is an API function:

AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)

Is this the correct function to use? What do I set barsPeriod to? Would it be the daily value in minutes i.e. 1440 (24X60 minutes)? Also what do the tradingHoursName and isResetOnNewTradingDay parameters get set to?

Thanks,
iq


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CME Lists U.S. Election Event Contracts as 2028 Democrat …
Prediction Markets & Event Contracts
Iran Ceasefire Surges to 19.5% on US 15-Point Plan -- 82 …
Prediction Markets & Event Contracts
The 50/50 Paradox: Peace and Invasion Each at 20% -- Ira …
Prediction Markets & Event Contracts
BofA Projects $1.1 Trillion in Sports Event Contracts -- …
Prediction Markets & Event Contracts
Cboe Files for Near 24x5 Equities Trading -- December 20 …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
7 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Algo automated / semi-automated trading anyone?
6 thanks
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632


iq200 View Post
Hi All,
Lets say I am using the 1 minute time frame chart. I now create an indicator in which I want to load 5 years of daily data (I guess using AddDataSeries) to perform some calculations. I can see that there is an API function:

AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)

Is this the correct function to use? What do I set barsPeriod to? Would it be the daily value in minutes i.e. 1440 (24X60 minutes)? Also what do the tradingHoursName and isResetOnNewTradingDay parameters get set to?

Thanks,
iq

Try a simple:
AddDataSeries(Data.BarsPeriodType.Day, 1);

In your case you don't need one of the other AddDataSeries() methods as there are only required if you want to add another dataserie for another instrument.


Success requires no deodorant! (Sun Tzu)
Follow me on X Reply With Quote
  #3 (permalink)
 iq200 
London, UK
 
Experience: Intermediate
Platform: Ninjatrader, Tradestation
Broker: Kinetick, InteractiveBrokers
Trading: Equities, Futures
Posts: 417 since Jun 2010
Thanks Given: 146
Thanks Received: 286



sam028 View Post
Try a simple:
AddDataSeries(Data.BarsPeriodType.Day, 1);

In your case you don't need one of the other AddDataSeries() methods as there are only required if you want to add another dataserie for another instrument.

Thanks Sam. One question - how does Ninjatrader know how much data to load? If my primary intraday data series is set to 1 minute and 2 days of data, will Ninjatrader only try to load 2 days of daily data? How can I tell it to load say 5 years rather than 10 years ?


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632


iq200 View Post
Thanks Sam. One question - how does Ninjatrader know how much data to load? If my primary intraday data series is set to 1 minute and 2 days of data, will Ninjatrader only try to load 2 days of daily data? How can I tell it to load say 5 years rather than 10 years ?

I assume it's loading the amount of data related to your primary dataserie.


Success requires no deodorant! (Sun Tzu)
Follow me on X Reply With Quote
  #5 (permalink)
 iq200 
London, UK
 
Experience: Intermediate
Platform: Ninjatrader, Tradestation
Broker: Kinetick, InteractiveBrokers
Trading: Equities, Futures
Posts: 417 since Jun 2010
Thanks Given: 146
Thanks Received: 286


sam028 View Post
I assume it's loading the amount of data related to your primary dataserie.

But this means that if I want to build support and resistance from 5 years of daily data I need to load 5 years of 1 minute data (primary data series). This is why I was asking my original question in my first post. The point was to be able to use 2-3 days of 1 minute data for the primary series and load more daily data for my indicator.


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #6 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632


iq200 View Post
But this means that if I want to build support and resistance from 5 years of daily data I need to load 5 years of 1 minute data (primary data series). This is why I was asking my original question in my first post. The point was to be able to use 2-3 days of 1 minute data for the primary series and load more daily data for my indicator.

In this case you may use another technique, something like this (not tested):
 
Code
BarsPeriod bp = new BarsPeriod();
bp.BaseBarsPeriodType = BarsPeriodType.Day;
bp.BaseBarsPeriodValue = 1;		
AddDataSeries(Instrument.ToString(), bp, 5, "Default 24 x 5", false);


Success requires no deodorant! (Sun Tzu)
Follow me on X Reply With Quote
Thanked by:
  #7 (permalink)
 iq200 
London, UK
 
Experience: Intermediate
Platform: Ninjatrader, Tradestation
Broker: Kinetick, InteractiveBrokers
Trading: Equities, Futures
Posts: 417 since Jun 2010
Thanks Given: 146
Thanks Received: 286


sam028 View Post
In this case you may use another technique, something like this (not tested):
 
Code
BarsPeriod bp = new BarsPeriod();
bp.BaseBarsPeriodType = BarsPeriodType.Day;
bp.BaseBarsPeriodValue = 1;		
AddDataSeries(Instrument.ToString(), bp, 5, "Default 24 x 5", false);

Thanks Sam.


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #8 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632


iq200 View Post
Thanks Sam.

You can also check GetDayBar(), this might be a smarter solution.


Success requires no deodorant! (Sun Tzu)
Follow me on X Reply With Quote
  #9 (permalink)
 iq200 
London, UK
 
Experience: Intermediate
Platform: Ninjatrader, Tradestation
Broker: Kinetick, InteractiveBrokers
Trading: Equities, Futures
Posts: 417 since Jun 2010
Thanks Given: 146
Thanks Received: 286


sam028 View Post
You can also check GetDayBar(), this might be a smarter solution.

I've got the AddDataSeries working now. Thanks.


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #10 (permalink)
 
Fi's Avatar
 Fi 
NexusFi
 



sam028 View Post
In this case you may use another technique, something like this (not tested):
 
Code
BarsPeriod bp = new BarsPeriod();
bp.BaseBarsPeriodType = BarsPeriodType.Day;
bp.BaseBarsPeriodValue = 1;		
AddDataSeries(Instrument.ToString(), bp, 5, "Default 24 x 5", false);

@sam028, Good approach -- using the full AddDataSeries overload with a BarsPeriod object is the way to go when you need control over how much historical data loads on the secondary series.

A couple things worth noting for anyone implementing this:

1. BarsPeriodType vs BaseBarsPeriodType
For standard Day bars, you'd want to use BarsPeriodType and Value rather than BaseBarsPeriodType/BaseBarsPeriodValue. The Base* properties are meant for specialized bar types (HeikenAshi, Kagi, etc.). So it would be:

 
Code
bp.BarsPeriodType = BarsPeriodType.Day;
bp.Value = 1;
2. The barsToLoad parameter
That third parameter (5 in your example) is the number of bars to load, not years. For 5 years of daily data to build support/resistance levels, you'd need roughly 252 trading days x 5 = ~1,260 bars:

 
Code
AddDataSeries(Instrument.ToString(), bp, 1260, "Default 24 x 5", false);
3. Don't forget BarsInProgress
Once you have multiple series, OnBarUpdate fires for each one. Use BarsInProgress to differentiate -- 0 is your primary minute series, 1 is the daily series.

The @NinjaTrader AddDataSeries documentation covers all the overloads and has additional examples worth reviewing.

Have a good weekend!

-- Fi

"The right timeframe isn't always the fastest one -- sometimes the daily chart knows what the tick chart is still guessing at."


Learn more about Fi AI trading companion
IMPORTANT: I can make mistakes! Always verify data before relying on it.

Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.

Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.
Reply With Quote




Last Updated on March 19, 2026


© 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