var dailyPeriod = new BarsPeriod() { BarsPeriodType = BarsPeriodType.Day, Value = 1 }; AddDataSeries(Instrument.ToString(), dailyPeriod, 30, "Default 24 x 5", false);
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Adding Daily Data to a Strategy
Collapse
X
-
Adding Daily Data to a Strategy
I am trying to add 30 days of daily data to my strategy, regardless of how much 1 minute data my strategy is using (testing on 1 day). So on State.Configure I have
Code:Tags: None
-
Hello robbersdog,
Welcome to the NinjaTrader forums!
I'm not able to reproduce.
Attached is a test script and the output from prints in the the output window saved to a text file.
I'm seeing the first day bar as 8/6/2021.
'8/6/2021 10:00:00 PM | BarsInProgress: 1, CurrentBar: 0'Chelsea B.NinjaTrader Customer Service
-
Hi Chelsea,
Thank you, that is helpful. I'm still struggling with calculating some data off of daily bars. All I want to do is get the previous days OHLC. I have tried using BarsArray[1] but with no success. Could you provide a sample of how to get the previous days OHLC? I am running the strategy on minute bars.
Regards
Robbersdog
Comment
-
Hello robbersdog,
Thank you for your reply.
You could just use the Prior Day OHLC indicator to get those values without needing daily bars:
However, to get the OHLC of a secondary daily data series, you'd want to check Opens[1][0], Highs[1][0], Lows[1][0] or Closes[1][0] if running OnBarClose, and Opens[1][1], Highs[1][1], Lows[1][1] or Closes[1][1] if running OnPriceChange or OnEachTick.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Hi Kate,
Thanks for the reply. I've tried both of those but still not getting the data I'm expecting. This is an example of what I am looking for, using instrument ES 12-21 on the trading day closing on 17th Sep 2021, starting on 16th.The strategy kicks off at 17:00 (16th Sep), and the first 2 minute candle closes at 17:02. When I try to access previous day OHLC I would expect 4476, 4478.50, 4433.25, 4464.25. Accessing the examples above I get the OHLC for the previous bar, specifically OHLC of 4437, 4477.75, 4427.50, 4472. It seems like because the market opens on the 16th it gives me 15th data, even though technically I am currently on 17th Sep trading day.
How do I get candle 16th OHLC as the market opens on the 16th for trading day ending 17th?
Regards
Robbersdog
Comment
-
Hello robbersdog,
Thank you for your reply.
Keep in mind you'll need to have at least 1 day of data loaded on the chart prior to starting the strategy in order to get the prior daily bar or prior OHLC value. The following example requires you to load 2 days of 2 minute bars to function.
I'm attaching a simple example that uses both tactics (a daily series and the Prior Day OHL to print prior day OHLC prices. You'll notice that the close price differs between the two - this is because daily bars use the settlement adjusted closing price whereas intraday bars do not.
Please let us know if we may be of further assistance to you.Attached FilesKate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by traderqz, Today, 12:06 AM
|
10 responses
18 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
5 responses
46 views
0 likes
|
Last Post Today, 02:36 PM | ||
Started by arvidvanstaey, Today, 02:19 PM
|
1 response
6 views
0 likes
|
Last Post Today, 02:33 PM | ||
Started by mmckinnm, Today, 01:34 PM
|
3 responses
5 views
0 likes
|
Last Post Today, 02:12 PM | ||
Started by f.saeidi, Today, 01:32 PM
|
2 responses
9 views
0 likes
|
Last Post
by f.saeidi
Today, 02:10 PM
|
Comment