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 03-14-2010, 01:05 PM   #1
tonyh
Member
 
Join Date: Oct 2007
Location: Florida
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Default SampleIntrabarBacktest - Premataure Exit at close of the day the trade was entered

Hello:
I am using the above Sample Education Resource within my strategy, which adds a 1 minute secondary bar series to fill orders. The strategy enters the trade correctly, but exits the trade at the end of the day without hitting either the stop loss or profit target. I did replace my strategy code with an EMA crossover to see if my code was causing this problem, but I got the same result. Can you give me some hint on what direction to take to handle this problem? Thanks.
tonyh is offline  
Reply With Quote
Old 03-14-2010, 06:38 PM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

You can change that in tools>options>Strategies>NinjaScript and uncheck the check box at the bottom.
NinjaTrader_Ben is offline  
Reply With Quote
Old 03-15-2010, 06:30 AM   #3
tonyh
Member
 
Join Date: Oct 2007
Location: Florida
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Default SampleIntrabarBacktest - Premature trade exit at end of day

Hello:

Under "Order Handling", I unchecked the "cancel strategy orders on strategy termination" box and each existing order still exits on the close of the day the trade was entered.

The "Stop and target submission" is currently set to "Per entry execution". Should it be set to "By strategy position"? Just grasping at straws. Thanks.
tonyh is offline  
Reply With Quote
Old 03-15-2010, 10:48 AM   #4
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

Hello Tonyh,

You can set "Exit on Close" to false whenever you apply the strategy.
You can also declare this in code:

ExitOnClose = false;

http://www.ninjatrader-support.com/H...itOnClose.html
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-15-2010, 11:11 AM   #5
tonyh
Member
 
Join Date: Oct 2007
Location: Florida
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Default SampleIntrabarBacktest - ExitOnClose = false;

Hello Ryan:

This also doesn't work. If no other suggestions are available, I guess I will create a new strategy with my trading code and gradually add the SampleIntrabarBacktest code to see where the problem is. As I like the idea of trading on the 1 minute bar data. Thanks.
tonyh is offline  
Reply With Quote
Old 03-15-2010, 11:30 AM   #6
tonyh
Member
 
Join Date: Oct 2007
Location: Florida
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Default SampleIntrabarBacktest - ExitOnClose = false; - Does it work in Strategy Analyzer?

Hello Ryan:

I kept the above code, added your change and added a small trading algorithm, and it works on a chart. However, when running the code on "Strategy Analyzer" it still exits at the close of each day. Is this code able to work in Strategy Analyzer? Thanks.
tonyh is offline  
Reply With Quote
Old 03-15-2010, 11:31 AM   #7
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

You can set this setting in the strategy analyzer. Select False on this setting when backtesting.
Attached Images
File Type: gif exitonCloseSA.png (37.0 KB, 8 views)
Last edited by NinjaTrader_RyanM; 03-15-2010 at 11:38 AM. Reason: replies crossed
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-15-2010, 02:33 PM   #8
tonyh
Member
 
Join Date: Oct 2007
Location: Florida
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Red face SampleIntrabarTest - ExitOnClose = false; - Strategy Analyzer

Thanks Ryan:

It works perfectly. I assumed that the ExitOnClose would be set to false with the code. I now fully know what "assume" means.
tonyh 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
Working with "Trade Class" on a day-by-day basis AnotherTrader Automated Trading 2 01-22-2010 07:45 AM
Enter trade at open and exit trade at close d.allen101 Strategy Development 3 11-11-2009 10:02 AM
Exit-on-close handling initiated after market close tooearly Automated Trading 3 08-05-2009 08:07 AM
Enter at Close, Exit next day Close tjendra Strategy Development 3 04-08-2009 11:33 AM
Possible to enter/exit during the day with a daily strategy? cunparis Strategy Development 2 11-01-2008 02:58 AM


All times are GMT -6. The time now is 06:48 AM.