Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Beta20 Bars.count giving wrong value

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

    Beta20 Bars.count giving wrong value

    To duplicate this, I have TF 09-10 5range loaded with 3 days.
    If I use a very simple test script
    ///////////////////////////////////////////////////////////
    protected override void Initialize() {
    CalculateOnBarClose = false;
    Add(PeriodType.Range, 10);
    }
    protected override void OnBarUpdate(){}
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max){
    Print("total bar count= "+Bars.Count);
    }
    ////////////////////////////////////////////////////////////////
    Total bar count displayed will be from 10range data, not the 5range chart.
    Is this the way it's supposed to be? How do I get it to give me total bar count of chart drawn?

    If I put this print statement in the OnBarUpdate instead, it will print out two
    total bar count values for both 5R and 10R. Not sure if this is correct either.

    -Alex

    #2
    AlexJetski, please ensure you are checking this property from within the correct BarsInProgress index.
    Code:
    Initailize()
    {
       Add(10 range);
    }
    OnBarUpdate()
    {
       if (BarsInProgress == 0)
          Print("total bars for primary series (5 range): " + Bars.Count);
       else if (BarsInProgress == 0)
          Print("total bars for secondary series (10 range): " + Bars.Count);
    Another option would be to use BarsArray[n] and access the values there:
    Code:
    OnBarUpdate()
    {
       Print("count for primary bars: " + BarsArray[0].Count);
       Print("count for secondary bars: " + BarsArray[1].Count);
    }
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks. Much appreciated. The clears up my issues.

      cheers

      Comment

      Latest Posts

      Collapse

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