![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Dec 2011
Posts: 18
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
I need to pre-load 1 week of 1-minute historical data for selected instrument(s) when my strategy starts. Ideally, I'l like to populate the same DataSeries already selected with Add(). Is there a way to accomplish this programmatically? Of cause, I can accomplish this through "extrernal" calls, but I'd like to use the same historical data managemer/connector already present in NT. Thank you. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Hello gena72, unfortunately you could not load data programmatically, it would be the same lookback applied by NT as for your primary series on which the strategy is run.
Another approach can be looking into the Pivots indicator that loads the data asyncronously, but unfortunately the methods used would not be supported by us.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Dec 2011
Posts: 18
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
Thank you for explaining this. Setting a lookback for, let's say 5 days, will pre-load the main DataSeries with historical data for selected instrument (and fetch it if necessary)? For instance, 5 days, is approximately 2500 bars, Will I be able to use Close[2500] inside the strategy? |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Yes, you can access the historical data via the index in your strategy, however you would need to ensure to not attempt to access the data too early, as the OnBarUpdate() method is processed sequentially from left to right you otherwise run into situations where there's no data for x bars back is available...the most obvious being the CurrentBar = 0, so the first bar of the chart if you attempt to access Close[1] here you're getting an error returned from NT and the script would be terminated.
http://www.ninjatrader.com/support/f...ead.php?t=3170
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Dec 2011
Posts: 18
Thanks: 0
Thanked 0 times in 0 posts
|
Let me get this straight. If I use a "lookback" function, onBarUpdate() will be called starting from which bar? The first real-time bar coming from the exchange (in which case CurrentBar > 0), or from the oldest bar loaded from historical data (which does not make sense for real-time strategy)?
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
It would be per default the oldest bar on the chart and then advance through all bars until it hits your current realtime bar.
If you would like to not calculate anything on historical bars, use Historical to return out of OnBarUpdate() for those bars. http://www.ninjatrader.com/support/h...historical.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Dec 2011
Posts: 18
Thanks: 0
Thanked 0 times in 0 posts
|
So the strategy will be actually running in two modes. Historical first, and then, real-time. Interesting, I will check this out.
Thank you. |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Correct, unless you filter with Historical - it arrives at it's historical strategy position and then trades live.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Historical Data Load Problem | oz-dog | Charting | 7 | 02-19-2011 03:15 AM |
| cannot load historical data | crmcwi | Connecting | 11 | 06-04-2010 11:23 AM |
| When does NinjaTrader Load Historical Data | AnotherTrader | Miscellaneous Support | 7 | 04-13-2010 09:10 AM |
| wont load historical data | davidwm88 | Charting | 2 | 06-21-2009 11:54 AM |
| Can't load historical data | Bud_Fox | Charting | 19 | 05-18-2009 09:18 AM |