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

VWAP Band Starting Values

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

    VWAP Band Starting Values

    These images show multiple VWAPs. One from my code and the other is the built-in indicator. The built-in indicator has starting values all at the same point where mine are influenced by previous session close data.

    Is there a known reason why this happens?

    Using examples from the documentation here (settigns: standard resolution, RTH, reset for each session) the various VWAP and band values are initialized to zero if this is the first session start in the data loaded. If the session is not the first session in the data loaded, it seems as though the values are initialized using (in part) values from the previous session.

    Days to load set to zero:
    Click image for larger version  Name:	01072023.png Views:	0 Size:	47.4 KB ID:	1230214

    Days to load set to 1:
    Click image for larger version  Name:	01072023b.png Views:	0 Size:	36.6 KB ID:	1230215

    The reason I'm looking at this is I was comparing the values from the calculations in the code I'm using to the values displayed on the chart and you can see that they differ. While trying to troubleshoot that I noticed this difference in how the first values are treated.

    I'm happy to provide code if necessary but it's part of some much more complicated code so I was hoping maybe this was a known type of user error I could ask about.

    Otherwise let me know and I can dig into the code and try to get a snippet working that recreates this and I can post that rather than the entire strategy.
    Last edited by WalterSkinner; 01-08-2023, 08:47 AM.

    #2
    Hello WalterSkinner,

    T​hanks for your post.

    I have created an indicator that plots each value of the Order Flow VWAP indicator values, enabled both the custom VWAP indicator (VWAPExample) and the Order Flow VWAP indicator that comes with NinjaTrader on the same chart window. Then, I opened a data box window to compare the values between the indicators. I am seeing that the values are exactly the same regardless of what the 'Days To Load' Data Series property is set to.

    See the attached screenshot demonstrating this. I have also attached the example indicator used to test this.

    If this does not resolve your inquiry, please send me a reduced example script that reproduces the behavior you are reporting and the exact steps and settings used to reproduce the issue.

    Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.

    I look forward to further assisting.
    Attached Files
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      I can't think of anything that would be more useful than this help thank you so much, you're awesome.

      Comment


        #4
        Originally posted by NinjaTrader_BrandonH View Post
        Hello WalterSkinner,

        T​hanks for your post.

        I have created an indicator that plots each value of the Order Flow VWAP indicator values, enabled both the custom VWAP indicator (VWAPExample) and the Order Flow VWAP indicator that comes with NinjaTrader on the same chart window. Then, I opened a data box window to compare the values between the indicators. I am seeing that the values are exactly the same regardless of what the 'Days To Load' Data Series property is set to.

        See the attached screenshot demonstrating this. I have also attached the example indicator used to test this.

        If this does not resolve your inquiry, please send me a reduced example script that reproduces the behavior you are reporting and the exact steps and settings used to reproduce the issue.

        Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.

        I look forward to further assisting.
        If you modify the trading hours to RTH you may see similar behavior. Can't share screenshot, away from desk.

        I used something similar to this:

        Code:
        TradingHours.String2TradingHours("CME US Index Futures RTH")
        I believe it may have been this change that resulted in the weird behavior. Set to volume or tick based chart set to eth then apply vwap with hard coded RTH.

        Comment


          #5
          Hello WalterSkinner,

          Thanks for your note.

          I have modified my previously attached example script to use the CME US Index Futures RTH trading hours template for the VWAP value calculations.

          The modified script was then applied to an ES 03-23 1000 Tick chart with the trading hours set to CME US Index Futures ETH.

          Next, I added the Order Flow VWAP indicator that comes with NinjaTrader and set it to use the CME US Index Futures RTH trading hours template for calculations so that it matches the trading hours being used for the sample script, VWAPExampleModified.

          When comparing the VWAPExampleModified script values to the Order Flow VWAP indicator in a Data Box window, I am seeing that the values match. See the screenshot below. Note that changing the 'Days to load' property for the Data Series did not affect the results matching

          I have attached the modified sample script below for you.

          Please let me know if I may assist further.
          Attached Files
          Last edited by NinjaTrader_BrandonH; 01-10-2023, 11:24 AM.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_BrandonH View Post
            Hello WalterSkinner,

            Thanks for your note.

            I have modified my previously attached example script to use the CME US Index Futures RTH trading hours template for the VWAP value calculations.

            The modified script was then applied to an ES 03-23 1000 Tick chart with the trading hours set to CME US Index Futures ETH.

            Next, I added the Order Flow VWAP indicator that comes with NinjaTrader and set it to use the CME US Index Futures RTH trading hours template for calculations so that it matches the trading hours being used for the sample script, VWAPExampleModified.

            When comparing the VWAPExampleModified script values to the Order Flow VWAP indicator in a Data Box window, I am seeing that the values match. See the screenshot below. Note that changing the 'Days to load' property for the Data Series did not affect the results matching

            I have attached the modified sample script below for you.

            Please let me know if I may assist further.
            Click image for larger version  Name:	2023-01-12 12_10_12-Chart - 1k Tick.png Views:	0 Size:	73.6 KB ID:	1231017
            Gotta be something on my end. The data series here was set to both "data series settings" as well as CME ETH.

            Values outside of RTH are zero. So should I just hard code a time filter?
            Last edited by WalterSkinner; 01-12-2023, 12:14 PM.

            Comment


              #7
              Hello WalterSkinner,

              Thanks for your note.

              I suggest going through each line of code in your custom script to find the exact line of code causing the issue in your script.

              You could compare the example scripts shared previously in this forum thread to your custom script to see where differences might be.

              Let me know if you have further questions.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_BrandonH View Post
                Hello WalterSkinner,

                Thanks for your note.

                I suggest going through each line of code in your custom script to find the exact line of code causing the issue in your script.

                You could compare the example scripts shared previously in this forum thread to your custom script to see where differences might be.

                Let me know if you have further questions.
                Sorry if I was unclear.

                This is VWAPExampleModified, which you had uploaded to post #5, not my code.

                I ended up just hard-coding the time in there since I only trade RTH.
                Last edited by WalterSkinner; 01-12-2023, 02:19 PM.

                Comment


                  #9
                  Hello WalterSkinner,

                  Thanks for your note.

                  I have tested this on my end using the VWAPExampleModified script and see the behavior you are referring to.

                  "I ended up just hard-coding the time in there since I only trade RTH."

                  This would be the correct way to have the values calculated based on a certain timeframe within those trading hours.

                  Please let me know if I may assist further.
                  Brandon H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by burtoninlondon, Today, 12:38 AM
                  0 responses
                  10 views
                  0 likes
                  Last Post burtoninlondon  
                  Started by AaronKoRn, Yesterday, 09:49 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post AaronKoRn  
                  Started by carnitron, Yesterday, 08:42 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post carnitron  
                  Started by strategist007, Yesterday, 07:51 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post strategist007  
                  Started by StockTrader88, 03-06-2021, 08:58 AM
                  44 responses
                  3,983 views
                  3 likes
                  Last Post jhudas88  
                  Working...
                  X