Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel all pending for symbol

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

    Cancel all pending for symbol

    Hello,

    In NT7 I'll be manually placing one of the following order configurations:

    1. Limit entry
    2. Stop entry
    3. OCO stop entry and limit entry

    I would like to write code that will cancel any and all pending entry orders for the current chart symbol Instrument.Fullname if certain conditions are met. How would I do this?

    I see CancelOrder() and ATMStrategyCancelEntryOrder() but if I've placed an entry order or two OCO orders manually, how would I know the order IDs? Is there another way?

    Thanks!

    #2
    Hello entropy,

    Thank you for writing in.

    There is not a documented way to do what you are looking for. I would like to provide a sample script that should get you going in the direction you want to.

    I would like to note that this is undocumented code and is not supported; therefore any questions pertaining to this script may or may not be answered by support.

    What this script does is the following process:

    -OnStartUp:The indicator loops through the available accounts and gets the specified account set in the variables.

    -If the account is found, it attaches Execution, OrderStatus, PositionUpdate, and ConnectionStatus handlers to the account.

    -If there is an event that happens, one of the handlers that was attached will catch the event
    OnTermination: loops through the accounts again and finds the specified account - then removes the handlers so that when the chart is closed or the indicator is removed the actions can no longer happen.

    This should give you the information you need to get the account position and other information in an indicator.

    I should also note that this is set up to print the status's to the Output window (Tools -> Output Window)

    Another method of accomplishing this would be to override the plot method and draw buttons on the chart which have event handlers that trigger when they are clicked and submit orders, so all the orders you submit would be able to be tracked internally.

    Please let me know if I may be of additional assistance.
    Attached Files
    Michael M.NinjaTrader Quality Assurance

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X