projection
The Projection tool draws a curved path using three anchors: a start/center and two arc points that shape the curve. It’s perfect for sketching “what-if” paths (rounded dips, soft recoveries, tops) without copying past bars—great for illustrating scenarios while you backtest.
Syntax (one line)
projection(originPoint, leftArcPoint, rightArcPoint, styles?)
Parameters
originPoint (PricedData) · Center/start of the projected curve (time & price).
leftArcPoint (PricedData) · Controls curvature/extent on the left side.
rightArcPoint (PricedData) · Controls curvature/extent on the right side.
styles (ProjectionLineToolOverrides) · Visual options for the curve and optional fill.
color1(string) · Primary color for the projection line or gradient start.color2(string) · Secondary color for gradient or shading.fillBackground(boolean) · Fill the area under/around the curve.level1(LinesLevels) · Per-level line look (e.g., linewidth, linestyle, color, visible).linewidth(number) · Thickness of the projection line.showCoeffs(boolean) · Show coefficient values if the style supports them.transparency(number) · Background transparency for the fill (0–100).trendline(object) · Base trendline styling inside the projection. ·color(string) · Color of the trendline. ·linestyle(number) · Line style (0=solid, 1=dotted, 2=dashed…). ·visible(boolean) · Toggle trendline visibility.
Return Value
(string) · The drawing ID of the created Projection.
Example
What this does: Every 48 candles, we draw a gentle “U-shaped” projection from an older pivot, using two arc points to suggest a dip and recovery. All visuals live in one const style that follows ProjectionLineToolOverrides.
Tips
Use meaningful pivots for arc points so the curve “hugs” real structure rather than slicing randomly.
Keep projection lines subtle (thin/dashed) so they’re clearly distinct from actual price.
Combine with channels or bands to show where the scenario might meet support/resistance.
Warning
Don’t pass raw
time()orpricevalues—always build anchors withnewPoint(time(offset), priceValue)or the drawing can fail.
Good Practice
Centralize visuals in a single
const styleso you can reuse and tweak consistently across tests.Save a few presets (e.g., orange dashed for “scenario”, gray dotted for “alt scenario”) to keep charts readable.
Last updated