Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsFirstTickOfBar and Series<T> Problem

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

    IsFirstTickOfBar and Series<T> Problem

    Hi, i have the problem that with fast market movements like news etc. my Series<T> are not taken over from one bar to the next. Can it be that e.g. with range bars no ticks are in a bar, and it therefore comes to problems?
    Code:
    if (IsFirstTickOfBar)
    {
       myDataSerie[0] = myDataSerie[1];
    }
    I take the values from the previous bar at the first tick of each new bar and use them to form my series. It happens that with fast moves (news), my series restarts because there is no data in the previous bar. How can I solve this most effectively, anyone has an idea?
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Maybe try this,

    Code:
    if (IsFirstTickOfBar)
    {
        myDataSerie[0] = Volume[1] > 0 ? myDataSerie[1] : 0;
    }​
    The idea is, if the previous bar has volume > 0, then presumably
    you have a valid value in your myDataSeries[1] -- otherwise there
    is zero volume in the previous bar and you use zero.

    Comment


      #3
      Hello sidlercom80,

      Thanks for your post.

      bltdavid is correct. You could create a condition checking if the volume of the previous bar (Volume[1]) is greater than 0. Then, you could assign myDataSeres[1] to myDataSeries[0].

      See this help guide page for more information about Volume[]: https://ninjatrader.com/support/help...ies_volume.htm

      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


        #4
        Originally posted by bltdavid View Post
        Maybe try this,

        Code:
        if (IsFirstTickOfBar)
        {
        myDataSerie[0] = Volume[1] > 0 ? myDataSerie[1] : 0;
        }​
        The idea is, if the previous bar has volume > 0, then presumably
        you have a valid value in your myDataSeries[1] -- otherwise there
        is zero volume in the previous bar and you use zero.
        Hi bltdavid and BrandonH, thanks for your posts. I can not use a value of 0, because otherwise my series would be interrupted and thus unusable. If I checked e.g. at the previous bar for volume and there is no volume, I would have to go back one bar further and check there for volume....To stay with your example with the volume, I add the volume bar by bar. So if now in a bar no volume is present, because no data is available, I can not use 0 for the next bar, because then the new bar would start again with a volume of 0.

        I would have to use something like this:
        Code:
        if (IsFirstTickOfBar)
        {
           myDataSerie[0] = Volume[1] > 0 ? myDataSerie[1] : myDataSerie[2];
        }
        The question is, is there a better way to do this?
        sidlercom80
        NinjaTrader Ecosystem Vendor - Sidi Trading

        Comment


          #5
          Hello sidlercom80,

          Thanks for your note.

          This would be the best way to go about accomplishing your goal. You would check if the previous bar's Volume[1] is greater than 0 and set your myDataSerie variable.

          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

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 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
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X