View Full Version : Multiple Timeframes
Gumphrie
09-01-2007, 05:31 PM
I was doing some work on C# Arraylists recently and it occurred to me that if I combined that with the Candle Clear code I'd written previously I could get NT to display multiple timeframes on one chart!
What I've ended up with works on all time based timeframes (except Monhtly and Yearly), as well as tick and volume timeframes. It also works for all chart types (Candlestick, OHLC, HiLoBars and LineOnClose). Theres also been a lot done to optimise the efficiency of the code, so it produces little overhead in terms of cpu usage.
http://www.acuclick.net/MTF.jpg
The above screenshot shows Multiple Timeframes (MTF) added 3 times with different options applied. The first MTF is given a Multiplier input of 2 (the default) which creates a 2 minute panel (because we started off with a 1 minute chart), I've then applied the embedded "Scalper style" option which gives the same results as the Scalper indicator would on a 2 minute chart. The second MTF I've created a 5 minute panel and applied the embedded ModHeikenAshi option. The third MTF I've created a 15 minute panel and applied the Candle scale option to produce larger candles.
http://www.acuclick.net/MTF-Properties.jpg
Above is a screenshot of the properties options all set to default. Notice that by default we take on the Plot type, such as "CandleStick", "OHLC" and the up/down colours directly from the Chart's existing defaults, but we can if we want use the override options to create mixed charts. There is no limit in terms of applying all the options at once, etc..
For those TTM fans I've attached another screenshot with the bars set in a TTM / OHLC manner with both Scalper and ModHeikenAshi stype options applied. The Scalper and ModHeikenAshi implementations are exactly the same as in the standalone indicators, with one exception, if you are running the Scalper on a time based chart within the MTF and have enabled the "Highlight current trigger bars" option you will be able to see historic trigger bars as you scroll backwards, an added bonus and side effect of the MTF optimisation process.
There are two things to be aware of.
1. NT will only allow indicators in seperate panels to display values/prices always set to 2 decimal places, so by default MTF will adjust the price, whether the ticksize is above or below 2 decimal places to be 2 decimal places. If you want to change the MTF behaviour you can by changing the "Price indicator scale" option in properties, you will probably soon notice the limitation, but it has the advantage in that you can overlay other indicators if the ticksize is not 2 decimal places (e.g. an EMA with a matching scale for its input period).
2. These candles are reconstructed bars completely done in MTF and do not constitute NT Bars objects or anything similar. So an MTF bar for a day, for example, which was created from minute bars, will possibly have different boundary times to a default NT daily bar.
To import:
- Download the file contained in this thread to your desktop
- From the Control Center window select the menu File > Utilities > Import NinjaScript
- Select the downloaded file
randyjb
09-01-2007, 09:43 PM
Gotta hand it to you Gump.. I have implemented this and it is pretty darn slick. Kudos to you once again. It will be interesting to finally use NT to run multiple time frames on the same chart.
What can I say.. you have outdone yourself this time.
Happy Trading,
EZ
jojojo
09-02-2007, 05:55 AM
Excellent work Gumphrie ! Contributions . I noticed a little bug - on the price scale of the second chart is one decimal-switch
regs
Jojo
Gumphrie
09-02-2007, 06:02 AM
Excellent work Gumphrie ! Contributions . I noticed a little bug - on the price scale of the second chart is one decimal-switch
regs
Jojo
Thanks Jojo,
Its a switch to two decimal places. Read "things to be aware of" point 1.
jojojo
09-02-2007, 06:21 AM
you are right - too fast because of excitement.:D This offers some substantial possibilities . Thanks again
Gumphrie
09-02-2007, 06:48 AM
On a related note I found it wasn't automatically scaling the price to 2 decimal places if the ticksize didn't contain a decimal point at all, (e.g. the YM), so I've updated the MTF attachment in the first post. (Seemed too minor to add a version number change at this early stage.)
zoltran
11-14-2007, 08:13 PM
Hello Gumphie
What would be involved in extending this such that it can be used as input to other indicators.
For example .. an EMA of the longer period...
Displayed on the main chart of course... ;-)
Gumphrie
11-15-2007, 02:57 AM
Hi Zoltran,
Not sure I understand the question.
For simple plots like an EMA its probably easier to overlay the indicators.
zoltran
11-15-2007, 08:15 AM
Let say I use a 5x MTF on a 1 min chart to produce a '5 min' chart pane. I'd like to put an EMA or other indicator on that 5 min pane and have it use the the derived 5min data as input.
ie.. another indicator on the mtf indicator.
I do this all the time with other indicators
For example EMA(CCI(14),4) to get a 4 period EMA of the CCI.
I'd like to do EMA(MTF(4),4) to get a 4 period EMA of the MTF output.
In the example at the top, .. the EMA line looks the same as an EMA of the base 1 minute data... not an EMA of the 5x the MTF output.
Gumphrie
11-15-2007, 04:31 PM
For that to work it would have to export or return a Dataseries and as a DataSeries is by definition in the same timeframe as the indicator that called it, it cannot work. You'd have to be able to create a new Bars object and you can only to that in a strategy, not an indicator. (Read "things to be aware of" point 2.)
MTF does not use DataSeries but C# ArrayLists within its custom plotting in order to get around this NT limitation.
But overlaying should work, if you open a 1 minute chart, create an 2 minute MTF, then overlay a 10 EMA onto the MTF it will in effect be the same as putting a 5 EMA onto a 2 minute chart. Obviously its not 'exactly' the same because of the bar spacing and averaging, but close.... Probably close enough for MAs.
The only way to add 'exact' implementations of other indicators on the MTF pane is to create style options within the MTF code itself like the embedded ModHA and Scalper options.
zoltran
11-16-2007, 12:27 PM
But overlaying should work, if you open a 1 minute chart, create an 2 minute MTF, then overlay a 10 EMA onto the MTF it will in effect be the same as putting a 5 EMA onto a 2 minute chart.
Thanks Gumphie...
Overlaying doesn't seem to work like that .. An EMA on a 5x MTF looks the same as it does on the primary timeframe.
No problem .. I'm just playing with some ideas here.
This really should be a base NT function (Multiple TFs )
slableak
01-13-2008, 04:22 AM
Hi Gumphrie,
Is there a way to insert indicators on the MTF window?
thanks,
David
Gumphrie
01-14-2008, 04:59 PM
Hi David,
Not without specifically designing one as an add-on. Did you have any in mind?
Otherwise, all you can do is overlay onto the panel.
tallsmartman
01-16-2008, 02:32 PM
Hello Gumphrie,
I am new to Ninja Trader, so I wanted to know if there was a way to use your script here on stochastics?
I am trying to find a way to get MTF stochastics (in 1 panel) for trading. 15min, 30min, 1hr, and 4hr.
Would that be possible with your script here? or would I need to find something else?
-MW
Gumphrie
01-16-2008, 06:30 PM
Hi MW,
Probably not in the MTF itself, as its mainly concerned with price bars rather than plots, but you certainly can use the (ArrayList) concepts in the code to create such an indicator.
Gumphrie
01-16-2008, 06:50 PM
On second thoughts, could do it in the MTF in the tradition of Josh's stochastic overlay. Interesting.....
NinjaTrader_Josh
01-16-2008, 11:52 PM
The Stochastics Overlay code will probably need some tweaking on its positional calculations though as it does not seem to like any panel but the price panel. Just an FYI for people undertaking further development.
dwalls
02-06-2008, 09:15 PM
MTF of the CCI would be very nice as well.
Is there any way to have indicators in Multiple Time Frames? on the same chart.
Thanks
NinjaTrader_Dierk
02-06-2008, 11:44 PM
Unfortunately this is not supported at this time. We have it on our lsit for Nt7 (end of this year).
Gumphrie
02-08-2008, 12:39 PM
Doing an MTF CCI, EMA at least, and maybe a Stochastics overlay are on my list of things to do. Hopefully I'll get it done before NT7!
Dierk, I assume in the upcoming native version in NT7 you will be able to reference MTFs within OnBarUpdate, a bit like multiple timeframes in strategies?
NinjaTrader_Dierk
02-08-2008, 12:42 PM
>> Dierk, I assume in the upcoming native version in NT7 you will be able to reference MTFs within OnBarUpdate, a bit like multiple timeframes in strategies?
We have this on our list, yes
astra
04-05-2008, 03:36 PM
Hi Gumphrie,
Thanks for the indicator. I am new to NT so forgive me if I misunderstood it.
My main chart is 1 min and I place your indicator to 5 minutes. What I notice is that the 5 min of your indicator do not visual correspond to the common five minutes interval chart, if are placed side by side (or place the crosshair on the middle of a 5 min candlestick chart and the time will show, say, 10:00 , 10:05, 10:10 etc while in your indicator doing the same it gives me 10:02, 10:07, 10:12 etc).
Maybe I am missing something ... - Can you help me? I need the higher timeframe of your indicator to be the same as the common 5 five chart. Many thanks,
astra
Gumphrie
04-18-2008, 11:53 AM
Hi Astra,
It does create its own bars, rather than using NT bar objects or similar. The cross hair won't match up time wise because the the spacing on the MTF is more to do with scaling rather than time.
However, I might be able to help on specific timeframes, but it may break something else. PM me with exactly what you need and I might be able to help.
GarryM
08-28-2009, 04:09 PM
Gumphrie,
I have been using this indicator for 2 weeks and I consider it the best out there. As a reader of price action, is there a way for you to modify this code to highlight certain candles such as bullish & bearish engulfing etc.. I would be happy to pay you for your work if this is possible.
Thanks again for a great indicator and your time.
GarryM
Gumphrie
08-29-2009, 05:29 AM
Thanks for the complements.
I did create a framework to easily convert any NT indicator to a Multi-Timeframe version. It uses the underlying "MTFBar.cs" indicator/class to do the actual calculations. Its still limited to 'multiples' of the displayed timeframe on the chart but is more intelligent in terms of missed bars and fitting time based timeframes into hours or days where appropriate (like genuine NT bars).
Attached, I've included MTF versions of SMA,EMA,MACD and Stochastics so other people can see how I've done it and create there own MTF indicators.
Perhaps people will like to post their conversions.
GarryM
08-29-2009, 03:27 PM
Gumphie,
Thank you for sharing this with me. I am not a programmer but if I can assist you in any way, let me know.
GarryM
whself beginner
08-31-2009, 08:28 AM
Thanx Gumphie, great work nice idea so i can use stochastic of two frames in one frame. I test out .... and work well
Wh
Eagle
09-13-2009, 03:33 AM
Hi Gumphrie
thanks for sharing this indicator. it worked great however it only seems to be plotting the
bar close in the databox? how do i see the other values like low or high?
same for using this in a strategy, thanks
Gumphrie
09-13-2009, 03:51 AM
Hi Gumphrie
thanks for sharing this indicator. it worked great however it only seems to be plotting the
bar close in the databox? how do i see the other values like low or high?
same for using this in a strategy, thanks
The MTF uses ArrayLists and not Plots, which is why you won't see anything in the databox.
Probably best you create an indicator using the Framework to expose the values you want, you can use that to see databox values and use in a strategy. Start out by looking at one of the sample indicators in the Framework zip.
thepcmd
09-14-2009, 07:08 PM
I really like this multiple time framework. I would like to use it with a time frame that is a fraction of the original time frame. I can only program in integers. Is it possible to program in say a 1.3 multiplier instead on only 1, 2, 3, 4 etc? Thanks for your hard work
Gumphrie
09-15-2009, 03:36 AM
I really like this multiple time framework. I would like to use it with a time frame that is a fraction of the original time frame. I can only program in integers. Is it possible to program in say a 1.3 multiplier instead on only 1, 2, 3, 4 etc? Thanks for your hard work
No, its not possible, if you think about it, you can't split up OHLC values across two bars and still get valid data.
The only alternatives are (a) use a lower main timeframe or (b) create a framework that just runs off tick data rather than OHLC data, but that won't work on NT for historical bars.
jdfagan
09-18-2009, 12:15 AM
This looks interesting. I was wondering if it can handle mixing different types of chart frequencies like say a volume or range chart as the primary base chart and then say a time based one like a 5 min or 15 min chart that is the supplemental/added chart types. From what I read, it seems that this would not work due to other chart types needing to be a multiple of the base, but figured I'd double check anyways.
If this is not possible with your framework, do you (or Dierk if you're listening) think NT7 will support such concepts of mixing different types of chart types for indicator displaying?
NinjaTrader_Bertrand
09-18-2009, 05:08 AM
jdfagan, this is supported with NinjaTrader 7 as we extend the multiseries concept we had in strategies to indicators - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html
New Multi-Series Charting
You can now mix multiple series on a single chart without limitations seen in other platforms. We have introduced a new chart level property "Equidistant bar spacing" which is automatically set to false when mixing more than one series. What this does is creates a time axis that is void of any missing bars so that mixed series of any type can all be accurately aligned to time. When this property is set to true, bars have even space between them and missing time bars are excluded.
RitaPacheco
07-26-2010, 04:00 AM
Hi
I like this indicator very much.
Is it possible to do a Text String on CurrentBar using High and Low of the large time frame?
Thanks
xenayoo
09-15-2010, 10:38 AM
excelent work!
But please one point: make it possible to sycrnonize mtf to a specific starttime, so that the plot looks correct.
thanks
Jens
abfc123
09-24-2010, 06:52 AM
Hi,
I have been using Amibroker for charting and backtesting strategies and am trying to achieve similar results in NT backtesting before running auto using NT.
Amibroker uses expandFirst and expandLast:-
TimeFrameSet( inWeekly );
EMA40 = EMA( C, 40 );
TimeFrameRestore();
//Last close is previous Friday of prior whole week
EMA40 = TimeFrameExpand( EMA40, inWeekly, expandLast );
// This gives close at whatever current bars close is within partial current week
EMA40 = TimeFrameExpand( EMA40, inWeekly, expandFirst );
...presumably equivalent to CalculateOnBarClose = false; and CalculateOnBarClose = false; respectively.
Can you advise if this is correct?
Also, I if i pull down the maximum lookback of historical data from Interactive brokers(1yr of 1minute bars?), does the Add(PeriodType.Weekly, 40) construct from minute bars or does it use weekly bars for the same instrument if they have been previously pulled down via a previous request?
Most importantly, as Interactive Brokers regularly gives out incorrect data which is subsequently cleansed overnight for the next request, is the data stored persistently in the users local database after each load(bad ticks and all) or is it possible to update from scratch at regular intervals?
Thank you for any assistance.
NinjaTrader_Bertrand
09-24-2010, 07:43 AM
abfc123, unfortunately we could not comment on this code and equivalents - weekly bars are build from daily data in NinjaTrader - http://www.ninjatrader-support.com/HelpGuideV6/HowDoesNinjaTraderBuildChartBars.html
If you reload historical data via a right click on your charts, the local database stored data is overwritten.
Taddypole
04-11-2011, 02:21 AM
I was reading about this Multi TImeFrame utility and thought to give it a try. However, after downloading and installing it, I don't see anything happening.
In the attached picture, I've loaded a 1 min chart of the EC and applied the MTFBar indicator to it. I Then applied the MACDMTF indicator but as you can see there is nothing plotted.
I guess it has something to do with the multiplier in each the MTFBar and the MTF indicator but don't really know what to do.
Can anyone help me get started:?
Thanks,
taddypole...
xenayoo
04-11-2011, 04:23 AM
MTF works fine with NT 6.5 . With NT7.x it doen't work at the moment....
Jens
Taddypole
04-11-2011, 11:53 AM
Thank you Jens...
Does any one know what is not working? I've compiled and applied it with no errors in the Log.
What kind of problems could there be if there are no compile errors or log errors?
taddypole...
xenayoo
04-12-2011, 02:18 AM
Well, i am quite new in NT7. You shold know, that NT7 is not only an update. NT7 is mor like a new programm. Some of the solutions in NT6 produces borders for the developers. That's why NT7 was taking so long for launching.
The problem with MTF may be caused by the new memory management. Dataseries store only the values of the last 256 bars. That makes NT faster and take less memory. That may be the problem - but i don't know exactly, because i'm not the develope of MTF.
You can try this:
write following statement as FIRST STATEMENT in the Intiialize()-Method - before Adding the plots, dataseries etc.:
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
Jens
Taddypole
04-12-2011, 10:53 AM
Hi Jens,
Thanks for the suggestion. I tried your recommendations but no joy.
Again no log errors and no compile errors.
taddypole....