TradingView
RezzaHmt
8 אפר׳ 2020 15:30

Symmetrically Weighted Moving Average 

Advanced Micro Devices, Inc.NASDAQ

תיאור

Symmetrically weighted moving average

Weight distribution starts from median of given period and it's reduced linearly to the sides so the ending and starting point of period have the least weight.
It's smooth and fast but reacts late to trend changes on higher lengths, it could be considered both advantage and disadvantage.

הערות שחרור

Removed redundant calculations.
תגובות
Twobob777
what a amazing MA, but may I request one small add, is it possible to have the option of setting the different time frames, example I'm looking on a 1h but I us the ma on a daily lvl and these are the points im most interested. amazing work buddy thank you so much
cryptolinx
Nice 😊 But could be shorten to your Cross Smoother Filter code. Same results! 😎

Try:

//@version=4

// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// Author: © RezzaHmt
// - de.tradingview.com/script/MjrqeXd0-Symmetrically-Weighted-Moving-Average/
// - de.tradingview.com/script/4bIRHfoF-Cross-Smoother-Filter/
// Editor: jango_blockchained

study("SWMA vs CSF", overlay=true)

len = input(24, title="_length", minval=1)
src = input(close, title="Source")

//-- -----------------------------------------------<▪

f_swma(_src,_len) =>
_return = .0, nR = .0, nL = .0, sR = .0, sL = .0
if floor(_len / 2) == round(_len / 2) // n = 2k
for i = 0 to _len / 2 - 1
wR = (_len - (_len - 1 - i)) * _len
nR := nR + wR
sR := sR + _src * wR
for j = _len / 2 to _len - 1
wL = (_len - j) * _len
nL := nL + wL
sL := sL + _src[j] * wL
_return :=
(sR + sL) / (nR + nL)
else // n = 2k + 1
for i = 0 to floor(_len / 2)
wR = (_len - (_len - 1 - i)) * _len
nR := nR + wR
sR := sR + _src * wR
for j = round(_len / 2) to _len - 1
wL = (_len - j) * _len
nL := nL + wL
sL := sL + _src[j] * wL
_return :=
(sR + sL) / (nR + nL)

swma = f_swma(src,len)
plot(swma, title="swma", color=color.yellow, linewidth=3)

//-- -----------------------------------------------<▪

f_swma_short(src, len) =>
x = floor(len / 2) + 1
y = round(len / 2)
_return =
sma(sma(src, x), y)

_swma = f_swma_short(src,len)
plot(_swma, title="swma short", color=color.maroon, linewidth=2, style=plot.style_circles)
cryptolinx
RezzaHmt
@iflostio, that's a very nice discovery you have made. I didn't notice that myself.
But you know, It's only the same as CSF if you use it with SMA.
They are both open-source and as you see codes are totally different, even the ideas behind them are totally different.

I'm gonna consider this another interesting fact about Cross Smoother Filter,
CSF with WMA is almost the same as Ehler's Super Smoother
With EMA it is the same as Ehler's Gaussian Filter
And now here we are...

I don't know maybe it can be something else too. LOL
VirtualJack
Thanks! :)
עוד