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

Cancel Order Unmanaged

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

    Cancel Order Unmanaged

    The following code looks to exit an existing position - which is a limit order that often gets split into parts upon being filled.

    {
    CancelOrder(myStopOrderFESXSHORT);
    ChangeOrder(myTargetOrderFESXSHORT,SizeFESX-voladjustFESX,GetCurrentAsk(19) + (fESXEOSTICKS*TickSize),0);
    }


    The aim above is to cancel the stoporder and move the target order to ensure it gets filled. The problem is that lets say we are short 14 lots from entry... and that was filled with a 4 lot and 10 lot pair of executions - the position of 14 lots is closed by the 4 lot order changing as above, and the 4 lot stop loss of the pair is cancelled... but it leaves a 10 lot stop loss and profit target pair still active. Ideas how to correct this? many thanks and regards.
    Last edited by elliot5; 05-14-2021, 06:13 AM.

    #2
    Hi elliot5, thanks for writing in.

    It would be better to use OCO pairing for the orders so that the stop can get canceled automatically. I attached an example for you to reference.

    Best regards,
    -ChrisL
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      OCO were in play. Please read my issue again - it is case of a limit order object being filled in more than one execution - and trying to Change all of those associated stoploss and profit target responses to OnExecution. Regards


      if (myEntryOrderFESXSHORT == execution.Order
      && FESXElont == false)
      {

      if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
      {
      myStopOrderFESXSHORT = SubmitOrderUnmanaged(19, OrderAction.BuyToCover, OrderType.StopMarket,execution.Quantity,0,((Math.M ax(MinStopFESXx, (FESXATR*1.70))) + FESXcdo),GetAtmStrategyUniqueId() +"FESXSHORToco","FESXSHORTstop");
      myTargetOrderFESXSHORT = SubmitOrderUnmanaged(19, OrderAction.BuyToCover, OrderType.Limit,execution.Quantity,FESXpdc+1,0,Get AtmStrategyUniqueId() +"FESXSHORToco","FESXSHORTtarget");

      if (execution.Order.OrderState != OrderState.PartFilled)
      {
      myEntryOrderFESXSHORT = null;
      }
      }
      }
      Last edited by elliot5; 05-14-2021, 10:22 AM.

      Comment


        #4
        Hi elliot5, thanks for your reply.

        Unfortunately, I will not be able to spend time debugging the custom strategy code. If you would like to hire a service to help with the issue, see a list of developers for hire here on the NInjaTrader Ecosystem website:
        https://ninjatraderecosystem.com/sea...mming-services

        Best regards,
        -ChrisL

        Disclaimer:
        The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          i am not asking for debugging service ... but guidance on a situation that must affect many users of unmanaged strategies. if you dont have the time please refer me to someone who does. Regards

          Comment


            #6
            Hi, thanks for your reply.

            In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

            What has been given is not enough to describe the issue. I recommend making a new script that only concentrates on the issue at hand and excludes all of these offsets and variables that you have within the parameters.

            Best regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi Elliot5,

              Just an FYI..

              On a quick pass through the issue/needs you raised I am not yet seeing where the "PartFilled" logic Jim wrote in the attached sample does not address that need.

              If you execute against the sample attached above without modification what need is not being addressed?

              HedgePlay

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, 04-17-2024, 06:40 PM
              6 responses
              49 views
              0 likes
              Last Post algospoke  
              Started by arvidvanstaey, Today, 02:19 PM
              4 responses
              11 views
              0 likes
              Last Post arvidvanstaey  
              Started by samish18, 04-17-2024, 08:57 AM
              16 responses
              61 views
              0 likes
              Last Post samish18  
              Started by jordanq2, Today, 03:10 PM
              2 responses
              9 views
              0 likes
              Last Post jordanq2  
              Started by traderqz, Today, 12:06 AM
              10 responses
              21 views
              0 likes
              Last Post traderqz  
              Working...
              X