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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X