Kalman hull supertend
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Kalman hull supertend
- This topic has 5 replies, 4 voices, and was last updated 6 months ago by Stenozar.
Viewing 6 posts - 1 through 6 (of 6 total)
-
-
05/11/2024 at 7:54 AM #232543
Buongiorno, è possibile tradurre questo indicatore? metto il link perchè non mi fa pubblicare il post se copio il codice: https://www.tradingview.com/script/PPHncdRt-Kalman-Hull-Supertrend-BackQuant/
Grazie05/11/2024 at 12:34 PM #23254605/11/2024 at 2:21 PM #23254705/11/2024 at 3:22 PM #23254905/28/2024 at 12:37 PM #233145Hola Aquí ha un'approssimazione dell'indicatore. Non è esattamente uguale, ma cambiare i parametri può renderlo più o meno sensato.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152//--------------------------------------------------------------////PRC_Kalman Hull Supertrend//version = 0//28.05.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//--------------------------------------------------------------////-----Inputs---------------------------------------------------//pricesource=customclosemeasurementNoise=3processNoise=0.01atrPeriod=12factor=1.7//showkalman=1//paintCandles=1//showlongshort=1//--------------------------------------------------------------////-----Kalman Price Filter Function-----------------------------//N=5if not isset($stateEstimate1[0]) thenfor j=0 to N-1 do$stateEstimate1[j]=pricesource$errorCovariance1[j]=1nextendiffor i=0 to N-1 do$predictedStateEstimate1[i]=$stateEstimate1[i]$predictedErrorCovariance1[i]=$errorCovariance1[i]+processNoisenextfor k=0 to N-1 dokg1=$predictedErrorCovariance1[k]/($predictedErrorCovariance1[k]+measurementNoise)$kalmanGain1[k]=kg1$stateEstimate1[k]=$predictedStateEstimate1[k]+kg1*(pricesource-$predictedStateEstimate1[k])$errorCovariance1[k]=(1-kg1)*$predictedErrorCovariance1[k]nextKalman1=$stateEstimate1[0]//--------------------------------------------------------------////-----Hull Moving Average with Kalman--------------------------////Kalman2if not isset($stateEstimate2[0]) thenfor j=0 to N-1 do$stateEstimate2[j]=pricesource$errorCovariance2[j]=1nextendiffor i=0 to N-1 do$predictedStateEstimate2[i]=$stateEstimate2[i]$predictedErrorCovariance2[i]=$errorCovariance2[i]+processNoisenextfor k=0 to N-1 dokg2=$predictedErrorCovariance2[k]/($predictedErrorCovariance2[k]+measurementNoise/2)$kalmanGain2[k]=kg2$stateEstimate2[k]=$predictedStateEstimate2[k]+kg2*(pricesource-$predictedStateEstimate2[k])$errorCovariance2[k]=(1-kg2)*$predictedErrorCovariance2[k]nextKalman2=$stateEstimate2[0]//Kalman Hull MAsrc=2*Kalman2-Kalman1length=round(sqrt(measurementNoise))if not isset($stateEstimate3[0]) thenfor j=0 to N-1 do$stateEstimate3[j]=src$errorCovariance3[j]=1nextendiffor i=0 to N-1 do$predictedStateEstimate3[i]=$stateEstimate3[i]$predictedErrorCovariance3[i]=$errorCovariance3[i]+processNoisenextfor k=0 to N-1 dokg3=$predictedErrorCovariance3[k]/($predictedErrorCovariance3[k]+length)$kalmanGain3[k]=kg3$stateEstimate3[k]=$predictedStateEstimate3[k]+kg3*(src-$predictedStateEstimate3[k])$errorCovariance3[k]=(1-kg3)*$predictedErrorCovariance3[k]nextKalmanHMA=$stateEstimate3[0]//--------------------------------------------------------------////-----SuperTrend Function--------------------------------------//if barindex <= atrperiod thenupperband=kalmanHMAlowerband=kalmanHMAdirection=1elseatr=averagetruerange[atrPeriod](close)upperband=kalmanHMA+factor*atrlowerband=kalmanHMA-factor*atrprevlowerband=lowerband[1]prevupperband=upperband[1]if lowerband>prevlowerband or close[1]<prevlowerband thenlowerband=lowerbandelselowerband=prevlowerbandendifif upperband<prevupperband or close[1]>prevupperband thenupperband=upperbandelseupperband=prevupperbandendifprevST=ST[1]if prevST=prevupperband thenif close > upperband thendirection=-1elsedirection=1endifelseif close < lowerband thendirection=1elsedirection=-1endifendifif direction=-1 thenST=lowerbandelseST=upperbandendifendif//--------------------------------------------------------------////-----Conditional Trend----------------------------------------//once trend=0SuperTrendLong=direction crosses under 0SuperTrendShort=direction crosses over 0if SupertrendLong and not SuperTrendShort thentrend=1r=0g=188b=212drawtext("▲",barindex,low)coloured(r,g,b)elsif SuperTrendShort thentrend=-1r=255g=82b=82drawtext("▼",barindex,high)coloured(r,g,b)endif//--------------------------------------------------------------////--------------------------------------------------------------//return ST as "Kalman Hull SuperTrend" coloured(r,g,b)style(line,3)05/29/2024 at 2:05 PM #233235 -
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
Find exclusive trading pro-tools on
Similar topics: