Tunable SWMADissected the standard SWMA function and added options for user to change just about every part of it. Weights ,Lookback ,Source can all be changed in the settings.
Green is the standard SWMA, Using the Input value selected.(MAs/LRC/VWAP)
Red is the tuned SWMA, with the option of applying a final Output filter (MAs/LRC/VWAP). Uses 8 datapoints instead of 4 for the default.
Customization can really help expand upon the standard SWMA I find. Enjoy tuning to your hearts content
Weighting
Weight Gain 4000 - (Adjustable Volume Weighted MA) - [mutantdog]Short Version:
This is a fairly self-contained system based upon a moving average crossover with several unique features. The most significant of these is the adjustable volume weighting system, allowing for transformations between standard and weighted versions of each included MA. With this feature it is possible to apply partial weighting which can help to improve responsiveness without dramatically altering shape. Included types are SMA, EMA, WMA, RMA, hSMA, DEMA and TEMA. Potentially more will be added in future (check updates below).
In addition there are a selection of alternative 'weighted' inputs, a pair of Bollinger-style deviation bands, a separate price tracker and a bunch of alert presets.
This can be used out-of-the-box or tweaked in multiple ways for unusual results. Default settings are a basic 8/21 EMA cross with partial volume weighting. Dev bands apply to MA2 and are based upon the type and the volume weighting. For standard Bollinger bands use SMA with length 20 and try adding a small amount of volume weighting.
A more detailed breakdown of the functionality follows.
Long Version:
ADJUSTABLE VOLUME WEIGHTING
In principle any moving average should have a volume weighted analogue, the standard VWMA is just an SMA with volume weighting for example. Actually, we can consider the SMA to be a special case where volume is a constant 1 per bar (the value is somewhat arbitrary, the important part is that it's constant). Similar principles apply to the 'elastic' EVWMA which is the volume weighted analogue of an RMA. In any case though, where we have standard and weighted variants it is possible to transform one into the other by gradually increasing or decreasing the weighting, which forms the basis of this system. This is not just a simple multiplier however, that would not work due to the relative proportions being the same when set at any non zero value. In order to create a meaningful transformation we need to use an exponent instead, eg: volume^x , where x is a variable determined in this case by the 'volume' parameter. When x=1, the full volume weighting applies and when x=0, the volume will be reduced to a constant 1. Values in between will result in the respective partial weighting, for example 0.5 will give the square root of the volume.
The obvious question here though is why would you want to do this? To answer that really it is best to actually try it. The advantages that volume weighting can bring to a moving average can sometimes come at the cost of unwanted or erratic behaviour. While it can tend towards much closer price tracking which may be desirable, sometimes it needs moderating especially in markets with lower liquidity. Here the adjustability can be useful, in many cases i have found that adding a small amount of volume weighting to a chosen MA can help to improve its responsiveness without overpowering it. Another possible use case would be to have two instances of the same MA with the same length but different weightings, the extent to which these diverge from each other can be a useful indicator of trend strength. Other uses will become apparent with experimentation and can vary from one market to another.
THE INCLUDED MODES
At the time of publication, there are 7 included moving average types with plans to add more in future. For now here is a brief explainer of what's on offer (continuing to use x as shorthand for the volume parameter), starting with the two most common types.
SMA: As mentioned above this is essentially a standard VWMA, calculated here as sma(source*volume^x,length)/sma(volume^x,length). In this case when x=0 then volume=1 and it reduces to a standard SMA.
RMA: Again mentioned above, this is an EVWMA (where E stands for elastic) with constant weighting. Without going into detail, this method takes the 1/length factor of an RMA and replaces it with volume^x/sum(volume^x,length). In this case again we can see that when x=0 then volume=1 and the original 1/length factor is restored.
EMA: This follows the same principle as the RMA where the standard 2/(length+1) factor is replaced with (2*volume^x)/(sum(volume^x,length)+volume^x). As with an RMA, when x=0 then volume=1 and this reduces back to the standard 2/(length+1).
DEMA: Just a standard Double EMA using the above.
TEMA: Likewise, a standard Triple EMA using the above.
hSMA: This is the same as the SMA except it uses harmonic mean calculations instead of arithmetic. In most cases the differences are negligible however they can become more pronounced when volume weighting is introduced. Furthermore, an argument can be made that harmonic mean calculations are better suited to downtrends or bear markets, in principle at least.
WMA: Probably the most contentious one included. Follows the same basic calculations as for the SMA except uses a WMA instead. Honestly, it makes little sense to combine both linear and volume weighting in this manner, included only for completeness and because it can easily be done. It may be the case that a superior composite could be created with some more complex calculations, in which case i may add that later. For now though this will do.
An additional 'volume filter' option is included, which applies a basic filter to the volume prior to calculation. For types based around the SMA/VWMA system, the volume filter is a WMA-4, for types based around the RMA/EVWMA system the filter is a RMA-2.
As and when i add more they will be listed in the updates at the bottom.
WEIGHTED INPUTS
The ohlc method of source calculations is really a leftover from a time when data was far more limited. Nevertheless it is still the method used in charting and for the most part is sufficient. Often the only important value is 'close' although sometimes 'high' and 'low' can be relevant also. Since we are volume weighting however, it can be useful to incorporate as much information as possible. To that end either 'hlc3' or 'hlcc4' tend to be the best of the defaults (in the case of 24/7 charting like crypto or intraday trading, 'ohlc4' should be avoided as it is effectively the same as a lagging version of 'hlcc4'). There are many other (infinitely many, in fact) possible combinations that can be created, i have included a few here.
The premise is fairly straightforward, by subtracting one value from another, the remaining difference can act as a kind of weight. In a simple case consider 'hl2' as simply the midrange ((high+low)/2), instead of this using 'high+low-open' would give more weight to the value furthest from the open, providing a good estimate of the median. An even better estimate can be achieved by combining that with 'high+low-close' to give the included result 'hl-oc2'. Similarly, 'hlc3' can be considered the basic mean of the three significant values, an included weighted version 'hlc2-o2' combines a sum with subtraction of open to give an estimated mean that may be more accurate. Finally we can apply a similar principle to the close, by subtracting the other values, this one potentially gets more complex so the included 'cc-ohlc4' is really the simplest. The result here is an overbias of the close in relation to the open and the midrange, while in most cases not as useful it can provide an estimate for the next bar assuming that the trend continues.
Of the three i've included, hlc2-o2 is in my opinion the most useful especially in this context, although it is perhaps best considered to be experimental in nature. For that reason, i've kept 'hlcc4' as the default for both MAs.
Additionally included is an 'aux input' which is the standard TV source menu and, where possible, can be set as outputs of other indicators.
THE SYSTEM
This one is fairly obvious and straightforward. It's just a moving average crossover with additional deviation (bollinger) bands. Not a lot to explain here as it should be apparent how it works.
Of the two, MA1 is considered to be the fast and MA2 is considered to be the slow. Both can be set with independent inputs, types and weighting. When MA1 is above, the colour of both is green and when it's below the colour of both is red. An additional gradient based fill is there and can be adjusted along with everything else in the visuals section at the bottom. Default alerts are available for crossover/crossunder conditions along with optional marker plots.
MA2 has the option for deviation bands, these are calculated based upon the MA type used and volume weighted according to the main parameter. In the case of a unweighted SMA being used they will be standard Bollinger bands.
An additional 'source direct' price tracker is included which can be used as the basis for an alert system for price crossings of bands or MAs, while taking advantage of the available weighted inputs. This is displayed as a stepped line on the chart so is also a good way to visualise the differences between input types.
That just about covers it then. The likelihood is that you've used some sort of moving average cross system before and are probably still using one or more. If so, then perhaps the additional functionality here will be of benefit.
Thanks for looking, I welcome any feedack
Weighted Close [CC]The weighted close isn't an option for an input yet on TV so here is my contribution. It gives more weight to the close prices and I have included a signal line to look for buy and sell signals. Buy when the indicator goes over its signal line and sell when it falls below it.
This was a special request so let me know what other scripts you would like to see me publish or if you want something custom done!
Cubed Weighted Moving AverageThis is another indicator that I have created that is my favorite script yet for a weighted moving average. This indicator is very similiar to a classic weighted moving average but in this version I'm cubing the weights. It hugs the price very closely as you can see and of course buy when the indicator line is green and sell when it is red.
Let me know if you would like me to publish other scripts or if you want something custom done!
Variable Power Weighted Moving AverageThe Variable Power Weighted Moving Average was created by RedKTrader so make sure you follow them! This is a very handy indicator where you can change the weights of the weighted moving average yourself!
For an easy guide here are common values to use to convert this indicator into other indicators:
Power = 0 = Simple Moving Average
Power = 0.5 = Square Root Weighted Moving Average
Power = 1 = Weighted Moving Average
Power = 2 = Squared Weighted Moving Average
Try it out and let me know what you think!
Let me know if you have other ideas for me or if you want something custom done!
Optimal Weighted Moving AverageThe Optimal Weighted Moving Average was created by Thomas Hutchinson and Peter G. Zhang, Ph.D. (Stocks & Commodities V. 11:12 (500-505)) and it is very similar to a classic weighted moving average but it uses the correlation between the input and the optimal weighted moving average output to use as the weights. Buy when the line turns green and sell when it turns red.
Let me know if you would like to see me publish any other scripts or if you want something custom done!
Squared Weighted Moving AverageThe Squared Weighted Moving Average is similar to the classic Weighted Moving Average but the difference is that it squares the weights instead of the classic weight values. Buy if the indicator line is green and sell when it goes red.
Let me know if you would like to see any more scripts from me or if you want something custom done!
Square Root Weighted Moving AverageThe Square Root Weighted Moving Average is similar to the classic Weighted Moving Average but the difference is that it uses the square root of the weights instead of the classic weight values. Buy if the indicator line is green and sell when it goes red.
Let me know if you would like to see any more scripts from me or if you want something custom done!
Combining Exponential And Volume Weighting Strategy The related article is copyrighted material from Stocks & Commodities 2009 Oct
Stochastic Weighted Moving Averages [DW]This is an experimental study derived from George Lane's Stochastic Oscillator.
The %KWMA is calculated by taking a moving average of source with a %K weighting factor over its specified period.
The %DWMA is calculated by taking a simple moving average of %KWMA over its specified period.
Custom bar color scheme included.
Triangular Moving AverageThe TRIMA is simply the SMA of the SMA -- a double-smoothed simple moving average . The end effect of the double smoothing is that greater weight is placed on values near the middle of the lookback period. It therefore reacts relatively slowly to price changes compared to most moving averages .
But why would I want more lag?
One potential use of this moving average that I've found is that it can allow price to run for a bit after crossing the TRIMA before catching up and creating an opposing signal. It therefore creates the chance for the price to "run its course" so to speak, which can make whipsaw signals less common.
Combining Exponential And Volume WeightingThe related article is copyrighted material from Stocks & Commodities 2009 Oct