Announcement

Collapse
No announcement yet.

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:	608
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.

    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:	433
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;

        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.

              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:	426
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.

                  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.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      599 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      344 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      558 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      557 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X