Comp_Ratio_MA
"RedK Compound Ratio Moving Average (CoRa_Wave)" by RedKTrader, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: RedK Compound Ratio Moving Average (CoRa_Wave) (v3.0), read 2026-10-12T16:18:00.165Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
RedK Compound Ratio Moving Average (CoRa_Wave) by RedKTrader, ported from Pine v4. Overlay indicator with 1 plot and 5 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader
// ------------------------------------------------------------------------------------------------
// Original author: RedKTrader
// Original title: RedK Compound Ratio Moving Average (CoRa_Wave)
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// Pine version: 4
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("Comp_Ratio_MA", shorttitle="CoRa Wave", overlay=true, timeframe="")
// ======================================================================
// Compound Ratio Weight MA function
// Compound Ratio Weight is where the weight increases in a "logarithmicly linear" way (i.e., linear when plotted on a log chart) - similar to compound ratio
// the "step ratio" between weights is consistent - that's not the case with linear-weight moving average (WMA), or EMA
// another advantage is we can significantly reduce the "tail weight" - which is "relatively" large in other MAs and contributes to lag
//
// Compound Weight ratio r = (A/P)^1/t - 1
// Weight at time t A = P(1 + r)^t
// = Start_val * (1 + r) ^ index
// Note: index is 0 at the furthest point back -- num periods = length -1
//
f_adj_crwma(source, length, Start_Wt, r_multi) =>
numerator = 0.0
denom = 0.0
c_weight = 0.0
//Start_Wt = 1.0 // Start Wight is an input in this version - can also be set to a basic value here.
End_Wt = length // use length as initial End Weight to calculate base "r"
r = math.pow(End_Wt / Start_Wt, 1 / (length - 1)) - 1
base = 1 + r * r_multi
for i = 0 to length - 1
c_weight := Start_Wt * math.pow(base, length - i)
numerator := numerator + source[i] * c_weight
denom := denom + c_weight
numerator / denom
// ====================================================================== ==
data = input.source(title="Source", defval=hlc3)
length = input.int(title="length", defval=20, minval=1)
r_multi = input.float(title="Comp Ratio Multiplier", defval=2.0, minval=0, step=.1)
smooth = input.bool(title="Auto Smoothing", defval=true, group="Smoothing")
man_smooth = input.int(title="Manual Smoothing", defval=1, minval=1, step=1, group="Smoothing")
s = smooth ? math.max(math.round(math.sqrt(length)), 1) : man_smooth
cora_raw = f_adj_crwma(data, length, 0.01, r_multi)
cora_wave = ta.wma(cora_raw, s)
c_up = color.new(color.aqua, 0)
c_dn = color.new(#FF9800, 0)
cora_up = cora_wave > cora_wave[1]
plot(cora_wave, title="Adjustible CoRa_Wave", color=cora_up ? c_up : c_dn, linewidth=3)
This file is under the Mozilla Public License 2.0; it is a port of the original by RedKTrader, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.