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

Closing Strategy Positions/Working Orders Without Disabling Strategy

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

    Closing Strategy Positions/Working Orders Without Disabling Strategy

    I have a strategy that enters orders and places take profit and stop loss. I'm trying to create a custom "Close" button that closes the position and working orders without disabling the strategy. I'm good with creating the button but haven't figured out the logic behind closing open positions and cancelling working orders without disabling the strategy. Any guidance would be appreciated.

    #2
    Hello jclose,

    Thank you for your post.

    <Account>.CancelAllOrders() could be used to cancel all orders on an instrument. This method can be used in a NinjaScript strategy.

    See this help guide page for more information about accessing the Account class and sample code: https://ninjatrader.com/support/help...ount_class.htm

    See this help guide page about <Account>.CancelAllOrders() and sample code: https://ninjatrader.com/support/help...lallorders.htm

    Another way to cancel all orders from the strategy is you can loop through the orders in the account and cancel them with CancelOrder().

    See this forum thread for more information about looping through orders on the account and canceling them with CancelOrder(): https://ninjatrader.com/support/foru...17#post1130617

    Please let me know if I may further assist.​
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by EvaisDery, Today, 05:44 AM
    0 responses
    5 views
    0 likes
    Last Post EvaisDery  
    Started by JerryWar, 11-19-2016, 08:14 AM
    3 responses
    2,070 views
    0 likes
    Last Post tradertom2012  
    Started by capt34, Today, 03:46 AM
    0 responses
    8 views
    0 likes
    Last Post capt34
    by capt34
     
    Started by wuannetraam, Today, 12:22 AM
    1 response
    11 views
    0 likes
    Last Post wuannetraam  
    Started by TGOG1, Yesterday, 03:02 PM
    2 responses
    27 views
    0 likes
    Last Post TGOG1
    by TGOG1
     
    Working...
    X