Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SUM of Volumes with a condition by period

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

    #46
    Hello Marom,

    Thanks for your note.

    Since we are detecting if there is a new bar by using IsFirstTickOfBar and are accessing the previous value in myPrimarySeriesTickCounter, we could add a print that prints out the previous time (Time[1]).

    For example, if we add a print for Time[1] and we run the script on a 1-Minute chart, we could see a print that looks something like this

    myPrimarySeriesTickCounter[1] count is 207 Time: 3/6/2023 2:58:00 PM
    Period is 207
    myPrimarySeriesTickCounter[1] count is 102 Time: 3/6/2023 2:59:00 PM
    Period is 102


    The 2:58 PM candle will hold the number of ticks that occurred from 2:57 to 2:58 when the script is run on a 1-Minute chart. We see a print output of 207 for the count of myPrimarySeriesTickCounter[1]. This means that there were 207 ticks that occurred from 2:57 PM to 2:58 PM.

    We can see there is a count of 102 from 2:58 PM to 2:59 PM in the prints above.

    Time: https://ninjatrader.com/support/help...eries_time.htm

    Please let me know if I may assist further.​
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #47
      Hello Brandon,

      Thank you for your response.

      I know what I'm see, I asked how can I synchronize between the counter times (Period) to mySeries times.
      As you could see below (please find the screenshot attached), I added Print(mySeries[0]), and in the output window for example, at 14:23 was series with 9 volumes while in Period was only 3.
      So this cause to the SUM calculate to plot a wrong result, and I would be happy if you could advise how to synchronize so that number of the ticks (Period value) will be identical to the number of the values that contained in mySeries, at a given time.


      Attached below the script and txt file.

      Please your advise.

      Thank you,

      Marom​
      Attached Files
      Last edited by marommos; 03-09-2023, 07:33 AM.

      Comment


        #48
        Hello Marom,

        Thanks for the clarification.

        In the code you shared on post # 43, you are syncing 'mySeries' to BarsArray[1]. If you would like 'myPrimarySeriesTickCounter' to be synced to the same bar object as 'mySeries', you would need to also sync 'myPrimarySeriesTickCounter' to BarsArray[1].

        else if (State == State.DataLoaded)
        {
        mySeries = new Series<double>(BarsArray[1]);
        volvalue = new Series<double>(BarsArray[1]);
        myPrimarySeriesTickCounter = new Series<int>(BarsArray[1]);
        }

        This will mean that both 'mySeries' and 'myPrimarySeriesTickCounter' are synched to the same bar object (the first added data series in the script). An example of this could be seen on the help guide page linked below.

        Series<T>: https://ninjatrader.com/support/help...t8/seriest.htm

        Please let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #49
          Hello Brandon,

          I created a new variables series with BarsArray[1]​ and after that I connected it to myPrimarySeriesTickCounter​.
          Now the script works very good. thank you very much. you helped me a lot

          Marom

          Last edited by marommos; 03-12-2023, 02:19 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X