Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disabling a strategy / preventing order

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

    Disabling a strategy / preventing order

    There are times when one of my strategies generates an order that I do not want it to execute.

    When I cancel that order, the strategy immediately generates an order to replace it.

    It seems that the only way around this is to disable the strategy - If I am wrong, I would love to learn how to do what I wish.

    One of the NT support folks recommended that I look at adding buttons, and directed me to a thread that had some examples. I have had trouble deciphering some of these examples so far.

    My question is this - has anyone created a button that can disable 1 of the specific strategies that is running. To put it another way, if I have Strat1, Strat2 and Strat3 running, and I wish to block orders from Strat1 without affecting the other two.

    Ideally, I would like to have 3 buttons on the toolbar that generates a "blocking signal" that I can then add to a strategy. Something like "if button is clicked then a blocking variable is set to TRUE" and the strategy then looks to that variable in its logic as a permissive.

    Any ideas?

    #2
    Hi RodS7,

    This is what programming is all about and the code you write will ultimately control what happens with your strategy order submission. We would not typically recommend adding buttons as this is more of a broader C# item that we cannot support. It may be useful to have but skirts the issue of writing code that does what you want it to do.

    When I cancel that order, the strategy immediately generates an order to replace it.
    It submits the order because there was code that told it to, so basically you will need to add structure so that it doesn't submit if you don't want it to. One approach to this is with bool flags, which is a simple true / false toggle used to control when your code is executed.

    Let's say you have some conditions for cancelling the order. Consider setting a bool flag here that's also used to control order submission. The last piece is defining a condition when you want to start accepting orders again. The three parts to this would look something like this:

    Code:
    if (cancelCondition)
    {
    	CancelOrder(myOrder);
    	okToSubmit = false;
    }
    
    if (orderSubmissionConditions && okToSubmit)
    {
    	//submit an order here. 	
    }
    
    if (conditionsForResettingFlag)
    {
    	okToSubmit = true;	
    }
    First step is getting the idea of how this is done simply, and then you could consider adding buttons later that sets or resets your flags as needed.
    Last edited by NinjaTrader_RyanM1; 06-27-2012, 01:31 PM.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    646 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    367 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X