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 07-06-2010, 07:18 PM   #1
Palance
Junior Member
 
Join Date: Mar 2010
Location: United States
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default Multi timeframe indicators

My first post -- great product and a great forum.

I'm testing some strats in Strategy Analyzer and liking these tools -- very nice. I am testing a daily/weekly strat. I would like to know if there is a way to get the value of the higher timeframe indicator as though it were calculated through the current bar of the lower time frame.

For example, I'm handling a Thursday daily bar, but the Stoch weekly value is four days out of date. Might there be some way to get a value for the weekly Stoch as though its last data point were the current daily bar? (And all previous values were the normal weekly values).

I realize that I could code this myself, but that can get to be a bit of work to do for many indicators. Stoch is not the only indicator I use.

I realize that CalculateOnBarClose is always true for backtesting.

Any ideas or suggestions would be appreciated.

Lew
Palance is offline  
Reply With Quote
Old 07-06-2010, 08:18 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Palance,

Welcome to the NinjaTrader forums!

When using version 6.5, the secondary series should be smaller than the primary series.

You would run the strategy against a weekly series and then add a daily series.

You define the context you're working from with BarsInProgress.

Example:

if (BarsInProgress == 1) //Refers to OnBarUpdate calls to the daily series
myDouble = Closes[0][0]; //Captures the value of the primary series into a variable.

This reference sample helps demonstrate the sequence of OnBarUpdate() calls in a multi-series strategy.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 07-06-2010, 10:49 PM   #3
Palance
Junior Member
 
Join Date: Mar 2010
Location: United States
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

Ryan, thanks much for the welcome and for the quick reply.

Interesting rule re making the highest time frame be the primary series -- I'll follow that. (And yes, I'm using 6.5).

But my entry conditions are mostly on the lower time frame object. So it can easily occur that several lower time frame bars beyond the higher time frame point have elapsed and thus that the higher time frame indicator value is that much out of date, at least until a new higher time frame bar completes.

So the weekly Stoch, for example, is completely current over the weekend, one day out of date after Monday, two days out of date after Tuesday, etc. And if my entry condition occurs on Thursday, I would like to have a "current" weekly Stoch that includes the current partial week.

Just wondering if there's a way to get this without coding it myself.

Lew
Palance is offline  
Reply With Quote
Old 07-07-2010, 09:19 AM   #4
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

Lew, when running the strategy real-time, you can set CalculateOnBarClose = false and then whenever you retrieve the weekly value, it would be current up to the most recent tick. The reference sample Ryan posted also goes over how to backtest with an intrabar granularity, and you could tweak it to your liking.

It would also be possible to construct a "fake" weekly series through DataSeries objects and then run whatever calculations you'd like on that series, although the specifics of such an implementation would be up to you.

Here are the applicable links:
Using a DataSeries object to store calculations
Synchronizing a DataSeries object to a secondary time frame
NinjaTrader_Austin is offline  
Reply With Quote
Old 07-07-2010, 09:54 AM   #5
Palance
Junior Member
 
Join Date: Mar 2010
Location: United States
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

OK. Thank you both very much. The Data Series objects may be a good way to go, at least for backtesting. I appreciate the help.

Lew
Palance 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
Multi-timeframe strategy skips lower timeframe bars at one point adamus Version 7 Beta General Questions & Bug Reports 13 07-03-2010 01:36 AM
Multi timeframe strategy calling indicators with drawn objects Shansen Strategy Development 4 05-31-2010 12:55 PM
Multi-timeframe indicators sbgtrading Version 7 Beta General Questions & Bug Reports 1 10-09-2009 07:40 AM
Multi-timeframe Moving Average indicators sbgtrading Indicator Development 1 02-11-2009 12:42 PM
master list of do-not-use indicators in multi-timeframe strategies sysimp Strategy Development 1 07-07-2008 12:52 AM


All times are GMT -6. The time now is 02:23 AM.