traduzione codice TW Trend reversal Predictor

Forums ProRealTime forum Italiano Supporto ProBuilder traduzione codice TW Trend reversal Predictor

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

    Buongiorno a tutti,

    vorrei provare questo interessante codice trovato su TW, abbastanza recente e che mi sembra interessante.

    Un grande grazie per il consueto aiuto.

    https://www.tradingview.com/script/T7AZI0z6-Trend-Reversal-Predictor/

    //@version=5
    indicator(“Danger Zones”, overlay=true)

    // Step 1: Trend Identification
    length = input.int(200, minval=1)
    src = input(close, title=”Source”)
    hma = ta.wma(2 * ta.wma(src, length / 2) – ta.wma(src, length), math.floor(math.sqrt(length)))
    start = input(0.02)
    increment = input(0.02)
    maximum = input(0.2, “Max Value”)
    sar = ta.sar(start, increment, maximum)

    trendUp = close > hma and close > sar
    trendDown = close < hma and close < sar
    trendNeutral = not trendUp and not trendDown

    // Step 2: Danger Zone Identification
    buyingVolumeSlowdownPeriod = input(5, title=”Buying Volume Slowdown Period”)
    sellingVolumeSlowdownPeriod = input(5, title=”Selling Volume Slowdown Period”)
    buyingVolumeRateOfChange = ta.change(volume, buyingVolumeSlowdownPeriod)
    sellingVolumeRateOfChange = ta.change(volume, sellingVolumeSlowdownPeriod)
    adrPeriod = input(14, title=”Average Daily Range (ADR) Period”)
    adr = ta.atr(adrPeriod)

    // Calculate average volume rate of change and net price movement
    averageBuyingVolumeRateOfChange = ta.sma(buyingVolumeRateOfChange, 5)
    averageSellingVolumeRateOfChange = ta.sma(sellingVolumeRateOfChange, 5)
    averageNetPriceMovement = ta.sma(close – close[1], 5)

    // RSI Integration
    ma(source, length, type) =>
    switch type
    “SMA” => ta.sma(source, length)
    “Bollinger Bands” => ta.sma(source, length)
    “EMA” => ta.ema(source, length)
    “SMMA (RMA)” => ta.rma(source, length)
    “WMA” => ta.wma(source, length)
    “VWMA” => ta.vwma(source, length)

    rsiLengthInput = input.int(14, minval=1, title=”RSI Length”, group=”RSI Settings”)
    rsiSourceInput = input.source(close, “Source”, group=”RSI Settings”)
    maTypeInput = input.string(“SMA”, title=”MA Type”, options=[“SMA”, “Bollinger Bands”, “EMA”, “SMMA (RMA)”, “WMA”, “VWMA”], group=”MA Settings”)
    maLengthInput = input.int(14, title=”MA Length”, group=”MA Settings”)
    bbMultInput = input.float(2.0, minval=0.001, maxval=50, title=”BB StdDev”, group=”MA Settings”)

    up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
    down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
    rsi = down == 0 ? 100 : up == 0 ? 0 : 100 – (100 / (1 + up / down))
    rsiMA = ma(rsi, maLengthInput, maTypeInput)
    isBB = maTypeInput == “Bollinger Bands”
    rsiBelowMA = rsi < rsiMA
    rsiAboveMA = rsi > rsiMA

    // Step 3: Trend Ending Prediction

    // Combine Conditions
    uptrendDangerZone = trendUp and buyingVolumeRateOfChange <= averageBuyingVolumeRateOfChange and averageNetPriceMovement < 0 and rsiBelowMA
    downtrendDangerZone = trendDown and sellingVolumeRateOfChange <= averageSellingVolumeRateOfChange and averageNetPriceMovement > 0 and rsiAboveMA
    rsiConditionUp = trendUp and rsiBelowMA
    rsiConditionDown = trendDown and rsiAboveMA
    trendReversalConditionUp = uptrendDangerZone and rsiConditionUp
    trendReversalConditionDown = downtrendDangerZone and rsiConditionDown

    // Final Trend Ending Prediction
    trendEndingPredictionUp = trendReversalConditionUp and rsiBelowMA
    trendEndingPredictionDown = trendReversalConditionDown and rsiAboveMA

    bgcolor(uptrendDangerZone ? color.orange : downtrendDangerZone ? color.blue : na, transp=70)

    #230268

    Ecco cosa hai:
    https://www.prorealcode.com/prorealtime-indicators/danger-zones-indicator/

    1 user thanked author for this post.
    #230277

    Gentilissimo, geazie!

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