NinjaTrader Support Forum  

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-22-2008, 01:38 PM   #1
wayneFH
Senior Member
 
Join Date: Mar 2008
Posts: 105
Thanks: 0
Thanked 0 times in 0 posts
Default Exit on Close exited 30 Minutes Early (instead of 30 secs)

The Exit on Close seems to work fine in historical testing.

Today was the first time my automated strategy was able to run on its own after resolving hosting and port problems, etc.

Well, it was in a winning short trade on USD/JPY from arount 10 AM EST and exited at 11:30 AM EST with an "Exit on close" signal.

HOWEVER, the session on the chart is setup at 6:00 AM to start and 12:00 PM to end.

The strategy is set to exit on close with "Exit on close seconds" set to 30.

This is on NT 6.5 (prod version).

Is it possible that the strategy exits 30 minutes early instead of 30 seconds when running real time?

Could this be a bug?

Maybe I have to disable "Exit on Close" and create my own exit on close code in the strategy.

Please advise.

- Wayne
wayneFH is offline  
Reply With Quote
Old 04-22-2008, 01:58 PM   #2
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

In the log tab can you confirm that the order to close the position was triggered by Exit On Close? What time did this log fire, exactly at 11:30?
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-22-2008, 02:28 PM   #3
wayneFH
Senior Member
 
Join Date: Mar 2008
Posts: 105
Thanks: 0
Thanked 0 times in 0 posts
Default

Here are the last entries in the log in reverse order.

Please advise.

Code:
4/22/2008 11:34:52 AM,Order,Order='0xk0101:0f75/E5568100' Name='Exit on close' New State=Filled Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1,000 Type=Market Filled=1000 Fill price=103.079 Error=NoError Native error='',
4/22/2008 11:34:52 AM,Execution,Execution='NT_20080422_0171' Instrument='$USDJPY' Account='E5568100' Exchange=Default Price=103.079 Quantity=1,000 Market position=Long Operation=Insert Order='0xk0101:0f75' Time='4/22/2008 11:34:52 AM' Multiplier=0.001 Rate=0.00970214417386242,
4/22/2008 11:34:52 AM,Position,Instrument='$USDJPY' Account='E5568100' Avg price=103.21 Quantity=1,000 Market position=Short Operation=Remove Currency=UsDollar,
4/22/2008 11:34:52 AM,Order,Order='0xk0101:0f75/E5568100' Name='Exit on close' New State=Working Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1,000 Type=Market Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:34:52 AM,Order,Order='0xk0101:0eak/E5568100' Name='Profit target' New State=Cancelled Instrument='$USDJPY' Action=BuyToCover Limit price=102.51 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:34:51 AM,Order,Order='0xk0101:0eaj/E5568100' Name='Stop loss' New State=Cancelled Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=103.19 Quantity=1,000 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:34:51 AM,Order,Order='0xk0101:0f75/E5568100' Name='Exit on close' New State=Accepted Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1,000 Type=Market Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:34:51 AM,Order,Order='2f2818f-greaterreturn-34/E5568100' Name='Exit on close' New State=PendingSubmit Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1,000 Type=Market Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:34:51 AM,Order,Order='0xk0101:0eak/E5568100' Name='Profit target' New State=PendingCancel Instrument='$USDJPY' Action=BuyToCover Limit price=102.51 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:34:51 AM,Strategy,Exit on close handling for strategy 'ProbabilityEMA' started.,
4/22/2008 11:34:51 AM,Order,Order='0xk0101:0eaj/E5568100' Name='Stop loss' New State=PendingCancel Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=103.19 Quantity=1,000 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:07:59 AM,Order,Order='0xk0101:0eaj/E5568100' Name='Stop loss' New State=Accepted Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=103.19 Quantity=1,000 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 11:07:59 AM,Order,Order='0xk0101:0eaj/E5568100' Name='Stop loss' New State=PendingChange Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=103.19 Quantity=1,000 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:20 AM,Order,Order='0xk0101:0eak/E5568100' Name='Profit target' New State=Working Instrument='$USDJPY' Action=BuyToCover Limit price=102.51 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:19 AM,Order,Order='0xk0101:0eak/E5568100' Name='Profit target' New State=Accepted Instrument='$USDJPY' Action=BuyToCover Limit price=102.51 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:19 AM,Order,Order='0xk0101:0eaj/E5568100' Name='Stop loss' New State=Accepted Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=103.26 Quantity=1,000 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:19 AM,Execution,Execution='NT_20080422_0153' Instrument='$USDJPY' Account='E5568100' Exchange=Default Price=103.21 Quantity=1,000 Market position=Short Operation=Insert Order='0xk0101:0eah' Time='4/22/2008 10:54:19 AM' Multiplier=0.001 Rate=0.00968898362561767,
4/22/2008 10:54:19 AM,Order,Order='0xk0101:0eah/E5568100' Name='cross low' New State=Filled Instrument='$USDJPY' Action=SellShort Limit price=103.2 Stop price=0 Quantity=1,000 Type=Limit Filled=1000 Fill price=103.21 Error=NoError Native error='',
4/22/2008 10:54:19 AM,Order,Order='2f2818f-greaterreturn-30/E5568100' Name='Profit target' New State=PendingSubmit Instrument='$USDJPY' Action=BuyToCover Limit price=102.51 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:19 AM,Order,Order='2f2818f-greaterreturn-2f/E5568100' Name='Stop loss' New State=PendingSubmit Instrument='$USDJPY' Action=BuyToCover Limit price=0 Stop price=103.26 Quantity=1,000 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:19 AM,Position,Instrument='$USDJPY' Account='E5568100' Avg price=103.21 Quantity=1,000 Market position=Short Operation=Insert Currency=UsDollar,
4/22/2008 10:54:19 AM,Order,Order='0xk0101:0eah/E5568100' Name='cross low' New State=Working Instrument='$USDJPY' Action=SellShort Limit price=103.2 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:19 AM,Order,Order='0xk0101:0eah/E5568100' Name='cross low' New State=Accepted Instrument='$USDJPY' Action=SellShort Limit price=103.2 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:54:18 AM,Order,Order='2f2818f-greaterreturn-2e/E5568100' Name='cross low' New State=PendingSubmit Instrument='$USDJPY' Action=SellShort Limit price=103.2 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:46:45 AM,Order,Order='0xk0101:0du2/E5568100' Name='Profit target' New State=Cancelled Instrument='$USDJPY' Action=Sell Limit price=103.75 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:46:44 AM,Order,Order='0xk0101:0du1/E5568100' Name='Stop loss' New State=Filled Instrument='$USDJPY' Action=Sell Limit price=0 Stop price=103 Quantity=1,000 Type=Stop Filled=1000 Fill price=103 Error=NoError Native error='',
4/22/2008 10:46:44 AM,Order,Order='0xk0101:0du2/E5568100' Name='Profit target' New State=PendingCancel Instrument='$USDJPY' Action=Sell Limit price=103.75 Stop price=0 Quantity=1,000 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='',
4/22/2008 10:46:44 AM,Execution,Execution='NT_20080422_0147' Instrument='$USDJPY' Account='E5568100' Exchange=Default Price=103 Quantity=1,000 Market position=Short Operation=Insert Order='0xk0101:0du1' Time='4/22/2008 10:46:44 AM' Multiplier=0.001 Rate=0.00970968055150986,
4/22/2008 10:46:44 AM,Position,Instrument='$USDJPY' Account='E5568100' Avg price=103.046 Quantity=1,000 Market position=Long Operation=Remove Currency=UsDollar,
wayneFH is offline  
Reply With Quote
Old 04-22-2008, 02:49 PM   #4
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

