NexusFi: Find Your Edge


Home Menu

 





Coding Multi Time Frame (MTF) Indicators with NinjaTrader


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 180 posts (562 thanks)
    2. looks_two Zondor with 19 posts (29 thanks)
    3. looks_3 madLyfe with 16 posts (10 thanks)
    4. looks_4 BankRobberNT with 14 posts (16 thanks)
      Best Posters
    1. looks_one gomi with 3.7 thanks per post
    2. looks_two Fat Tails with 3.1 thanks per post
    3. looks_3 Zondor with 1.5 thanks per post
    4. looks_4 BankRobberNT with 1.1 thanks per post
    1. trending_up 188,819 views
    2. thumb_up 743 thanks given
    3. group 87 followers
    1. forum 424 posts
    2. attach_file 166 attachments




 
Search this Thread

Coding Multi Time Frame (MTF) Indicators with NinjaTrader

  #211 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Zondor View Post
An approach that I have been using is to not tie the secondary series to a defined time, range, etc but instead to define it based on multiples of the primary data series. I believe this has been referred to as composite bars.

So, on any type of chart, the 2x "extended" time frame would simply look back twice as far as the base indicator, etc. This is not necessarily as simple as it seems. Sometimes when looking back twice as far you need to skip every other data point. Or when looking back three times as far, only look at one of every three of the previous data points. Otherwise all you are doing is doubling or tripling the lookback period in the base time frame. Except for indicators like the stochastic that are looking for highest highs and lowest lows.

I have coded a whole series of those indicators. Example below is the MACD. It is based on composite bars. I have not published it yet, because I still want to modify to take into account "rolling composite bars", for example if I have a 15 minute chart and a timeframe factor of 4, I could calculate the indicator values from the series of hourly bars shifted by 5 minutes, when the minute bars plots for 00:05.

Chart below shows the MACD calculated from composite bars, that is it displays the values for a 60 minute MACD on a 15 min chart.

Attached Thumbnails
Click image for larger version

Name:	6E 12-11 (15 Min)  28_10_2011.jpg
Views:	262
Size:	141.7 KB
ID:	53464  
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
Increase in trading performance by 75%
The Elite Circle
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Tao te Trade: way of the WLD
24 thanks
Diary of a simple price action trader
21 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #212 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Zondor View Post
So, on any type of chart, the 2x "extended" time frame would simply look back twice as far as the base indicator.

Not any type of chart. It will work on minute, tick and volume charts, as a 100 tick bar can be built from two 50 tick bars, but what about range bars? You cannot build an 8-range bar from two 4-range bars, because typically they overlap.

I have solved this issue by using the proportionality between range and the square root of time. You can effectively build an 8-range bar from
2 * 2 = 4 of those 4-range bars. The resulting indicators will run smoother than the original indicator that runs on an 8-range bar.

Attached Thumbnails
Click image for larger version

Name:	FDAX 12-11 (2 Range) _ FDAX 12-11 (4 Range)  28_10_2011.jpg
Views:	247
Size:	107.8 KB
ID:	53471  
Started this thread Reply With Quote
Thanked by:
  #213 (permalink)
 
wahn's Avatar
 wahn 
New York, NY
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: CL
Posts: 101 since Sep 2010
Thanks Given: 1,800
Thanks Received: 62



Fat Tails View Post
I do not have 8 range no gap bars installed, so I can only run it on a range chart. I am now running it in real time against the old indicator and will post the result in a few minutes. I have also modified the test indicators to show whether they have detected historical data (blue dots) or real-time data (red dots). This makes it easier to find out what happens.

The modified indicator with the dots added and one additional minor change relating to the first real-time tick, when a minute bar series is loaded, is attached below:


Hi FT,

Thanks for providing better VisualMA!

How can I make dots(Blue or Red) smaller on larger bar width (8 or larger)?
Cheers,

Wahn

Attached Thumbnails
Click image for larger version

Name:	snagit 0006.png
Views:	288
Size:	142.4 KB
ID:	53577  
Reply With Quote
  #214 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


wahn View Post
Hi FT,

Thanks for providing better VisualMA!

How can I make dots(Blue or Red) smaller on larger bar width (8 or larger)?
Cheers,

Wahn

There will be no dots on the final version of the indicator, because the drawing all those dots is unnecessary and slows down NinjaTrader. Currently I just use the dots to mark the data as historical or real-time. Blue dots detect historical data, red dots real-time data.

Now I know that your chart uses historical data.

Started this thread Reply With Quote
  #215 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


