Screener Super Trend AI Clustering
Forums › ProRealTime forum Français › Support ProScreener › Screener Super Trend AI Clustering
- This topic has 4 replies, 3 voices, and was last updated 2 weeks ago by
Alai-n.
-
-
09/11/2025 at 4:55 PM #250715
Bonjour,
Je souhaiterais modifier ce code disponible dans la bibliothèque des Indicateurs, le Super Trend AI Clustering.
Seulement, lorsque je fais une tentative j’ai des erreurs de syntaxe en pagaille que je n’arrive pas à régler!
Serait-il possible de simplifier l’écriture de ce code afin de pouvoir l’utiliser dans un Screener ?
Merci
Super Trend AI Clustering123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330//---------------------------------------------------------------////SuperTrend AI Clustering//version = 2//02.06.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------------------------------------------------------------////-----Inputs----------------------------------------------------////---------------------------------------------------------------////length=10 // ATR length//minMult=1//maxMult=5//step=0.5//perfAlpha=10 // Performance memory//fromCluster=1 // 1=best 2=average 3=worstmaxiter=10 // Número máximo de iteraciones de clusteringepsilon=0.0001 // Precisión para simular convergencia//---------------------------------------------------------------////-----Average True Range----------------------------------------////---------------------------------------------------------------//atr=averagetruerange[length](close)//---------------------------------------------------------------////-----Supertrend cálculo múltiple-------------------------------////---------------------------------------------------------------//$holderUpper[0]=(high+low)/2$holderLower[0]=(high+low)/2k=0for factor=0 to floor((maxMult-minMult)/step) doup=(high+low)/2+atr*factordn=(high+low)/2-atr*factorif close > $holderUpper[k] then$holderTrend[k]=1elsif close < $holderUpper[k] then$holderTrend[k]=0else$holderTrend[k]=$holderTrend[k]endifif close[1]<$holderUpper[k] then$holderUpper[k]=min(up,$holderUpper[k])else$holderUpper[k]=upendifif close[1]>$holderLower[k] then$holderLower[k]=max(dn,$holderLower[k])else$holderLower[k]=dnendifif (close[1]-$holderOutput[k])>0 thendiff=1elsif (close[1]-$holderOutput[k])<0 thendiff=-1elsediff=0endif$holderPerf[k]=$holderPerf[max(0,k-1)]+2/(perfAlpha+1)*((close-close[1])*diff-$holderPerf[max(0,k-1)])if $holderTrend[k]=1 then$holderOutput[k]=$holderLower[k]else$holderOutput[k]=$holderUpper[k]endif$holderFactor[k] = (minMult+k*step)k=k+1next//---------------------------------------------------------------////-----K-means con convergencia----------------------------------////---------------------------------------------------------------//centroid1 = 0centroid2 = 0centroid3 = 0count = kFOR i = 0 TO count - 1 DOIF i < count / 3 THENcentroid1 = centroid1 + $holderPerf[i]ELSIF i < 2 * count / 3 THENcentroid2 = centroid2 + $holderPerf[i]ELSEcentroid3 = centroid3 + $holderPerf[i]ENDIFNEXTcentroid1 = centroid1 / (count / 3)centroid2 = centroid2 / (count / 3)centroid3 = centroid3 / (count / 3)converged = 0iter = 0WHILE iter < maxiter AND converged = 0 DOold1 = centroid1old2 = centroid2old3 = centroid3$cluster1Perf[0] = 0$cluster2Perf[0] = 0$cluster3Perf[0] = 0$cluster1Factors[0] = 0$cluster2Factors[0] = 0$cluster3Factors[0] = 0FOR i = 0 TO count - 1 DOdist1 = abs($holderPerf[i] - centroid1)dist2 = abs($holderPerf[i] - centroid2)dist3 = abs($holderPerf[i] - centroid3)IF dist1 <= dist2 AND dist1 <= dist3 THEN$cluster1Perf[$cluster1Perf[0]+1] = $holderPerf[i]$cluster1Factors[$cluster1Factors[0]+1] = $holderFactor[i]$cluster1Perf[0] = $cluster1Perf[0] + 1$cluster1Factors[0] = $cluster1Factors[0] + 1ELSIF dist2 <= dist1 AND dist2 <= dist3 THEN$cluster2Perf[$cluster2Perf[0]+1] = $holderPerf[i]$cluster2Factors[$cluster2Factors[0]+1] = $holderFactor[i]$cluster2Perf[0] = $cluster2Perf[0] + 1$cluster2Factors[0] = $cluster2Factors[0] + 1ELSE$cluster3Perf[$cluster3Perf[0]+1] = $holderPerf[i]$cluster3Factors[$cluster3Factors[0]+1] = $holderFactor[i]$cluster3Perf[0] = $cluster3Perf[0] + 1$cluster3Factors[0] = $cluster3Factors[0] + 1ENDIFNEXTcentroid1 = 0centroid2 = 0centroid3 = 0IF $cluster1Perf[0] > 0 THENFOR i = 1 TO $cluster1Perf[0] DOcentroid1 = centroid1 + $cluster1Perf[i]NEXTcentroid1 = centroid1 / $cluster1Perf[0]ENDIFIF $cluster2Perf[0] > 0 THENFOR i = 1 TO $cluster2Perf[0] DOcentroid2 = centroid2 + $cluster2Perf[i]NEXTcentroid2 = centroid2 / $cluster2Perf[0]ENDIFIF $cluster3Perf[0] > 0 THENFOR i = 1 TO $cluster3Perf[0] DOcentroid3 = centroid3 + $cluster3Perf[i]NEXTcentroid3 = centroid3 / $cluster3Perf[0]ENDIFIF abs(centroid1 - old1) < epsilon AND abs(centroid2 - old2) < epsilonAND abs(centroid3 - old3) < epsilon THENconverged = 1ENDIFiter = iter + 1WEND//---------------------------------------------------------------////-----Cluster seleccionado y nuevo Supertrend-------------------////---------------------------------------------------------------//finalFactor = 0finalPerf = 0perf = 0fact = 0IF fromCluster = 1 THEN// BestIF centroid1 > max(centroid2, centroid3) THENFOR j = 1 TO lastset($cluster1Perf) DOperf = perf + $cluster1Perf[j]fact = fact + $cluster1Factors[j]NEXTfinalFactor = fact / lastset($cluster1Factors)if lastset($cluster1Perf) > 0 thenfinalPerf = perf / lastset($cluster1Perf)elsefinalPerf = 0endifELSIF centroid2 > max(centroid1, centroid3) THENFOR j = 1 TO lastset($cluster2Perf) DOperf = perf + $cluster2Perf[j]fact = fact + $cluster2Factors[j]NEXTfinalFactor = fact / lastset($cluster2Factors)if lastset($cluster2Perf) > 0 thenfinalPerf = perf / lastset($cluster2Perf)elsefinalPerf = 0endifELSEFOR j = 1 TO lastset($cluster3Perf) DOperf = perf + $cluster3Perf[j]fact = fact + $cluster3Factors[j]NEXTfinalFactor = fact / lastset($cluster3Factors)if lastset($cluster3Perf) > 0 thenfinalPerf = perf / lastset($cluster3Perf)elsefinalPerf = 0endifENDIFELSIF fromCluster = 2 THEN// AverageIF centroid1 > centroid2 AND centroid1 < centroid3 THENFOR j = 1 TO lastset($cluster1Perf) DOperf = perf + $cluster1Perf[j]fact = fact + $cluster1Factors[j]NEXTfinalFactor = fact / lastset($cluster1Factors)if lastset($cluster1Perf) > 0 thenfinalPerf = perf / lastset($cluster1Perf)elsefinalPerf = 0endifELSIF centroid2 > centroid1 AND centroid2 < centroid3 THENFOR j = 1 TO lastset($cluster2Perf) DOperf = perf + $cluster2Perf[j]fact = fact + $cluster2Factors[j]NEXTfinalFactor = fact / lastset($cluster2Factors)if lastset($cluster2Perf) > 0 thenfinalPerf = perf / lastset($cluster2Perf)elsefinalPerf = 0endifELSEFOR j = 1 TO lastset($cluster3Perf) DOperf = perf + $cluster3Perf[j]fact = fact + $cluster3Factors[j]NEXTfinalFactor = fact / lastset($cluster3Factors)if lastset($cluster3Perf) > 0 thenfinalPerf = perf / lastset($cluster3Perf)elsefinalPerf = 0endifENDIFELSIF fromCluster = 3 THEN// WorstIF centroid1 < min(centroid2, centroid3) THENFOR j = 1 TO lastset($cluster1Perf) DOperf = perf + $cluster1Perf[j]fact = fact + $cluster1Factors[j]NEXTfinalFactor = fact / lastset($cluster1Factors)if lastset($cluster1Perf) > 0 thenfinalPerf = perf / lastset($cluster1Perf)elsefinalPerf = 0endifELSIF centroid2 < min(centroid1, centroid3) THENFOR j = 1 TO lastset($cluster2Perf) DOperf = perf + $cluster2Perf[j]fact = fact + $cluster2Factors[j]NEXTfinalFactor = fact / lastset($cluster2Factors)if lastset($cluster2Perf) > 0 thenfinalPerf = perf / lastset($cluster2Perf)elsefinalPerf = 0endifELSEFOR j = 1 TO lastset($cluster3Perf) DOperf = perf + $cluster3Perf[j]fact = fact + $cluster3Factors[j]NEXTfinalFactor = fact / lastset($cluster3Factors)if lastset($cluster3Perf) > 0 thenfinalPerf = perf / lastset($cluster3Perf)elsefinalPerf = 0endifENDIFENDIF//---------------------------------------------------------------////-----Renderizado final del Supertrend--------------------------////---------------------------------------------------------------//newup = (high + low) / 2 + atr * finalFactornewdown = (high + low) / 2 - atr * finalFactorif close[1] < newupper thennewupper = min(newup, newupper)elsenewupper = newupendifif close[1] > newlower thennewlower = max(newdown, newlower)elsenewlower = newdownendifif close > newupper thennewOS = 1elsif close < newlower thennewOS = 0elsenewOS = newOSendifif newOS and newOS[1]=0 thennewST = newlowerr = 0g = 255transp=0elsif newOS thennewST = newlowerr = 0g = 255transp=255elsif newOS=0 and newOS[1] thennewST = newupperr = 255g = 0transp=0elsenewST = newupperr = 255g = 0transp=255endif//---------------------------------------------------------------//return newST style(line,2) coloured(r,g,0,transp)09/11/2025 at 5:19 PM #250724Les lignes 156 et 157 étaient séparées, alors qu’elles auraient dû être une seule ligne :
1IF abs(centroid1 - old1) < epsilon AND abs(centroid2 - old2) < epsilon AND abs(centroid3 - old3) < epsilon THEN09/12/2025 at 8:53 AM #250743Bonjour. Tu dois supprimer toutes les variables qui ne sont pas utilisées dans le code.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253//-----Inputslength=10minMult=1maxMult=5step=0.5perfAlpha=10 // Performance memoryfromCluster=1 // 1=best 2=average 3=worstmaxiter=10 // Número máximo de iteraciones de clusteringepsilon=0.0001 // Precisión para simular convergencia//-----Average True Rangeatr=averagetruerange[length](close)//-----Supertrend cálculo múltiple$holderUpper[0]=(high+low)/2$holderLower[0]=(high+low)/2k=0for factor=0 to floor((maxMult-minMult)/step) doup=(high+low)/2+atr*factordn=(high+low)/2-atr*factorif close > $holderUpper[k] then$holderTrend[k]=1elsif close < $holderUpper[k] then$holderTrend[k]=0else$holderTrend[k]=$holderTrend[k]endifif close[1]<$holderUpper[k] then$holderUpper[k]=min(up,$holderUpper[k])else$holderUpper[k]=upendifif close[1]>$holderLower[k] then$holderLower[k]=max(dn,$holderLower[k])else$holderLower[k]=dnendifif (close[1]-$holderOutput[k])>0 thendiff=1elsif (close[1]-$holderOutput[k])<0 thendiff=-1elsediff=0endif$holderPerf[k]=$holderPerf[max(0,k-1)]+2/(perfAlpha+1)*((close-close[1])*diff-$holderPerf[max(0,k-1)])if $holderTrend[k]=1 then$holderOutput[k]=$holderLower[k]else$holderOutput[k]=$holderUpper[k]endif$holderFactor[k] = (minMult+k*step)k=k+1next//-----K-means con convergenciacentroid1 = 0centroid2 = 0centroid3 = 0count = kFOR i = 0 TO count - 1 DOIF i < count / 3 THENcentroid1 = centroid1 + $holderPerf[i]ELSIF i < 2 * count / 3 THENcentroid2 = centroid2 + $holderPerf[i]ELSEcentroid3 = centroid3 + $holderPerf[i]ENDIFNEXTcentroid1 = centroid1 / (count / 3)centroid2 = centroid2 / (count / 3)centroid3 = centroid3 / (count / 3)converged = 0iter = 0WHILE iter < maxiter AND converged = 0 DOold1 = centroid1old2 = centroid2old3 = centroid3$cluster1Perf[0] = 0$cluster2Perf[0] = 0$cluster3Perf[0] = 0$cluster1Factors[0] = 0$cluster2Factors[0] = 0$cluster3Factors[0] = 0FOR i = 0 TO count - 1 DOdist1 = abs($holderPerf[i] - centroid1)dist2 = abs($holderPerf[i] - centroid2)dist3 = abs($holderPerf[i] - centroid3)IF dist1 <= dist2 AND dist1 <= dist3 THEN$cluster1Perf[$cluster1Perf[0]+1] = $holderPerf[i]$cluster1Factors[$cluster1Factors[0]+1] = $holderFactor[i]$cluster1Perf[0] = $cluster1Perf[0] + 1$cluster1Factors[0] = $cluster1Factors[0] + 1ELSIF dist2 <= dist1 AND dist2 <= dist3 THEN$cluster2Perf[$cluster2Perf[0]+1] = $holderPerf[i]$cluster2Factors[$cluster2Factors[0]+1] = $holderFactor[i]$cluster2Perf[0] = $cluster2Perf[0] + 1$cluster2Factors[0] = $cluster2Factors[0] + 1ELSE$cluster3Perf[$cluster3Perf[0]+1] = $holderPerf[i]$cluster3Factors[$cluster3Factors[0]+1] = $holderFactor[i]$cluster3Perf[0] = $cluster3Perf[0] + 1$cluster3Factors[0] = $cluster3Factors[0] + 1ENDIFNEXTcentroid1 = 0centroid2 = 0centroid3 = 0IF $cluster1Perf[0] > 0 THENFOR i = 1 TO $cluster1Perf[0] DOcentroid1 = centroid1 + $cluster1Perf[i]NEXTcentroid1 = centroid1 / $cluster1Perf[0]ENDIFIF $cluster2Perf[0] > 0 THENFOR i = 1 TO $cluster2Perf[0] DOcentroid2 = centroid2 + $cluster2Perf[i]NEXTcentroid2 = centroid2 / $cluster2Perf[0]ENDIFIF $cluster3Perf[0] > 0 THENFOR i = 1 TO $cluster3Perf[0] DOcentroid3 = centroid3 + $cluster3Perf[i]NEXTcentroid3 = centroid3 / $cluster3Perf[0]ENDIFIF abs(centroid1 - old1) < epsilon AND abs(centroid2 - old2) < epsilon AND abs(centroid3 - old3) < epsilon THENconverged = 1ENDIFiter = iter + 1WEND//-----Cluster seleccionado y nuevo SupertrendfinalFactor = 0perf = 0fact = 0IF fromCluster = 1 THEN// BestIF centroid1 > max(centroid2, centroid3) THENFOR j = 1 TO lastset($cluster1Perf) DOperf = perf + $cluster1Perf[j]fact = fact + $cluster1Factors[j]NEXTfinalFactor = fact / lastset($cluster1Factors)ELSIF centroid2 > max(centroid1, centroid3) THENFOR j = 1 TO lastset($cluster2Perf) DOperf = perf + $cluster2Perf[j]fact = fact + $cluster2Factors[j]NEXTfinalFactor = fact / lastset($cluster2Factors)ELSEFOR j = 1 TO lastset($cluster3Perf) DOperf = perf + $cluster3Perf[j]fact = fact + $cluster3Factors[j]NEXTfinalFactor = fact / lastset($cluster3Factors)ENDIFELSIF fromCluster = 2 THEN// AverageIF centroid1 > centroid2 AND centroid1 < centroid3 THENFOR j = 1 TO lastset($cluster1Perf) DOperf = perf + $cluster1Perf[j]fact = fact + $cluster1Factors[j]NEXTfinalFactor = fact / lastset($cluster1Factors)ELSIF centroid2 > centroid1 AND centroid2 < centroid3 THENFOR j = 1 TO lastset($cluster2Perf) DOperf = perf + $cluster2Perf[j]fact = fact + $cluster2Factors[j]NEXTfinalFactor = fact / lastset($cluster2Factors)ELSEFOR j = 1 TO lastset($cluster3Perf) DOperf = perf + $cluster3Perf[j]fact = fact + $cluster3Factors[j]NEXTfinalFactor = fact / lastset($cluster3Factors)ENDIFELSIF fromCluster = 3 THEN// WorstIF centroid1 < min(centroid2, centroid3) THENFOR j = 1 TO lastset($cluster1Perf) DOperf = perf + $cluster1Perf[j]fact = fact + $cluster1Factors[j]NEXTfinalFactor = fact / lastset($cluster1Factors)ELSIF centroid2 < min(centroid1, centroid3) THENFOR j = 1 TO lastset($cluster2Perf) DOperf = perf + $cluster2Perf[j]fact = fact + $cluster2Factors[j]NEXTfinalFactor = fact / lastset($cluster2Factors)ELSEFOR j = 1 TO lastset($cluster3Perf) DOperf = perf + $cluster3Perf[j]fact = fact + $cluster3Factors[j]NEXTfinalFactor = fact / lastset($cluster3Factors)ENDIFENDIF//-----Renderizado final del Supertrendnewup = (high + low) / 2 + atr * finalFactornewdown = (high + low) / 2 - atr * finalFactorif close[1] < newupper thennewupper = min(newup, newupper)elsenewupper = newupendifif close[1] > newlower thennewlower = max(newdown, newlower)elsenewlower = newdownendifif close > newupper thennewOS = 1elsif close < newlower thennewOS = 0elsenewOS = newOSendifscreener[newOS<>newOS[1]]1 user thanked author for this post.
09/22/2025 at 2:31 PM #251264Bonjour,
J’ai un problème pour terminer ce Screener, les résultats retournés ne sont pas juste! Ici sur la photo jointe, pour se rendre compte du problème, je l’ai posé comme un indicateur dans une fenêtre sous le prix.
L’idée initiale est de mettre en évidence la tendance haussière ou baissière du SuperTrend AI Clustering ligne 204 à 230 dans le code. Mais on peut voir clairement qu’il y a une différence notable entre l’indicateur sur le graphique et l’indicateur dans la fenêtre sous le prix…
Je ne trouve pas la solution !
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235//-----Inputslength=10minMult=1maxMult=5step=0.5perfAlpha=10 // Performance memoryfromCluster=1 // 1=best 2=average 3=worstmaxiter=10 // Número máximo de iteraciones de clusteringepsilon=0.0001 // Precisión para simular convergencia//-----Average True Rangeatr=averagetruerange[length](close)//-----Supertrend cálculo múltiple$holderUpper[0]=(high+low)/2$holderLower[0]=(high+low)/2k=0for factor=0 to floor((maxMult-minMult)/step) doup=(high+low)/2+atr*factordn=(high+low)/2-atr*factorif close > $holderUpper[k] then$holderTrend[k]=1elsif close < $holderUpper[k] then$holderTrend[k]=0else$holderTrend[k]=$holderTrend[k]endifif close[1]<$holderUpper[k] then$holderUpper[k]=min(up,$holderUpper[k])else$holderUpper[k]=upendifif close[1]>$holderLower[k] then$holderLower[k]=max(dn,$holderLower[k])else$holderLower[k]=dnendifif (close[1]-$holderOutput[k])>0 thendiff=1elsif (close[1]-$holderOutput[k])<0 thendiff=-1elsediff=0endif$holderPerf[k]=$holderPerf[max(0,k-1)]+2/(perfAlpha+1)*((close-close[1])*diff-$holderPerf[max(0,k-1)])if $holderTrend[k]=1 then$holderOutput[k]=$holderLower[k]else$holderOutput[k]=$holderUpper[k]endif$holderFactor[k] = (minMult+k*step)k=k+1next//-----K-means con convergenciacentroid1 = 0centroid2 = 0centroid3 = 0count = kFOR i = 0 TO count - 1 DOIF i < count / 3 THENcentroid1 = centroid1 + $holderPerf[i]ELSIF i < 2 * count / 3 THENcentroid2 = centroid2 + $holderPerf[i]ELSEcentroid3 = centroid3 + $holderPerf[i]ENDIFNEXTcentroid1 = centroid1 / (count / 3)centroid2 = centroid2 / (count / 3)centroid3 = centroid3 / (count / 3)converged = 0iter = 0WHILE iter < maxiter AND converged = 0 DOold1 = centroid1old2 = centroid2old3 = centroid3$cluster1Perf[0] = 0$cluster2Perf[0] = 0$cluster3Perf[0] = 0$cluster1Factors[0] = 0$cluster2Factors[0] = 0$cluster3Factors[0] = 0FOR i = 0 TO count - 1 DOdist1 = abs($holderPerf[i] - centroid1)dist2 = abs($holderPerf[i] - centroid2)dist3 = abs($holderPerf[i] - centroid3)IF dist1 <= dist2 AND dist1 <= dist3 THEN$cluster1Perf[$cluster1Perf[0]+1] = $holderPerf[i]$cluster1Factors[$cluster1Factors[0]+1] = $holderFactor[i]$cluster1Perf[0] = $cluster1Perf[0] + 1$cluster1Factors[0] = $cluster1Factors[0] + 1ELSIF dist2 <= dist1 AND dist2 <= dist3 THEN$cluster2Perf[$cluster2Perf[0]+1] = $holderPerf[i]$cluster2Factors[$cluster2Factors[0]+1] = $holderFactor[i]$cluster2Perf[0] = $cluster2Perf[0] + 1$cluster2Factors[0] = $cluster2Factors[0] + 1ELSE$cluster3Perf[$cluster3Perf[0]+1] = $holderPerf[i]$cluster3Factors[$cluster3Factors[0]+1] = $holderFactor[i]$cluster3Perf[0] = $cluster3Perf[0] + 1$cluster3Factors[0] = $cluster3Factors[0] + 1ENDIFNEXTcentroid1 = 0centroid2 = 0centroid3 = 0IF $cluster1Perf[0] > 0 THENFOR i = 1 TO $cluster1Perf[0] DOcentroid1 = centroid1 + $cluster1Perf[i]NEXTcentroid1 = centroid1 / $cluster1Perf[0]ENDIFIF $cluster2Perf[0] > 0 THENFOR i = 1 TO $cluster2Perf[0] DOcentroid2 = centroid2 + $cluster2Perf[i]NEXTcentroid2 = centroid2 / $cluster2Perf[0]ENDIFIF $cluster3Perf[0] > 0 THENFOR i = 1 TO $cluster3Perf[0] DOcentroid3 = centroid3 + $cluster3Perf[i]NEXTcentroid3 = centroid3 / $cluster3Perf[0]ENDIFIF abs(centroid1 - old1) < epsilon AND abs(centroid2 - old2) < epsilon AND abs(centroid3 - old3) < epsilon THENconverged = 1ENDIFiter = iter + 1WEND//-----Cluster seleccionado y nuevo SupertrendfinalFactor = 0perf = 0fact = 0IF fromCluster = 1 THEN// BestIF centroid1 > max(centroid2, centroid3) THENFOR j = 1 TO lastset($cluster1Perf) DOperf = perf + $cluster1Perf[j]fact = fact + $cluster1Factors[j]NEXTfinalFactor = fact / lastset($cluster1Factors)ELSIF centroid2 > max(centroid1, centroid3) THENFOR j = 1 TO lastset($cluster2Perf) DOperf = perf + $cluster2Perf[j]fact = fact + $cluster2Factors[j]NEXTfinalFactor = fact / lastset($cluster2Factors)ELSEFOR j = 1 TO lastset($cluster3Perf) DOperf = perf + $cluster3Perf[j]fact = fact + $cluster3Factors[j]NEXTfinalFactor = fact / lastset($cluster3Factors)ENDIFENDIF//-----Renderizado final del Supertrendnewup = (high + low) / 2 + atr * finalFactornewdown = (high + low) / 2 - atr * finalFactorif close[1] < newupper thennewupper = min(newup, newupper)elsenewupper = newupendifif close[1] > newlower thennewlower = max(newdown, newlower)elsenewlower = newdownendifif close > newupper thennewOS = 1elsif close < newlower thennewOS = 0elsenewOS = newOSendif/////////////////////////////////////////////////////////////////////////////////////////////////////////////////if newOS[0]>newOS[1] thenhaussier = 1endifif newOS[0]<newOS[1] thenhaussier = 0endif//if newOS[0]<newOS[1] thenbaissier = 1endifif newOS[0]>newOS[1] thenbaissier = 0endifSignal = 0If Haussier ThenSignal = 1EndifIf Baissier ThenSignal = -1Endif//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Return Signal as "Signal"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////10/14/2025 at 11:25 AM #252578UP
@Iván je n’arrive pas à finir ce Screener de tendance, post précédent #251264 !
Je souhaiterais de plus, pouvoir identifier lorsque l’on passe d’une situation haussière à une situation baissière(image ci-jointe) sur l’indicateur “Super Trend AI Clustering”, pour pouvoir l’incorporer dans une approche Multi TimeFrame et je ne m’en sors pas avec NewOs ou Newupper ou Newlower !!!
-
AuthorPosts
Find exclusive trading pro-tools on 