Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get Volume of current Day

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

    Get Volume of current Day

    Hello,

    I'm trying to develop an indicator that use volume of the current day but when i use VOL(indicator), GetVolume function or Volumes(series) with a daily series i get the volume of prior day but not current day.

    Can anyone help me ?

    Example:

    AddDataSeries(Data.BarsPeriodType.Day, 1);
    ....

    Print("VOL - Current: " + VOL(BarsArray[0])[CurrentBars[0]]);
    Print("VOL - Daily: " + VOL(BarsArray[1])[CurrentBars[1]]);
    Print("GET - Current: " + BarsArray[0].GetVolume(CurrentBars[0]));
    Print("GET - Daily: " + BarsArray[1].GetVolume(CurrentBars[1]));
    Print("VOLUMES - Current: " + Volumes[0][CurrentBars[0]]);
    Print("VOLUMES - Daily: " + Volumes[1][CurrentBars[1]]);

    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    #2
    I didn't notice it but I need to get Weekly and Monthly volume too
    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    Comment


      #3
      Hi johnok,
      On a historical data set, you only have OHLC Vol and Time, but cannot the view "into" the bar. To "kind of" look into a bar (e.g. daily), you can use/add another data series with more granularity (e.g. 1 min) and capture cumulated volume (or whatever) of that more granular series while the bigger bar is still forming.
      Watch-Out: If you use the StrategyBuilder, the drum beat of OnBarUpdate always refers to the primary series. With StrategyBuilder, you therefore have to use the bar with the highest granularity (e.g. 1min) as primary and add a bar with a higher time frame (e.g. daily) as secondary. Then, use the smallest series as drum beat and CumVol logger. You can still refer to your Daily bars for other indicators and conditions if so desired.
      Here is how this can be accomplished:
      1) Add a custom series CumVol (double),
      2a) Check in one "Set" if you have a new day (Date series 0 of Default input is not equal to Date series 1 of Default input).
      3a) If Yes, set CumVol[0] to the Vol of the current bar (primary series),
      2b) Check in another "Set" that you do not have new day (Date series 0 of Default input is equal to Date series 1 of Default input).
      3b) If Yes, set CumVol[0] to CumVol[1] + Vol of current bar (primary series).
      4) Consider to add "Prints" to your sets with DateTime and CumVol to check the logic.
      The same concept can be used for weekly or monthly CumVol (or whatever) while these bars are forming.
      With NinjaScript, you have more flexibility what to use as primary and secondary, but you would still need to refer to OnBarUpdate of the smaller series, if you want to "kind of" look into the bigger bar.
      NT-Roland

      Comment


        #4
        Hello johnok,

        Thanks for your post.

        To get the current day/week/month volume, you would need to add the supporting data series AND set your indicators Calculate setting to Calculate.OnEachTick or Calculate.OnPriceChange.

        When using Calculate.OnBarClose in a multi series script, the bars ago index of [0] points to the "Just closed" bar, in each data series. Calculate.OnEachTick or Calculate.OnPriceChange will shift the bars ago index of [0] to the currently forming bar and [1] would then point to the just closed bar. In your case of today's volume you want to value of the currently forming bar.

        This is well documented in the section: https://ninjatrader.com/support/help...nstruments.htm and is diagrammatically shown here: https://ninjatrader.com/support/help...taIsReferenced





        Comment


          #5
          I tested both and all works !

          Thanks to you !

          Have i nice day !
          johnok
          NinjaTrader Ecosystem Vendor - Trade With Me

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          628 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          359 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          562 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X