Ich habe Ihren Code umstrukturiert, um beide Probleme zu beheben. Die Ursache liegt darin, dass ProRealTime beim Laden des Diagramms alles auf jedem Balken neu zeichnet, wodurch sich DrawText , DrawRectangle und DrawSegment im Verlauf ansammeln.
1. defparam drawonlastbaronly = true — Löscht alle Zeichenobjekte bei jedem Tick und zeichnet sie neu.
2. Speichere die Boxdaten in Arrays, wenn jeder Bereich erkannt wird (bei jedem Balken, außerhalb islastbarupdate ).
3. Alles innerhalb von islastbarupdate neu zeichnen – historische Felder aus gespeicherten Daten, aktuelles Feld mit Beschriftungen und Projektionen
defparam drawonlastbaronly = true
Transparency = 100
maxBoxes = 50 // Max historical boxes to display
// === TIMEFRAME DETECTION (unchanged) ===
once NbBar = 1
if BarIndex 0 THEN
myOffset = AverageTrueRange[14](close) * 0.5
// --- Historical boxes (subtle) ---
startIdx = max(0, boxCnt - maxBoxes)
FOR i = startIdx TO boxCnt - 2 DO
bx = $bEnd[i]
fr = $bFrame[i]
mx = $bMax[i]
mini = $bMin[i]
pp = $bPips[i]
cx = bx - round(0.5 * fr)
md = mini + (mx - mini) / 2
DrawRectangle(bx - fr, mx, bx, mini) coloured("firebrick", 20) bordercolor("firebrick", 100)
DrawText("#pp#", cx, md, SansSerif, Bold, 16) coloured("firebrick", 150)
NEXT
// --- Latest box (highlighted + labels + projections) ---
DrawRectangle(lastEnd - Frame, lastMax, lastEnd, lastMin) coloured("firebrick", Transparency) bordercolor("firebrick", 255)
centerX = lastEnd - round(0.5 * Frame)
DrawText("RBO", centerX, lastMax + myOffset * 3, SansSerif, Bold, 12) coloured("firebrick", 255)
DrawText("H: #lastMax#", centerX, lastMax + myOffset, SansSerif, Bold, 10) coloured("firebrick", 255)
DrawText("L: #lastMin#", centerX, lastMin - myOffset, SansSerif, Bold, 10) coloured("firebrick", 255)
DrawText("#lastPips#", centerX, lastMid, SansSerif, Bold, 16) coloured("firebrick", 255)
// Projection lines (only from latest box to current bar)
DrawSegment(lastEnd, lastMax, barindex, lastMax) coloured("firebrick", 255)
DrawSegment(lastEnd, lastMin, barindex, lastMin) coloured("firebrick", 255)
DrawSegment(lastEnd, lastMid, barindex, lastMid) style(dottedline3) coloured("firebrick", 180)
ENDIF
RETURN