• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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?
    Patrick H.NinjaTrader Customer Service

    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.
        Patrick H.NinjaTrader Customer Service

        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.
            Patrick H.NinjaTrader Customer Service

            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 kattiehowe, Today, 09:01 AM
                1 response
                19 views
                0 likes
                Last Post MojoJojo  
                Started by kylef, Today, 11:36 AM
                1 response
                16 views
                0 likes
                Last Post kylef
                by kylef
                 
                Started by dafty, Today, 10:44 AM
                0 responses
                17 views
                0 likes
                Last Post dafty
                by dafty
                 
                Started by shs232, Today, 10:02 AM
                0 responses
                8 views
                0 likes
                Last Post shs232
                by shs232
                 
                Started by cary1267, Today, 09:37 AM
                0 responses
                8 views
                0 likes
                Last Post cary1267  
                Working...
                X