Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intrabar VWAP

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

    Intrabar VWAP

    Hello support,

    I would like to create an indicator, that creates a small dot onto the bar upon its close. This dot is to represent the VWAP for the given bar. Thus, I calculate followingly:


    Code:
    		
          #region Variables
            // Wizard generated variables
            // User defined variables (add any user defined variables below)
    		private double SumPrices;
    		private double SumVolume;
            #endregion
    
    ...
    
    protected override void OnMarketData(MarketDataEventArgs e)
    		{
    		if ( FirstTickOfBar ){
    			SumPrices = 0;
    			SumVolume = 0;
    			}
    			
    		SumPrices += e.Price;
    		SumVolume += e.Volume;
    		
    		DrawDot( "IntrabarVWAP" + CurrentBar, false, 0, SumPrices / SumVolume, Color.Black);
    		}
    However, some 3M bars with nonzero volume plot no dot, while some bars plot a dot which is outside the High-Low range. Where am I doing the mistake?

    Sincerely,
    Daniel.

    #2
    Hi Daniel, unfortunately we would not offer custom coded debugging services - I would suggest you add Print() statements in your script to understand where the calculations are not working out your expectations.

    Comment


      #3
      Hello Bertrand,

      OK no problem, just curious though whether you see some obvious errors in my code.

      Regards,
      Daniel.

      Comment


        #4
        Originally posted by Eubie View Post
        Hello Bertrand,

        OK no problem, just curious though whether you see some obvious errors in my code.

        Regards,
        Daniel.
        SumPrices / SumVolume is not the VWAP.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        154 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        306 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        244 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        345 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        176 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X