Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT 8 ChartControl object error in Strategy Analyzer...

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

    NT 8 ChartControl object error in Strategy Analyzer...

    I'm getting this error whence running the Strategy Analyzer *only*:

    Code:
    Strategy 'SysV4': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object.
    Running the strategy otherwise works fine, *only when doing backtesting in Strategy Analyzer* do I get this message.

    Here's my code which on a UniRenko chart, is grabbing the *reversal* value:

    Code:
    protected override void OnBarUpdate()
    {
    			if (CurrentBar < BarsRequiredToTrade)
    				return;
                           double reversal = (ChartControl.BarsPeriod.Value2 * TickSize) * 100;
    }

    #2
    Hello funk101,

    Thank you for writing in.

    You'll want to use just BarsPeriod rather than ChartControl.BarsPeriod: http://ninjatrader.com/support/helpG...barsperiod.htm

    The reason for that error is due to ChartControl being null during the backtest. You can check for this with a simple test here:
    Code:
    if (ChartControl == null)
         Print("ChartControl is null " + Time[0]);
    else
         Print("ChartControl is not null " + Time[0]);
    ChartControl remains null on every call of OnBarUpdate() during the backtest.

    Using just BarsPeriod, and not grabbing BarsPeriod from ChartControl, will get around this.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks, that did it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      672 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X