Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strat wo'nt trade in strategy analyzer

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

    strat wo'nt trade in strategy analyzer

    My strategy is doing great and making at least 2 trades from 9:30 to 9:40 AM EST evey day in market playback, but when I try to test in strategy analyzer, it only does 1 trade or even zero, over a month date range.

    It uses the default data series from the chart (I use 1min candles), and my strategy needs to calculate on tick, not OnBarClose. What do I select in strategy analyzer to replicate this so I can do a proper test?

    #2
    Update: I discovered a bug in my strategy that was causing it to not trade right in strategy analyzer. In OnBarUpdate, I was checking if the current time was in the allowed trading window, and if not, just returning. Why's that bad? Well, it prevented all of my position management logic from being called. So even if we had an open position, my strategy would abandon it as soon as the trading window ended. I fixed that and now backtesting works.

    I want to point out that this is one of the reasons market replay is essential when developing a strategy. You can watch it trade and get ideas to help filter out bad trades. You can also see bugs happen. My strategy has been especially prone to bugs because I am using unmanaged approach.

    Comment


      #3
      Hello iantriestrading,

      Glad you were able to work out the issue.

      Printing the values compared in the conditions with labels for each value and comparison operator is a quick way to understand what is causing issues.


      In backtest, the current pc time won't have any value, and the time of each bar must be used. For any second granularity events you want to trigger it would be recommended to add a 1 second series with AddDataSeries() to drive those events.

      Also, keep in mind the differences between real-time and backtest and the need for intra-bar granularity to improve accuracy.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      53 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X