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 10-19-2009, 11:42 AM   #1
Trade1953
Member
 
Join Date: Feb 2008
Location: Wellsville, Ut
Posts: 81
Thanks: 0
Thanked 0 times in 0 posts
Default MultiTimeFrame CalcOnBarClose

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
Trade1953 is offline  
Reply With Quote
Old 10-19-2009, 11:45 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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).
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-19-2009, 12:03 PM   #3
Trade1953
Member
 
Join Date: Feb 2008
Location: Wellsville, Ut
Posts: 81
Thanks: 0
Thanked 0 times in 0 posts
Default

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
Trade1953 is offline  
Reply With Quote
Old 10-19-2009, 12:15 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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].
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-19-2009, 10:54 PM   #5
Trade1953
Member
 
Join Date: Feb 2008
Location: Wellsville, Ut
Posts: 81
Thanks: 0
Thanked 0 times in 0 posts
Default

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
Trade1953 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
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


All times are GMT -6. The time now is 11:59 AM.