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

Command to exit and close everything?

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

    Command to exit and close everything?

    I am using a strategy that used the unmanaged approach to enter orders. Suppose I wish to immediately exit all orders at market and cancel all pending orders (eg stops and targets). Is there a simple command I can use to close/cancel everything? Yes I know that strategies do this automatically when RealtimeErrorHandling is StopCancelClose, but I want to trigger this in specific conditions inside my strategy.

    UPDATE: I found the strategy method CloseStrategy(string). Is this the method that I'm looking for? Will CloseStrategy(null) just close/cancel everything (which is what I want)?
    Last edited by westofpluto; 08-11-2021, 08:05 AM.

    #2
    Hello westofpluto,

    Thank you for the post.

    The command which would do all of that will also disable the strategy, that is the CloseStrategy command:



    The alternative would be to just use the order objects that you are tracking to cancel those orders. Any open positions could then be exited after confirming all targets were cancelled, you would generally do that part in OnOrderUpdate.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi jess - yes disabling the strategy is fine, as long as it also closes everything. Like I said, I want to replicate the default behavior of what happens when we get a rejected order, which is to close all open positions, cancel any pending stops and targets. If CloseStrategy does this then that's what I want.

      Comment


        #4
        Hello westofpluto,

        Thank you for the post.

        Yes the method will do what you are asking, there is a sample and more information in the help guide page I had linked. Please ensure to read the help guide notes to make sure that works for your use case, otherwise you just need to manage the orders/position yourself in your logic.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rhyminkevin, Today, 04:58 PM
        4 responses
        52 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Started by iceman2018, Today, 05:07 PM
        0 responses
        5 views
        0 likes
        Last Post iceman2018  
        Started by lightsun47, Today, 03:51 PM
        0 responses
        7 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        14 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        50 views
        0 likes
        Last Post futtrader  
        Working...
        X