![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Apr 2011
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
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! |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Apr 2011
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Apr 2011
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
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! |
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
Hello,
Glad you where able to find this that works for you! Let me know if I can be of further assistance.
Brett
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |