NinjaTrader Support Forum  
X

Attention!

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


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 12-14-2008, 05:59 PM   #1
coolraz
Junior Member
 
Join Date: Dec 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
Default Enter on bars, exit on ticks and min bars requirment

I have some questions about exiting positions.

My position trades on x min bars, but I want to exit on Ticks. Right now, it waits until the end of the bar to close out the position IF the bar's close meets the exit criteria.
I set the CalculateOnBarClose = false; but that did not seem to do it.

The other question is about MinimumBars. So let's say I have it set to 10. When I run the backtest, it waits 10 bars. However, my startegy closes out at 4PM and starts trading again at 6PM. However when it starts trading again at 6PM, it doesn't wait anymore the 10 bars before going in, it trades immediately b/c it considers the bars before it as part of the required 10 bars. How do I set it so that every time it does "SessionBegins" it resets the amount of bars required that is has seen and will then have to wait for the 10 bars again.

Thanks for helping out a NT Scripting newbie!!
coolraz is offline  
Reply With Quote
Old 12-15-2008, 08:05 AM   #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,

My position trades on x min bars, but I want to exit on Ticks. Right now, it waits until the end of the bar to close out the position IF the bar's close meets the exit criteria.
I set the CalculateOnBarClose = false; but that did not seem to do it.

>>Are you backtesting? By default backtesting works on closed bar information only. To backtest using ticks see this link:
http://www.ninjatrader-support2.com/...ead.php?t=6652


The other question is about MinimumBars. So let's say I have it set to 10. When I run the backtest, it waits 10 bars. However, my startegy closes out at 4PM and starts trading again at 6PM. However when it starts trading again at 6PM, it doesn't wait anymore the 10 bars before going in, it trades immediately b/c it considers the bars before it as part of the required 10 bars. How do I set it so that every time it does "SessionBegins" it resets the amount of bars required that is has seen and will then have to wait for the 10 bars again.

>>The MinimumBars only comes into play when your SessionBegins. Your session begins times is set either on the chart (double click the chart>session begins and session ends) or in the strategy attachment properties (right click the Strategy tab>New Strategy>Session begins and ends. When your strategy starts working again at 6pm you will need to build in some logic to have it wait the 10 bars that you want then check for a signal.
NinjaTrader_Ben is offline  
Reply With Quote
Old 12-15-2008, 09:35 AM   #3
coolraz
Junior Member
 
Join Date: Dec 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
Default

Sounds good, I will build the granularity like you said with the code you described. From the sample code, I understand how you can TRADE on the 1 min bar rather than waiting for your primary bar to close.

However, is it possible to trade on the 1 min bar as soon as a condition is met where that condition can be met DURING your current primary bar (instead of waiting for that bar to close to see if the condition has bee met?)

What I mean is : If I want to say "if the current price is above the price of the last 30 min bar", can I accomplish this with the code you referenced?

Basically, when I use the function High[0], is that going to be updated constantly at every tick or will it only be calculated on the close of this bar?
In live trading, I think the answer is yes, however in backtesting, I presume the answer is no. Am I correct? Is there any way around this?

Thanks!
coolraz is offline  
Reply With Quote
Old 12-15-2008, 09:59 AM   #4
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

Not possible in backtesting. Reason is if you have the OHLC value of a bar that bar is closed. There is nothing more you can do once the bar is closed.
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
It seems to take 2 bars to Exit a position and then enter in opposite direction scjohn Strategy Development 1 11-06-2008 03:03 PM
Min bars required in a live strategy bluelou Strategy Development 5 08-25-2008 12:04 PM
Different prices on 3 min vs 15 second bars Uncas Miscellaneous Support 5 05-31-2008 02:09 PM
Min Bars required under strategy backtesting Sidhartha Strategy Development 4 04-08-2008 07:17 AM
Editing out bars/ticks - filtering spikes Drew Charting 1 05-16-2007 08:34 AM


All times are GMT -6. The time now is 01:50 AM.