NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 07-17-2008, 01:21 PM   #1
Ari Gold
Junior Member
 
Join Date: Jul 2008
Location: Bay Area, CA
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default ExitShort / ExitLong Not Exiting

I have my script entering with X quantity - if something happens, it exits X quantity, no problem.

If something else happens, it only exits x/2 quantity. OK, still no problem.

Then, when this same x/2 trigger happens again, it will not exit the other x/2 quantity and leave me flat. My output screen shows that the command was called, but NT does nothing. I tried calling an additional command ExitShort/Long() with no quantity mentioned - thinking I may have a problem with my variable, but it still doesn't execute. Something is blocking this order from being received by NT. Any thoughts?

If I let it continue to run, many bars later it will exit and re-enter at the same time. Weird.
Ari Gold is offline  
Reply With Quote
Old 07-17-2008, 01:29 PM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Please debug your strategy as per here to see what's going on: http://www.ninjatrader-support.com/v...ead.php?t=3627
NinjaTrader_Dierk is offline  
Reply With Quote
Old 07-17-2008, 01:52 PM   #3
Ari Gold
Junior Member
 
Join Date: Jul 2008
Location: Bay Area, CA
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for the help -

Here's my log:

Last Bar was Green
7/17/2008 12:47:00 PM Entered internal PlaceOrder() method at 7/17/2008 12:47:00 PM: Action=BuyToCover OrderType=Market Quantity=0.1M LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
7/17/2008 12:47:00 PM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=100000 LimitPrice=0 StopPrice=0 SignalName=Buy to cover' FromEntrySignal='' Reason='There already is a matching, terminal exit order in place'
Getting out Short SH
106.68
2nd Short SH, all out
7/17/2008 12:47:00 PM Entered internal PlaceOrder() method at 7/17/2008 12:47:00 PM: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
7/17/2008 12:47:00 PM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName=Buy to cover' FromEntrySignal='' Reason='There already is a matching, terminal exit order in place'
106.68

The first try was my original code, and the second was the extra code I added. Looks like they are both working, but I don't understand the reason why it won't be executed. There are no pending orders listed in the control center and I did not code any other weird exits.
Ari Gold is offline  
Reply With Quote
Old 07-17-2008, 01:54 PM   #4
Ari Gold
Junior Member
 
Join Date: Jul 2008
Location: Bay Area, CA
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

Later, it does get out, but only when my script is telling it to re-buy. Here is the log.

7/17/2008 12:51:44 PM Entered internal PlaceOrder() method at 7/17/2008 12:51:44 PM: Action=Buy OrderType=Market Quantity=0.2M LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
Got in Long, x = 0
106.72
106.68
7/17/2008 12:52:00 PM
7/17/2008 12:51:45 PM Cancelled remaining exit order: Order='52f9779e65dc4bacb4bfbd664f5366c2/Sim101' Name='Close position' State=Filled Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=0 Quantity=0.1M Strategy='Pipper' Type=Market Tif=Gtc Oco='' Filled=100000 Fill price=106.72 Token='52f9779e65dc4bacb4bfbd664f5366c2' Gtd='12/1/2099 12:00:00 AM'
7/17/2008 12:51:45 PM Cancelled remaining exit order: Order='f511e7f0a30d4f5aa9cb9174fb1a5e81/Sim101' Name='Buy to cover' State=Filled Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=0 Quantity=0.1M Strategy='Pipper' Type=Market Tif=Gtc Oco='' Filled=100000 Fill price=106.7 Token='f511e7f0a30d4f5aa9cb9174fb1a5e81' Gtd='12/1/2099 12:00:00 AM'
FirstTick
Ari Gold is offline  
Reply With Quote
Old 07-17-2008, 02:49 PM   #5
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

See near bottom of page "Internal Order Handling...."

http://www.ninjatrader-support.com/H...verview36.html
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-17-2008, 03:04 PM   #6
Ari Gold
Junior Member
 
Join Date: Jul 2008
Location: Bay Area, CA
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

All my orders are market orders and I do not have any Set commands, no stop losses, so the internal order handling rules don't seem applicable.

It seems there are hidden pending orders somewhere - how can I see where they are so that I can track where they came from?
Ari Gold is offline  
Reply With Quote
Old 07-17-2008, 03:23 PM   #7
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Will come back to you.
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-17-2008, 11:49 PM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Hi Ari Gold,

The solution is to use two uniquely named entry signals. You would use a blank fromEntrySignal parameter if you wish to exit the whole position or you can call the various signal names to exit in portions.
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-19-2008, 12:29 AM   #9
Ari Gold
Junior Member
 
Join Date: Jul 2008
Location: Bay Area, CA
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank You Josh!

Looks like it's fixed - now to try it on real data next week...
Ari Gold 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
ExitLong ignoring condition verge Strategy Development 2 05-13-2008 07:28 AM
ExitShort() / ExitLong() andrewbee General Programming 1 02-06-2008 10:57 AM
ExitLong() is being “skipped” CashCache Strategy Development 2 01-28-2008 05:43 PM
Closing a forex position with ExitLong() henry.omd Strategy Development 2 01-05-2008 12:31 PM
ExitLong and ExitShort mazachan Strategy Development 3 07-30-2007 03:15 PM


All times are GMT -6. The time now is 06:24 PM.