This indicator shows multiple MAs of any type ( etc) with BB and MTF support
There are several versions: Simple, MTF, Pro MTF and Ultimate MTF. This is the MTF version. The Differences are listed below. All versions have BB
- Simple: you have 2 groups of MAs that can be assigned any type (5+5)
- MTF: +assign 1 custom Timeframe to any group combo (5+5 Custom TF)
- Pro MTF: +multiple Timeframes for multiple MA groups (4*3 MTF), horizontal levels and show max bars back options
- Ultimate MTF: +individual settings for each MA, multiple Timeframes
There are 2 groups of MAs, 3rd group is BB. You can:
- show/hide all MAs in a group. Use length 0 to hide a particular MA independently or uncheck in Style.
- apply any MA type to all MAs in a particular MA group. For example, you can assign all EMAs the type. Groups are called EMAs and SMAs just for reference.
- assign Custom Timeframe to a particular MA/BB group combination or all groups. For example, show daily (D) EMAs+SMAs on H1 Timeframe, or only H4 (240) BB on H1.
You can use different types of MAs as dynamic S/R levels to trade of off and MA crosses as signals for possible trend change (golden/death bull/bear crosses).
Current Timeframe MAs can be used together with Custom Timeframe MAs on a single chart. Higher TF MAs are more important than lower TF MAs.
Most common MA types are: , , , .
Most common MA lengths are: 12, 20, 26, 30, 50, 100, 200, 400 etc.
- Script UI uses simple timeframe textbox instead of input resolution dropdown to allow for 240 120 and other custom TFs
- Groups that are not assigned a Custom TF will use Current Timeframe (0).
- MTF will work for any MA type assigned to the group. BB group always uses type.
- MTF works both ways: you can display a higher TF MA/BB on a lower TF or a lower TF MA/BB on a higher TF.
- MTF MA values are normally aligned at the boundary of their native timeframe. This produces stair stepping when a higher TF MA is viewed on a lower TF.
Therefore Point Density/Smoothing is applied by default on MA MTF for visual aesthetics. Set to 0 to disable and see exact ma mtf values (lines with stair stepping and original mtf alignment).
- Smoothing is disabled for BB MTF because fill doesn't work with smoothed MAs after duplicate values are replaced with na.
- MTF MA Value fluctuation is possible on the current bar due to default security lookahead
- 2 groups of custom 5+5 MAs of any type including ( )
- 1x Custom Timeframe with step line smoothing for 3 groups (MAs + BB)
1. based on 3EmaBB, uses plot, fill, security, change, barstate, stdev and custom functions
2. you can't set certain constants from input due to Pinescript limitations - change the code as needed, recompile and use as a private script version
3. you can't have plot* inside ?/if/for/function, and implementing condition forks using 2 sets of plots (na vs non-na) doubles indicator params and styles - confusing
4. swma has a fixed length = 4, and linreg have additional offset and smoothing params
Feel free to use. Good Luck!
- fixed hma/wma(src, 0) error when len = 1 by adding a max(2,len) wrapper to hma function
- 3x separate TFs for EMAs, SMAs and BB groups instead of 7 preset combinations
- any BB MA Type option
- advanced X,Y Smoothing from MTF Pro version, added Y == 0, X > 0, TF >= deltaX_max_tf - X,Y smoothing disabled (stair stepping on high TFs)
- smoothing applied to BB MA only, excluding BB bands because fill won't work with smoothed bands. See MTF Pro version to learn how smoothing works.
- support for timeframes in H: H, 2H, 4H etc
- removed src security call (not needed)
- moved show/hide flags to top
Note: Recently TradingView has limited Replay Mode to D,W,MN only for free accounts. Pinescript security calls are now also limited.
You won't be able to plot any TF < D1 in Replay Mode (you will see straight lines) but all TFs will work properly in history and real-time modes. This is not a bug.
X Y Point Density/MTF Smoothing of MA stair stepping on custom TFs - decides whether to show/hide ma values
- X,Y == 0 - X,Y smoothing disabled (stair stepping on high TFs)
- X == 0, Y > 0 - X,Y smoothing applied to all TFs
- Y == 0, X > 0 - X smoothing applied to all TFs < deltaX_max_tf, Y smoothing disabled
- Y == 0, X > 0, TF >= deltaX_max_tf - X,Y smoothing disabled (stair stepping on high TFs)
- X > 0, Y > 0 - Y smoothing applied to all TFs, then X smoothing applied to all TFs < deltaX_max_tf
X Smoothing with Y == 0 - shows only every deltaX-th point starting from the first bar.
X Smoothing with Y > 0 - shows only every deltaX-th point starting from the last shown Y point, essentially filling huge gaps remaining after Y Smoothing with points and preserving the curve's general shape
Y Smoothing reduces points on all TFs, removes adjacent points with prices within deltaY, while preserving the smaller curve details.
X Smoothing on high TFs with already scarce points produces weird curve shapes, it works best only on high density lower TFs
A combination of X,Y produces the most accurate smoothing. Higher delta value - larger range, more points removed.
- better screen on script's home page
Here I'm using 1440 and W timeframes (with the rest of your settings) because free accounts can't load custom timeframes like 12H, but I can see what seems to be the problem.
For charts with very low fractional prices like Stellar/BTC (0.00002) with many decimal digits of precision you need to adjust X Y smoothing accordingly or disable it completely.
Please read the comments in the code to learn how exactly smoothing works.
You can also cross check the output of Multi SMA MTF with Multi SMA Simple indicator which doesn't have timeframes/smoothing. In your case all HMAs 1440 (or D) should look the same in both indicators which they do.
Other common reason for missing MAs is when there's simply not enough bars in history to even start plotting it. For example, for W1 EMA200 you need at least 200 bars on the weekly chart, So, you will only see W1 MAs 20 and 50 on XLMBTC.
XLMBTC with X Y smoothing disabled (0, 0)
XLMBTC with smoothing Y = 0.0000001 (even 0.000001 is not enough in this case)
Just wondering, what does one lose when smoothing is disabled?
smoothing is applied by default to all TFs >= D only for visual aesthetics. You can change this.
When smoothing is disabled you will see staircasing/line stepping when higher TF EMAs are displayed on lower TFs because they have a lower res with less bars.
The real values of MAs from higher TFs don't change on every bar on a lower TF, producing straight lines across series of bars/stepping.
Smoothing attempts to visually eliminate line stepping by approximation - it generates intermediate points with customizable X Y steps.