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 rbeckmann05, Today, 06:48 PM
      0 responses
      2 views
      0 likes
      Last Post rbeckmann05  
      Started by rhyminkevin, Today, 04:58 PM
      4 responses
      52 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      7 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      14 views
      0 likes
      Last Post 00nevest  
      Working...
      X