Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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.

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by knowmad, Yesterday, 03:52 AM
        5 responses
        46 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by ETFVoyageur, Yesterday, 07:05 PM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geotrades1, Today, 07:54 AM
        2 responses
        6 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by prisonbreaker82, 02-24-2024, 11:16 AM
        2 responses
        35 views
        0 likes
        Last Post proptradingshop  
        Started by MGHORBEL, Today, 06:25 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X