Skip to content
ChartDeck ChartScript docs Account Open the terminal

place

Helpers for placing labels: the same answer on the chart, on the server and in alerts.

#Functions

#place.free_pricefunction

The nearest price to price, stepping by gap in direction, that is at least gap away from every price in taken. After max_steps steps it gives the last price tried.

place.free_price(price: float, taken: array<float>, gap: float, { direction?: int = 1, max_steps?: int = 10 }): float
ParameterTypeDescription
pricefloatWhere you would like to put the label.
takenarray<float>The prices already used.
gapfloatThe room a label needs, in price (for example ta.atr(14) * 0.5).
directionintdefault 11 = step up (default), -1 = step down.
max_stepsintdefault 10The most steps to try (default 10, at most 100).

Returns float.

Example

ChartScriptFragmentOpen in editor
const taken = array.from(close, close + ta.atr(14))
const y = place.free_price(close, taken, ta.atr(14), { direction: 1 })
plot(y, "Free price above")

Since ChartScript 1

The ChartScript documentation is in English for now; translations will follow.