traduzione codice TW SuperTrend Fisher

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

    Buongiorno a tutti,

    vorrei provare questo codice di cui richiedo cortese traduzione.

    Sembra rendere più preciso l’uso dell’indicatore con doppio supertrend, riducendo i falsi segnali, grazie all’abbinamento del Fisher transform ( che sinceramente non conosco).

    Grazie per la consueta collaborazione

    https://it.tradingview.com/script/gFaDiMOm-SuperTrend-Fisher-AlgoAlpha/

    Calculates the Fisher Transform:

    value = 0.0
    value := round_(.66 * ((src – low_) / (high_ – low_) – .5) + .67 * nz(value[1]))
    fish1 = 0.0
    fish1 := .5 * math.log((1 + value) / (1 – value)) + .5 * nz(fish1[1])
    fish1 := ta.hma(fish1, l)

    Calculates the SuperTrend:

    supertrend(factor, atrPeriod, srcc) =>
    src = srcc
    atr = atrr(srcc, atrPeriod)
    upperBand = src + factor * atr
    lowerBand = src – factor * atr
    prevLowerBand = nz(lowerBand[1])
    prevUpperBand = nz(upperBand[1])

    lowerBand := lowerBand > prevLowerBand or srcc[1] < prevLowerBand ? lowerBand : prevLowerBand
    upperBand := upperBand < prevUpperBand or srcc[1] > prevUpperBand ? upperBand : prevUpperBand
    int direction = na
    float superTrend = na
    prevSuperTrend = superTrend[1]
    if na(atr[1])
    direction := 1
    else if prevSuperTrend == prevUpperBand
    direction := srcc > upperBand ? -1 : 1
    else
    direction := srcc < lowerBand ? 1 : -1
    superTrend := direction == -1 ? lowerBand : upperBand
    [superTrend, direction]

    Screenshot-2024-04-16-at-08-50-20-SuperTrend-Fisher-AlgoAlpha-—-Indicatore-di-AlgoAlpha.png Screenshot-2024-04-16-at-08-50-20-SuperTrend-Fisher-AlgoAlpha-—-Indicatore-di-AlgoAlpha.png
    #231575 quote
    Iván González
    Moderator
    Master

    ciao
    ecco l’indicatore

     

    //-------------------------------------------------------------------------//
    //PRC_SuperTrend Fisher
    //version = 0
    //16.04.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-------------------------------------------------------------------------//
    //-----Inputs--------------------------------------------------------------//
    period=14//Fair-value Period
    length=14//EMA length
    len=9//Fisher Period
    stFactor=0.3//SuperTrend Factor
    stPeriod=10//SuperTrend Period
    l=20//Hma period
    //-------------------------------------------------------------------------//
    n=max(period,max(l,length))*3
    //-----Detrended Price Oscillator + Standard deviation---------------------//
    barsback=round(period/2)+1
    ma=average[period](close)
    dpo1=close-ma[barsback]
    sd = dpo1/(average[period,1](high-low))*100
    //-------------------------------------------------------------------------//
    //-----Fisher Transform Formula + Smoothing--------------------------------//
    src=sd
    high1=highest[len](src)
    low1=lowest[len](src)
    if barindex <= n then
    myvalue=src
    fish1=src
    MAfish=src
    else
    val=0.66*((src-low1)/(high1-low1)-0.5)+0.67*myvalue[1]
    
    if val > 0.99 then
    myvalue=0.999
    elsif val < -0.99 then
    myvalue=-0.999
    else
    myvalue=val
    endif
    fish1= 0.5*log((1+myvalue)/(1-myvalue))+0.5*mafish1[1]
    mafish1=hullaverage[l](fish1)
    endif
    //-------------------------------------------------------------------------//
    source=mafish1
    //-------------------------------------------------------------------------//
    //-----ATR from Fisher transformation--------------------------------------//
    hh=highest[stPeriod](source)
    ll=lowest[stPeriod](source)
    if barindex<=stPeriod then
    trueRange=hh-ll
    else
    trueRange=max(max(hh-ll,abs(hh-source[1])),abs(ll-source[1]))
    endif
    alpha = 1/stPeriod
    if barindex <= n then
    atr = average[stPeriod](trueRange)
    else
    atr = alpha*trueRange + (1-alpha)*atr[1]
    endif
    //-------------------------------------------------------------------------//
    //-----Supertrend Integration----------------------------------------------//
    upperband=source+stFactor*atr
    lowerband=source-stFactor*atr
    
    if barindex <= n then
    prevLowerband=source
    prevUpperband=source
    else
    prevLowerband=lowerband[1]
    prevUpperband=upperband[1]
    
    if lowerband>prevlowerband or source[1]<prevlowerband then
    lowerband=lowerband
    else
    lowerband=prevlowerband
    endif
    
    if upperband < prevupperband or source[1]>prevupperband then
    upperband=upperband
    else
    upperband=prevupperband
    endif
    endif
    
    prevStvalue=stvalue[1]
    if prevStValue = prevupperband then
    if source > upperband then
    stdirection = -1
    else
    stdirection = 1
    endif
    else
    if source < lowerband then
    stdirection = 1
    else
    stdirection = -1
    endif
    
    endif
    if stdirection = -1 then
    stvalue=lowerband
    else
    stvalue=upperband
    endif
    
    q2= average[length,1](source)
    //-------------------------------------------------------------------------//
    //-----Overbought and Oversold Bands---------------------------------------//
    obLevel = 4.0
    osLevel = -4.0
    obupper = obLevel
    obmid = obLevel+0.9
    oblower = obLevel + 2
    osupper = osLevel
    osmid = osLevel - 0.9
    oslower = osLevel - 2
    //-------------------------------------------------------------------------//
    //-----Color definition----------------------------------------------------//
    if source > stValue then
    r =0
    g=255
    else
    r=255
    g=0
    endif
    if barindex > n then
    colorbetween(source,stvalue,r,g,0,90)
    
    colorbetween(obupper, oblower,"red",50)
    colorbetween(osupper, oslower,"green",50)
    colorbetween(obmid, oblower,"red",50)
    colorbetween(osmid, oslower,"green",50)
    endif
    //-------------------------------------------------------------------------//
    return q2 as "ema fish"coloured(120,123,134)style(line,2),source as "Fish"coloured(r,g,0),stValue as "StValue"coloured(r,g,0),0 as "0" coloured(121,121,121)
    
    #231578 quote
    Msport71
    Participant
    Junior

    Grazie e mille.

     

    Buon pomeriggio.

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

traduzione codice TW SuperTrend Fisher


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, 11 months ago.

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