NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-27-2012, 12:40 PM   #1
RodS7
Member
 
Join Date: Mar 2012
Location: DFW, TX
Posts: 40
Thanks: 3
Thanked 7 times in 4 posts
Default 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?
RodS7 is offline  
Reply With Quote
Old 06-27-2012, 01:01 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

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.

Quote:
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_RyanM; 06-27-2012 at 01:31 PM.
NinjaTrader_RyanM is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loss of connection preventing any further signals from strategy JezzaNT Automated Trading 5 06-04-2012 01:56 PM
Orders outside market disabling strategy taotree Strategy Development 4 07-01-2011 01:57 PM
strategy disabling nicknamed Automated Trading 3 01-06-2011 06:41 AM
Disabling Strategy when closing position bstrader Version 7 Beta General Questions & Bug Reports 2 08-18-2010 06:39 AM
Hot keys query and disabling order placement confirmation window. Scooter1 Miscellaneous Support 1 02-02-2009 12:31 AM


All times are GMT -6. The time now is 10:19 AM.