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 TheTechnician86, Yesterday, 05:47 PM
            2 responses
            18 views
            0 likes
            Last Post TheTechnician86  
            Started by bigc0220, 09-18-2018, 09:16 AM
            8 responses
            2,615 views
            0 likes
            Last Post bsteeze
            by bsteeze
             
            Started by bortz, 11-06-2023, 08:04 AM
            54 responses
            2,112 views
            0 likes
            Last Post rene69851  
            Started by DawnTreader, 05-08-2024, 05:58 PM
            24 responses
            104 views
            0 likes
            Last Post DawnTreader  
            Started by rwlink3z8, Today, 06:17 PM
            0 responses
            7 views
            0 likes
            Last Post rwlink3z8  
            Working...
            X