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 Option Whisperer, Today, 09:55 AM
      1 response
      11 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      1 view
      0 likes
      Last Post port119
      by port119
       
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      3 views
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      2 views
      0 likes
      Last Post 00nevest  
      Started by Jonafare, 12-06-2012, 03:48 PM
      5 responses
      3,986 views
      0 likes
      Last Post rene69851  
      Working...
      X