Conversion Indicateur RSI cyclic smoothed v2 de TV à PRT
Forums › ProRealTime forum Français › Support ProBuilder › Conversion Indicateur RSI cyclic smoothed v2 de TV à PRT
- This topic has 11 replies, 5 voices, and was last updated 4 weeks ago by Iván.
-
-
11/18/2024 at 9:05 PM #240510
Bonjour à toute l’équipe ProRealCode,
Tout d’abord, merci pour votre travail exceptionnel et votre contribution à la communauté ProRealTime.
SVP est il possible de convertir cet indicateur TradingView en ProRealTime : Lien vers l’indicateur TV. De plus, serait-il envisageable d’y ajouter des divergences haussières et baissières (ligne verte et rouge) similaires à celles décrites dans cet indicateur RSI de votre forum : Lien vers l’indicateur PRT.
Cet outil serait précieux pour identifier les renversements. Merci d’avance pour votre aide !
Cordialement,
RSI cyclic smoothed v212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788//@version=4//// Copyright (C) 2017 CC BY, whentotrade / Lars von Thienen// Source:// Book: Decoding The Hidden Market Rhythm - Part 1: Dynamic Cycles (2017)// Chapter 4: "Fine-tuning technical indicators for more details on the cRSI Indicator//// Usage:// You need to derive the dominant cycle as input parameter for the cycle length as described in chapter 4.//// License:// This work is licensed under a Creative Commons Attribution 4.0 International License.// You are free to share the material in any medium or format and remix, transform, and build upon the material for any purpose,// even commercially. You must give appropriate credit to the authors book and website, provide a link to the license, and indicate// if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.//study(title="RSI cyclic smoothed", shorttitle="cRSI")src = closedomcycle = input(20, minval=10, title="Dominant Cycle Length")crsi = 0.0cyclelen = domcycle / 2vibration = 10leveling = 10.0cyclicmemory = domcycle * 2//set min/max ranges?h1 = hline(30, color=color.silver, linestyle=hline.style_dashed)h2 = hline(70, color=color.silver, linestyle=hline.style_dashed)torque = 2.0 / (vibration + 1)phasingLag = (vibration - 1) / 2.0up = rma(max(change(src), 0), cyclelen)down = rma(-min(change(src), 0), cyclelen)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)crsi := torque * (2 * rsi - rsi[phasingLag]) + (1 - torque) * nz(crsi[1])lmax = -999999.0lmin = 999999.0for i = 0 to cyclicmemory - 1 by 1if nz(crsi[i], -999999.0) > lmaxlmax := nz(crsi[i])lmaxelseif nz(crsi[i], 999999.0) < lminlmin := nz(crsi[i])lminmstep = (lmax - lmin) / 100aperc = leveling / 100db = 0.0for steps = 0 to 100 by 1testvalue = lmin + mstep * stepsabove = 0below = 0for m = 0 to cyclicmemory - 1 by 1below := below + iff(crsi[m] < testvalue, 1, 0)belowratio = below / cyclicmemoryif ratio >= apercdb := testvaluebreakelsecontinueub = 0.0for steps = 0 to 100 by 1testvalue = lmax - mstep * stepsabove = 0for m = 0 to cyclicmemory - 1 by 1above := above + iff(crsi[m] >= testvalue, 1, 0)aboveratio = above / cyclicmemoryif ratio >= apercub := testvaluebreakelsecontinuelowband = plot(db, "LowBand", color.aqua)highband = plot(ub, "HighBand", color.aqua)fill(h1, h2, color=color.silver, transp=90)fill(lowband, highband, color=color.gray, transp=90)plot(crsi, "CRSI", color.fuchsia)11/19/2024 at 4:19 PM #240537Voici ce que vous avez :
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107//-------------------------------------////PRC_RSI Cyclic Smoothed//version = 0//19.11.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------////Inputs//-------------------------------------//src=closedomcycle=20cyclelen=domcycle/2vibration=10leveling=10cyclicmemory=domcycle*2once crsi=0//-------------------------------------//// CRSI calculation//-------------------------------------//torque=2/(vibration+1)phasinglag=floor((vibration-1)/2)length = cyclelenalpha = 1/lengthsrcUp = max(src-src[1],0)if barindex = length thenup = average[length](srcUp)elseup = alpha*srcUp + (1-alpha)*up[1]endifsrcDw = -min(src-src[1],0)if barindex = length thendw = average[length](srcdw)elsedw = alpha*srcdw + (1-alpha)*dw[1]endifif dw=0 thenmyrsi=100elsif up=0 thenmyrsi=0elsemyrsi=100-100/(1+up/dw)endifif barindex>cyclicmemory thencrsi=torque*(2*myrsi-myrsi[phasinglag])+(1-torque)*crsi[1]endif//-------------------------------------//// LowBand and HighBand calculation//-------------------------------------//Period=cyclicMemorypercent = leveling/100periodMinusone = period-1maxima = -999999.0minima = 999999.0for i=0 to periodMinusone doif crsi[i] > maxima thenmaxima = crsi[i]elsif crsi[i] < minima thenminima = crsi[i]endifnextstepfactor = (maxima-minima)/100lowband = 0for steps=0 to 100 dotestvalue = minima+stepfactor*stepsbelow=0for m=0 to periodMinusone doif crsi[m]<testvalue thenbelow=below+1endifnextif below/period >= percent thenlowband = testvaluebreakendifnexthighband=0for steps=0 to 100 dotestvalue=maxima-stepfactor*stepsabove=0for m=0 to periodMinusone doif crsi[m]>=testvalue thenabove=above+1endifnextif above/Period >= percent thenhighband=testvaluebreakendifnextcolorbetween(highband,lowband,204,204,119,90)//-------------------------------------//// Plot//-------------------------------------//h1=30h2=70//-------------------------------------//return highband as "UpperBand"coloured("aqua"),lowband as "LowerBand"coloured("aqua"),crsi as "CRSI"coloured("fuchsia")style(line,2), h1 as "OB level"style(dottedline), h2 as "OS level"style(dottedline)1 user thanked author for this post.
11/19/2024 at 4:45 PM #240542Super merci bcp , c ‘est génial , Stp , serait-il envisageable d’y ajouter des divergences haussières et baissières (ligne verte et rouge) similaires à celles décrites dans cet indicateur RSI de votre forum : Lien vers l’indicateur PRT. ? merci
11/20/2024 at 9:37 AM #24056411/20/2024 at 9:45 AM #240565Bonjour. Pour les divergences il vous suffit de copier le code indiqué dans votre lien en dessous de l'indicateur et de changer la ligne dans laquelle est définie la variable irsi :
1234minimalBars=5obLevel=h2osLevel=h1irsi = crsi1 user thanked author for this post.
11/20/2024 at 10:26 AM #240574oui je viens de faire ca mais j ‘ai une erreur au niveau de la ligne 119 , ci-joint une photo et voici le code mixé , pourrais tu m’aider à résoudre ca ? merci bcp pour ton aide Ivan.
Mixt des deux script123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184//-------------------------------------////PRC_RSI Cyclic Smoothed//version = 0//19.11.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------//defparam drawonlastbaronly=trueDEFPARAM CALCULATEONLASTBARS = 300//Inputs//-------------------------------------//src=closedomcycle=32cyclelen=domcycle/2vibration=10leveling=10cyclicmemory=domcycle*2once crsi=0//-------------------------------------//// CRSI calculation//-------------------------------------//torque=2/(vibration+1)phasinglag=floor((vibration-1)/2)length = cyclelenalpha = 1/lengthsrcUp = max(src-src[1],0)if barindex = length thenup = average[length](srcUp)elseup = alpha*srcUp + (1-alpha)*up[1]endifsrcDw = -min(src-src[1],0)if barindex = length thendw = average[length](srcdw)elsedw = alpha*srcdw + (1-alpha)*dw[1]endifif dw=0 thenmyrsi=100elsif up=0 thenmyrsi=0elsemyrsi=100-100/(1+up/dw)endifif barindex>cyclicmemory thencrsi=torque*(2*myrsi-myrsi[phasinglag])+(1-torque)*crsi[1]endif//-------------------------------------//// LowBand and HighBand calculation//-------------------------------------//Period=cyclicMemorypercent = leveling/100periodMinusone = period-1maxima = -999999.0minima = 999999.0for i=0 to periodMinusone doif crsi[i] > maxima thenmaxima = crsi[i]elsif crsi[i] < minima thenminima = crsi[i]endifnextstepfactor = (maxima-minima)/100lowband = 0for steps=0 to 100 dotestvalue = minima+stepfactor*stepsbelow=0for m=0 to periodMinusone doif crsi[m]<testvalue thenbelow=below+1endifnextif below/period >= percent thenlowband = testvaluebreakendifnexthighband=0for steps=0 to 100 dotestvalue=maxima-stepfactor*stepsabove=0for m=0 to periodMinusone doif crsi[m]>=testvalue thenabove=above+1endifnextif above/Period >= percent thenhighband=testvaluebreakendifnextcolorbetween(highband,lowband,204,204,119,90)//-------------------------------------//// Plot//-------------------------------------//h1=30h2=70//-------------------------------------//return highband as "UpperBand"coloured("aqua"),lowband as "LowerBand"coloured("aqua"),crsi as "CRSI"coloured("fuchsia")style(line,2), h1 as "OB level"style(dottedline), h2 as "OS level"style(dottedline)//-------------------------------------////PRC_AnotherRSIdivergences | indicator//25.02.2019//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge// --- settingsRSIp=14 //RSI periodminimalBars=5 //minimal count of bars where RSI is ob or osobLevel=h2 // Adjusted to match the previous h2osLevel=h1 // Adjusted to match the previous h1// --- end of settingsirsi = crsi // Adjusted irsi to use crsiob = irsi>obLevelos = irsi<osLevelif ob thenif not ob[1] thenmaxrsi = 0maxprice = 0firstobbar = barindexendifmaxrsi=max(maxrsi,irsi)maxprice=max(maxprice,high)if maxrsi<>maxrsi[1] thenmaxrsibar=barindexendifendifif os thenif not os[1] thenminrsi = 100minprice = close*100firstosbar = barindexendifminrsi=min(minrsi,irsi)minprice=min(minprice,low)if minrsi<>minrsi[1] thenminrsibar=barindexendifendifdivsell=0if irsi crosses under obLevel then//verif divergencediv = maxprice>oldmaxprice and maxrsi<oldmaxrsi and (barindex-firstobbar)>=minimalBarsif div thendrawsegment(oldmaxrsibar,oldmaxrsi,maxrsibar,maxrsi) coloured(200,0,0)drawarrowdown(maxrsibar,maxrsi) coloured(200,0,0)divsell=osLevelendifoldmaxrsi = maxrsioldmaxprice = maxpriceoldmaxrsibar = maxrsibarendifdivbuy=0if irsi crosses over osLevel then//verif divergencediv = minprice<oldminprice and minrsi>oldminrsi and (barindex-firstosbar)>=minimalBarsif div thendrawsegment(oldminrsibar,oldminrsi,minrsibar,minrsi) coloured(0,200,0)drawarrowup(minrsibar,minrsi) coloured(0,200,0)divbuy=osLevelendifoldminrsi = minrsioldminprice = minpriceoldminrsibar = minrsibarendifreturn irsi style(line,2) as "RSI",obLevel coloured(168,168,168) style(dottedline,1) as "overbought level", osLevel coloured(168,168,168) style(dottedline,1) as "oversold level", divsell coloured(200,0,0) style(histogram) as "sell divergence", divbuy coloured(0,200,0) style(histogram) as "buy divergence"11/20/2024 at 2:02 PM #240581hello
votre erreur ligne 119 est causée par le return de la ligne 110 , il ne doit y avoir qu’un seul return en fin de code .
1 user thanked author for this post.
11/20/2024 at 2:16 PM #240583hello , merci pour ta réponse , il faut que je fasse quoi ? supprimer le return de la ligne 110 et garder que ca : ” highband as UpperBand”coloured(“aqua”),lowband as “LowerBand”coloured(“aqua”),crsi as “CRSI”coloured(“fuchsia”)style(line,2), h1 as “OB level”style(dottedline), h2 as “OS level”style(dottedline) ”
j’ai fais ca mais tjrs une erreur enfait au niveau de la ligne 178 179 .. désolé mais j ai aucune connaissance en programmation je m’aide avec GPT ..
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184//-------------------------------------//// PRC_RSI Cyclic Smoothed// version = 0// 19.11.2024// Iván González @ www.prorealcode.com//-------------------------------------//defparam drawonlastbaronly = truedefparam calculateonlastbars = 300// Inputssrc = closedomcycle = 32cyclelen = domcycle / 2vibration = 10leveling = 10cyclicmemory = domcycle * 2once crsi = 0//-------------------------------------//// CRSI Calculation//-------------------------------------//torque = 2 / (vibration + 1)phasinglag = floor((vibration - 1) / 2)length = cyclelenalpha = 1 / lengthsrcUp = max(src - src[1], 0)if barindex = length thenup = average[length](srcUp)elseup = alpha * srcUp + (1 - alpha) * up[1]endifsrcDw = -min(src - src[1], 0)if barindex = length thendw = average[length](srcDw)elsedw = alpha * srcDw + (1 - alpha) * dw[1]endifif dw = 0 thenmyrsi = 100elsif up = 0 thenmyrsi = 0elsemyrsi = 100 - 100 / (1 + up / dw)endifif barindex > cyclicmemory thencrsi = torque * (2 * myrsi - myrsi[phasinglag]) + (1 - torque) * crsi[1]endif//-------------------------------------//// LowBand and HighBand Calculation//-------------------------------------//period = cyclicmemorypercent = leveling / 100periodMinusone = period - 1maxima = -999999.0minima = 999999.0for i = 0 to periodMinusone doif crsi[i] > maxima thenmaxima = crsi[i]elsif crsi[i] < minima thenminima = crsi[i]endifnextstepfactor = (maxima - minima) / 100lowband = 0for steps = 0 to 100 dotestvalue = minima + stepfactor * stepsbelow = 0for m = 0 to periodMinusone doif crsi[m] < testvalue thenbelow = below + 1endifnextif below / period >= percent thenlowband = testvaluebreakendifnexthighband = 0for steps = 0 to 100 dotestvalue = maxima - stepfactor * stepsabove = 0for m = 0 to periodMinusone doif crsi[m] >= testvalue thenabove = above + 1endifnextif above / period >= percent thenhighband = testvaluebreakendifnextcolorbetween(highband, lowband, 204, 204, 119, 90)//-------------------------------------//// Divergence Detection and Plot//-------------------------------------//h1 = 30h2 = 70RSIp = 14minimalBars = 5obLevel = h2osLevel = h1irsi = crsi// Overbought logicob = irsi > obLevelif ob thenif not ob[1] thenmaxrsi = 0maxprice = 0firstobbar = barindexendifmaxrsi = max(maxrsi, irsi)maxprice = max(maxprice, high)if maxrsi <> maxrsi[1] thenmaxrsibar = barindexendifendif// Oversold logicos = irsi < osLevelif os thenif not os[1] thenminrsi = 100minprice = close * 100firstosbar = barindexendifminrsi = min(minrsi, irsi)minprice = min(minprice, low)if minrsi <> minrsi[1] thenminrsibar = barindexendifendif// Divergence Logicdivsell = 0if irsi crosses under obLevel thendiv = maxprice > oldmaxprice and maxrsi < oldmaxrsi and (barindex - firstobbar) >= minimalBarsif div thendrawsegment(oldmaxrsibar, oldmaxrsi, maxrsibar, maxrsi) coloured(200, 0, 0)drawarrowdown(maxrsibar, maxrsi) coloured(200, 0, 0)divsell = osLevelendifoldmaxrsi = maxrsioldmaxprice = maxpriceoldmaxrsibar = maxrsibarendifdivbuy = 0if irsi crosses over osLevel thendiv = minprice < oldminprice and minrsi > oldminrsi and (barindex - firstosbar) >= minimalBarsif div thendrawsegment(oldminrsibar, oldminrsi, minrsibar, minrsi) coloured(0, 200, 0)drawarrowup(minrsibar, minrsi) coloured(0, 200, 0)divbuy = osLevelendifoldminrsi = minrsioldminprice = minpriceoldminrsibar = minrsibarendif// Unified returnreturn highband as "UpperBand" coloured("aqua"),lowband as "LowerBand" coloured("aqua"),crsi as "CRSI" coloured("fuchsia") style(line, 2),h1 as "OB level" style(dottedline),h2 as "OS level" style(dottedline),divsell coloured(200, 0, 0) style(histogram) as "sell divergence",divbuy coloured(0, 200, 0) style(histogram) as "buy divergence"11/20/2024 at 2:34 PM #24058411/20/2024 at 2:34 PM #240585il faut supprimer la ligne 110 et grouper en derniere lignereturn highband as “UpperBand”coloured(“aqua”),lowband as “LowerBand”coloured(“aqua”),crsi as “CRSI”coloured(“fuchsia”)style(line,2), h1 as “OB level”style(dottedline), h2 as “OS level”style(dottedline),irsi style(line,2) as “RSI”,obLevel coloured(168,168,168) style(dottedline,1) as “overbought level”, osLevel coloured(168,168,168) style(dottedline,1) as “oversold level”, divsell coloured(200,0,0) style(histogram) as “sell divergence”, divbuy coloured(0,200,0) style(histogram) as “buy divergence”1 user thanked author for this post.
11/20/2024 at 2:35 PM #240586Mettez le Return sur une seule ligne pour voir.
12// Unified returnreturn highband as "UpperBand" coloured("aqua"),lowband as "LowerBand" coloured("aqua"),crsi as "CRSI" coloured("fuchsia") style(line, 2),h1 as "OB level" style(dottedline),h2 as "OS level" style(dottedline),divsell coloured(200, 0, 0) style(histogram) as "sell divergence",divbuy coloured(0, 200, 0) style(histogram) as "buy divergence"1 user thanked author for this post.
11/20/2024 at 3:51 PM #240588Et enfin, une chose importante. Supprimez la ligne 8. Sinon vous n’obtiendrez de résultats que dans la dernière bougie. Vous pouvez également modifier le nombre de bougies dans lesquelles l'indicateur est calculé pour accélérer les calculs en modifiant la ligne 9.
-
AuthorPosts
Find exclusive trading pro-tools on