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

NT silently fails with strategy

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

    NT silently fails with strategy

    I have a strategy that I am testing. Sometimes when I load it, it runs correctly, and sometimes not -- NT will simply disable the strategy. The indicators are not always displayed/calculated correctly when NT fails to load the strategy--they are displayed on the chart in various partial states.

    Based on debugging, it would appear that NT is failing after calling the Initialize() in the strategy, but never calls OnStartUp(). When I set breakpoints in Visual Studio at the last line in Initialize() and the first line of OnStartUp(), the breakpoint in OnStartUp() is never reached.

    I am running the strategy with market reply data. If I switch the date one or two times to test different time periods, NT will fail to load the strategy at any of those reloads. But it varies--I do not see any consistency to indicate when it will fail.

    There is nothing in the log to indicate an error of any type.

    Since this is occurring after the strategy's Initialize() and before OnStartUp(), I have no idea how to determine exactly where NT is failing.

    Using my own debug code, here is what I see when it works *correctly*:

    Code:
    In Initialize() for rfMTFMAStatus
    Strategy Intialize() complete
    **NT** Enabling NinjaScript strategy 'MTFMA Trading Strategy/bd5e003128124d2f9d792e088e553a5f' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=UniqueEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=False MaxRestarts=4 in 5 minutes
    In OnStartUp: MTFMA Strategy....
    In CreateHigherTimeFrameIndicators....
    Adding higher timeframe MA indicators: 150 Tick
    In OnStartUp: rfMovingAverage PPMA Fast (SMA-1)....
    In OnStartUp: rfMovingAverage PPMA Slow (SMA-3)....
    In OnStartUp: rfDualMovingAverage PPMA Dual MA: PPMA Fast (SMA-1) & PPMA Slow (SMA-3)....
    In OnStartUp: rfMovingAverage Trigger Fast (EMA-8)....
    In OnStartUp: rfMovingAverage Trigger Slow (SMA-13)....
    In OnStartUp: rfDualMovingAverage Trigger Dual MA: Trigger Fast (EMA-8) & Trigger Slow (SMA-13)....
    In OnStartUp: rfExpansionContraction....
    In OnStartUp: rfMovingAverage DMA1 (SMA-20)....
    In OnStartUp: rfMTFMAStatus
    When it does NOT work, here is what I see:

    Code:
    In Initialize() for rfMTFMAStatus
    Strategy Intialize() complete
    **NT** Enabling NinjaScript strategy 'MTFMA Trading Strategy/1dc6f2ee01c14f93b40b084500329641' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=UniqueEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=False MaxRestarts=4 in 5 minutes
    In OnStartUp: rfExpansionContraction....
    In OnStartUp: rfMovingAverage PPMA Fast (SMA-1)....
    In OnStartUp: rfMovingAverage PPMA Slow (SMA-3)....
    In OnStartUp: rfDualMovingAverage PPMA Dual MA: PPMA Fast (SMA-1) & PPMA Slow (SMA-3)....
    In OnStartUp: rfMovingAverage Trigger Fast (EMA-8)....
    In OnStartUp: rfMovingAverage Trigger Slow (SMA-13)....
    In OnStartUp: rfDualMovingAverage Trigger Dual MA: Trigger Fast (EMA-8) & Trigger Slow (SMA-13)....
    In OnStartUp: rfMTFMAStatus
    In OnStartUp: rfMovingAverage DMA1 (SMA-20)....
    rfMTFMAStatus: indicators not yet defined
    rfMTFMAStatus: indicators not yet defined
    Notice how in the second example there is no "In OnStartUp: MTFMA Strategy...." and it looks like NT suddenly jumps to the OnStartUp() of one of the indicators instead of calling OnStartUp() of the strategy.

    The strategy is too involved to create a "toy" version.

    How would I even begin to determine why NT is failing? Any debugging/logging mode that can be used?

    #2
    Hello risingfire,

    Thank you for your post.

    Is this only occurring in Market Replay()? Can you provide the full Initialize() method from your strategy?

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Is this only occurring in Market Replay()? Can you provide the full Initialize() method from your strategy?
      Yes, this is occurring in Market Replay. My Initialize() method in the strategy is pretty involved and specific to my model, so I'm not sure how helpful it will be.

      However, it seems that the issue may be resolved. I'll know for sure as I test more.

      I performed an Options->Data->Reset DB and Repair DB and the strategy can now be tested multiple times again on various times and dates.

      I'm not sure which one of those options corrected the situation since I did both at the same time.

      Can you shed any light on the situation as to why this would have corrected this issue? I made no changes to the strategy -- just did those resets.

      Comment


        #4
        Hi Patrick,

        I spoke too soon. This issue (where NT fails to run load the strategy correctly) is still occurring. I did a database reset/repair again, and this time it not correct the situation. I had to completely exit NT and start it again. Once restarted, NT loads and runs the strategy correctly. For now--until I start bouncing around different time periods to test at which point it will once again fail.

        It would seem that perhaps something is becoming corrupted in memory, but without anything more diagnostic from NT, I'm not sure how to track it down.

        Ideas?

        Comment


          #5
          Originally posted by risingfire View Post
          Hi Patrick,

          I spoke too soon. This issue (where NT fails to run load the strategy correctly) is still occurring. I did a database reset/repair again, and this time it not correct the situation. I had to completely exit NT and start it again. Once restarted, NT loads and runs the strategy correctly. For now--until I start bouncing around different time periods to test at which point it will once again fail.

          It would seem that perhaps something is becoming corrupted in memory, but without anything more diagnostic from NT, I'm not sure how to track it down.

          Ideas?
          Look in the output window. There will be clues in there as to whit is causing the failures.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          23 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          14 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          45 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          21 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          181 views
          0 likes
          Last Post jeronymite  
          Working...
          X