If I am using a 50MA does this mean my bars required needs to be 50?
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
Determining bars required
Collapse
X
-
Determining bars required
For backtesting purposes if it matters. How do you determine what your bars required number should be? It seems 20 is the standard default but what is the significance or purpose for that?
If I am using a 50MA does this mean my bars required needs to be 50?Tags: None
-
Hello zachj,
Thank you for your post.
That is correct, you are going to want more bars on the chart than your period by at least one. The period would be the number of bars used to calculate so it makes sense we need that many bars before the values can be calculated.
For information on making sure you have enough bars on your chart before accessing them please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170
Please let me know if I may be of further assistance.
-
So with the 50MA and using a 5min chart it would take about 4hrs for the 50MA to form so the first trade could not be until about 130pm. But say I had my bars required set to 20 that would allow the first trade to be around 1115am as I can see from looking at the trades in the backtest. So what does it do just resort to a 20 bar MA?
Comment
-
Originally posted by zachj View PostSo with the 50MA and using a 5min chart it would take about 4hrs for the 50MA to form so the first trade could not be until about 130pm. But say I had my bars required set to 20 that would allow the first trade to be around 1115am as I can see from looking at the trades in the backtest. So what does it do just resort to a 20 bar MA?
For a 50-period SMA you would need at least 50 bars. For a 50-period EMA you may need as many as 100 bars to approach the correct value of the moving average. This is because the EMA is an IIR filter (infinitive impulse response filter) that calculates the current value by using the EMA values of the preceding bars.
For your 50-period moving average, you can use data of the prior day. Markets are now mostly running around the clock, why would you want to start calculations with the daybreak?
If you wish to use a session indicator that only takes into account trades of the current session, I would recommend a VWAP over a traditional moving average.
Comment
-
Yes I realize that but Harry mentioned I could use data of the prior day which I assume he is talking about the 24/7 setting but that will include AH/PM which I do not want. This went off track and one of my original questions wasn't really answered, I was just curious if I have it set for 20 for bars required and I have a 50 MA in my script will it just resort to a 20 MA, then 21 MA and so on until it reaches a 50 MA? I will just set it to 50 or 51 but just was curious how it operates when enough data is not available. And I do realize that it will just not take the trade if its set to RTH and that it will only do this for 24/7 setting.
Comment
-
Originally posted by zachj View PostYes I realize that but Harry mentioned I could use data of the prior day which I assume he is talking about the 24/7 setting but that will include AH/PM which I do not want. This went off track and one of my original questions wasn't really answered, I was just curious if I have it set for 20 for bars required and I have a 50 MA in my script will it just resort to a 20 MA, then 21 MA and so on until it reaches a 50 MA? I will just set it to 50 or 51 but just was curious how it operates when enough data is not available. And I do realize that it will just not take the trade if its set to RTH and that it will only do this for 24/7 setting.
Whether a 50 MA will resort to a 20 MA or not depends on
-> the type of the moving average
-> and the formula that is used
There are different ways for each indicator to code an approximation for the training period, and you really need to check the script. The NinjaTrader SMA(50) will resort to SMA(19), if there are only 19 bars on your chart and to a SMA(37), if there are 37 bars. With an EMA this is not possible, as the training period is longer than the indicator period.
The best option is to code a new indicator that works in the way you have described.
For example I have coded a SMA that detects the first bar of the regular session and then calculates a simple moving average that gradually builds up until the number of bars equivalent to the selected lookback period is reached. I use this inidcator on the NYSE Tick, as I am not interested to include any tick readings from the prior evening to determine the trend of the current day.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by sidlercom80, 10-28-2023, 08:49 AM
|
168 responses
2,262 views
0 likes
|
Last Post
by sidlercom80
Today, 12:05 AM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
3 responses
10 views
0 likes
|
Last Post Yesterday, 11:58 PM | ||
Started by WeyldFalcon, 12-10-2020, 06:48 PM
|
14 responses
1,429 views
0 likes
|
Last Post
by Handclap0241
Yesterday, 10:43 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
2 responses
9 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:31 PM
|
||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
41 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
Comment