This probably has to do with your CalculateOnBarClose settings. When set to true you will get the value of the last complete bar, not the in-process bar. To get the most recent values, change CalculateOnBarClose to false. You can hard code this property or change the setting whenever you run it.
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
Multi time frame and WMA
Collapse
X
-
Hello David,
This probably has to do with your CalculateOnBarClose settings. When set to true you will get the value of the last complete bar, not the in-process bar. To get the most recent values, change CalculateOnBarClose to false. You can hard code this property or change the setting whenever you run it.Ryan M.NinjaTrader Customer Service
-
The problem is that I am not getting the values from the last complete bar. I am getting the bar before that, in the added time frame only.
After running this some more, this is some kind of timing issue.
For example, when I start a market replay, just after 9:30 I get my first print statement. In the primary time frame I am seeing the correct values for "Close" and "WMA High" from the last 10 minute bar of the previous day. In the added time frame I am getting values not from the last bar of the previous day, but from the 2nd last bar of the day. Then at 9:40 in my next print statement I am again seeing the correct values for my primary time frame, those from the first bar of the day. On the secondary time frame, now I am seeing the values for the last bar of the previous day.
This pattern continues on during the day ...
In testing this has caused some entries to occur 1 bar later than intended.
Thanks,
David
Comment
-
Originally posted by NinjaTrader_RyanM View PostDave,
Attachments are handled through individual posts. Click reply and when composing your post look for Manage Attachments button under Additional Options.
Maybe I'll add a smiley face while I'm here...Attached Files
Comment
-
Hi David,
One thing I noticed from your strategy is that your secondary time frame is larger than the primary. This is important in version 6.5, but shouldn't matter as much in version 7.
You should modify your strategy so that secondary series is smaller than the primary series.
Please see this reference sample on Backtesting NinjaScript Strategies with an intrabar granularity for assistance on coding this. Below is the section that discusses the order of OnBarUpdate calls in a multi instrument strategy.
When working with multiple bar series objects it is important to understand the sequential order in which the
OnBarUpdate() method is triggered. The bars will always run with the primary first followed by the secondary and
so on.
Important: Primary bars will always execute before the secondary bar series.
If a bar is timestamped as 12:00PM on the 5min bar series, the call order between the equally timestamped 12:00PM
bar on the 1min bar series is like this:
12:00PM 5min
12:00PM 1min
12:01PM 1min
12:02PM 1min
12:03PM 1min
12:04PM 1min
12:05PM 5min
12:05PM 1minLast edited by NinjaTrader_RyanM1; 06-02-2010, 11:36 AM.Ryan M.NinjaTrader Customer Service
Comment
-
Sorry I'm a bit confused by your response. Just to be clear (if you could not tell from the cs) I am using version 6.5.
First you said my "secondary time frame is larger". Yes I agree, it is.
Then you said I should modify so that my "primary series" is"smaller" than the larger. Isn't it already???
I'm guesing you mean that my higher time frame, 30 min, should be my primary rather than the 10 min time frame? Also you seem to be suggesting that the way I have it now is preferable for 6.5?
Comment
-
Yes, you're right. Thanks for seeking clarification.
If you have two series, a 10 minute and 30 minute:
Your 30 minute series should be the primary series. This is the series you run the strategy against.
Your 10 minute series should be the secondary series. This is the series you add in the initialize method.
This is preferred when using version 6.5 due to the timing of bar objects.Ryan M.NinjaTrader Customer Service
Comment
-
Ryan,
This looks promising after my initial tests on market replay data this morning. I had to do some tweaking as my entry and exit conditions are on my secondary timeframe now (as compared to the example with the entry condition on the primary time frame) but my entries, exits and all print statements are now looking like I envisioned.
Thanks,
David
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ETFVoyageur, Today, 02:15 AM
|
5 responses
29 views
0 likes
|
Last Post Today, 01:06 PM | ||
Started by drnoggin, Today, 12:19 PM
|
1 response
14 views
0 likes
|
Last Post Today, 12:46 PM | ||
Started by synthhokie, Today, 12:00 PM
|
1 response
16 views
0 likes
|
Last Post Today, 12:31 PM | ||
Started by moneyexe, Today, 11:22 AM
|
1 response
12 views
0 likes
|
Last Post Today, 11:32 AM | ||
Started by stevec1824, Today, 11:00 AM
|
2 responses
8 views
0 likes
|
Last Post
by stevec1824
Today, 11:32 AM
|
Comment