![]() |
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: Dec 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
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!! |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
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.
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Dec 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
|
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! |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |