TradingView
millerrh
3. Jun. 2021 03:24

MTF Trend Widget 

Futu Holdings LimitedNASDAQ

Beschreibung

This indicator identifies trends in multiple higher timeframes (D, W, M) and shows them in a widget off to the right of the chart.
It's meant to be used as an alternative filter for "trading with the trend." Typically people use moving averages of varying lengths for this (i.e. if over 200 MA it's an uptrend, etc.), but I wanted to see if it might be more effective to see if the higher timeframes were actually trending or not in a certain direction.
For the purposes of this indicator, an uptrend is defined as higher highs and higher lows. So if currently in a downtrend and the highs are broken, the indicator will flip to an uptrend because now we have a higher high. Vice versa for downtrends.
The user can choose the lookback period for defining these highs/lows (the pivot points). A smaller lookback number will give you more frequent pivot points.
The user can toggle on visibility of all historical pivot points to make sure the frequency and placement of the swing highs/lows is to their liking.
The user can show the support/resistance lines of those most recent swing high/low points on the multiple timeframes as well.
When these lines are breached, that is when the trends change, so you can see if you are close to changing any longer term trends.
My hope is that this gives people a quick glance at the overall trend without having to cycle through different timeframes.

Versionshinweise

This update:
  • Optimizes the code for improved speed (with some coding help from @RozaniGhani-RG)
  • Allows the user to select which timeframes they want to view the trend information on instead of that being hard coded
  • Moves the information from the widget that was at the right of the chart to a table (upper right) for easier viewing at all zoom levels and to allow me to pass on the variable timeframe (which was not allowed on the widget)
  • Adds additional color options for support/resistance lines to give the user greater control over how they look


Hope you guys find it useful!

Versionshinweise

More speed optimization to limit the number of security calls. Allow for ability for user to reposition the table.

Versionshinweise

Updating to Pine v5 and adding a user input to change the thickness of the support/resistance line. The reason this is needed is that when color calculations are done (as is with the trend table) all formatting of everything else is removed from the Style tab, so must be explicitly fed to the user through the Inputs tab.

Versionshinweise

This indicator didn't work correctly on lower timeframes. As an example, if you were on a daily chart, but one if your trend boxes were for the hourly time frame, it would show you a value and show you the pivot lines for the hourly timeframe, but they weren't necessarily correct. This update grays out the boxes of lower time frames if you are on the higher time frames and makes the support resistance lines disappear when you are on the higher timeframes to remove both of those from view and not clutter with info on the lower timeframes that might not be 100% correct.

Versionshinweise

Added the ability to use close instead of wick (high/low) to determine levels and trend changes.

Versionshinweise

Added a fourth timeframe.

Versionshinweise

Bug fix where the arrow of the 4th timeframe was the same as the 3rd timeframe.

Versionshinweise

Fixed copy/paste bug where TF 4 was looking at TF 3 data.
Kommentare
rick_hubka
Little bug...
Line 124/125

// 4th Timeframe
highLine4 = TF3Check ? na : showMTFLevels ? f_line(tSH_04, hL_04, hL_04, fourColorR) : na
lowLine4 = TF3Check ? na : showMTFLevels ? f_line(tSL_04, lL_04, lL_04, fourColorS) : na
**************** change TF3Check to TF4Check as below
// 4th Timeframe
highLine4 = TF4Check ? na : showMTFLevels ? f_line(tSH_04, hL_04, hL_04, fourColorR) : na
lowLine4 = TF4Check ? na : showMTFLevels ? f_line(tSL_04, lL_04, lL_04, fourColorS) : na

Cheers. Love this indicator
millerrh
@rickb50sd, Good catch, thanks! Just fixed it. Little copy/paste error with all the duplicate code.
rick_hubka
@millerrh, You are welcome. The only reason I found it is because I changed my copy to have 6 Time frames. I trade on 1 minute and wanted 15M, 30M, 1H, 4H, 1D, 1W, 1M trends heads up.
I'm a retired programmer and started learning futures day trading 6 months a go. Still lots to learn. This indicator is a real keeper for all my charts!!! Thanks so much. The tuple trick is great!
AznRambo
Is it possible to also put a “ranging option” - so that it isn’t showing forcing a bullish or bearish determination?
millerrh
@AznRambo, Not with the current logic this indicator has. Also, something can be ranging while still being in an up or downtrend as long as the highs/lows aren't breached. As long as higher highs are maintained, it says uptrend. As soon as a low is breached it will pivot to downtrend. The purest form of trend analysis is looking for higher highs and higher lows or lower highs and lower lows and this tries to capture that. You'll still have to use your eyes to look for ranges.
zschonn
Thanks
The_Currency_Guy
Love this works perfect with my strategy thanks for sharing
AznRambo
Great indicator & exactly what I’m looking for. What does it mean when the monthly cell is red but there is an up arrow? This is currently the case for TESLA on all timeframes (as of Aug 29, 2023).
millerrh
@AznRambo, Thanks for pointing that out. That was an error with the code where the arrow for the 4th box was always the same as the arrow for the 3rd box. I fixed it just now and uploaded the new version.
AznRambo
@millerrh, wow you are quick. Thanks for the quick fix and also for creating this great snapshot!
Mehr