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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      78 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X