Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

what is the best way to count stoploss executions

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

    what is the best way to count stoploss executions

    Hello,

    I want to be able to count how many times a signal to enter results in failure. For example, if some event happens and I enter long and get stopped, and then I get the signal again and enter again and a get stopped again, I want to know that I was stopped out twice in the long direction.

    Is there someway of using IExecution or perhaps another way to know?

    Please advise, thank you.

    #2
    crmcwi, you could for example work with the IOrder objects and count the returned fill order states - http://www.ninjatrader-support.com/H...V6/IOrder.html

    An easier way would be to access the performance statistics of the strategy directly with the Performance class - http://www.ninjatrader-support2.com/...ad.php?t=19289
    BertrandNinjaTrader Customer Service

    Comment


      #3
      thanks Bertrand, let me digest this.

      Comment


        #4
        Bertrand,

        Can you point me to examples of how to use the IExecution interface? I'm not clear on how to count stop losses when they are executed from SetStopLoss().

        Comment


          #5
          crmcwi, you unfortunately can't work with the Set Methods for this as they don't return an IOrder object for you to 'read'.

          To access the IOrder ojects of your stops please use the Exit() methods to place those - http://www.ninjatrader-support2.com/...ead.php?t=7499
          BertrandNinjaTrader Customer Service

          Comment


            #6
            excellent. Thank you.

            Comment


              #7
              How to separate one kind of stop from another.

              I have followed your suggetion and have implemented a stop and target strategy using the OnExecution() method. I have a question though about how to modify or cancel the stop if the target executes.

              In OnBarUpdate() if a condition is met, I enter with 3 FX lots. In the OnExecution() of my entry, I enter a stop and target as follows:
              1. a stop order at a 10 pips out of the money to flatten
              2. a target order to take one lot off at a 10 pip profit.
              If my target is filled, I still have 2 lots on and I want to either modify the stop or cancel it. The new stop will exit at break even and flatten taking 2 off. I want to know can I modify the existing stop or should I cancel it and create a new order. It is critical that I can count the stops that produce losses vs. the stops at break even.

              If the original target order executes, in addition to taking 1 lot off at a profit and setting a stop at breakeven, I want to let the remaining lot run with the market using an ATM-like strategy. Can I actually call an external strategy or must I code this market-chasing exit into this strategy?

              Comment


                #8
                do I need to cancel the corresponding stop or target should one be executed?

                Guys,

                Just to be clear and referring to the example in this thread, if either of the exit orders are executed, must I explicitly cancel the other or will NT handle it automatically?

                i.e. If my entry order is filled and then I'm stopped out, must I explicitly cancel the target order? I ask because in the example given, the ExitLongLimit().liveUntilCanceled = true. I just want to make sure it's really gone.

                The example also shows setting MyStop = null and MyTarget = null. I am confused and don't want to assume that setting my C# objects to null is the same thing as cancelling.
                Last edited by crmcwi; 08-08-2009, 08:32 PM. Reason: forgot about the = null

                Comment


                  #9
                  crmcwi, sorry for the late reply. Yes, when working with the Exit() methods you would need to code the OCO logic in yourself, this is in contrast to the Set() methods where this is handled natively.

                  You can also call an ATM strategy template for exit management, for sample code please look into the 'SampleAtmStrategy' provided per default with NinjaTrader.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    thanks Bertrand. I appreciate it very much.

                    Comment


                      #11
                      does anyone have ATM-like code

                      Bertrand,

                      Thank you for your suggestion to CreateATMStrategy(). The problem is that such ATM's cannot be back tested. Thus, I need to code my own.

                      I have perused the forum and I have found only one posting by a user, who's developing an ATM-like code. His code implements using Set() order methods within the OnBarUpdate().

                      Based upon our discussions, I expect such code should use Enter[Long/Short]Stop methods. Are there any code samples that implement a trailingStop or autoTrail strategy?

                      Comment


                        #12
                        crmcwi, sorry you're correct for your purpose you need to code this out for backtesting - here's a basic one -





                        A custom code trailing stop 'skeleton' can also be found in the sharing / strategies section of the forum - http://www.ninjatrader-support2.com/...ks.php?catid=2
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Hi Bertrand,

                          Please don't think me to be obstinate, I don't want to leave that impression.

                          The links you gave me all use the Set() methods, instead of the Exit() methods I must use.

                          Are there any examples using the Exit methods in OnExecution()? the tricky part to the OnExecution() approach is what quantity is executed and if you want to set a target for half your position, but not half is executed.... well that's an important conundrum. Do you have any ideas?

                          I sent the bulk of my code to cite and ask such a question to the support@NT box because I thought it too lengthy for the forum.

                          Comment


                            #14
                            Not sure what you mean by "half the position, but not half executed". You know the quantity you entered your entry order as. You know the amount that have been filled. You can divide by 2 whichever value is the quantity you want to use for your exit though you should not exit at a quantity greater than the amount that is filled.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Josh,

                              I understand your point. Remember your perspective is that of someone who knows what's going on inside the NT box.

                              I don't yet.

                              Let me explain, please.

                              Let's say you make a call to Enter(). It may trigger one or more OnExecution()'s. Each execution will a filled amount.

                              If you are setting your stops and targets in OnExecution, and there are multiple executions, you will be setting multiple stops and targets, yes? Or am I wrong.

                              If I am right, then if you want to set a target to take 1/2 off your position, you'll need to make a target order in each entry-execution that specifies 1/2 that execution's fill size. Then, in order to manage those target orders should they need to be cancelled for example, I need to know if they must be handled individually or if they are somehow aggregated by NT or the broker.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by tkaboris, Today, 05:13 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post tkaboris  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              16 responses
                              3,281 views
                              0 likes
                              Last Post Leafcutter  
                              Started by WHICKED, Today, 12:45 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Taddypole, Today, 02:47 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Taddypole  
                              Working...
                              X