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

Volume for each tick and candle

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

    Volume for each tick and candle

    Hi All!
    I want to count the number of Bid and Ask ticks and volume for each candle. But something is not correct.
    If I have a 30 tick candle, I think i would have AskTick + BidTick = 30, correct?
    What am I missing?
    Thanks in advance.
    Morris

    int AskTick = 0;
    int BidTick = 0;
    long AskVol = 0;
    long BidVol = 0;

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    // Print some data to the Output window
    if (e.MarketDataType == MarketDataType.Last) {
    // Totals for each candle
    Print(e.Time + " Last = " + e.Price + ", Vol = " + e.Volume);
    Print("Ask " + AskTick + " " + AskVol);
    AskTick=0;
    AskVol=0;
    Print("Bid " + BidTick + " " + BidVol);
    BidTick=0;
    BidVol=0;
    }
    else if (e.MarketDataType == MarketDataType.Ask) {
    AskTick++;
    AskVol+= e.Volume;
    Print(e.Time + " Ask = " + e.Price + ", Vol = " + e.Volume); // For each Ask tick
    }
    else if (e.MarketDataType == MarketDataType.Bid) {
    BidTick++;
    BidVol+= e.Volume;
    Print(e.Time + " Bid = " + e.Price + ", Vol = " + e.Volume); // For each Bid tick
    }
    }


    Example of my results:
    5/4/2022 12:37:31 AM Ask = 4174.5, Vol = 4
    5/4/2022 12:37:31 AM Bid = 4174.25, Vol = 10
    ========================= Is First Tick
    5/4/2022 12:37:31 AM 35
    ========================= Is First Tick
    Ask 157 1090
    Bid 157 988
    5/4/2022 12:37:31 AM Last = 4174.5, Vol = 2
    ========================= Is First Tick
    Ask 0 0
    Bid 0 0
    5/4/2022 12:37:31 AM Last = 4174.5, Vol = 1
    5/4/2022 12:37:31 AM Ask = 4174.75, Vol = 15
    5/4/2022 12:37:31 AM Ask = 4174.75, Vol = 14
    5/4/2022 12:37:31 AM Ask = 4174.75, Vol = 13


    #2
    I tiurned on the BuySellVolume indicator and set the bar size to 30 ticks. I am observing some nice extremes which will help me better understand what is going on with volume.
    The bar produced is Green (Buy) stacked on top of Red (Sell)

    What must change so that I can see the Buy and Sell bars displayed side by side instead of stacked?



    Click image for larger version

Name:	TikykTiky.png
Views:	414
Size:	529.1 KB
ID:	1199938

    Comment


      #3
      Hello morrnel,

      What you are seeing is correct, not every order is 1 volume. For a 30 tick chart you should see 30 ticks but the volume will vary a lot between bars.

      The buysellvolume indicator is generally how we suggest to make a script that accumulates volume.

      If you wanted to display the volume in a different way you would need to use OnRender or Plots to do that.
      JesseNinjaTrader Customer Service

      Comment


        #4
        buy sell volume indicator
        See the missing bars to the left? What do I need to change so that all the bars are filled when I open ?
        Thanks.

        Click image for larger version

Name:	TikykTiky2.png
Views:	363
Size:	444.8 KB
ID:	1199955

        Comment


          #5
          Hello morrnel,

          That is correct, the BuySellVolume is a realtime indicator. You can turn on tick replay for it to estimate the historical results, for it to actually calculate as it would in realtime it would need to be run in realtime or forward through playback.

          JesseNinjaTrader Customer Service

          Comment


            #6
            Kewl, thanks.

            Why didn't VOL need it?

            Comment


              #7
              Hello morrnel,

              The VOL indicator uses the Volume series which is based on historical data. The BuySellVolume uses OnMarketData which is not stored in historical data, by using TickReplay it can call OnMarketData historically.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Perr0Grande, Today, 08:16 PM
              0 responses
              2 views
              0 likes
              Last Post Perr0Grande  
              Started by elderan, Today, 08:03 PM
              0 responses
              5 views
              0 likes
              Last Post elderan
              by elderan
               
              Started by algospoke, Today, 06:40 PM
              0 responses
              10 views
              0 likes
              Last Post algospoke  
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              12 views
              0 likes
              Last Post maybeimnotrader  
              Started by quantismo, Today, 05:13 PM
              0 responses
              7 views
              0 likes
              Last Post quantismo  
              Working...
              X