Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detecting same BarsPeriodType and Value

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

    Detecting same BarsPeriodType and Value

    I was planing to AddDataSeries(BarsPeriodType.Tick, 500);

    However, I noticed that, if my chart is already BarsPeriodType == Tick and value == 500, it still run the AddDataSeries.

    Is that anyway to detect it and thus not adding the AddDataSeries(BarsPeriodType.Tick, 500); when my chart is already same BarsPeriodType and value same.

    #2
    Hello cincai,

    Thank you for writing in.

    In most cases, we could retrieve information on the primary data series from State.Configure using BarsPeriod, but this is not fully supported. (Optimizations are one place where accessing data from State.Configure would not be able to load information on primary data series)

    That being said, you could use BarsPeriod.BarsPeriodType and BarsPeriod.Value to get the BarsPeriod type and value within your script.

    Also, something you could do is write the logic in your script to ignore BarsInProgress 0 within the OnBarUpdate() method. To do so, the code would look something like this.

    if (BarsInProgress == 0)
    return;

    See the help guide documentation below for more information.
    BarsPeriod - https://ninjatrader.com/support/help...barsperiod.htm
    BarsInProgress - https://ninjatrader.com/support/help...inprogress.htm

    Let us know if we 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
    601 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    347 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    559 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    558 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X