Is there any way to provide the strategy with historical data to fill in this data gap so that the strategy has sufficient data to start using the OnBarUpdate() immediately for the Realtime State calculation when it is trading live?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
BarsRequiredToTrade - Historical to live trading
Collapse
X
-
BarsRequiredToTrade - Historical to live trading
My strategy uses a moving average with a period of 200. My understanding therefor is that the BarsRequiredToTrade must be set to 200 to ensure enough historical data is available to perform the calculations. For backtesting, this is not a problem. However, once this strategy trades live, I don't want to have to wait 200 bars before the strategy starts looking for opportunities to open a position. The strategy is used on a daily chart which means I would have to wait 200 trading days before it will even start to look to open any positions.
Is there any way to provide the strategy with historical data to fill in this data gap so that the strategy has sufficient data to start using the OnBarUpdate() immediately for the Realtime State calculation when it is trading live?Tags: None
-
You already gave the answer to your own problem.Originally posted by JulieV View PostMy strategy uses a moving average with a period of 200. My understanding therefor is that the BarsRequiredToTrade must be set to 200 to ensure enough historical data is available to perform the calculations. For backtesting, this is not a problem. However, once this strategy trades live, I don't want to have to wait 200 bars before the strategy starts looking for opportunities to open a position. The strategy is used on a daily chart which means I would have to wait 200 trading days before it will even start to look to open any positions.
Is there any way to provide the strategy with historical data to fill in this data gap so that the strategy has sufficient data to start using the OnBarUpdate() immediately for the Realtime State calculation when it is trading live?
When creating the new chart that you add the strategy to, setup your "Days to Load" to be at least 200.
The chart will load 200 days worth of historical bars, which your strategy will process as directed, just like it
does in backtest.
-
Hello JulieV,
Thanks for your post.
To elaborate on bltdavid's response, BarsRequiredToTrade is a setting that tells the strategy to wait until it has processed a certain number of bars before it is allowed to take trades. This counts historical bars and real time bars, so increasing your DaysToLoad or BarsToLoad will load more bars for the strategy to begin taking trades when it is processing historical data.
Let us know if you have any additional questions.
Comment
-
Hi JimOriginally posted by NinjaTrader_Jim View PostHello JulieV,
Thanks for your post.
To elaborate on bltdavid's response, BarsRequiredToTrade is a setting that tells the strategy to wait until it has processed a certain number of bars before it is allowed to take trades. This counts historical bars and real time bars, so increasing your DaysToLoad or BarsToLoad will load more bars for the strategy to begin taking trades when it is processing historical data.
Let us know if you have any additional questions.
Thanks for the explanation behind how BarsRequiredToTrade is calculated. I have gone into the data series of the instrument I am looking at and it's default setting is Days To Load = 365.
Just to make sure I am understanding everything correctly here. Because the data series already loads in 365 days worth of data, the strategy will automatically have enough data available to start looking for trading opportunities immediately because the BarsRequiredToTrade is set to 200 which is less than what is already available?
Comment
-
Hello JulieV,
To avoid confusion with Start Behaviors, I don't want to answer with a direct "yes."
When the strategy starts it begins processing historical data to determine a virtual position which is later used by the strategy's Start Behavior when the strategy transitions to realtime data and begins taking live trades. I'll include some documented information on Start Behaviors and Strategy/Account Position to further clarify on how these work if further reference is needed.
Having 365 DaysToLoad will ensure that the strategy has enough historical data to develop signals within the historical processing, so you will not be limited to taking trades when the strategy transitions to realtime. The data is already there and has been processed by the strategy.
One final item that should be clear is that BarsRequiredToTrade limits when NinjaTrader allows orders to submit. It should not be confused with "Making sure you have enough data in the data series you are accessing" explained below.
Making sure you have enough data in the data series you are accessing - https://ninjatrader.com/support/help...nough_bars.htm
Reference for understanding Strategy Position vs. Account Position and Start Behaviors is linked below.
Strategy vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm
Syncing Account Positions (Start Behaviors) - https://ninjatrader.com/support/help..._positions.htm
Let me know if you have any other questions we can assist with.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
86 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
151 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
79 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
53 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
60 views
0 likes
|
Last Post
|

Comment