traduzione codice TW ADx Candle

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #240231 quote
    Msport71
    Participant
    Senior

    Buongiorno,

    richiedo cortese traduzione del seguente codice mi sembra piuttosto interessante mi piacerebbe testarlo; grazie come sempre per l’aiuto prezioso.

    https://www.tradingview.com/script/ZTxqGBuF/

    //@version=2
    study(“ADX Candle”,overlay=true)
    len = input(title=”Length”, type=integer, defval=10)
    th = input(title=”threshold”, type=integer, defval=20)

    TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))
    DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0
    DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0

    SmoothedTrueRange = nz(SmoothedTrueRange[1]) – (nz(SmoothedTrueRange[1])/len) + TrueRange
    SmoothedDirectionalMovementPlus = nz(SmoothedDirectionalMovementPlus[1]) – (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus
    SmoothedDirectionalMovementMinus = nz(SmoothedDirectionalMovementMinus[1]) – (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus

    DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
    DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
    DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
    ADX = sma(DX, len)
    //smooth DI
    di=(sma((DIPlus-DIMinus),5)+(DIPlus-DIMinus))/2

    adxin=(ADX+ADX[14])/2
    cy=cross(ADX,adxin)?black:di>=0 and ADX>th?lime:di<0 and ADX>th?red:ADX<th?silver:na
    barcolor(color=cy)

    Screenshot-2024-11-11-at-08-22-33-ADX-Candle-—-Indicator-by-MarcoValente-—-TradingView.png Screenshot-2024-11-11-at-08-22-33-ADX-Candle-—-Indicator-by-MarcoValente-—-TradingView.png
    #240291 quote
    Iván González
    Moderator
    Legend

    Ecco qui

    //---------------------------------------//
    
    
    //---------------------------------------//
    // Inputs
    //---------------------------------------//
    len=10
    th=20
    //---------------------------------------//
    // ADX and Directionals
    //---------------------------------------//
    If barindex>1 then
    trueRange=max(max(high-low,abs(high-close[1])),abs(low-close[1]))
    if (high-high[1]) > (low[1]-low) then
    DMplus=max(high-high[1],0)
    else
    DMplus=0
    endif
    
    if (low[1]-low) > (high-high[1]) then
    DMMinus=max(low[1]-low,0)
    else
    DMMinus=0
    endif
    
    SmoothedTrueRange=SmoothedtrueRange[1]-SmoothedtrueRange[1]/len+TrueRange
    SmoothedDMplus=SmoothedDMplus[1]-SmoothedDMplus[1]/len+DMplus
    SmoothedDMMinus=SmoothedDMMinus[1]-SmoothedDMMinus[1]/len+DMMinus
    
    DIP=SmoothedDMplus/SmoothedTrueRange*100
    DIM=SmoothedDMMinus/SmoothedTrueRange*100
    
    DX=ABS(DIP-DIM)/(DIP+DIM)*100
    ADX1=AVERAGE[LEN](DX)
    
    smoothDi=(average[5](DIP-DIM)+(DIP-DIM))/2
    adxin=(adx1+adx1[14])/2
    
    if adx1 crosses over adxin or adx1 crosses under adx1 then
    r=0
    g=0
    b=0
    elsif smoothDi >=0 and adx1>th then
    r=0
    g=255
    b=0
    elsif smoothDi<0 and adx1>th then
    r=255
    g=0
    b=0
    elsif adx1<th then
    r=124
    g=124
    b=124
    else
    r=255
    g=255
    b=255
    endif
    drawcandle(open,high,low,close)coloured(r,g,b)
    endif
    //---------------------------------------//
    return 
    Msport71 thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

traduzione codice TW ADx Candle


ProBuilder: Indicatori & Strumenti Personalizzati

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

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
1 year, 10 months ago.

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