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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        29 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        17 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        9 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        15 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        18 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X