protected override void OnBarUpdate() { if (CurrentBar < BarsRequiredToTrade) return; if (State != State.Realtime) return; string timeStamp = Time[0] + " (" + Instrument.FullName + ")"; Print(""); double vwap0 = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("US Equities ETH"), VWAPStandardDeviations.None, 1, 2, 3).VWAP[0]; Print(timeStamp + " VWAP0: " + vwap0); double vwap1 = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.None, 1, 2, 3).VWAP[0]; Print(timeStamp + " VWAP1: " + vwap1); }
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
OrderFlowVWAP in a Strategy does not match OrderFlowVWAP on Chart
Collapse
X
-
OrderFlowVWAP in a Strategy does not match OrderFlowVWAP on Chart
I am trying to use OrderFlowVWAP in a strategy, but the VWAP value I get in the strategy is different than what I see on the chart. I created a simple test strategy that just prints out the VWAP Value in OnBarUpdate. I have also attached screenshots of the TestStrategy parameters and the OrderFlowVWAP indicator properties. I do not have tick replay enabled on the data series.
Code:Last edited by TheTradingMantis; 08-10-2021, 06:46 AM.Tags: None
-
I changed the number of days to load on the chart, and the Strategy VWAP changes. This leads me to believe the Strategy VWAP is not being reset at the end of each session.
I also changed the data series to load 25 bars so only data from the current session is loaded. In this situation the Strategy and Chart VWAPs match.
How can I get the VWAP I use in a strategy to reset with each session / trading day?Last edited by TheTradingMantis; 08-10-2021, 07:07 AM.
-
Hello gregschr,
Thank you for your reply.
I'm unable to replicate a discrepancy on real time data on my end - the prints I get match the Order Flow VWAP on the same instrument you're using (MVST) as well as on other instruments.
Are you currently running the latest version of the platform? The current version is 8.0.24.3. You can find your version number under Help > About.
If you delete the cache, does the issue persist? To delete the cache, follow the steps below.- Shut down NinjaTrader.
- Open the Documents > NinjaTrader 8 > db folder.
- Delete the sub-folder named 'cache'.
- Restart NinjaTrader and test.
Kate W.NinjaTrader Customer Service
Comment
-
Comment
-
Hello gregschr,
Thank you for your reply.
I'm unable to replicate a discrepancy using the settings provided. I've created a test indicator and workspace that includes the test indicator on a MVST chart, printing the values to a NinjaScript output window. If you import the below .Zip file, you should be able to open the workspace and confirm whether you're seeing matching values on your end.
Here's a screenshot to illustrate what I'm seeing:
Do you see discrepancies when using the attached workspace and indicator?
Thanks in advance; I look forward to assisting you further.Kate W.NinjaTrader Customer Service
Comment
-
Hi Kate,
The indicator you included worked as expected.
The problem occurs when using this in a Strategy.
I've attached an image from the workspace you sent, with the same code running in a Strategy (same code I attached above).
Thanks, Greg
Comment
-
Hello gregschr,
Thank you for your reply.
I'm unable to replicate this behavior either with your code from the original post in a strategy or with code that saves the VWAPs to variables and accesses them that way. I've attached both my test scripts - are you able to replicate with either of these? Are both the strategy and the chart VWAPs running on the same Calculate mode?
Thanks in advance; I look forward to assisting you further.Attached FilesKate W.NinjaTrader Customer Service
Comment
-
Hi Kate,
I tried both the strategies you included and both display correctly when using Calculate.OnBarClose.
But when I switch them to Calculate.OnEachTick, the VWAP values in the strategies do not match the chart. This is MES futures since the stock market was closed.
I also tried changing the calculate mode on the chart. The chart displays the same value, no matter which calculate mode (OnBarClose or OnEachTick) is selected.
Thanks,
GregLast edited by TheTradingMantis; 08-12-2021, 06:45 AM.
Comment
-
Hello gregschr,
Thank you for your reply.
I was able to replicate this with your code on my end, and the issue seems to stem from restricting the script from processing OnBarUpdate only if we're on real time data - if you remove that check, the prints are correct. However, we don't think this should be occurring, so we're going to send it to our QA team for them to take a look at. As soon as I hear back from them, I'll update you. For now, if you remove this line:
if (State != State.Realtime) return;
You should get the correct prints showing.
Thanks in advance; I look forward to assisting you further.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
||
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
47 views
0 likes
|
Last Post Today, 12:28 AM |
Comment