Traduzione Codice “Market Structure Algo” da TV

Forums ProRealTime forum Italiano Supporto ProBuilder Traduzione Codice “Market Structure Algo” da TV

Viewing 3 posts - 1 through 3 (of 3 total)
  • #252684
    Buongiorno, ho notato su TV questo indicatore che trovo fantastico, si potrebbe avere la traduzione in PRT?
    Grazie in anticipo!
    Franco
    // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © OmegaTools
    //@version=5
    indicator(“Market Structure Algo”, “MS Algo”, true)
    left = input.int(5, “Internal MS”, minval = 2)
    left1 = input.int(30, “External MS”, minval = 7)
    dist = input.float(2.00, “Zone Distance”, minval = 1, step = 0.1, inline = “zone”)
    zone = input.bool(true, “”, inline = “zone”)
    right = left
    right1 = left1
    upcolor = input.color(#2962ff, “Positive color”, group = “Appearence”)
    downcolor = input.color(#e91e63, “Negative color”, group = “Appearence”)
    // Internal
    pvh = ta.pivothigh(left, right)
    pvl = ta.pivotlow(left, right)
    var float ph = na
    var float pl = na
    ph := pvh != 0 ? pvh : ph[1]
    pl := pvl != 0 ? pvl : pl[1]
    currenth = ta.valuewhen(pvh != 0, high[right], 0)
    lasth = ta.valuewhen(pvh != 0, high[right], 1)
    currentl = ta.valuewhen(pvl != 0, low[right], 0)
    lastl = ta.valuewhen(pvl != 0, low[right], 1)
    var int ms = na
    ms := if currenth > lasth and currentl > lastl and close > ph
        ms := 2
    else if close > ph
        ms := 1
    else if currenth < lasth and currentl < lastl and close < pl
        ms := -2
    else if close < pl
        ms := -1
    else
        ms[1]
    var int last = na
    longsig = close > ph and ms[1] < 0
    shortsig = close < pl and ms[1] > 0
    longsig1 = close > ph and ms[1] > 0
    shortsig1 = close < pl and ms[1] < 0
    longsig2 = longsig1 and longsig1[1] == false and longsig[1] == false
    shortsig2 = shortsig1 and shortsig1[1] == false and shortsig[1] == false
    longexit = high > ph and close < ph
    shortexit = low < pl and close > pl
    // External
    pvh1 = ta.pivothigh(left1, right1)
    pvl1 = ta.pivotlow(left1, right1)
    var float ph1 = na
    var float pl1 = na
    ph1 := pvh1 != 0 ? pvh1 : ph1[1]
    pl1 := pvl1 != 0 ? pvl1 : pl1[1]
    // Zone
    ma = ta.sma(close, left1)
    atr = ta.atr(left1)
    ma2 = ms > 0 and ms[1] > 0 ? ma – atr * dist : ms < 0 and ms[1] < 0 ? ma + atr*dist : na
    ma3 = ms > 0 and ms[1] > 0 ? ma2 + atr : ms < 0 and ms[1] < 0 ? ma2 – atr : na
    // Plot
    if pvh != 0
        l1 = line.new(x1 = bar_index – right, y1 = ph, x2 = bar_index + math.round(right/2), y2 = ph, color = color.new(upcolor, 50), style = line.style_dashed)
    if pvl != 0
        l2 = line.new(x1 = bar_index – right, y1 = pl, x2 = bar_index + math.round(right/2), y2 = pl, color = color.new(downcolor, 50), style = line.style_dashed)
    if pvh1 != 0
        l3 = line.new(x1 = bar_index – right1, y1 = ph1, x2 = bar_index + math.round(right1/2), y2 = ph1, color = upcolor, width = 2)
    if pvl1 != 0
        l4 = line.new(x1 = bar_index – right1, y1 = pl1, x2 = bar_index + math.round(right1/2), y2 = pl1, color = downcolor, width = 2)
    barcolor(ms >= 2 ? upcolor : ms == 1 ? color.new(upcolor, 50) : ms <= -2 ? downcolor : ms == -1 ? color.new(downcolor, 50) : na)
    plotshape(longsig, “Long Signal”, shape.labelup, location.belowbar, upcolor, 0, “↑”, textcolor = color.new(color.white, 50))
    plotshape(longsig2, “Buy Signal”, shape.triangleup, location.belowbar, upcolor)
    plotshape(shortsig, “Short Signal”, shape.labeldown, location.abovebar, downcolor, 0, “↓”, textcolor = color.new(color.white, 50))
    plotshape(shortsig2, “Sell Signal”, shape.triangledown, location.abovebar, downcolor)
    plotshape(longexit, “Long Exit”, shape.triangledown, location.abovebar, color.gray)
    plotshape(shortexit, “Short Exit”, shape.triangleup, location.belowbar, color.gray)
    p1 = plot(zone ? ma2 : na, “External Zone”, close > ma2 ? upcolor : close < ma2 ? downcolor : na, 1, plot.style_linebr)
    p2 = plot(zone ? ma3 : na, “Internal Zone”, close > ma2 ? color.new(upcolor, 80) : close < ma2 ? color.new(downcolor, 80) : na, 1, plot.style_linebr)
    fill(p1, p2, color = close > ma2 ? color.new(upcolor, 80) : color.new(downcolor, 80), title = “Zone fill”)
    alertcondition(longsig, “Long CHoCH”)
    alertcondition(shortsig, “Short CHoCH”)
    alertcondition(longsig2, “Long BOS”)
    alertcondition(shortsig2, “Short BOS”)
    #252698

    Ecco:

    #252706

    Grazieeee Ivan lo provo buon weekend!

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