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

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
      Brandon H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by llanqui, Today, 03:53 AM
      0 responses
      4 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X