Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reference Sample: Strategy: Stopping a strategy after consecutive losers

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

    Reference Sample: Strategy: Stopping a strategy after consecutive losers

    Suggestions, please ...

    As far as I understand it, the Reference Sample: "Strategy: Stopping a strategy after consecutive losers" (the code downloads as an NJ snippet called "SampleTradeObjects") works fine unless there are partial fills.

    In the sample code, the strategy stops entering positions if the last three consecutive trades were losers.

    However, if a single trade results in 3 partial fills, and if all those partial fills are stopped out, then the 3-losers-in-a-row condition will be triggered, when it's "really" just one trade.

    I am trying to determine the best approach to modifying this snippet so that partial fills don't get treated as separate trades, but instead get lumped together to be treated as a single trade for the purpose of evaluating this condition.

    Any suggestions as to the best way forward?

    Thanks

    #2
    You will have to track partial fills in OnExecution() and adjust your code accordingly to however many partial fills you receive.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I am looking for a way to move this forward.

      Does the strategy parameter “Stop & target submission” have any effect on how NinjaScript runs the “SampleTradeObjects” code?

      Specifically, if this parameter is set to “ByStrategyPosition”, will Performance.AllTrades.Count ignore partial fills, and just count the number of “whole” trades?

      Thanks.

      Comment


        #4
        AnotherTrader,

        It makes a difference in determining how many stops and target orders you want to submit. ByStrategyPosition means it will submit a single stop/target order for the overall position. As you scale-in more times, the stop/target will amend in quantity. PerEntryExecution means you get a new stop/target bracket per execution. If you partial filled 10 times that means 10 sets of stop/targets.

        Please be aware there are bugs in this area in NT6.5. If you wish to proceed in this area I suggest you try NT7.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          OK, thanks.

          So the performance of Performance.AllTrades.Count is NOT altered by the "ByStrategyPosition" setting. That's clear to me now.

          Many thanks.

          Comment


            #6
            Setting Up Sample Trade Objects

            Josh,
            I installed SampleTradeObjects on a paper money account. My understanding is that it stops trading after three consecutive losses. Is that correct. Can this strategy be used to limit draw down during a certain period also? If so is that thru the Slippage parameter?
            What is the ADX period?
            How does this strategy differ from "SamplePnL"?
            Thanks,
            Robert

            Comment


              #7
              Robert, that's correct - it would stop the trade logic calls in the OnBarUpdate() calls after 3 losses in a row.

              The ADX period is a user input, it's defaulted to 14.

              Slippage is for backtesting only and applied to market orders only, you can see for example then how your results are influenced by getting a worse fill on those, to see if that would break your strategy from being profitable - usually then a sign of a too low avg trade.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rocketman7, Today, 02:12 AM
              3 responses
              19 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by trilliantrader, 04-18-2024, 08:16 AM
              7 responses
              27 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by samish18, 04-17-2024, 08:57 AM
              17 responses
              64 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by briansaul, Today, 05:31 AM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by PaulMohn, Today, 03:49 AM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X