Blackflag FTS indicator

Forums ProRealTime forum Italiano Supporto ProBuilder Blackflag FTS indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • #245324

    Buon pomeriggio, chiedo la traduzione del seguente indicatore.

    Grazie

     

    //@version=6
    indicator(“Blackflag FTS”, overlay = true)

    // inputs
    trailType = input.string(“modified”, title = “Trailtype”, options = [“modified”, “unmodified”])
    ATRPeriod = input.int(28, title = “ATR Period”)
    ATRFactor = input.int(12, title = “ATR Factor”)
    show_fib_entries = input.bool(true, title = “Show Fib Entries?”)

    norm_o = request.security(syminfo.tickerid, timeframe.period, open)
    norm_h = request.security(syminfo.tickerid, timeframe.period, high)
    norm_l = request.security(syminfo.tickerid, timeframe.period, low)
    norm_c = request.security(syminfo.tickerid, timeframe.period, close)

    //////// FUNCTIONS //////////////
    Wild_ma(_src, _malength) =>
    var _wild = 0.0
    _wild := na(_wild[1]) ? _src : _wild[1] + (_src – _wild[1]) / _malength

    /////////// TRUE RANGE CALCULATIONS /////////////////
    HiLo = math.min(norm_h – norm_l, 1.5 * ta.sma((norm_h – norm_l), ATRPeriod))

    HRef = norm_l <= norm_h[1] ?
    norm_h – norm_c[1] :
    (norm_h – norm_c[1]) – 0.5 * (norm_l – norm_h[1])

    LRef = norm_h >= norm_l[1] ?
    norm_c[1] – norm_l :
    (norm_c[1] – norm_l) – 0.5 * (norm_l[1] – norm_h)

    trueRange =
    trailType == “modified” ? math.max(HiLo, HRef, LRef) :
    math.max(norm_h – norm_l, math.abs(norm_h – norm_c[1]), math.abs(norm_l – norm_c[1]))

    /////////// TRADE LOGIC ////////////////////////
    loss = ATRFactor * Wild_ma(trueRange, ATRPeriod)

    Up = norm_c – loss
    Dn = norm_c + loss

    var TrendUp = Up
    var TrendDown = Dn
    var Trend = 1 // Initialize Trend as long (1)

    TrendUp := norm_c[1] > TrendUp[1] ? math.max(Up, TrendUp[1]) : Up
    TrendDown := norm_c[1] < TrendDown[1] ? math.min(Dn, TrendDown[1]) : Dn

    Trend := norm_c > TrendDown[1] ? 1 : norm_c < TrendUp[1] ? -1 : Trend[1]
    trail = Trend == 1 ? TrendUp : TrendDown

    ex = 0.0
    ex :=
    ta.crossover(Trend[1], 0) ? norm_h :
    ta.crossunder(Trend[1], 0) ? norm_l :
    Trend == 1 ? math.max(ex[1], norm_h) :
    Trend == -1 ? math.min(ex[1], norm_l) : ex[1]

    ////// FIBONACCI LEVELS ///////////
    state = Trend == 1 ? “long” : “short”

    fib1Level = 61.8
    fib2Level = 78.6
    fib3Level = 88.6

    f1 = ex + (trail – ex) * fib1Level / 100
    f2 = ex + (trail – ex) * fib2Level / 100
    f3 = ex + (trail – ex) * fib3Level / 100
    l100 = trail + 0

    Fib1 = plot(f1, title = “Fib 1”, style = plot.style_line, color = color.black)
    Fib2 = plot(f2, title = “Fib 2”, style = plot.style_line, color = color.black)
    Fib3 = plot(f3, title = “Fib 3”, style = plot.style_line, color = color.black)
    L100 = plot(l100, title = “l100”, style = plot.style_line, color = color.black)

    fill(Fib1, Fib2, color = state == “long” ? color.green : state == “short” ? color.red : na)
    fill(Fib2, Fib3, color = state == “long” ? color.new(color.green, 70) : state == “short” ? color.new(color.red, 70) : na)
    fill(Fib3, L100, color = state == “long” ? color.new(color.green, 60) : state == “short” ? color.new(color.red, 60) : na)

    l1 = state[1] == “long” and ta.crossunder(norm_c, f1[1])
    l2 = state[1] == “long” and ta.crossunder(norm_c, f2[1])
    l3 = state[1] == “long” and ta.crossunder(norm_c, f3[1])
    s1 = state[1] == “short” and ta.crossover(norm_c, f1[1])
    s2 = state[1] == “short” and ta.crossover(norm_c, f2[1])
    s3 = state[1] == “short” and ta.crossover(norm_c, f3[1])

    atr = ta.sma(trueRange, 14)

    /////////// FIB PLOTS /////////////////
    plotshape(show_fib_entries and l1 ? low – atr : na, title = “LS1”, style = shape.triangleup, location = location.belowbar, color = color.yellow, size = size.tiny)
    plotshape(show_fib_entries and l2 ? low – 1.5 * atr : na, title = “LS2”, style = shape.triangleup, location = location.belowbar, color = color.yellow, size = size.tiny)
    plotshape(show_fib_entries and l3 ? low – 2 * atr : na, title = “LS3”, style = shape.triangleup, location = location.belowbar, color = color.yellow, size = size.tiny)
    plotshape(show_fib_entries and s1 ? high + atr : na, title = “SS1”, style = shape.triangledown, location = location.abovebar, color = color.purple, size = size.tiny)
    plotshape(show_fib_entries and s3 ? high + 2 * atr : na, title = “SS3″, style = shape.triangledown, location = location.abovebar, color = color.purple, size = size.tiny)

    /////////// ADDING BUY and SELL INDICATORS ////////////

    // Conditions for Trend Change (Green -> Red or Red -> Green)
    trendChangeToRed = Trend == -1 and Trend[1] == 1 // Green to Red
    trendChangeToGreen = Trend == 1 and Trend[1] == -1 // Red to Green

    // Plot only the color changes without text
    plotshape(trendChangeToRed, title=”Trend Change to Red”, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
    plotshape(trendChangeToGreen, title=”Trend Change to Green”, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)

    // Adding Alerts for Trend Change
    alertcondition(trendChangeToRed, title=”Trend Change to Red”, message=”Trend changed from Green to Red.”)
    alertcondition(trendChangeToGreen, title=”Trend Change to Green”, message=”Trend changed from Red to Green.”)

    #245333

    Ecco

    #245366

    Grazie mille!

Viewing 3 posts - 1 through 3 (of 3 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login