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!
See more
See less

Partner 728x90

Collapse

OrderFlowVWAP in a Strategy does not match OrderFlowVWAP on Chart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:
    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);
    
    }
    Thanks, Greg
    Attached Files
    Last edited by TheTradingMantis; 08-10-2021, 06:46 AM.
    The Trading Mantis
    NinjaTrader Ecosystem Vendor - The Trading Mantis

    #2
    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.
    The Trading Mantis
    NinjaTrader Ecosystem Vendor - The Trading Mantis

    Comment


      #3
      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.
      Thanks in advance; I look forward to assisting you further.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        Hi Kate,

        I deleted the db cache and restarted and am still seeing the same issue. Also, I am on the current version 8.0.24.3

        I've attached the DataSeries properties I'm using so you can test on your end.

        Thanks,
        Greg
        Attached Files
        The Trading Mantis
        NinjaTrader Ecosystem Vendor - The Trading Mantis

        Comment


          #5
          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:

          Click image for larger version

Name:	2021-08-10_08-36-49.png
Views:	223
Size:	93.5 KB
ID:	1167218

          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


            #6
            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).

            Click image for larger version

Name:	Screenshot.png
Views:	191
Size:	73.2 KB
ID:	1167363

            Thanks, Greg
            The Trading Mantis
            NinjaTrader Ecosystem Vendor - The Trading Mantis

            Comment


              #7
              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 Files
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                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.

                Click image for larger version  Name:	stuff.png Views:	0 Size:	15.1 KB ID:	1167517

                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,
                Greg
                Last edited by TheTradingMantis; 08-12-2021, 06:45 AM.
                The Trading Mantis
                NinjaTrader Ecosystem Vendor - The Trading Mantis

                Comment


                  #9
                  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 Graci117, Today, 09:02 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by ETFVoyageur, Today, 07:55 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post ETFVoyageur  
                  Started by janio973, Today, 07:24 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by aligator, 01-06-2022, 12:14 PM
                  4 responses
                  246 views
                  0 likes
                  Last Post john_44573  
                  Started by reynoldsn, Today, 05:56 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post reynoldsn  
                  Working...
                  X