Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unhandled exception: Object reference not set to an instance of an object

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

    Unhandled exception: Object reference not set to an instance of an object

    Hi,

    After editing my properties I keep receiving the error:
    Unhandled exception: Object reference not set to an instance of an object.
    Visual Studio debugger does get the error even before reaching the first breakpoint, just on the call to OnChange().

    To find out some more, I did try to call the indicator from Strategy Builder, and I get the error:
    'NinjaTrader.Gui.Stroke' is a 'type', which is not valid in the given context
    Below are the The Strategy Builder call to my indicator.

    Also attach is a fresh and short trace file, which only opens NT8 and trying to load the indicator to a chart.

    I believe this is what get called in that early stage of Indicator loading by interface.

    Your help is much appreciated 111

    Thanks, Shai

    The call to my indicator that the Strategy Builder creates is:
    Code:
    else if (State == State.DataLoaded)
    
    {
    
    MyIndicator1 = MyIndicator(Close, 4, 14, true, 2, DistanceType.None, 0.5, DistanceType.None, 1, 0, 2000, true, true, DistanceType.ATR, 1, 0, true, false, DistanceType.ATR, 1, 0, true, NinjaTrader.Gui.Stroke, NinjaTrader.Gui.Stroke, true, NinjaTrader.Gui.Stroke, NinjaTrader.Gui.Stroke, false, Brushes.Yellow, false, Brushes.WhiteSmoke, 10, Brushes.Green, Brushes.Red, SignalMarkTyps.LineSolidBold2, SignalMarkTyps.LineDashed, true, true, 10);
    
    }
    Last edited by Shai Samuel; 05-27-2022, 10:08 AM.

    #2
    Hello Shai Samuel,

    The error message you are seeing means an object was null. That is a general C# error, it sounds like you found that it was in OnStateChange so you would need to confirm that by not using visual studio and check that the platform also reports the same error. If so you can check the objects used in OnStateChange to see what may ne null.

    The other error mentions Stroke as the type in error. The builder supports brushes so you can make those non NinjaScript properties by removing the [NinjaScriptProperty] which will remove them from the indicators input string.

    Comment


      #3
      Thank you Jesse.

      The issue wasn't OnStateChange, it was the [NinjaScriptProperty] tags that I had over the visual properties. Once I remove all of them, everything works great.

      One more question, on the same subject of properties, if I may:
      • My Signal plot can be {2,1,0,-1,-2} and it's with the other Plots Price1, Price2, which shows price information. I avoid the scale on the chart overriding the OnCalculateMinMax().
      • I am trying to use my indicator with BloodHound. BloodHound reads my Signal, but sometime ignore it or add fake ones. On the other had, the "Data Box" shows my signals are correct. Do you think there might be any issue with my plots
      Here is a list of my plots:

      Code:
      [Browsable(false)][XmlIgnore] public Series<double> Structure { get { return Values[plotStructure]; } }
      [Browsable(false)][XmlIgnore] public Series<double> Signal { get { return Values[plotSignal]; } }
      [Browsable(false)][XmlIgnore] public Series<double> Price1 { get { return Values[plotPrice1]; } }
      [Browsable(false)][XmlIgnore] public Series<double> Price2 { get { return Values[plotPrice2]; } }
      Could you

      Comment


        #4
        Hello Shai Samuel,

        All I could really suggest on that item would be to make a simple strategy using the builder and see if that also misses signals. I don't know how bloodhound works to say if that is related or not.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        650 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        577 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X