Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Language References for Volume

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

    Language References for Volume

    Hi,

    I have been currently searching through the language reference for total volume, total bid volume, and total ask volume. I require it to obtain the ratio between the bid:ask volume for a indicator/strategy i am working on. Also, is it possible to obtain the same data (total volume, total bid volume, and total ask volume) with a selected number of price levels like we see in level II access.

    Thanks

    #2
    Hello agriggs,

    Thank you for your post, and welcome to the NinjaTrader forum.

    There is a default indicator called "BuySellVolume" this will be the indicator to reference if you want to collect bid and ask data, that indicator uses the OnMarketData method to do this. If you want something like daily total volume, the DailyVolume Market Analyzer column achieves that by overriding OnMarketData and waiting for the MarketDataType to equal MarketDataType.DailyVolume.

    e.g.

    Code:
    protected override void OnMarketData(Data.MarketDataEventArgs marketDataUpdate)
            {
                if (marketDataUpdate.IsReset)
                    CurrentValue    = double.MinValue;
                else if (marketDataUpdate.MarketDataType == Data.MarketDataType.DailyVolume)
                {
                    instrumentType  = marketDataUpdate.Instrument.MasterInstrument.InstrumentType;
                    CurrentValue    = instrumentType == InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(marketDataUpdate.Volume) : marketDataUpdate.Volume;
                }
            }
    The values collected here would only be available on real-time data though.

    For access through historical data, you would need to add a Daily series to your script with AddDataSeries. This will let you reference the Daily bar's volume at any given price index.

    e.g.

    Code:
    protected override void OnStateChange()
            {
                ...
                else if (State == State.Configure)
                {
                    AddDataSeries(BarsPeriodType.Day, 1);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if(CurrentBars[0] < 1 || CurrentBars[1] < 1)
                    return;
    
                if(BarsInProgress == 0)
                {
                    Print("The Daily volume for " + Times[0][0] + " is " + Volumes[1][0]);
                }
    
            }
    Please let me know if I can assist any further.
    Last edited by NinjaTrader_ChrisL; 04-08-2019, 10:42 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    639 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X