madLyfe View Post
what about this, is the new version supposed to follow the bar exactly like shown here(blue)? the old one is in black and kinda hanging back..

I have tested the NewVisual Indicators during the week end, and indeed in some cases the new indicator is not lagging any more. The last old version had compensated the lag, in case that the primary bars were identical with the secondary bar type loaded. The new version will also compensate the lag for different bar types, so there is indeed some improvement.

The chart below shows a range chart (primary bars, green and red) and secondary tick bars (control series in gray although not required by the indicator). The old indicator (orange) when calculating values from tick bars and plotting them to a range chart did indeed show a lag. while the new indicator (red) compensates for that lag.

The data box shows that the range bar and the tick bar have an identical time stamp at 14:38:05. The new indicator already uses the indicator value from that tick bar and displays it simultaneously for that range bar, while the old indicator lags one bar behind.


Started this thread Reply With Quote
  #216 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

Here comes the next test version. There was a minor bug which affected the interpolation in visual mode directly after the session begin. On a non-equidistant chart the interpolation algorithm needs to substract the duration of the session break from the interpolation interval, which was omitted. It is now corrected.

I am very satisfied with the stability and performance of the new version. I just displayed an hourly 20-period EMA on a 1-minute chart with a lookback period of 365 days. These were the loading times:

old version of the indicator : 2 minutes and 10 seconds
new version of the indicator : 7 seconds

There is a significant performance gain, due to simplification. As shown in the post above the new version also produces a smaller lag than the old version. The indicator is slowly leaving its adolescence.

The latest test version of the indicator is attached below




Attached Files
Elite Membership required to download: VisualIndicatorsTest4.zip
Started this thread Reply With Quote
  #217 (permalink)
 
prisonbreaker82's Avatar
 prisonbreaker82 
Rio de Janeiro
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire, IB
Trading: Equity & Futures
Posts: 312 since Jun 2010
Thanks Given: 58
Thanks Received: 141

Hi Fat Tails,

I tested the indicator today and I got this message when using the indicator on a 5 minute chart.



Fat Tails View Post
Here comes the next test version. There was a minor bug which affected the
interpolation in visual mode directly after the session begin. On a non-equidistant chart the interpolation algorithm needs to substract the duration of the session break from the interpolation interval, which was omitted. It is now corrected.

I am very satisfied with the stability and performance of the new version. I just displayed an hourly 20-period EMA on a 1-minute chart with a lookback period of 365 days. These were the loading times:

old version of the indicator : 2 minutes and 10 seconds
new version of the indicator : 7 seconds

There is a significant performance gain, due to simplification. As shown in the post above the new version also produces a smaller lag than the old version. The indicator is slowly leaving its adolescence.

The latest test version of the indicator is attached below





Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	211
Size:	35.6 KB
ID:	53626  
Visit my NexusFi Trade Journal Reply With Quote
  #218 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


prisonbreaker82 View Post
Hi Fat Tails,

I tested the indicator today and I got this message when using the indicator on a 5 minute chart.

I suppose that you got that message, when you tried to save the template. I think that there is a NinjaTrader bug, which occasionaly hits and causes problems with the serialization. Best solution is to shutdown NinjaTrader and to restart it again.

If this does not help, please let me know what exactly you did to produce this message.

If anybody else has made the same observation, please let me also know.

Started this thread Reply With Quote
  #219 (permalink)
 
PHXtrader's Avatar
 PHXtrader 
Boston
 
Experience: Intermediate
Platform: Jigsaw
Trading: NQ
Posts: 84 since Apr 2011
Thanks Given: 48
Thanks Received: 76

Hey Fat Tails

I still heavily use your original version it does take a while to load but works like a charm once its up and running so a quicker load time got me interested in trying your new version. I imported the new one and it works great. I was just wondering if you could make it so you can select those dots on or off. I find they clutter up the screen a bit. Thanks for all the hard work on these indies!

Visit my NexusFi Trade Journal Reply With Quote
  #220 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



PHXtrader View Post
Hey Fat Tails

I still heavily use your original version it does take a while to load but works like a charm once its up and running so a quicker load time got me interested in trying your new version. I imported the new one and it works great. I was just wondering if you could make it so you can select those dots on or off. I find they clutter up the screen a bit. Thanks for all the hard work on these indies!

The dots will disappear or be selectable in the final version. I have forced them now, because they tell me whether a chart that is posted uses historical or real-time data. The dots are just required for the testing process.

Started this thread Reply With Quote




Last Updated on April 19, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts