Compound Ratio Weighted Average (CoRa_Wave) is a moving average where the weights increase in a “logarithmically linear” way – from the furthest point in the data to the current point – the formula to calculate these weights work in a similar way to how “compound ratio” works – you start with an initial amount, then add a consistent “ratio of the cumulative prior sum” each period until you reach the end amount. The result is, the “step ratio” between the weights is consistent – This is not the case with linear-weights moving average ( WMA ), or EMA
– for example, if you consider a Weighted Moving Average ( WMA ) of length 5, the weights will be (from the furthest point towards the most current) 1, 2, 3, 4, 5 — we can see that the ratio between these weights are inconsistent. in fact, the ratio between the 2 furthest points is 2:1, but the ratio between the most recent points is 5:4 — the ratio is inconsistent, and in fact, more recent points are not getting the best weights they should/can get to counter-act the lag effect. Using the Compound ratio approach addresses that point.
a key advantage here is that we can significantly reduce the “tail weight” – which is “relatively” large in other MAs and would be main cause for lag – giving more weights to the most recent data points – and in a way that is consistent, reliable and easy to “code”
– the outcome is, a moving average line that suffers very little lag regardless of the length, and that can be relied on to track the price movements and swings closely.
other features:
===============
– An accelerator, or multiplier, has been added to further increase the “aggressiveness” of the moving average line, giving even more weights to the more recent points – the multiplier will have more effect between 1 and 5, then will have a diminishing effect after that – note that a multiplier of 0 (which effectively causes a comp. ratio of 0 to be applied) will produce a Simple Moving Average line 🙂
– We also added the ability to use an “automatic smoothing” mechanism, that user can over-ride by manually choosing how much smoothing is used. This gives more flexibility to how we can leverage this Moving Average in our charting.
– User can also select the Resolution and Source price for the CoRa_Wave. by default, they will be set to “same as chart” and hlc3
(description from author RedKTrader, all credits go to him).
//PRC_Adjustible CoRa_Wave | indicator
//20.03.2023
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//author: RedKTrader
// --- settings
length = 20 //length
rmulti = 2.0 //Comp Ratio Multiplier
smooth = 1 //Auto Smoothing
mansmooth = 1 //Manual Smoothing
// --- end of settings
data = customclose
if barindex>length then
if smooth then
s = max(round(sqrt(length)),1)
else
s = mansmooth
endif
source = data
StartWt = 0.01
EndWt = length
r = pow((EndWt / StartWt),(1 / (length - 1))) - 1
base = 1 + r * rmulti
numerator = 0.0
denom = 0.0
cweight = 0.0
for i = 0 to length -1
cweight = StartWt * pow(base,(length - i))
numerator = numerator + source[i] * cweight
denom = denom + cweight
next
coraraw = numerator / denom
// ====================================================================== ==
corawave = weightedaverage[s](coraraw)
coraup = corawave > corawave[1]
if coraup then
colorr=0
colorg=255
colorb=225
else
colorr=255
colorg=152
colorb=0
endif
endif
return corawave as "Adjustible CoRa_Wave" coloured(colorr,colorg,colorb) style(line,3)