Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pause after X trades for Y trades

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

    Pause after X trades for Y trades

    Hello,

    can someone help me with the following:

    Does everyone have an idea how I can implement a code that skipped X Trades after the strategy had X winners?

    thanks

    #2
    Well, you would have to keep track of your winning trades, first of all, and then keep track of when you had a trade setup that you would otherwise enter, before you actually do, so you can decide if you should do it or not. One way to keep track of your winning trades is to use OnPositionUpdate or OnExecutionUpdate to catch when your position becomes flat from long or short, and then to check SystemPerformance to get the just closed trade's profit or loss and update your count of winning trades if it was a win. Then, if your wins reaches X, you could make note of the number of trade setups you have had, and when you're considering whether to actually enter when you have a trade setup, don't do so until you reach X + Y.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello Lopat,

      Thanks for your post.

      QuantKey_Bruce is correct. You would need to track your winning trades to determine if there are a certain number of winning trades that occur and track when you had a trade setup that you would otherwise enter.

      This could be done by using the SystemPerformance.AllTrades TradeCollection to determine if a trade is a winning trade. Then, you could check if your winning trades are equal to a certain number "X" as QuantKey_Bruce noted.

      We have a reference sample linked below that checks for a certain number of losing trades that you might find helpful. You could apply similar logic in your script to track winning trades instead of losing trades.

      SampleTradeObjects: https://ninjatrader.com/support/help...after_cons.htm
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 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
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      72 views
      0 likes
      Last Post PaulMohn  
      Working...
      X