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

Trouble with VWAP indicators

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

    Trouble with VWAP indicators

    Hello everyone,

    I am currently using VWAP from: https://thevwap.com/free-vwap-indicator-ninjatrader/ and it works great
    I wanted to do some changes to the way the bands are calculated but I couldn't because the source code is locked.
    So I downloaded another VWAP( I attached the file) with open source code that seems to be the same value but with one issue, as seen in the picture, once the data is live( right to the blue horizontal line) there is a deviation between the two VWAPs and I don't know why it happens and how to fix it.

    some notes:
    red line = correct VWAP
    white line =wrong VWAP
    both are calculated "on each tick"

    Please help me
    Click image for larger version

Name:	image.png
Views:	196
Size:	45.5 KB
ID:	1279247

    #2
    Hello gjb1234,

    That would be difficult to say what may be happening as the source code for what you are comparing against is not available. Its possible that the closed source version uses different logic to calculate the value in realtime. OnEachTick processing only matters in realtime so if the values match historically its likely some difference in how the indicator handles specifically realtime bars.

    JesseNinjaTrader Customer Service

    Comment


      #3
      its seem like it starts to calculate the VWAP from the moment I placed it. I also have an Anchored VWAP that I place on the same time and the values are very close.
      How I can tell ninja to just continue with the calculation and not to start a new one?

      Click image for larger version

Name:	image.png
Views:	94
Size:	11.8 KB
ID:	1279260
      Attached Files

      Comment


        #4
        Hello gjb1234,

        When you apply an indicator it first does a backtest over the chart data before entering realtime. If you want to prevent historical bars from being calculated you can add the condition:

        if(State == State.Historical) return;

        JesseNinjaTrader Customer Service

        Comment


          #5
          I will try and let you know if it works
          thank you for the help!

          Comment


            #6
            did not work.
            I want it to keep the historical data and add to it the fresh one

            Comment


              #7
              Hello gjb1234,

              I am not sure what you mean, when you apply a script it starts on bar 0 and calculates moving forward 1 bar at a time. When you enter realtime that will continue doing the exact same calculation in realtime. I am not sure what you mean by fresh one, the script would be the same script when moving from historical to realtime.
              JesseNinjaTrader Customer Service

              Comment


                #8
                by "fresh one" I mean the next bar from the moment I loaded the indicator into the chart.

                this is the code, maybe you are able to see something I don't

                Click image for larger version

Name:	image.png
Views:	90
Size:	46.2 KB
ID:	1279271

                Comment


                  #9
                  Hello gjb1234,

                  When you add an indicator to the chart it will first process historical data up to realtime. After that the calculated data is available for use in realtime and the first realtime bar will continue to use that calculation for new bars. The code you provided is using 0 bars ago in the calculation so for every bar historical or realtime it would calculate a new value and plot it. That logic is delegated by the first bar of the session, the iCumVolume and ICumTypicalVolume variables are reset on the first bar of the session and then used to append to the calculation for each bar during the session.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Jesse can you explain to me why it diverge? I dont get it. If I tell it to calculate "on bar close" there are no problems with it

                    Comment


                      #11
                      Hello gjb1234,

                      No that would not be possible without seeing the code for the closed source indicator. There would be no way to know what logic they used to know if what you are doing is similar or not.

                      If it works right OnBarClose you would likely need to just use OnBarClose if you are trying to match the other indicator and its values.

                      JesseNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by fx.practic, 10-15-2013, 12:53 AM
                      5 responses
                      5,406 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Started by Shai Samuel, 07-02-2022, 02:46 PM
                      4 responses
                      98 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Started by DJ888, Yesterday, 10:57 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by MacDad, 02-25-2024, 11:48 PM
                      7 responses
                      160 views
                      0 likes
                      Last Post loganjarosz123  
                      Started by Belfortbucks, Yesterday, 09:29 PM
                      0 responses
                      9 views
                      0 likes
                      Last Post Belfortbucks  
                      Working...
                      X