The logs would not indicate 30 minutes early since the time stamp would then be 11:30:XX and not 11:34XX.

Can you double check that you have not hard coded some setting in your strategy for exit on close that would override the default setting of 30 seconds?
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-22-2008, 09:33 PM   #5
wayneFH
Senior Member
 
Join Date: Mar 2008
Posts: 105
Thanks: 0
Thanked 0 times in 0 posts
Default

I searched by "exit" and "close" and there's nothing related to "exit on close" in my script.

Based on the help, there's two related properties. ExitOnClose and ExitOnCloseSeconds. But my strategy never refers to them. What else could possibly create this bizarre behavior?

It must be running off of the defaults.

Sincerely,
Wayne
wayneFH is offline  
Reply With Quote
Old 04-23-2008, 01:45 AM   #6
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

Hmm. This is quite an odd case. Do you mind emailing me your strategy so I can test it out on my end? Thanks. josh[at] ninjatrader dot com
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-28-2008, 04:52 AM   #7
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 wayneFH,

I've examined your strategy for a bit and was not able to find anything. The only thing that strikes me is that you basically rewrote all the entry methods with your own helper methods. I would put my suspicions around that area. Unfortunately this is beyond the scope of support we can offer. Please try testing for yourself the SampleMACrossOver strategy for ExitOnClose functionality. You should find that it works as expected.
NinjaTrader_Josh 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
Time to flatten vs. Exit on close dtf139 Automated Trading 1 01-11-2008 07:11 AM
Exit On Close doesn't work fine MrBaffalo General Programming 6 11-30-2007 06:18 AM
Get a stop condition to exit/close all mutiple entrys scjohn Strategy Development 4 09-13-2007 02:59 PM
Profit Targets & 'Exit on Close' dgregor5 General Programming 2 07-15-2007 01:35 PM
Exit on Close Displays Negative Price KBJ Strategy Analyzer 4 04-20-2007 05:10 AM


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