newPoint

newPoint is a simple helper that creates a chart point using a time and a price. Many drawing functions (like trendLine, rayLine, channels, and patterns) require you to pass in two or more “points” on the chart. Instead of writing { time: ..., price: ... } each time, you can use newPoint to quickly generate them.

Think of it as: “Give me a point at this candle’s time and that price level.”

Syntax

newPoint(time, price)

Parameters

  • time number — The bar index or timestamp where the point is placed.

  • price number — The price level for the point.

Return Value

Returns an object:

{ time: number, price: number }

You can pass this directly into drawing functions.

Example

// Create two points
const p1 = newPoint(100, 1.2000)   // candle at index 100, price 1.2000
const p2 = newPoint(time(0), closeC(0)); 

Tips

  • Use newPoint every time you need to mark a specific candle and price — it keeps your code cleaner and easier to read.

  • Store your points in variables (p1, p2, etc.) so you can reuse them across multiple drawings.

Warning

Good Practice

Last updated