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 04-18-2010, 07:11 AM   #1
MJUK05
Junior Member
 
Join Date: Feb 2010
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
Default Protective Stop Orders Not Being Sent

Would someone be able to suggest to me why my stop orders are not being placed when I execute a long position please? The stop orders are working fine when a short position is executed and the code - as far as i can see - is identical.

entryOrderL/entryOrderS are the IO entry order tags for Long and Short positions respectivel
stopOrderL/stopOrderS are the protective stop orders for long and short position respectively
StopLevelL/StopLevelS are doubles that store specific price levels to enter the protective stop order and are stored when the entry signal is triggered.

Any suggestions would be much appreciated.

Mark

Quote:

protected override void OnExecution(IExecution execution)
{


// Long Execution Stop
if (entryOrderL != null && entryOrderL.Token == execution.Order.Token)
{

if (execution.Order.OrderState == OrderState.Filled)
{
// Long Stop at low of signal
stopOrderL = ExitLongStop(0, true, 1, StoplevelL, "stop", "long entry");


// Resets the entryOrder object to null after the order has been filled
if (execution.Order.OrderState != OrderState.PartFilled)
{
entryOrderL = null;
}
}
}


// Short execution stop
if (entryOrderS != null && entryOrderS.Token == execution.Order.Token)
{

if (execution.Order.OrderState == OrderState.Filled)
{


// Short Stop
stopOrderS = ExitShortStop(0, true, 1, StoplevelS, "stop", "Short entry");

if (execution.Order.OrderState != OrderState.PartFilled)
{
entryOrderS = null;
}
}
MJUK05 is offline  
Reply With Quote
Old 04-18-2010, 07:28 AM   #2
Sleeping Troll
Senior Member
 
Join Date: Mar 2010
Location: Tampa, FL
Posts: 186
Thanks: 0
Thanked 3 times in 1 post
Send a message via Yahoo to Sleeping Troll
Default

Check your code where you set StoplevelL.
Sleeping Troll is offline  
Reply With Quote
Old 04-18-2010, 07:46 AM   #3
MJUK05
Junior Member
 
Join Date: Feb 2010
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi

Thanks. I had checked and it seems fine.

Quote:

{
entryOrderL = EnterLongStop(0, true, 1, High[0] + 5 * TickSize, "Long entry");
StoplevelL = MIN ((Low), 2)[0] - (5 * TickSize);
}

{
entryOrderS = EnterShortStop(0, true, 1, Low[0] - 5 * TickSize, "Short entry");
StoplevelS = MAX ((High), 2)[0] + (5 * TickSize);
}
The wierd thing is I set up the long side first and it was working fine. I then set-up the short side by using the same code and swapping things around and now only short side works! Puzzling....
MJUK05 is offline  
Reply With Quote
Old 04-18-2010, 07:48 AM   #4
Sleeping Troll
Senior Member
 
Join Date: Mar 2010
Location: Tampa, FL
Posts: 186
Thanks: 0
Thanked 3 times in 1 post
Send a message via Yahoo to Sleeping Troll
Default

Sounds like your short is cancelling your long.
Sleeping Troll is offline  
Reply With Quote
Old 04-18-2010, 12:19 PM   #5
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

MJUK05, please set TraceOrders = true in the Initialize() section to see why orders are not being sent or are being canceled.
NinjaTrader_Austin is offline  
Reply With Quote
Old 04-18-2010, 12:23 PM   #6
james377
Member
 
Join Date: May 2009
Posts: 60
Thanks: 0
Thanked 0 times in 0 posts
Default wont compile thread

Hello ninja trader austin i was wondering if you could take a look at my wont compile thread to tell me what I am doing wrong? many thanks James
james377 is offline  
Reply With Quote
Old 04-18-2010, 12:25 PM   #7
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

James, I am currently wading my way through all the support tickets. Since yours is the most recent, I will get there last. We look at all threads, so asking us to look at your thread isn't necessary.

EDIT: I now see you have multiple tickets open. I'll answer them as I get to them.
NinjaTrader_Austin is offline  
Reply With Quote
Old 04-18-2010, 12:27 PM   #8
james377
Member
 
Join Date: May 2009
Posts: 60
Thanks: 0
Thanked 0 times in 0 posts
Default many thanks!

Thanks for the reply Austin,

I am new to this area so I am keen to learn! Speak to you soon!

James
james377 is offline  
Reply With Quote
Old 04-18-2010, 01:23 PM   #9
MJUK05
Junior Member
 
Join Date: Feb 2010
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by Sleeping Troll View Post
Sounds like your short is cancelling your long.

I don't think so. I did not post it as it appears in the strategy. I just cut both snippets of code. They both have different IF entry criteria i.e. entryOrder(short or long) != null so should be working at different times.

Austin - thanks i'll give it a go.

Cheers

Mark
MJUK05 is offline  
Reply With Quote
Old 04-19-2010, 03:24 AM   #10
AnotherTrader
Senior Member
 
Join Date: Aug 2009
Posts: 266
Thanks: 41
Thanked 8 times in 8 posts
Send a message via ICQ to AnotherTrader
Default

In one place you use lower case to label the signal (i.e. "long entry"):

Code:
stopOrderL = ExitLongStop(0, true, 1, StoplevelL, "stop", "long entry");

In the other, you use upper case (i.e. "Long entry"):

Code:
entryOrderL = EnterLongStop(0, true, 1, High[0] + 5 * TickSize, "Long entry");
Try making the two consistent.
AnotherTrader is offline  
Reply With Quote
Old 04-25-2010, 08:08 AM   #11
MJUK10
Senior Member
 
Join Date: Dec 2009
Posts: 102
Thanks: 4
Thanked 0 times in 0 posts
Default

Anothertrader

Thanks - good spot.

Now the shorts don't trigger but the longs are working as they should.

On to solving the next problem!

Cheers

Mark
MJUK10 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
Chart Trading with Buy Stop/ Sell Stop orders tschalli27 Charting 3 10-20-2009 03:35 PM
Strategy: Using OnOrderUpdate() and OnExecution() methods to submit protective orders NinjaTrader_Josh Reference Samples 0 05-08-2008 01:42 AM
Order Entry Property: Use stop market for stop loss orders higler SuperDOM and other Order Entry Windows 7 07-02-2007 09:06 AM
Stop Loss Orders activated by number of trades past stop level DoveforUsAll Suggestions And Feedback 1 02-08-2006 01:19 AM
Targets - Stop Orders or Stop Limit Orders? Nereus ATM Strategies (Discretionary Trading) 3 05-31-2005 07:13 AM


All times are GMT -6. The time now is 08:40 AM.