Attachments forums

List of attachments posted on this forum.


All files on forums: 163307

Re: Already Converted TradingView Indicators to MT4 Indicators

RodrigoRT7, Sat Sep 03, 2022 5:04 am

Knight wrote: Fri Sep 02, 2022 7:28 pm JCFBaux Volatility [Loxx] (close, 15, 0, 300)


Can this indicator be converted to mt4?


It's one of the best for filtering low volatility and choppy markets.
Here we go , bro :D

Code: Select all

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx

//@version=5
indicator("JCFBaux Volatility [Loxx]", shorttitle = "JCFBV [Loxx]",  timeframe="", timeframe_gaps=true, overlay = false)
greencolor = #2DD204

_a_jurik_filt(src, len, phase) =>
    len1 = math.max(math.log(math.sqrt(0.5 * (len-1))) / math.log(2.0) + 2.0, 0)
    pow1 = math.max(len1 - 2.0, 0.5)
    volty = 7.0, avolty = 9.0, vsum = 8.0, bsmax = 5.0, bsmin = 6.0, avgLen = 65
    
    del1 = src - nz(bsmax[1])
    del2 = src - nz(bsmin[1])
    
    div = 1.0 / (10.0 + 10.0 * (math.min(math.max(len-10, 0), 100)) / 100)
    volty := math.abs(del1) > math.abs(del2) ? math.abs(del1) : math.abs(del2)
    vsum := nz(vsum[1]) + div * (volty - nz(volty[10]))
    
    temp_avg = ta.sma(vsum, avgLen)
    
    y = bar_index + 1
    if(y <= avgLen + 1)
        avolty := nz(avolty[1]) + 2.0 * (vsum - nz(avolty[1])) / (avgLen + 1)	   
    else
        avolty := temp_avg
        
    dVolty = avolty > 0 ? volty / avolty : 0
    dVolty := dVolty > math.pow(len1, 1.0/pow1) ? math.pow(len1, 1.0/pow1) : dVolty
    dVolty := dVolty < 1 ? 1 : dVolty
    pow2 = math.pow(dVolty, pow1)
    len2 = math.sqrt(0.5 * (len - 1)) * len1
    Kv = math.pow(len2 / (len2 + 1), math.sqrt(pow2))
    bsmax := del1 > 0 ? src : src - Kv * del1
    bsmin := del2 < 0 ? src : src - Kv * del2
    phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5
    beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
    alpha = math.pow(beta, pow2)
    jma1 = 0.0, e0 = 0.0, e1 = 0.0, e2 = 0.0
    e0 := (1 - alpha) * src + alpha * nz(e0[1])
    e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
    e2 := (e0 + phaseRatio * e1 - nz(jma1[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
    jma1 := e2 + nz(jma1[1])
    jma1
    

src = input.source(close, "Source")
depth = input.int(15, "Depth")
depthphase = input.float(0, "Jurik Smoothing Phase")
lensmdd = input.int(300, "Smoothing Period")

_jcfbau(src, depth)=>
    jrc04 = 0.0, jrc05 = 0.0, jrc06 = 0.0, jrc13 = 0.0, jrc03 = 0.0, jrc08 = 0.0
    if (bar_index >= bar_index - depth * 2) 
        for k = depth - 1 to 0
            jrc04 := jrc04 + math.abs(nz(src[k]) - nz(src[k+1]))
            jrc05 := jrc05 + (depth + k) * math.abs(nz(src[k]) - nz(src[k+1]))
            jrc06 := jrc06 + nz(src[k+1])
    if(bar_index < bar_index - depth * 2)
        jrc03 := math.abs(src - nz(src[1]))
        jrc13 := math.abs(nz(src[depth]) - nz(src[depth+1]))
        jrc04 := jrc04 - jrc13 + jrc03
        jrc05 := jrc05 - jrc04 + jrc03 * depth
        jrc06 := jrc06 - nz(src[depth+1]) + nz(src[1])
    jrc08 := math.abs(depth * src - jrc06)
    jcfbaux = jrc05 == 0.0 ? 0.0 : jrc08/jrc05
    jcfbaux
    
jcfbaux = _jcfbau(src, depth)
signal = _a_jurik_filt(jcfbaux, lensmdd, depthphase)

plot(signal, color = color.white)
plot(jcfbaux, color = jcfbaux >= signal ? greencolor : color.gray, linewidth = 2)
barcolor(jcfbaux >= signal ? greencolor : color.gray)
All files in topic