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-08-2009, 05:38 AM   #1
tjendra
Senior Member
 
Join Date: Mar 2009
Posts: 220
Thanks: 0
Thanked 0 times in 0 posts
Default Enter at Close, Exit next day Close

I am backtesting a strategy on daily charts, whereby the entry would be on market close on the same day the signal is generated and the exit would be on the close of the next day.

However, during backtesting, the entry is on next day open and exit is on the day after next open, which are 1 day late.

How do I change the code such that it enter and exit the way I want it as describe in the first instance? Else my backtest results will be incorrect. Thanks.
tjendra is offline  
Reply With Quote
Old 04-08-2009, 06:07 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Hi tjendra, you would need to add a finer datastream for execution then to your daily chart. This reference sample will demonstrate how to achieve this - http://www.ninjatrader-support2.com/...ead.php?t=6652
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-08-2009, 10:05 AM   #3
tjendra
Senior Member
 
Join Date: Mar 2009
Posts: 220
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Hi tjendra, you would need to add a finer datastream for execution then to your daily chart. This reference sample will demonstrate how to achieve this - http://www.ninjatrader-support2.com/...ead.php?t=6652
Hi Bertrand, I tried following the example but can't get it work as expected. My strategy is pretty simple, go short at close of daily bar if there was 2 consecutive higher close, exit close of next daily bar. Go long at close of daily bar if there was 2 consecutive lower close, exit close of next daily bar.

I attached the graph which showed the intrabar entry and exit and also the output and source code of the strategy. The entry and exit shown on the graph is on the wrong bar and also doesn't tally with the output of the strategy.
Attached Images
File Type: jpg Intrabar.jpg (67.0 KB, 19 views)
Attached Files
File Type: txt Output2.txt (3.2 KB, 14 views)
File Type: zip ThreeBarStrategy.zip (975 Bytes, 18 views)
tjendra is offline  
Reply With Quote
Old 04-08-2009, 11:33 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Hi Tjendra, the code looks ok, with the faster series as the secondary to submit the orders to. I guess you're probably wondering about the display as the entry is displayed at the next bar but at the correct price from the last daily close. You can add a Print statement like
Code:
Print(Time[0].ToString())
to you EnterShort / EnterLong lines to match off the times with the Executions tab for review.
NinjaTrader_Bertrand 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
How to enter long/short on close of a candle? pbastowski Automated Trading 1 02-26-2009 02:59 PM
Exit on close starrynight Automated Trading 12 01-15-2009 05:59 AM
Exit On Close TraderGuy Strategy Development 15 01-07-2009 02:10 AM
Possible to enter/exit during the day with a daily strategy? cunparis Strategy Development 2 11-01-2008 02:58 AM
How to enter market on close order? cunparis Strategy Development 1 10-06-2008 08:17 AM


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