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 akm39, Yesterday, 05:17 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Jim  
                Started by kaywai, Today, 05:22 AM
                0 responses
                2 views
                0 likes
                Last Post kaywai
                by kaywai
                 
                Started by c_schmitti, Today, 05:20 AM
                0 responses
                6 views
                0 likes
                Last Post c_schmitti  
                Started by RookieTrader, Today, 04:42 AM
                0 responses
                6 views
                0 likes
                Last Post RookieTrader  
                Started by viaketofr, Today, 03:37 AM
                0 responses
                2 views
                0 likes
                Last Post viaketofr  
                Working...
                X