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 05-15-2011, 12:40 PM   #1
neuro_doc
Junior Member
 
Join Date: Apr 2011
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default Enter On Next Open, Exit at Session End

I am having some difficulty setting up a strategy that will:
a. Enter on Open of Bar.
b. Exit at Close of Bar.

A code snippet of how to accomplish this within a strategy would be greatly appreciated.
Thanks!
neuro_doc is offline  
Reply With Quote
Old 05-15-2011, 07:05 PM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

This is only possible in realtime with NinjaTrader. As indicators and strategy only calculate on the close of the bar so it is not possible to open a new position until the the bar closes on each bar. This is for historical processing and backtesting.

You can however run an indicator or strategy with calculate on bar close = false in the parameters and this will run on every tick incomming into NinjaTrader. In which case you would use FirstTickOfBar to do this live.

http://www.ninjatrader.com/support/h...ttickofbar.htm
NinjaTrader_Brett is offline  
Reply With Quote
Old 05-15-2011, 07:20 PM   #3
neuro_doc
Junior Member
 
Join Date: Apr 2011
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Here is the problem in more detail:
1. At market close, calculate a signal.
2. On market open the next day, enter at market order.
3. That same day, if stop has not been triggered, close the position at 4:00. Repeat.

O--------C--------O--------C
----------(1)-------(2)------(3)

The backtesting system is not showing the entry until the Close of the NEXT bar, which is way too late.
O--------C--------O--------C--------O--------C
----------(1)-----------------(2)-----------------(3)
This is completely not what I need. I need for the trade to be in force for a maximum of one day, and to enter on the opening value of the upcoming trade session. How can I make this happen?
Thanks!
Last edited by neuro_doc; 05-15-2011 at 07:23 PM.
neuro_doc is offline  
Reply With Quote
Old 05-15-2011, 07:52 PM   #4
neuro_doc
Junior Member
 
Join Date: Apr 2011
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

I have found something which will very closely approximate what I am looking for of being able to enter on the next open in backtesting...

http://www.ninjatrader.com/support/f...ead.php?t=6652

The example download file does cover this, so it is definitely possible within NT.

Thanks!
neuro_doc is offline  
Reply With Quote
Old 05-15-2011, 08:16 PM   #5
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Glad you where able to find this that works for you!

Let me know if I can be of further assistance.
NinjaTrader_Brett 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
Enter at Session Open upshon Strategy Development 1 01-03-2011 04:00 AM
How to enter on the open and exit on the close of a bar brooksrimes Strategy Development 5 07-07-2010 12:28 PM
Strategy won't exit at end of session dancorcal Automated Trading 3 01-13-2010 02:18 PM
Enter trade at open and exit trade at close d.allen101 Strategy Development 3 11-11-2009 10:02 AM
Exit at close and enter at open Andy_Mil Strategy Development 5 06-24-2009 12:17 PM


All times are GMT -6. The time now is 12:13 AM.