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 07-03-2009, 01:28 PM   #1
boulbi
Junior Member
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default Close ATM strategy in priority to stop loss generated by AtmStrategyCreate

Quote:
// Condition set 1
if (orderId.Length == 0 && atmStrategyId.Length == 0 && CrossAbove(Close[1]etc.))
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Buy, OrderType.Limit, 0, 0, TimeInForce.Day, orderId, "MY-ATM", atmStrategyId);
}
So i have a stop on my Dom with that code.

But if i want to put another priority condition > to my stop loss generated on the Dom to close my strategy, do i have to put :

Quote:
// Condition set 2
if (Close[1] < MyIndicator(...))
{
AtmStrategyClose("idValue");
Is that right, or i need to add another code ?

thanks
boulbi is offline  
Reply With Quote
Old 07-03-2009, 03:21 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

That will indeed close the active ATM strategy, but you need to use proper AtmStrategyId in that parameter.
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-04-2009, 12:09 AM   #3
boulbi
Junior Member
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Josh,

But how can i get previous AtmStrategyId from previous "AtmStrategyCreate" and put in AtmStrategyClose("HERE");?

Thanks for your help !
boulbi is offline  
Reply With Quote
Old 07-04-2009, 01:34 PM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Quote:
Originally Posted by boulbi View Post
Thanks Josh,

But how can i get previous AtmStrategyId from previous "AtmStrategyCreate" and put in AtmStrategyClose("HERE");?

Thanks for your help !
When you call the ...Create() method, you pass in an id value thus you would need to hold onto this value in your script. Create a variable outside of OnBarUpdate() in the "variables" section. Check out the SampleAtmStrategy, it does exactly this.
NinjaTrader_Ray 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
Going from a Stop Loss to a Trailing Stop within a strategy Sidhartha Strategy Development 28 03-24-2009 03:11 PM
Strategy stop loss junkone Strategy Development 6 12-11-2008 10:32 AM
Atm strategy/ stop priority nico_p Strategy Development 5 04-18-2008 12:56 AM
Sample ATM strategy resets on position close tecmisc1 Strategy Development 1 04-10-2008 09:08 AM
ATM strat with stop loss and target order Angel ATM Strategies (Discretionary Trading) 5 11-08-2007 09:44 AM


All times are GMT -6. The time now is 07:45 PM.