Welcome to NexusFi: the best trading community on the planet, with over 200,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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
Can you help answer these questions from other members on NexusFi?
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 ?
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):
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:
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:
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.
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.