Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I get volume?

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

    How do I get volume?

    I even used ChatGPT and it kept giving me big syntax problems with trying to write a volume indicator.



    int buyVolume = barsType.Volumes[CurrentBar].TotalBuyingVolume;
    int sellVolume = barsType.Volumes[CurrentBar].TotalSellingVolume;​


    I try to compile this, but it tells me "the name barsType doesn't exist in the current context.'

    Please tell me what does. I literally just want to populate my variable with the total buy volume or total sell volume for the current bar.


    #2
    Hello Darth_Trader,

    Thank you for your post.

    The BuySell Volume indicator could be used to get the buy and sell volume for a bar that is referenced with a barsAgo index (not CurrentBar). Here is the help guide page with the syntax information:


    Returns buy volume
    BuySellVolume().Buys[int barsAgo]
    BuySellVolume(ISeries<double> input).Buys[int barsAgo]

    Returns sell volume
    BuySellVolume().Sells[int barsAgo]
    BuySellVolume(ISeries<double> input).Sells[int barsAgo]
    Otherwise, you could use the OnMarketData() method to get buy and sell volume information. The source code for the BuySell Volume indicator may be viewed inside of the NinjaScript Editor for an idea of how the indicator gets that calculation. For more information about OnMarketData() please see the following page:


    Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X