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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      45 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      30 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      99 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      177 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      170 views
      0 likes
      Last Post CarlTrading  
      Working...
      X