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

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 cre8able, Today, 01:16 PM
    2 responses
    9 views
    0 likes
    Last Post cre8able  
    Started by chbruno, 04-24-2024, 04:10 PM
    3 responses
    48 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by samish18, Today, 01:01 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by WHICKED, Today, 12:56 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by WHICKED, Today, 12:45 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X