traduzione codice TW SuperTrend Fisher
Forums › ProRealTime forum Italiano › Supporto ProBuilder › traduzione codice TW SuperTrend Fisher
- This topic has 2 replies, 2 voices, and was last updated 8 months ago by Msport71.
-
-
04/16/2024 at 7:49 AM #231561
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]04/16/2024 at 1:21 PM #231575ciao
ecco l’indicatore123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136//-------------------------------------------------------------------------////PRC_SuperTrend Fisher//version = 0//16.04.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------------------------------------------////-----Inputs--------------------------------------------------------------//period=14//Fair-value Periodlength=14//EMA lengthlen=9//Fisher PeriodstFactor=0.3//SuperTrend FactorstPeriod=10//SuperTrend Periodl=20//Hma period//-------------------------------------------------------------------------//n=max(period,max(l,length))*3//-----Detrended Price Oscillator + Standard deviation---------------------//barsback=round(period/2)+1ma=average[period](close)dpo1=close-ma[barsback]sd = dpo1/(average[period,1](high-low))*100//-------------------------------------------------------------------------////-----Fisher Transform Formula + Smoothing--------------------------------//src=sdhigh1=highest[len](src)low1=lowest[len](src)if barindex <= n thenmyvalue=srcfish1=srcMAfish=srcelseval=0.66*((src-low1)/(high1-low1)-0.5)+0.67*myvalue[1]if val > 0.99 thenmyvalue=0.999elsif val < -0.99 thenmyvalue=-0.999elsemyvalue=valendiffish1= 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 thentrueRange=hh-llelsetrueRange=max(max(hh-ll,abs(hh-source[1])),abs(ll-source[1]))endifalpha = 1/stPeriodif barindex <= n thenatr = average[stPeriod](trueRange)elseatr = alpha*trueRange + (1-alpha)*atr[1]endif//-------------------------------------------------------------------------////-----Supertrend Integration----------------------------------------------//upperband=source+stFactor*atrlowerband=source-stFactor*atrif barindex <= n thenprevLowerband=sourceprevUpperband=sourceelseprevLowerband=lowerband[1]prevUpperband=upperband[1]if lowerband>prevlowerband or source[1]<prevlowerband thenlowerband=lowerbandelselowerband=prevlowerbandendifif upperband < prevupperband or source[1]>prevupperband thenupperband=upperbandelseupperband=prevupperbandendifendifprevStvalue=stvalue[1]if prevStValue = prevupperband thenif source > upperband thenstdirection = -1elsestdirection = 1endifelseif source < lowerband thenstdirection = 1elsestdirection = -1endifendifif stdirection = -1 thenstvalue=lowerbandelsestvalue=upperbandendifq2= average[length,1](source)//-------------------------------------------------------------------------////-----Overbought and Oversold Bands---------------------------------------//obLevel = 4.0osLevel = -4.0obupper = obLevelobmid = obLevel+0.9oblower = obLevel + 2osupper = osLevelosmid = osLevel - 0.9oslower = osLevel - 2//-------------------------------------------------------------------------////-----Color definition----------------------------------------------------//if source > stValue thenr =0g=255elser=255g=0endifif barindex > n thencolorbetween(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)04/16/2024 at 2:24 PM #231578 -
AuthorPosts
Find exclusive trading pro-tools on