Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

collecting volume traded at bid / at ask

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

    collecting volume traded at bid / at ask

    I need bid and sell volume at bars separatedly, so i am writing an indicator to do that.
    I does not seems to work yet, so tried something easier: collecting volume together.

    Basically collect all trades no matter it was bid or ask.

    Code:
    		protected override void OnBarUpdate()
    			{
    				totalvol = totalvol + eVol;
    				totalvolplot.Set(totalvol);	
    				
                                    if(FirstTickOfBar)
    				{
    				totalvol = eVol;
    				}
    			}
    	
    
    		protected override void OnMarketData(MarketDataEventArgs e)
                       {
    			
    			//Set AskPrice
    			if(e.MarketDataType == MarketDataType.Ask)
    			{
    				AskPrice = e.Price;
    			}
    			
    			//Set BidPrice
    			if(e.MarketDataType == MarketDataType.Bid)
    			{
    				BidPrice = e.Price;
    			}
    			
    			//Trade calculations done on incoming trade data
    			if (e.MarketDataType == MarketDataType.Last)
    			{
    						
    			//Buys calculations
    				if(e.Price >= AskPrice)
    				{
    					eVol = e.Volume;
    				}
    		
    				//Sells calculations
    				if(e.Price <= BidPrice)
    				{
    					eVol = e.Volume;
    				}
    			}
    		    }
    		#endregion
    The problem is that (compared to VOL indicator): sometimes it disregard the FirstTickOfBar part, and adds the volume of previous bar to the current bar.

    Why is that?
    Are there any other solution to achieve this?

    #2
    Hello andre.adamov,

    Thank you for writing in.

    You can Add() both a bid and ask series and check the volume of each series once their respective bars have closed.

    More information about Add() can be found here: http://ninjatrader.com/support/helpGuides/nt7/?add3.htm

    To reference the volume of each object, you'll want to utilize Volumes: http://ninjatrader.com/support/helpG...7/?volumes.htm

    Additionally, as we're now working with multiple series, I would suggest taking a look at this help guide link as well that details further about working with multiple series: http://ninjatrader.com/support/helpG...nstruments.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    571 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    331 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    549 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    550 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X