Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

overfills

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

    overfills

    Hello,

    when running my strategies (not backtesting) there occur overfills. I know there is an information from NT about risk of electronic trading. I want to do the following questions please:

    a.) I assume one can not avoid overfills when working with targets and - dynamic - stops(?) But could one avoid overfills when working only with stops (so that there are no 2 "conditions" to be met at the same moment of time)?

    b.) if there is an overfill can I close the positions in my strategy somehow (automatically not by hand of course)? Llike "if Position>0 && stopxx != accepted then flatten()?

    c.) if there is an overfill can I add a stop to the position? Like "if Position>0 && stopxx != accepted then stoporder...?

    Thanks
    Tony

    #2
    Hi Tony, I would not say you can avoid them 100% of the time, but you can look to minimize the chances of seeing them, simply be optimizing your script to work with less competing orders for example, generally the closer the order are to the inside market and more you have working, the higher chance to run into such situations.

    When NT detects an overfill, it would disable the strategy and attempt to close it's open positions, custom managing overfill scenarios would be only possible though in unmanaged mode - http://www.ninjatrader.com/support/h...htsub=overfill
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand, thanks for your reply.

      Referring to my question c.) I want to ask again please if there is there a possibiltiy to add a stop to a "naked" position caused by an overfill (if it matters how the entry was done) in a script-strategy? Like "if marketpos short && "nostop" then add stop position qty"

      Thanks
      Tony

      Comment


        #4
        Tony, would only be possible if you an unmanaged mode script, here you could detect the overfill and then for example amend your stop accordingly.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Betrand,

          I´m a little depressed when I see some answers in the forum with hints for coding by answering a snippet or syntax. With your information "detect " and "then for example amend your stop accordingly" this is the same as my question between the " " but in other words.

          Could you please help me how you mean to detect the overfill and to amend the stop please? I cant find an example on the help sites. What is the syntax to do?

          ???: if(Position.MarketPosition == MarketPosition.Short && .......?)
          stopOrderOverfill = ExitShortStop(0, true, 1000, execution.Order.AvgFillPrice, "Stop", "Shorts");???

          Thank you for your support!

          Best
          Tony



          Originally posted by NinjaTrader_Bertrand View Post
          Tony, would only be possible if you an unmanaged mode script, here you could detect the overfill and then for example amend your stop accordingly.

          Comment


            #6
            Tony, right that's the code you need to create in your script to use it - but then you cannot implement a custom overfill handling in a managed mode strategy, this would only be possible by completely changing the code over to unmanaged. I would unfortunately not have an example here to show you, but will add this to our list to look into enhancing - you would need to keep in mind though the unmanaged mode was created for advanced programmers though that would seek ultimate flexibility, this comes with added responsibility on the custom code used as standard NT safeguards of the managed mode would not be present.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hello,

              thank you for your reply.

              I do forcing overfills with simulated datafeed and I can bring in a stoploss for the overfill with

              if(Position.MarketPosition==MarketPosition.Long)
              { if(stopOrderOverfill1==null)
              stopOrderOverfill1 = ExitLongStop(Position.Quantity,Low[0] -10 * TickSize);

              in onbarupdate (in managed mode).

              But the stop is cancelled immediately. In the output window there appears

              22.04.2013 00:13:37 Entered internal PlaceOrder() method at 22.04.2013 00:13:37: BarsInProgress=3 Action=Sell OrderType=Stop Quantity=1.000 LimitPrice=0 StopPrice=0,8317'4 SignalName='' FromEntrySignal=''

              22.04.2013 00:13:49 Cancelled expired order: BarsInProgress=1: Order='8fe709300ef54180b5a7c9d4c46ed92a/Sim101' Name='Sell' State=Accepted Instrument='$NZDUSD' Action=Sell Limit price=0 Stop price=0,83174 Quantity=1.000 Strategy='a111xShortWithOverfill' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='8fe709300ef54180b5a7c9d4c46ed92a' Gtd='01.12.2099 00:00:00'

              I have no idea why the stop is cancelled.

              Thanks
              Tony


              Originally posted by NinjaTrader_Bertrand View Post
              Tony, right that's the code you need to create in your script to use it - but then you cannot implement a custom overfill handling in a managed mode strategy, this would only be possible by completely changing the code over to unmanaged. I would unfortunately not have an example here to show you, but will add this to our list to look into enhancing - you would need to keep in mind though the unmanaged mode was created for advanced programmers though that would seek ultimate flexibility, this comes with added responsibility on the custom code used as standard NT safeguards of the managed mode would not be present.

              Comment


                #8
                Hi Tony, the stop order will expire on the next bar update - that would be the default behavior here if the order is not resubmitted or sent first time via liveUntilCancelled set in the advanced overload.

                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Hi Bertrand,

                  thank you for your reply. When using in the syntax also the live untill cancelled do I have to use then also from entrysignal? (Because I dont have as I do not know the entrysiganl in case of overfill I assume, please correct me, thanks) Or can I do without entrysignal?

                  Could I bring in the stop also in with

                  * onPosition (if marketposition = Long && stopOrderOverfill1==null...?

                  * or in onExecution (or will this not be possible in onExecution because I have no definition for the executed order)?

                  PS: I do not know how to work in unmanaged mode, so I have to settle it this way. As we have reached already overfills - this will be one of the last questions, as you might know then (I dont think after overfill there is something I can anticipate;-)

                  Thank you for your support!

                  Best
                  Tony


                  Originally posted by NinjaTrader_Bertrand View Post
                  Hi Tony, the stop order will expire on the next bar update - that would be the default behavior here if the order is not resubmitted or sent first time via liveUntilCancelled set in the advanced overload.

                  http://www.ninjatrader.com/support/h...b=ExitLongStop
                  Last edited by tonynt; 04-22-2013, 04:01 AM.

                  Comment


                    #10
                    Bertrand,

                    thank you. It works!!! It works without "from entrysignal" (by using simply " " instead) and I can do it in onPosition. So I have now also my overfill-management. There´s nothing more I can do, and not 10% of what I have coded I could have done with another software than NinjaTrader and the great support.

                    Thank you for all!

                    But one question appears in this concern: as you helped me with your information that the stop order expires the next bar update without liveuntillcancelled set - why and when it makes sense to use the exitXXXstop with the first 5 syntax-samples on the referred help-guide-site? Who will use this and for what reason or purpose?

                    Best regards
                    Tony

                    Comment


                      #11
                      Thanks for the kind words Tony, we're glad to hear that.

                      Some more info would be contained here - http://www.ninjatrader.com/support/h...r_handling.htm

                      It's easier to start out, as you would not have to concerned with cancellations and IOrder objects, but I can understand you wanted (and needed) more control in your script, that's where flexibility shines!
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by tonynt View Post
                        Bertrand,

                        thank you. It works!!! It works without "from entrysignal" (by using simply " " instead) and I can do it in onPosition. So I have now also my overfill-management. There´s nothing more I can do, and not 10% of what I have coded I could have done with another software than NinjaTrader and the great support.

                        Thank you for all!

                        But one question appears in this concern: as you helped me with your information that the stop order expires the next bar update without liveuntillcancelled set - why and when it makes sense to use the exitXXXstop with the first 5 syntax-samples on the referred help-guide-site? Who will use this and for what reason or purpose?

                        Best regards
                        Tony
                        hi
                        can you tell me more about how you got a handle on this overfill issue ?
                        It has been a problem for me also.
                        shane

                        Comment


                          #13
                          hi,

                          you have to check if you have a trade in the other direction and then you bring in a stop for this trade with "Position.Quantity" (as you don´t know what quantity it might be)

                          Best
                          Tony

                          Originally posted by shanemcdonald View Post
                          hi
                          can you tell me more about how you got a handle on this overfill issue ?
                          It has been a problem for me also.
                          shane

                          Comment


                            #14
                            thank you !
                            best !

                            shane

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Graci117, Today, 09:02 PM
                            1 response
                            10 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by ETFVoyageur, Today, 07:55 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post ETFVoyageur  
                            Started by janio973, Today, 07:24 PM
                            1 response
                            7 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by aligator, 01-06-2022, 12:14 PM
                            4 responses
                            248 views
                            0 likes
                            Last Post john_44573  
                            Started by reynoldsn, Today, 05:56 PM
                            0 responses
                            15 views
                            0 likes
                            Last Post reynoldsn  
                            Working...
                            X