Anyone know how to code a bubble or label that plots on price at ATH and updates live? Should ideally only visible on chart where ATH is within range/sight/scope. One that prints high of day and/or ATH would be killer also. I attached a TOS image of similar.
Thanks!
Hi. Here an example to calculate the ATH.
DEFPARAM DRAWONLASTBARONLY = TRUE // Ensures that the drawing is only updated on the last bar
// Calculation of the All-Time High (ATH)
ONCE highestATH = 0 // Variable to store the highest recorded price
IF high > highestATH THEN
highestATH = high // Update the highest ATH if a new high is reached
ENDIF
// Draws the ATH label if it is within the visible range
IF islastbarupdate THEN
DRAWTEXT("ATH: #highestATH#", -100, -100, Dialog, Bold, 12) COLOURED(255,0,0,255) ANCHOR(TOPRIGHT, xshift, yshift)
DRAWHLINE(highestATH) STYLE(DOTTEDLINE3) COLOURED("RED") // Draws a horizontal dotted line at ATH level
ENDIF
RETURN
Great! Thank you! I will also try on my own, as I’m trying to learn more coding everyday, but I’m pretty sure it’s possible to anchor text to the high candle, correct? I just think that with my still very limited knowledge, it would continue to repeat a new label rather than just move with the new high, but I will try to figure that out as well. I won’t be upset if you beat me to it. Ha! Thanks again.