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

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 Brevo, Today, 01:45 AM
    0 responses
    4 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    241 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    6 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Working...
    X