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

IntraDay Cumulated Volume

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

    IntraDay Cumulated Volume

    I'm writing an indicator whose main target is comparing volumes and price ranges. Time Frame= 1 Minute

    I need an reliable method to get cumulated volumes but i get diferent results in diferent scenaries.
    I'm trying this three methods:
    1. Volume[0] from Added period type.Day
    2. Volume[0] "last" from default dataseries
    3. Volume[0] from default dataseries when data is historical plus e.Volume from "OnMarketData" when online

    I guess method 1 is the correct but not my favorite even i don't know if is suitable for price ranges. .

    I'd like to know where diferences are because i'm always using Method 2 and probably is a wrong practice.

    Code:
    protected override void Initialize()
          {
                 Add(PeriodType.Day,1);
                CalculateOnBarClose=false;
    }
    protected override void OnBarUpdate()
            {
            if (CurrentBars[1] < 1)
                return;
            if (Bars.FirstBarOfSession && FirstTickOfBar)
                    {
                    volume1 = 0;
                    volume2 = 0;
                    volume3 = 0;
                    sToday = Time[0].Date.ToString("dd/MM/yyyy");
                    }
                
             if (Historical)
                    volume3 = Volumes[0][0];
                
             volume1 = Volumes[1][0];
             volume2 += Volumes[0][0];
                
            }
            protected override void OnMarketData(MarketDataEventArgs e)
                {
                base.OnMarketData(e);
                if (e.MarketDataType == MarketDataType.Last)
                    volume3 += e.Volume;
                }
    Example attached.
    Attached Files

    #2
    Hello Ramon,

    Thank you for your post.

    For the volume of the session, your volume2 method is the way I would go as well. Are you finding that this is wrong at the end of the day? How are you determining this/what value are you comparing against?

    Comment


      #3
      Exec1: Capture after a several minutes of execution. datas are diferent.

      exec2: Same chart, and session after a reload ninjascript.

      All data changes, and reduce its value. Data on method 2 and method 3 are equal.

      When the data is good ?. Before the reload with online data? Or after the reload with historical data.?
      Attached Files

      Comment


        #4
        Hello Ramon,

        Thank you for your response.

        On reload of NinjaScript you would reload the historical data as well, this would provide historical volume from the provider where you were previously storing the real-time volume.

        Comment


          #5
          So ...the best way is to cumulate Volume [0] within OnBarUpdate. isn't it?

          Comment


            #6
            Hello Ramon,

            That would be correct for the volume update per bar.

            Comment


              #7
              Hi,Here again.
              I Have an indicator that calculates volumes by price
              Initially I took the price and volume data from Close [0] Volume [0] respectively but leaves an overly large volume.
              I have found that Volume [0] does not provide the last tick volume but contains the accumulated for the bar.
              For example:
              Tick 1 Volume 2
              Tick 2 Volume 4
              Tick 3 Volume 1
              Volume[0] Will show 2,6 and finally 7 that correspond with total of the bar.
              I'm not interested in volumes per bar but volumes by price.
              So, how I can get in "OnBarUpdate" price data volume for the last tick?
              Necessarily I have to do it from "OnMarketData"?

              This would complicate things for me .All the logic of the indicator is into OnBarUpdate and would have two separate, and manage both.
              Thank you.

              Comment


                #8
                Hello Ramon,

                Yes, this information would need to be collected in OnMarketData (if you are wanting Level I volume) or OnMarketDepth (if you are wanting Level II volume).

                Attached I am providing examples I have made previously to capture level I volume events.

                For level II, below I am adding a link to a reference sample of a level II order book.
                http://www.ninjatrader.com/support/f...ead.php?t=3478

                (Update Sept 13th, 2018: removed the condition that prevents the text if the volume is lower than the BlockSize)
                Attached Files
                Last edited by NinjaTrader_ChelseaB; 09-13-2018, 02:47 PM.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NRITV, Today, 01:15 PM
                2 responses
                6 views
                0 likes
                Last Post NRITV
                by NRITV
                 
                Started by frankthearm, Today, 09:08 AM
                7 responses
                30 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by maybeimnotrader, Yesterday, 05:46 PM
                5 responses
                25 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by quantismo, Yesterday, 05:13 PM
                2 responses
                18 views
                0 likes
                Last Post quantismo  
                Started by adeelshahzad, Today, 03:54 AM
                5 responses
                33 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X