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

Getting "Indicator 'VPA': Error on calling 'OnBarUpdate' method on bar 20 -

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

    Getting "Indicator 'VPA': Error on calling 'OnBarUpdate' method on bar 20 -

    I added a few divergence plots, added my interpretations of bag holding and end of a rising market plots, it compiles ok and exports ok but I am getting errors when applying to charts : "Indicator 'VPA': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object". I am not a coder I had a freelancer add plots for use in Market Analyzer to VPA a couple of years ago and have been adding plots like he did. I was hoping you guys could check out the code now and expain how to fix the error if possible? The export is attached and the plots I added are listed below. Wanting to submit to User Share once error fixed .
    Thanks

    AddPlot(Brushes.Transparent, "demandTestBar_");
    AddPlot(Brushes.Transparent, "demandTestInDownTrendBar_");
    AddPlot(Brushes.Transparent, "successfulDemandTestBar_");
    AddPlot(Brushes.Transparent, "RSIPosDvg_");
    AddPlot(Brushes.Transparent, "RSINegDvg_");
    AddPlot(Brushes.Transparent, "MACDPosDvg_");
    AddPlot(Brushes.Transparent, "MACDNegDvg_");
    AddPlot(Brushes.Transparent, "StochPosDvg_");
    AddPlot(Brushes.Transparent, "StochNegDvg_");
    AddPlot(Brushes.Transparent, "EndOfRisingMarket_");
    AddPlot(Brushes.Transparent, "EndOfRisingMarketCondOne_");
    AddPlot(Brushes.Transparent, "BagHolding_");
    AddPlot(Brushes.Transparent, "BagHoldingConditionOne_");
    AddPlot(Brushes.Transparent, "RangeIncrease_");
    AddPlot(Brushes.Transparent, "RangeDecrease_");
    Attached Files

    #2
    Hello Tradarr,

    Thanks for your post.

    We will not be able to debug and correct the script for you, but we would be happy to advise on how you can take debugging steps to identify the problematic part of code and how to resolve the issue once it is identified.
    1. The first step is reproducing the issue. It looks like you can easily reproduce the issue just by adding the indicator to the chart
    2. The next step is to add debugging prints throughout the OnBarUpdate method, and any methods called from OnBarUpdate, so that when you reproduce the issue, you can identify the specific part of code that throws the error
    3. After the part of code is identified it would then be examined to see how it would encounter that error. For example, "Object reference not set to an instance of an object" would mean an object on the line of code that throws the error is null when it is referenced. You could add conditions above the line of code to see which object is null. I.E: if (ThisObject == null) Print("ThisObject is null");
    4. Once the specific object that is null is identified, a correction would then need to be devised. I.E:
      1. Is it ok for this object to be null and should the code skip the reference if the object is null? (You can check if (ThisObject != null) { } to make sure the object is not null when it is referenced.)
      2. Should the object not be null when the code references it? In this case, further debugging steps would need to be taken to see when the object gets assigned to make sure it is assigned and not null when it should be.
    Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

    If the process is too difficult, you could consider enlisting the services of a NinjaScript Consultant to debug the script and make these changes for you.

    Let us know if you have any questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by Tradarr View Post
      "Indicator 'VPA': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object".
      Code:
       demandTestBar = new Series<bool>(this); // is missing


      -=Edge=-
      NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

      Comment


        #4
        Originally posted by -=Edge=- View Post

        Code:
         demandTestBar = new Series<bool>(this); // is missing

        Thank You Very Much!

        Comment


          #5
          hi tradar! With the contribution here if you managed to correct the issue of the debugging and if you graph the divergences. Maybe you can share it to test it, I have been following the topic since I wanted to improve the layout of the original vpa.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Learner Trader, Today, 01:49 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by alcorr247, Yesterday, 09:53 PM
          1 response
          37 views
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by traderslab, Yesterday, 10:27 PM
          0 responses
          36 views
          0 likes
          Last Post traderslab  
          Started by jjanguda, Yesterday, 09:40 PM
          1 response
          41 views
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by jeronymite, Yesterday, 07:15 PM
          0 responses
          60 views
          0 likes
          Last Post jeronymite  
          Working...
          X