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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      64 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      139 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X