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 argusthome, Yesterday, 10:06 AM
      0 responses
      18 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      17 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      9 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      38 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X