Rectangles superposés
Forums › ProRealTime forum Français › Support ProBuilder › Rectangles superposés
- This topic has 4 replies, 2 voices, and was last updated 7 hours ago by
Bernard13.
-
-
11/06/2025 at 5:23 PM #253376
Bonjour,
Je ne sais pas comment m’y prendre pour transformer mon code ci-dessous afin d’obtenir sur le graph que les derniers rectangles des Ranges Bollinger sur l’historique et éviter ainsi les superpositions. Merci d’avance.#I BYP Bollinger Range1234567891011121314151617181920212223// Bollinger Range//DEFPARAM DrawOnLastBarOnly= True // Force the graph to the right. => Uniquement le dernier rectangle dessiné.DEFPARAM DrawOnLastBarOnly= False // No force the graph to the right. => Tous les rectangles mais tous repeints.Src= ClosedeltaRangeBB= 5 // Range de 5 points sur le Spot Gold: XAUUSDBBup= BollingerUp[20](close)BBdn= BollingerDown[20](close)RangeBB= BBup - BBdn // En pointsLenRange= LenRange + 1 // longueur du rangeIF RangeBB >= deltaRangeBB THENlenRange= 1xRange= BarIndexELSE // Range en courtHH= Highest[LenRange](Src)LL= Lowest[LenRange](Src)DrawRectangle(xRange, LL, Barindex, HH) Coloured("Yellow", 50) BorderColor("Yellow", 0)ENDIFRETURN11/07/2025 at 9:36 AM #25339012345678910111213141516171819202122232425262728293031323334353637383940//DEFPARAM DrawOnLastBarOnly = FalsedeltaRangeBB = 15period = 20BBup = BollingerUp[period](close)BBdn = BollingerDown[period](close)RangeBB = BBup - BBdnONCE isInRange = 0ONCE xStartRange = 0ONCE HH = 0ONCE LL = 0IF RangeBB >= deltaRangeBB THENIF isInRange = 1 THENDrawRectangle(xStartRange, LL, BarIndex - 1, HH) COLOURED("Blue", 50) BorderColor("Blue", 0)ENDIFisInRange = 0ELSEIF isInRange = 0 THENisInRange = 1xStartRange = BarIndexHH = highLL = lowELSEHH = MAX(HH, high)LL = MIN(LL, low)ENDIFENDIFIF isInRange = 1 AND islastbarupdate THENDrawRectangle(xStartRange, LL, BarIndex, HH) COLOURED("Blue", 50) BorderColor("Blue")ENDIFRETURN1 user thanked author for this post.
11/07/2025 at 9:42 AM #253391Bonjour,
Finalement, j’ai trouvé la solution sans passer par les DEFPARAM, ou un LookBack et des tableaux.
C’est en forgeant, qu’on devient forgeron !
Bon codage à Toutes et à Tous. 🙂// Bollinger Range
//DEFPARAM DrawOnLastBarOnly= True // Force the graph to the right. => Uniquement le dernier rectangle dessiné.
//DEFPARAM DrawOnLastBarOnly= False // No force the graph to the right. => Tous les rectangles mais tous repeint.src= Close
//deltaRangeBB= 5 // Range de 5 points sur le Spot Gold: XAUUSDBBup= BollingerUp[pBB](src)
BBdn= BollingerDown[pBB](src)
RangeBB= BBup – BBdn // En pointsLenRange= LenRange + 1 // longueur du range
IF RangeBB >= deltaRangeBB THEN // Extinction du Range
lenRange= 1
HH= Highest[LenRange](Src)
LL= HH //Lowest[LenRange](Src) // Evite les bavures à 0 de ColorBetween
a= 0
ELSE // Range en court
HH= Highest[LenRange](Src)
LL= Lowest[LenRange](Src)
a= 200
ENDIFColorBetween(HH,LL,”Yellow”,a)
RETURN
11/07/2025 at 9:52 AM #25339311/07/2025 at 10:15 AM #253394 -
AuthorPosts
