OSGFC indicator
OSGFC indicator
2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("One-Sided Gaussian Filter w/ Channels [Loxx]",
shorttitle="OSGFC [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_gaussian(size, x)=>
out = (math.exp(-x * x * 9 / ((size + 1) * (size + 1))))
out
//calc weights given fibo numbers and how many fibos chosen
_gaussout(levels)=>
perin = array.size(levels)
arr_gauss = matrix.new<float>(perin, perin, 0.)
for k = 0 to array.size(levels) - 1
sum = 0.
for i = 0 to perin - 1
if (i >= array.get(levels, k))
break
matrix.set(arr_gauss, i, k, _gaussian(array.get(levels, k), i))
sum += matrix.get(arr_gauss, i, k)
for i = 0 to perin - 1
if (i >= array.get(levels, k))
break
temp = matrix.get(arr_gauss, i, k) / sum
matrix.set(arr_gauss, i, k, temp)
arr_gauss
haclose = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, ohlc4)
lmax = smthper + 1
out1 = _smthMA(smthper, src, lmax)
out = _twopoless(out1, extrasmthper)
sig = out[1]
colorout = out > sig ? greencolor : redcolor
atr = ta.atr(atrper)
smax = out + atr * mult
smin = out - atr * mult