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 values initially not correct

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

    OrderFlowVWAP values initially not correct

    When using OrderFlowVWAP in a strategy, the values are not correct when the strategy is initially enabled. After the following message is printed to the output window, the values are correct:

    Enabling NinjaScript strategy 'VWAPStrategy1/241469855' : On starting a real-time strategy - StartBehavior=ImmediatelySubmit EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=False SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes

    Is there a way to test for when the OrderFlowVWAP is ready?

    Thank you,
    Marc

    #2
    Hello marcmclean,

    Thanks for your post and welcome to the NinjaTrader forums!.

    What data feed do you connect to?

    Are you using standard resolution or tick resolution?

    If using tick resolution have you added a 1 tick series and added the update code as shown in the help guide?: https://ninjatrader.com/support/help...flow_vwap2.htm
    Last edited by NinjaTrader_PaulH; 01-21-2022, 09:36 AM. Reason: added welcome!
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul H,

      The resolution is Tick:
      VWAPValue = OrderFlowVWAP(VWAPResolution.Tick, Bars.TradingHours, VWAPStandardDeviations.Three, 1, 2, 3).VWAP[0];

      The data series is in the OnStateChange() function:

      else if(State == State.Configure)
      {
      AddDataSeries(Data.BarsPeriodType.Tick, 1);
      }

      The update code is in the OnBarUpdate() function:

      }else if (BarsInProgress == 1)
      {
      // We have to update the secondary tick series of the cached indicator using Tick Resolution to make sure the values we get in BarsInProgress == 0 are in sync
      OrderFlowVWAP(BarsArray[0], VWAPResolution.Tick, BarsArray[0].TradingHours, VWAPStandardDeviations.Three, 1, 2, 3).Update(OrderFlowVWAP(BarsArray[0], VWAPResolution.Tick, BarsArray[0].TradingHours, VWAPStandardDeviations.Three, 1, 2, 3).BarsArray[1].Count - 1, 1);
      }

      Is there a way to detect when 'Enabling NinjaScript strategy' message above is written to the output window? The OrderFlowVWAP values are correct after that.

      Marc

      Comment


        #4
        Hello marcmclean,

        Thanks for your reply.

        The message would typically be produced when switching from State.Historical to State.RealTime.

        What data feed (data provider) do you connect to?





        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Data provider is My Kinetick.

          I set a flag when State == State.RealTime and then wait until the flag is set to start using the OrderFlowVWAP values. That seems to work fine.

          Thank you for your help,

          Marc

          Comment


            #6
            Hello marcmclean,

            Thanks for your reply.

            I would like to investigate this further to understand why your code is returning incorrect values historically.

            Can you provide a reduced code simplified example that demonstrates pulling incorrect historical values and the steps needed to recreate on our end?



            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hi PaulH,

              It may be that historic data is correct. I'm only looking at real time data.

              Marc

              Comment


                #8
                Hello marcmclean,

                Thanks for your reply.

                The title of the thread is "OrderFlowVWAP values initially not correct" so I would like to better understand what specifically is incorrect so if you can provide a test script that shows incorrect values and the steps to recreate we would be glad to review.

                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RubenCazorla, 08-30-2022, 06:36 AM
                3 responses
                77 views
                0 likes
                Last Post PaulMohn  
                Started by f.saeidi, Yesterday, 12:14 PM
                9 responses
                23 views
                0 likes
                Last Post f.saeidi  
                Started by Tim-c, Today, 03:54 AM
                0 responses
                3 views
                0 likes
                Last Post Tim-c
                by Tim-c
                 
                Started by FrancisMorro, Today, 03:24 AM
                0 responses
                3 views
                0 likes
                Last Post FrancisMorro  
                Started by Segwin, 05-07-2018, 02:15 PM
                10 responses
                1,772 views
                0 likes
                Last Post Leafcutter  
                Working...
                X