Indicateur PRC_Protein+ : gros ralentissement à cause de boucles longues
Forums › ProRealTime forum Français › Support ProBuilder › Indicateur PRC_Protein+ : gros ralentissement à cause de boucles longues
- This topic has 2 replies, 2 voices, and was last updated 1 week ago by
AdilMed10.
-
-
06/04/2025 at 11:34 AM #247869
Bonjour,
SVP, j’aime beaucoup l’indicateur PRC_Protein+, mais il ralentit fortement mes graphiques (parfois plusieurs secondes en UT 5min).
J’ai demandé à GPT de l’optimiser, et il m’a signalé que le ralentissement venait probablement de :
-
Des boucles
for
très longues sans limite (barindex downto 0
) -
Et du redessin de rectangles à chaque tick sans condition de mise à jour
J’ai tenté une version corrigée avec
lookbackLimit
et une limite de pivots, mais le résultat n’est pas concluant.Avez-vous une version optimisée qui ne provoque pas ce type de lenteur sans perdre sa logique ?
Merci beaucoup pour votre retour et votre aide comme toujours.PRC_Protein +12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182//---------------------------------------------------------////PRC_Protein +//version = 0//14.10.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------------------------------------------------------//defparam drawonlastbaronly=true//---------------------------------------------------------////----Inputs----------------------------------------------////---------------------------------------------------------//length=10leftbars=lengthrightbars=lengthsrc1 = lowsrc2 = highboxwidth=5atr=averagetruerange[50](close)//---------------------------------------------------------////-----Calculate Pivots Low--------------------------------////---------------------------------------------------------//if src1 > src1[rightbars] and lowest[rightbars](src1) > src1[rightbars] and src1[rightbars] < lowest[leftbars](src1)[rightbars+1] then$ply[z+1] = src1[rightbars]$plx[z+1] = barindex[rightbars]$crossLow[z+1]=0$Lowrightidx[z+1]=0$atrLow[z+1]=atrz = z + 1endif//---------------------------------------------------------////-----Calculate Pivots High-------------------------------////---------------------------------------------------------//if src2 < src2[rightbars] and highest[rightbars](src2)<src2[rightbars] and src2[rightbars]>highest[leftbars](src2)[rightbars+1] then$phy[t+1]=src2[rightbars]$phx[t+1]=barindex[rightbars]$crossHigh[t+1]=0$Highrightidx[t+1]=0$atrHigh[t+1]=atrt=t+1endif//---------------------------------------------------------////-----Check for broken levels-----------------------------////---------------------------------------------------------//n=barindexif islastbarupdate thenfor i=t downto 1 do//drawpoint($phx[i],$phy[i],2)coloured("blue",50)for j=barindex downto 0 doif barindex[j]>$phx[i] and high[j]>$phy[i] and $crossHigh[i]=0 then$crossHigh[i]=1$Highrightidx[i]=barindex[j]breakendifnextif $crossHigh[i]=1 thendrawsegment($phx[i],$phy[i],$Highrightidx[i],$phy[i])coloured("red")style(dottedline)elsedrawrectangle($phx[i],$phy[i]-0.5*$atrHigh[i]*boxwidth/10,barindex,$phy[i]+0.5*$atrHigh[i]*boxwidth/10)coloured("red",0)fillcolor("red",30)endifnextfor i=z downto 1 do//drawpoint($plx[i],$ply[i],2)coloured("blue",50)for j=barindex downto 0 doif barindex[j]>$plx[i] and low[j]<$ply[i] and $crossLow[i]=0 then$crossLow[i]=1$Lowrightidx[i]=barindex[j]breakendifnextif $crossLow[i]=1 thendrawsegment($plx[i],$ply[i],$Lowrightidx[i],$ply[i])coloured("blue")style(dottedline)elsedrawrectangle($plx[i],$ply[i]-0.5*$atrLow[i]*boxwidth/10,barindex,$ply[i]+0.5*$atrLow[i]*boxwidth/10)coloured("blue",0)fillcolor("blue",30)endifnextendifreturn06/04/2025 at 2:19 PM #247878PRC_Protein + Stéroïdes123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687//---------------------------------------------------------////PRC_Protein + Stéroïdes//version = 0//14.10.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------------------------------------------------------//defparam drawonlastbaronly = true//---------------------------------------------------------////----Inputs----------------------------------------------////---------------------------------------------------------//once length = 10once leftbars = lengthonce rightbars = lengthonce boxwidth = 5once coef = 0.05*boxwidthonce ShowOnlyLastPivots = 20once idxPLow = -1once idxPHigh = -1atr=averagetruerange[50](close)//---------------------------------------------------------////-----Calculate Pivots Low--------------------------------////---------------------------------------------------------//if low[rightbars] = lowest[leftbars+rightbars+1](low) then$plx[idxPLow+1] = barindex-rightbars$Lowrightidx[idxPLow+1] = 0$atrLow[idxPLow+1] = atr[rightbars]*coefidxPLow = idxPLow+1endif//---------------------------------------------------------////-----Calculate Pivots High-------------------------------////---------------------------------------------------------//if high[rightbars] = highest[leftbars+rightbars+1](high) then$phx[idxPHigh+1] = barindex-rightbars$Highrightidx[idxPHigh+1] = 0$atrHigh[idxPHigh+1] = atr[rightbars]*coefidxPHigh = idxPHigh+1endif//---------------------------------------------------------////-----Check for broken levels-----------------------------////---------------------------------------------------------//If idxPHigh >= 0 thenfor i= idxPHigh downto Max(0,idxPHigh-ShowOnlyLastPivots+1) doif $Highrightidx[i] = 0 thenif high > High[barindex-$phx[i]] then$Highrightidx[i] = barindexendifendifif $Highrightidx[i] > 0 thendrawsegment($phx[i],High[barindex-$phx[i]],$Highrightidx[i],High[barindex-$phx[i]])coloured("red")style(dottedline)elsedrawrectangle($phx[i],High[barindex-$phx[i]]-$atrHigh[i],barindex,High[barindex-$phx[i]]+$atrHigh[i]) coloured("red",0) fillcolor("red",30)endifnextEndifIf idxPLow >= 0 thenfor i= idxPLow downto Max(0,idxPLow-ShowOnlyLastPivots+1) doif $Lowrightidx[i] = 0 thenif low < low[barindex-$plx[i]] then$Lowrightidx[i] = barindexendifendifif $Lowrightidx[i] > 0 thendrawsegment($plx[i],Low[barindex-$plx[i]],$Lowrightidx[i],Low[barindex-$plx[i]])coloured("blue")style(dottedline)elsedrawrectangle($plx[i],Low[barindex-$plx[i]]-$atrLow[i],barindex,Low[barindex-$plx[i]]+$atrLow[i]) coloured("blue",0) fillcolor("blue",30)endifnextEndifreturn4 users thanked author for this post.
06/04/2025 at 3:31 PM #247888 -
-
AuthorPosts
Find exclusive trading pro-tools on