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

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.

    BertrandNinjaTrader Customer Service

    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 alifarahani, Today, 09:40 AM
        6 responses
        36 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Waxavi, Today, 02:00 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        17 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X