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

Fill or kill order add-on

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

    Fill or kill order add-on

    Has anybody tried to develop a Fill-Or-Kill add-on type of order?
    Thank you!

    #2
    Hello Sgr888,

    I'm not quite sure what you are describing.

    Are you asking if it is possible to cancel an order if the order does not fill on the bar it is submitted on?

    Are you creating a NinjaScript Strategy or an Addon?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      To be more precise: a stop limit order that if it is not filled at the desired price with 1 contract, for the first time the price action passes through that value, then it is automatically canceled.

      So the condition would be not to be filled in the same bar, but at the first brake of the desired price, because on a bigger time-frame setup or a renko setup, that would leave the possibility of the order to be filled the second or the third time the price hits the desired value.

      Thanks!

      Comment


        #4
        Hello Sgr888,

        It sounds like you are trying to create an automated NinjaScript Strategy, is this what you are creating?

        I am also not fully understanding "if it is not filled at the desired price with 1 contract, for the first time the price action passes through that value".

        Are you wanting to send a cancellation if the price touches the order and the order does not fill?
        (As a heads up, this is likely to result in an in-flight-execution and trigger an overfill if the order begins to fill as the cancellation is sent)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Yes, I want to integrate this type of order in an automated NinjaScript Strategy.

          Well then if the order is canceled after the bar is closed does the possibility of in-flight-execution diminishes?

          Yes, as seen in the 1 tick chart attached, I need the order to be filled in point A only, if not to be canceled. Getting filled in point B is not what I need.

          Thanks!
          Attached Files

          Comment


            #6
            Hello Sgr888,

            I have moved your thread from the NinjaTrader 8 Addon Development section to the NT8 Strategy Development section of the forums.

            If the order has not filled the entire time the bar was open, likely the current price is not near the order, the order is not as likely going to fill and not as likely to trigger an overfill.

            If the current price touches the order and immediately a cancellation is sent, likely the current price is very near the order, the order is much more likely to experience a fill, and is much more likely to experience an overfill with the cancellation.

            You can do this though.

            You will need intra-bar granularity either from a secondary tick series or from Calculate set to .OnEachTick / .OnPriceChange. In OnBarUpdate you would compare the limit or stop price of the order to the current price. If they are equal then check the order state and and send a cancellation.

            To cancel an order use CancelOrder().


            For example:
            Code:
            private Order myOrder;
            protected override void OnBarUpdate()
            {
            	if (Position.MarketPosition == MarketPosition.Flat)
            	{
            		myOrder = EnterLongStopLimit(High[0] + 5 * TickSize, High[0] + 5 * TickSize);
            	}
            	if (myOrder != null && (myOrder.OrderState ==  OrderState.Accepted || myOrder.OrderState ==  OrderState.Working) && myOrder.StopPrice == Close[0])
            	{
            		CancelOrder(myOrder);
            	}
            }
            Last edited by NinjaTrader_ChelseaB; 05-09-2017, 10:13 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I'm not much of a coder, but if I understood correctly, I should replace the:

              Code:
              {
              				EnterLong(Convert.ToInt32(DefaultQuantity), "");
              			}
              that is in my strategy, with the code you have wrote? And why do you use "5 * TickSize"?

              Thanks!

              Comment


                #8
                Hello Sgr888,

                EnterLongStopLimit places a stop limit order.

                EnterLong places a market order which will fill immediately.

                I've set the buy stop limit stop price to 5 ticks above the high of the trigger bar. High[0] is the high of the bar. 5 * TickSize adds 5 ticks to that price.

                A buy stop limit must be placed above the ask price.

                No, I am not recommending that you replace your code with the sample code I have posted. I am recommending that you use this concept where you need in your own script.
                Last edited by NinjaTrader_ChelseaB; 05-10-2017, 07:01 AM.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by XXtrader, Yesterday, 11:30 PM
                2 responses
                11 views
                0 likes
                Last Post XXtrader  
                Started by Waxavi, Today, 02:10 AM
                0 responses
                6 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by TradeForge, Today, 02:09 AM
                0 responses
                11 views
                0 likes
                Last Post TradeForge  
                Started by Waxavi, Today, 02:00 AM
                0 responses
                2 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by elirion, Today, 01:36 AM
                0 responses
                7 views
                0 likes
                Last Post elirion
                by elirion
                 
                Working...
                X