Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using OrderFlowVWAP in Strategy

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

    Using OrderFlowVWAP in Strategy

    I am using OrderFlowVWAP as indicated in the help guide at https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?order_flow_vwap2.htm to get the VWAP.

    It works fine the session I enable it, gives accurate value.

    But when i check the value the next session, it is off by quite a few ticks, obviously reset doesn't to happen properly. I checked the parameters and it appears fine to me. Can you please help?

    My intention is to get the VWAP for that session, each session.

    My code

    double VWAPValue = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures ETH"), VWAPStandardDeviations.Three, 1, 2, 3).VWAP[0];

    #2
    Hello GauthamK,

    Thanks for your post.

    Please clarify the details of the application:

    What instrument, bar type, time frame (bars size) is this strategy applied to?

    What are the applied trading hours of the chart/strategy?

    Do you have any other added data series in the strategy?

    Can you show an example chart that this is applied to and advise the differences that your strategy is seeing versus what you see on the chart? (Prints to the output window)

    What version of Ninjatrader8 are you using (Look under Help>about)

    What data feed do you connect to?



    Comment


      #3
      Hi paul,

      instrument: ES
      timeframe 5 min bars

      applied trading hours: as shown in the code pasted, its CME US Index Futures ETH

      No other data series added.

      o/p from the print window

      both are printed on the same candle. 1st o/p is from the incorrect VWAP calc. 2nd o/p is for a new window/chart that is opened today (correct).

      prevHigh price 4418 prevLow: 4293.75
      The current VWAP with a standard resolution on CME US Index Futures ETH is 4361.25369443674
      VWAP price 4361.25

      prevHigh price 4418 prevLow: 4293.75
      The current VWAP with a standard resolution on CME US Index Futures ETH is 4364.64162532773
      VWAP price 4364.75

      Am on NT8 8.0.24.3 64-bit

      datafeed: NT Continuum

      Comment


        #4
        Hello GauthamK,

        Thanks for your reply.

        I'm not seeing where/when you are comparing the data. Can you provide a screenshot, or other information, that shows me what specific bars you are comparing the VWAP on?

        How does PrevHigh and PrevLow relate to the VWAP question?

        Comment


          #5
          I am not sure why that is relevant here to see what I am comparing VWAP to. My question is only for the actual VWAP for the session.

          if its useful in anyways, here are some snippets

          double VWAPValue = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures ETH"), VWAPStandardDeviations.Three, 1, 2, 3).VWAP[0];
          Print("The current VWAP with a standard resolution on CME US Index Futures ETH is " + VWAPValue.ToString());
          double vwPrice = Instrument.MasterInstrument.RoundToTickSize(VWAPVa lue);
          VWAP[0] = vwPrice;
          Print("VWAP price " + vwPrice);

          .....
          ....

          bool isNeartoVWAP = High[3] >= VWAPValue && Low[3] <= VWAPValue;

          .....

          .....

          if (entryOrder == null && Low[1] > VWAPValue && Low[2] > VWAPValue && isNeartoVWAP) {
          ....
          ....

          }

          Comment


            #6
            Hello GauthamK,

            Thanks for your reply.

            My apologies as I am still not following what specific bar you are comparing the Order Flow VWAP on.

            I would suggest always adding a timestamp to your print statements so you know what bar they were produced on.

            Are you saying that the VWAP on any bar today will not be the same tomorrow when looking back at today's bars?

            Comment


              #7
              Sorry for any confusion.

              See below with the timestamps.

              incorrect VWAP printed from a chart, that was opened yesterday.

              Current price 4349.25 Pivot: 4353.25 Timestamp: 9/21/2021 1:25:00 PM Settlement 4348.25
              prevHigh price 4418 prevLow: 4293.75
              The current VWAP with a standard resolution on CME US Index Futures ETH is 4360.4318102969
              VWAP price 4360.5


              Correct VWAP printed from a chart, that is opened in the current session
              Current price 4349.25 Pivot: 4353.25 Timestamp: 9/21/2021 1:25:00 PM Settlement 4348.25
              prevHigh price 4418 prevLow: 4293.75
              The current VWAP with a standard resolution on CME US Index Futures ETH is 4363.35352241373
              VWAP price 4363.25

              both are for the same bar on ES chart today 5 min bar that started at 1:20 pm CST

              Comment


                #8
                Hello GauthamK,

                Thanks for your reply and clarifications.

                On both charts, please right-mouse click and select "data series" and verify that "Break at EOD" is checked and that both are using the same Trading hours (or <use Instrument settings> and that they are using the same days to load, also check to see that tick replay is enabled or not for both.

                If those are all the same then, at the end of the day:

                Please use the steps below to change/check your Time Zone and sync the PC clock:
                • Shutdown NinjaTrader
                • Right-click the clock in the lower right corner of your desktop
                • Select Adjust date/time
                • For Windows 10 click 'Date, Time, and regional formatting' -> Then click 'Additional date, time, and regional settings' -> then click 'Set the time and date'
                • Select the 'Internet Time' tab at the top
                • Set the server to time.nist.gov and then click Update.
                • If the message that appears says successful your PC clock should now be updated.
                • If not, select a different server from the Server: drop-down and try again (repeat until one of the servers is successful)

                After updating the PC clock, please restart NinjaTrader, then right-click the chart and select Reload All Historical Data.


                Comment


                  #9
                  I did all this now coming back to the main question.

                  1) Is OrderFlowVWAP API supposed to return the current session VWAP in a strategy even when the chart is left to for multiple days?

                  Comment


                    #10
                    Hello GauthamK,

                    Thanks for your reply.

                    The Order Flow VWAP reset interval is set to the session. As each session starts, the VWAP will reset.

                    I would suggest printing the VWAP value bar by bar (and bar time) to see this.

                    Comment


                      #11
                      Thank you will check again and post the results. Will have to wait until Tomm.

                      meanwhile to print the current time I am using Time[0]. Is that correct?

                      Comment


                        #12
                        Hello GauthamK,

                        Thanks for your reply.

                        Time[0] will print the Date and close time of the bar.

                        Comment


                          #13
                          How can i print the current time?

                          Comment


                            #14
                            Hello GauthamK,

                            Thanks for your reply.

                            Print (DateTime.Now);

                            The time printed will be related to when OnBarUpdate() is called which is set by the Calculate setting.

                            Comment


                              #15
                              Hi,

                              The below post sums up my issue perfectly, and looks like there is an issue with this API when getting used in a strategy. onBarUpdate vs OnEachTick.

                              Is there an ETA for the resolution?

                              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


                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Today, 05:17 AM
                              0 responses
                              50 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              127 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              69 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              42 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              46 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X