OPEN-SOURCE SCRIPT
Percent Line/Box Toolkit

- Percent Line/Box Toolkit is an overlay tool that draws horizontal lines and rectangles at percentage distances from the current price.
It is built for anyone who reads a chart in percentage terms rather than in absolute prices: eight percent above the market means the same thing on any symbol and at any price level, while a fixed price distance has to be worked out again whenever the price moves or the instrument changes.
Every drawing is anchored to the latest close, and its vertical position is expressed as a percentage of that close, so the whole set travels with the market instead of standing still.
The horizontal geometry of each drawing is measured in bars of a reference timeframe chosen separately for that drawing, rather than in bars of the chart.
Six lines and four rectangles are available, each one positioned, sized, labeled and colored independently of the others.
Line (present six times, Line 1 to Line 6, each instance identically structured)
- Switch, label text, label size:
The switch turns the line on or off, the text field holds the label, and the dropdown sets the size it is drawn in. An empty text field means no label.
- Level (%):
Vertical position of the line, as a percentage of the current close.
- Offset (Bars):
Horizontal position, measured in bars. Positive values move the line to the left, negative values to the right.
- Length (Bars):
Width of the line, measured in bars.
- Reference Timeframe:
Offset and length are counted in bars of this timeframe. If it is left empty, the chart's own timeframe is used.
- Style, width, color:
The line style (solid, dotted or dashed), the thickness of the line, and its color.
Box (present four times, Box 1 to Box 4, each instance identically structured)
- Switch, label text, label size:
The switch turns the box on or off, the text field holds the label, and the dropdown sets the size it is drawn in. An empty text field means no label.
- Upper (%):
One edge of the box, as a percentage of the current close.
- Lower (%):
The other edge, also as a percentage of the current close. The two fields can be filled in either order.
- Offset (Bars):
Horizontal position, measured in bars. Positive values move the box to the left, negative values to the right.
- Length (Bars):
Width of the box, measured in bars.
- Reference Timeframe:
Offset and length are counted in bars of this timeframe. If it is left empty, the chart's own timeframe is used.
- Border width, border color, fill color:
The thickness of the outline, its color, and the color of the area inside. A border width of zero leaves the box without an outline.
- Every enabled line is drawn as a horizontal segment at its percentage level, and every enabled box as a rectangle spanning its two levels.
Everything is rebuilt from the current close on each new bar, so the drawings follow the price instead of staying where they were put.
Nothing remains on past bars: there is no history to scroll back through, only the state the chart is in right now.
The two edges of a box are sorted before it is drawn, so the higher value always becomes the top edge and the order in which they are entered makes no difference.
Offset shifts a drawing along the time axis: positive values move it left into the existing bars, negative values right into the empty space beyond the last bar.
Because offset and length count bars of the reference timeframe rather than bars of the chart, a drawing holds its size when the chart timeframe is changed; a line 50 bars wide on a 4-hour reference stays that wide whether the chart shows 5-minute or daily bars.
On instruments that do not trade continuously the time axis runs through the closed periods as well, so a drawing covers its length in calendar terms rather than in visible bars and appears shorter than the bar count suggests.
Any drawing can carry a label at its right-hand end, drawn in the color of the line or of the box border; it appears as soon as its text field is filled and disappears when the field is cleared, without affecting the drawing itself.
- This indicator is intended solely for market analysis and does not constitute investment advice or a guarantee of success.
Use it at your own discretion and risk; past results are not indicative of future performance.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。