comment
Drops a small text comment pointing to a specific bar and price. Perfect for quick notes like “news spike” or “stop moved”. It’s lighter than a callout—just a neat label with optional background and border.
Syntax (one line)
comment(time, price, styles?, text?)
Parameters
time (number) · Candle time where the comment is anchored (e.g., time(0)).
price (number) · Price level where the comment sits (e.g., closeC(0)).
styles (CommentLineToolOverrides) · Visual options for the comment:
backgroundColor(RGBAColor | BaseColors) · Fill color behind the text.borderColor(RGBAColor | BaseColors) · Border color around the comment box.color(RGBAColor | BaseColors) · Text color.fontsize(number) · Font size for the text.transparency(number) · 0–100 background transparency (higher = lighter).text(string) · The message shown in the comment.
Return Value
(string) · The drawing ID of the created Comment.
Example
What this does: Every 40 candles, it pins a compact comment at the current close with a short note. We keep all visuals in one const style.
//@version=1
init = () => {
indicator({ onMainPanel: true, format: 'inherit' });
};
onTick = () => {
if (index % 40 === 0) { // draw occasionally to keep charts clean
// 1) Style (CommentLineToolOverrides)
const style = {
backgroundColor: color.rgba(0, 150, 136, 0.18), // teal tint
borderColor: color.rgba(0, 150, 136, 0.9),
color: color.white,
fontsize: 12,
transparency: 82
};
// 2) Place the comment at this bar’s close
comment(time(0), closeC(0), style, "News spike");
}
};Tips
Keep comments short and specific (1–3 words) so they don’t cover candles.
Use a high-contrast
colorvsbackgroundColorfor easy reading.
Warning
Too many comments in the same region can overlap—space them out or reduce the frequency.
Good Practice
Create presets (e.g., teal for info, red for risk) so comments are instantly recognizable.
Centralize your preferred comment styling in a
const styleand reuse it across scripts.
Last updated