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

Cumulative Delta vs Buy Sell Volume

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

    Cumulative Delta vs Buy Sell Volume

    I'm comparing the NT supplied indicators:

    1. Order Flow Cumulative Delta (Bid Ask) set to display Period Bar rather than Session so that I can see the net volume (hitting at or above the ask minus that which is hitting at or below the bid ).
    2. Buy sell volume

    The Buy sell volume indicator is plotting to things:
    1. the total volume transacting at or above the ask. plotted as "Buys"
    2. the total volume transacting at or below the bid. plotted as "Sells"

    I'm expecting that subtracting sells from buys would produce the same delta value that's being plotted by the Order Flow Cumulative delta as I have it configured. But that's not what I'm seeing. The values are different.
    For example see this screenshot:
    Click image for larger version  Name:	CummulativeDelta vs Buy Sell Volume.png Views:	0 Size:	111.8 KB ID:	1261421

    Here we see Order Flow's Delta Close plotting 14.
    Buy sell volume is plotting buys 248, sells 117. The math: 248 - 117 = 131

    EDIT: I was expecting the result to be 14 to match Delta Close plotting. Also I just noticed that the Volume for the bar is also 248. I would expect the sum of the Buys and Sells to equal 248.

    The code for Buy sell volume is:

    Code:
    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if(e.MarketDataType == MarketDataType.Last)
    {
    if(e.Price >= e.Ask)
    buys += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
    else if (e.Price <= e.Bid)
    sells += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
    }
    }
    ​
    How can this code be changed to produce the same values plotted by Delta Close?
    Last edited by Brillo; 07-21-2023, 03:27 PM. Reason: See my EDIT in bold for additional comments.

    #2
    Hello Brillo,

    May I confirm you have the Cumulative Delta - Period set to Bar, and the Delta type set to BidAsk?

    The Cumulative Delta does process differently than the BuySellVolume. The BuySellVolume is driven by market updates in OnMarketData, while the Cumulative Delta is driven by ticks updating OnBarUpdate. Market updates can different from Ask/Bid stamped Ticks. There also can be slight differences when ticks are received with the same timestamp.

    This example provided by Jim has some general details on how this indicator builds.
    Hi, i'm trying to build my first strategy. I want to use the values of the BuySellVolume indicator, but it seems like the DataSeries from the indicator are empty. No trade entry happens with this strategy.... The code looks like this: namespace NinjaTrader.NinjaScript.Strategies { public class DeltaRatioKursDivergenz :
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mishhh, 05-25-2010, 08:54 AM
    19 responses
    6,189 views
    0 likes
    Last Post rene69851  
    Started by gwenael, Today, 09:29 AM
    0 responses
    4 views
    0 likes
    Last Post gwenael
    by gwenael
     
    Started by Karado58, 11-26-2012, 02:57 PM
    8 responses
    14,830 views
    0 likes
    Last Post Option Whisperer  
    Started by Option Whisperer, Today, 09:05 AM
    0 responses
    2 views
    0 likes
    Last Post Option Whisperer  
    Started by cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Working...
    X