![]() |
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 |
|
Member
Join Date: Feb 2008
Location: Wellsville, Ut
Posts: 81
Thanks: 0
Thanked 0 times in 0 posts
|
Hey Everybody,
When using MultiTimeFrame charts in a strategy, is it possible to set CalculateOnBarClose = true on one and CalculateOnBarClose = false on the other? I've searched Help and the Forum and can't find the answer. The second chart (index 1) is exactly the same as the primary (index 0). Both are 10 Range. When the primary is in CalcOnBarClose = false, I want the index 1 chart to stay in CalcOnBarClose = true. So, when a condition happens on the index 1 chart (COBC = true), I want the primary chart (COBC = false) to see that and take action. Is it even possible to have one chart processing tic by tic and the other processing bar by bar in the same strategy? I've tried all kinds of things, but the strat will always run on one or the other. Thanks, Joe |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
No, processing of the script is all or nothing for CalculateOnBarClose. It will either be all true or all false. If you want to mimic some true and some false, you need to set it to false and duplicate the true logic by filtering out all the intrabar processing with if (FirstTickOfBar).
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Feb 2008
Location: Wellsville, Ut
Posts: 81
Thanks: 0
Thanked 0 times in 0 posts
|
OK, that's what I kind of suspected. I thought about FirstTickOfBar but it won't work since I need to know whether the last Range Bar closed higher or lower than it opened.
Thanks for the speedy reply! Joe |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
The closing event of a bar is the same event as the opening of the next bar. So you can use if (FirstTickOfBar) and then back reference the indexes by 1 to access the just closed bar. So use [1].
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Feb 2008
Location: Wellsville, Ut
Posts: 81
Thanks: 0
Thanked 0 times in 0 posts
|
Josh,
My situation was a little more complicated since the strat doesn't go into CalcOnBarClose = false until it gets a setup and places the trade. However, your suggestion gave me a great idea. I just set a variable = Close of the setup bar (tradeprice. while COBC = true). COBC is immediately set to COBC = false as soon as the trade is placed. Then I set another variable at FirstTickOfBar (while COBC = false), then compare the 2 on the next tic. That tells me if the bar after the entry bar has a Close > Open or Close < Open. It may be off a tic at times due to an opening tic gap, but it works GREAT and does exactly what it's needed for! Thanks for the suggestion!!! Joe |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting stopped on same bar (CalcOnBarClose = True) | BigDog008 | Strategy Development | 14 | 07-13-2009 10:10 AM |
| MultiTimeframe Dataseries smoothing | jrs | Strategy Development | 3 | 02-14-2009 09:55 AM |
| BarsSinceEntry in MultiTimeFrame | zark.be | Strategy Development | 1 | 01-16-2009 07:12 AM |
| Multitimeframe strategy | julen | Strategy Development | 5 | 10-09-2008 03:25 AM |
| MultiTimeframe syntax | nico_p | General Programming | 6 | 04-29-2008 08:59 AM |