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| Parameter | Type | Description |
|---|---|---|
price | float | Where you would like to put the label. |
taken | array<float> | The prices already used. |
gap | float | The room a label needs, in price (for example ta.atr(14) * 0.5). |
direction | intdefault 1 | 1 = step up (default), -1 = step down. |
max_steps | intdefault 10 | The most steps to try (default 10, at most 100). |
Returns float.
Example
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