Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Close unmanaged order

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

    Close unmanaged order

    Hi,

    How can I close an Unmanaged order when status is Filled or PartFilled and cancel it when status is Working or Submitted?

    #2
    Hello bosajin,

    Thank you for your post.

    To close an order when using the Unmanaged approach when the order status is Filled or PartFilled, you could check if order.OrderState == OrderState.Filled || order.OrderState == OrderState.PartFilled in OnOrderUpdate followed by calling SubmitOrderUnmanaged to place an order opposite of the entry order. For example, if we have a buy market entry order, we would use SubmitOrderUnmanaged to submit a sell market order to close out of our long position.

    You could cancel an order when the status is Working or Submitted by first checking if the order state is working or filled in OnOrderUpdate. To do this you would check if order.OrderState == OrderState.Working || order.OrderState == Order.State.Submitted followed by calling CancelOrder() to cancel the order.

    Please see the help guide links below for more information

    SubmitOrderUnmanaged - https://ninjatrader.com/support/help...runmanaged.htm

    CancelOrder() - https://ninjatrader.com/support/help...ancelorder.htm

    Checking the OrderState in OnOrderUpdate - https://ninjatrader.com/support/help.../nt8/order.htm

    OnOrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      Would you please explain how I can get Realized and UnRealized profit of each Unmanaged order.

      Comment


        #4
        Hello bosajin,

        Thank you for your note.

        You would get the Realized PnL and Unrealized PnL from the Account class by calling <Account>.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar) and <Account>.Get(AccountItem.UnrealizedProfitLoss, Currency.UsDollar).

        Please see the attached example script which demonstrates how this could be accomplished.

        Also, please see the help guide links below for more information.

        Account - https://ninjatrader.com/support/help...ount_class.htm

        AccountItem - https://ninjatrader.com/support/help...ccountitem.htm

        Get() - https://ninjatrader.com/support/helpGuides/nt8/get.htm

        Let us know if we may assist further.
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X