Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Instance not set

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

    Instance not set

    My strategy keeps disabling itself,, must have to do something else?

    here is the snippet of the indicator properties

    [Browsable(false)]
    public BoolSeries Trend
    {
    get { return trend; }
    }



    here is the snippet of the strategy
    if (FluxTrendStalker(14, FluxTrendStalker_MAType.SMA, 2.618, 14, FluxTrendStalker_Mode.Adaptive).Trend[0]);

    here is what the output window says
    .**NT** Error on calling 'OnBarUpdate' method for strategy 'TrendStalkerCL/87768cd084174f3199d8a2e24d32d64f': Object reference not set to an instance of an object.

    #2
    Hi gg80108,

    I don't think the error is being caused by the code you have posted.

    Typically, this error comes when you try and access something that is null.

    May we have the full script? (You can send this to platformsupport [at] ninjatrader [dot] com, if you would like to keep the script private. Just add a link to this thread of you choose to do this.)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I created this with the wizard to begin with then opened the code.

      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Strategy;
      #endregion

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Enter the description of your strategy here
      /// </summary>
      [Description("Enter the description of your strategy here")]
      public class TrendStalkerCL : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      private bool trend = false;
      #endregion

      /// <summary>
      /// This method is used to configure the strategy and is called once before any strategy method is called.
      /// </summary>
      protected override void Initialize()
      {

      CalculateOnBarClose = true;

      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {

      // Condition set 1
      if (FluxTrendStalker(14, FluxTrendStalker_MAType.SMA, 2.618, 14, FluxTrendStalker_Mode.Adaptive).Trend[0]);
      {
      // ExitShort("", "");
      // EnterLong(DefaultQuantity, "");
      // DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
      }

      // Condition set 2
      // if (FluxTrendStalker(14, FluxTrendStalker_MAType.SMA, 2.618, 14, FluxTrendStalker_Mode.Adaptive).Trend[0] )
      {
      // DrawArrowDown("My down arrow" + CurrentBar, false, 0, 0, Color.Red);
      // ExitLong("", "");
      // EnterShort(DefaultQuantity, "");
      }
      }

      #region Properties
      [Description("")]
      [GridCategory("Parameters")]
      public int MyInput0
      {
      get { return myInput0; }
      set { myInput0 = Math.Max(1, value); }
      }
      #endregion
      }
      }
      Attached Files

      Comment


        #4
        Hi gg80108,

        I need the referenced indicator as well.

        May I have this as an export?

        To export your script do the following:

        1. Click File -> Utilities -> Export NinjaScript
        2. Enter a unique name for the file in the value for 'File name:'
        3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
        4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message

        By default your exported file will be in the following location:

        * (My) Documents/NinjaTrader 7/bin/Custom/ExportNinjaScript/<export_file_name.zip>


        Below is a link to the help guide on Exporting NinjaScripts.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Attached the export zip
          Attached Files
          Last edited by gg80108; 07-19-2014, 10:59 AM.

          Comment


            #6
            Hi gg80108,

            In the indicator you are syncing the trend private bool series in OnStartUp().
            This has to be done in Initialize().

            Make this change and the error will stop.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by yertle, Yesterday, 08:38 AM
            7 responses
            28 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by bmartz, 03-12-2024, 06:12 AM
            2 responses
            21 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by funk10101, Today, 12:02 AM
            0 responses
            4 views
            0 likes
            Last Post funk10101  
            Started by gravdigaz6, Yesterday, 11:40 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by MarianApalaghiei, Yesterday, 10:49 PM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X