traduzione codice Donchian Volatility

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #232658 quote
    Msport71
    Participant
    Junior

    Buongiorno,

    sono a chiedere cortese traduzione del codice in oggetto che analizza la larghezza del canale di donchian come indicatore di volatilità dell’asset.

    Mi sembra interessante.

    Grazie dell’aiuto

    https://it.tradingview.com/script/UYVkIXD3-Donchian-Volatility-Indicator-Adaptive-Channel-Width/

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

    //@version=5
    indicator(“Donchian Volatility Indicator – Adaptive Channel Width”, overlay=false)

    // Calculation Inputs
    length = input.int(50, “Lookback Period for Donchian Channel”)
    atrPeriod = input.int(14, “ATR Period”)
    atrMultiplier = input.float(2.0, “ATR Multiplier”)
    lookbackPeriod = input.int(250, “Lookback Period for Extremes”)
    signalPeriod = input.int(50, “Length of Signal Line”)

    // Calculate ATR
    atr = ta.atr(length = atrPeriod)

    // Calculate Upper and Lower Channels
    upperChannel = ta.highest(high, length) + atr * atrMultiplier
    lowerChannel = ta.lowest(low, length) – atr * atrMultiplier

    // Calculate Channel Width
    channelWidth = upperChannel – lowerChannel

    // Signal Line
    signalLine = ta.sma(channelWidth, signalPeriod)

    // Plotting
    plot(channelWidth, color=color.maroon, linewidth=4, title=”Channel Width”)
    plot(signalLine, color=color.aqua, linewidth=4, title=”Signal Line”)

    // Bar Color
    barC = channelWidth > signalLine ? color.lime : color.fuchsia
    barcolor(barC)

    // Background Color
    bgcolor(barC, transp=80)

    Screenshot-2024-05-15-at-09-31-08-Donchian-Volatility-Indicator-Adaptive-Channel-Width-di-LeafAlgo.png Screenshot-2024-05-15-at-09-31-08-Donchian-Volatility-Indicator-Adaptive-Channel-Width-di-LeafAlgo.png
    #232698 quote
    Iván González
    Moderator
    Master

    Hola qui hai il codice:

    //-----------------------------------------------------------//
    //PRC_Donchian Volatility Indicator
    //version = 0
    //15.05.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-----------------------------------------------------------//
    //-----Inputs------------------------------------------------//
    length=50//Lookback Period for Donchian Channel
    atrPeriod=14//ATR Period
    atrMultiplier=2.0//ATR Multiplier
    lookbackPeriod=250//Lookback Period for Extremes
    signalPeriod=50//Length of Signal Line
    //-----------------------------------------------------------//
    //-----Calculate ATR-----------------------------------------//
    atr=averagetruerange[atrPeriod](close)
    //-----------------------------------------------------------//
    //-----Calculate Upper and Lower Channels--------------------//
    upperChannel=highest[length](high)+atr*atrMultiplier
    lowerChannel=lowest[length](low)-atr*atrMultiplier
    //-----------------------------------------------------------//
    //-----Calculate Channel Width-------------------------------//
    channelWidth=upperChannel-lowerChannel
    //-----------------------------------------------------------//
    //-----Signal Line-------------------------------------------//
    signalLine=average[signalPeriod](channelWidth)
    //-----------------------------------------------------------//
    //-----Bar Color---------------------------------------------//
    if channelWidth>signalLine then
    r=0
    g=230
    b=118
    else
    r=224
    g=64
    b=251
    endif
    //This piece of code works in price chart
    //DRAWCANDLE(open, high, low, close) coloured(r,g,b)
    //-----------------------------------------------------------//
    //-----Background Color--------------------------------------//
    BACKGROUNDCOLOR (r,g,b,30)
    //-----------------------------------------------------------//
    //-----Plotting----------------------------------------------//
    return channelWidth as "Channel Width"coloured("maroon")style(line,4),signalLine as "Signal Line"coloured("aqua")style(line,4)
    
    Distincttacos thanked this post
    #232703 quote
    Msport71
    Participant
    Junior

    Grazie e mille!!!!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

traduzione codice Donchian Volatility


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Msport71 @carlo-pasca Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Msport71
1 year, 10 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 05/15/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...