• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy: Halting a Strategy Once User Defined Conditions Are Met

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

    Strategy: Halting a Strategy Once User Defined Conditions Are Met

    For error-handling, money-management or any other reason you may want to halt your strategy from processing its' core program logic. Before you halt your strategy, it is best to close all positions and cancel all active orders to prevent the risk of having an unmanaged position in the market. We have provided two reference samples for these topics.

    Key concepts in the SampleHaltBasicStrategy example*
    • Using PnL statistics to determine when to halt processing of the strategy
    • Cancelling active orders
    • Closing active positions


    Key concepts in the SampleHaltAdvancedStrategy example**
    • Using a custom method to halt processing on all event-driven methods
    • Advanced order handling in error situations with the OnOrderUpdate() method


    * This is intended for strategies driven exclusively by the OnBarUpdate() method.
    ** This sample's intended audience is for advanced programmers who have programmed strategies that take advantage of event-driven methods such as, but not limited to, OnMarketData() or OnOrderUpdate() in addition to the OnBarUpdate() method.


    Important related documentation:

    NinjaTrader 8

    * This reference sample uses the .AllTrades property. This property will include all historical virtual trades as well as real-time trades. If you wish to only make calculations based on real-time trades you can use the .RealtimeTrades property.

    NinjaTrader 7


    Import instructions:

    NinjaTrader 8
    1. Download the file contained in this thread to your PC desktop
    2. From the Control Center window, select the menu Tools > Import > NinjaScript
    3. Select the downloaded file


    NinjaTrader 7
    1. Download the file contained in this thread to your PC desktop
    2. From the Control Center window, select the menu File > Utilities > Import NinjaScript
    3. Select the downloaded file and click Import.
    Attached Files
    Last edited by NinjaTrader_PatrickH; 07-12-2017, 01:22 PM.
    Josh P.NinjaTrader Customer Service

Latest Posts

Collapse

Topics Statistics Last Post
Started by nytdfs, Today, 05:00 AM
0 responses
1 view
0 likes
Last Post nytdfs
by nytdfs
 
Started by PG7940, Today, 04:36 AM
0 responses
2 views
0 likes
Last Post PG7940
by PG7940
 
Started by elliot5, Today, 03:40 AM
0 responses
3 views
0 likes
Last Post elliot5
by elliot5
 
Started by itrader46, Today, 02:23 AM
1 response
7 views
0 likes
Last Post NinjaTrader_Marco  
Started by jeronymite, Today, 01:57 AM
0 responses
6 views
0 likes
Last Post jeronymite  
Working...
X