NexusFi: Find Your Edge


Home Menu

 





How to cancel orders and positions of a certain strategy when disabling the strategy


Discussion in NinjaTrader

Updated
    1. trending_up 1,488 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 janiodesouza 
Francisco Beltrão PR Brazil
 
Experience: Intermediate
Platform: NinjaTrader
Trading: forex
Posts: 4 since Oct 2019
Thanks Given: 0
Thanks Received: 1

How to cancel orders and positions of a certain strategy when disabling the strategy?

Account.FlattenEverything() or Account.Flatten() i couldn't do it. I don't want the whole account, just the one instance that (State == State.Terminated) was called.

Help me please?


Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
1 thanks
  #2 (permalink)
 vsltradr 
Boise, Idaho/United Sates
 
Experience: Advanced
Platform: NinjaTrader
Posts: 25 since Jun 2014
Thanks Given: 38
Thanks Received: 24

An approach could be to save all Order objects generated by the strategy to a list within the strategy. Then on termination you’d loop through the strategy’s orders and cancel those that are pending, as well as submit a closing order at market for the strategy’s outright quantity (I.e. sell 2 at market if strategy is net long 2 at the time of termination).


Reply With Quote
Thanked by:




Last Updated on February 28, 2021


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts