Announcement

Collapse
No announcement yet.

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.

    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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          89 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          135 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          68 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          119 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          69 views
          0 likes
          Last Post PaulMohn  
          Working...
          X