• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    JoshNinjaTrader 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.
        JoshNinjaTrader 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 rickyblah12, Today, 01:01 PM
              0 responses
              8 views
              0 likes
              Last Post rickyblah12  
              Started by dadarara, Today, 12:18 PM
              0 responses
              8 views
              0 likes
              Last Post dadarara  
              Started by joemiller, Today, 07:33 AM
              2 responses
              12 views
              0 likes
              Last Post joemiller  
              Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
              7 responses
              38 views
              0 likes
              Last Post DaveS
              by DaveS
               
              Started by claxxical, Yesterday, 10:00 PM
              0 responses
              13 views
              0 likes
              Last Post claxxical  
              Working...
              X