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

Strategy working fine on Charts but error on Strategy Analyzer

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

    Strategy working fine on Charts but error on Strategy Analyzer

    I've an strategy that it seems working fine in chart but when I try to backtest in Strategy Analyzer crashes and it doesn't show anything.

    On output shows the next:

    12/02/2024 18:56:00: OnOrderUpdate. orderId='NT-00000-1699' account='Backtest' name='MyBuyMar****rder' orderState=Submitted instrument='NQ 03-24' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-12 18:56:00' gtd='2099-12-01' statementDate='2024-02-20' error: NoError
    12/02/2024 18:56:00: OnOrderUpdate. orderId='NT-00000-1699' account='Backtest' name='MyBuyMar****rder' orderState=Accepted instrument='NQ 03-24' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-12 18:56:00' gtd='2099-12-01' statementDate='2024-02-20' error: NoError
    12/02/2024 18:56:00: OnOrderUpdate. orderId='NT-00000-1699' account='Backtest' name='MyBuyMar****rder' orderState=Working instrument='NQ 03-24' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-12 18:56:00' gtd='2099-12-01' statementDate='2024-02-20' error: NoError
    12/02/2024 18:56:00: OnOrderUpdate. orderId='NT-00000-1699' account='Backtest' name='MyBuyMar****rder' orderState=Filled instrument='NQ 03-24' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=1 averageFillPrice=18099 onBehalfOf='' id=-1 time='2024-02-12 18:56:00' gtd='2099-12-01' statementDate='2024-02-20' error: NoError
    Strategy 'Strategy/-1': Error on calling 'OnOrderUpdate' method on bar 567: Object reference not set to an instance of an object.


    It seems the problem is inside OnOrderUpdate​ method, what i should check or look? I can't see the exact line where the error is throwing.

    #2
    Hello franjcy,
    Object reference not set to an instance of an object means some object you used was null. One example would be Order variable that you are using inside OnOrderUpdate​.

    To find the specific line having an error you can add prints between each line of your OnOrderUpdate code and then look to see what the last print before the error was, the next line would be the line having the error.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello franjcy,
      Object reference not set to an instance of an object means some object you used was null. One example would be Order variable that you are using inside OnOrderUpdate​.

      To find the specific line having an error you can add prints between each line of your OnOrderUpdate code and then look to see what the last print before the error was, the next line would be the line having the error.
      I think I found the line that triggers error.

      I'm using "ChartBars.Bars.Count" and it seems in Strategy Analyzer is null? If so, how can i do to get the total of bars at that moment ?

      Comment


        #4
        Originally posted by franjcy View Post
        how can i do to get the total of bars at that moment ?
        Isn't that just CurrentBar?

        Comment


          #5
          Originally posted by bltdavid View Post

          Isn't that just CurrentBar?
          Uff, absolutely correct, sometimes I forget such simple things.

          Thanks to all, all have been fixed.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by JoMoon2024, Today, 06:56 AM
          0 responses
          6 views
          0 likes
          Last Post JoMoon2024  
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          17 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          5 views
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,786 views
          0 likes
          Last Post Leafcutter  
          Started by poplagelu, Today, 05:00 AM
          0 responses
          3 views
          0 likes
          Last Post poplagelu  
          Working...
          X