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

manually closed order

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

    manually closed order

    I have an addons that replicates orders in different accounts, if in the replicated account I close that order from the char trader, the order does not become null, and I don't know how to prevent the addons from taking as an open order this order that I already closed from the chart
    if (Largos && OrdenEntrada11 != null)
    {
    var prueba = OrdenEntrada11.Quantity;
    OrdenCierre = submissionAccount1.CreateOrder(ActivoReplica, OrderAction.Sell, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, OrdenEntrada11.Filled, 0, 0, string.Empty, "CIERRE REPLICA", Globals.MaxDate, null);
    submissionAccount1.Submit(new[] { OrdenCierre });
    submissionAccount1.Cancel(new[] { OrdenEntrada11 });
    OrdenEntrada11 = null;
    }
    Then, as seen in the code, when I close the entry of the mother account and by not passing the order entry 11 to null, after closing it in the chart, it places the closing order that I should not place since entry 11 has already been closed.​

    #2
    Hello franatas,

    An order does not become null when cancelled. It stays an object and will have the OrderState.Cancelled.

    You are assigning a null value to the OrdenEntrada11 variable. If you don't want the variable to be null, don't set this to null.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      When the atm cancels it, if I set it null, the problem is that if I cancel it from chart its state is still filled, I have already checked it
      I have solved it with
      if (Long && EntryOrder11 != null && submissionAccount1.Positions.Count > 0)

      If submissionAccount1.Positions.Count == 0 does it mean that it is flat ????
      I tried it like this and it works but I'm not sure if my theory is correct​​

      Comment


        #4
        Hello franatas,

        How do you know the order state is filled for that specific order and not another order? Are you checking the order's OrderState?

        If the account.Positions.Count is 0, this would likely mean that the position is flat.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          If I check it, if I close it from the chart the status continues to be filled, so if I close it from the chart, when I close the entry of the mother account it automatically sends me the order to close the replica because it is still filled . that's why I asked about account.Positions.Count is 0, and it's working ok, thank you very much

          Comment


            #6
            Hello franatas,

            It wouldn't matter if the code cancels the order or if the order is manually cancelled, the OrderState will be OrderState.Cancelled.

            Can you provide print output showing the OrderState is OrderState.Filled after the order is showing as cancelled on the Orders tab of the Control Center?

            "when I close the entry of the mother account it automatically sends me the order to close the replica because it is still filled"

            Unfortunately, I am not understanding what this means.

            May I confirm you are printing the order information from the Account.OrderUpdate event handler method?
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by itrader46, Today, 10:22 AM
            0 responses
            9 views
            0 likes
            Last Post itrader46  
            Started by NM_eFe, Today, 10:13 AM
            0 responses
            2 views
            0 likes
            Last Post NM_eFe
            by NM_eFe
             
            Started by hdge4u, Yesterday, 12:23 PM
            1 response
            10 views
            0 likes
            Last Post hdge4u
            by hdge4u
             
            Started by 1001111, Today, 09:45 AM
            0 responses
            10 views
            0 likes
            Last Post 1001111
            by 1001111
             
            Started by DTSSTS, 01-28-2024, 12:07 PM
            11 responses
            558 views
            0 likes
            Last Post bmo111
            by bmo111
             
            Working...
            X