1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
90 lines of Pine Script v6 from web/public/frost-script-ai.txt, published under AGPL-3.0. Keep the author's credit and licence lines when you reuse it.
frost-script-ai.txt
//@version=6, indicator(...) leave out; overlay=false is pane own
input.int/float(14, "L", minval, maxval, step) input l = 14 min .. max .. step .. "L"
input.bool / input.color / input.string(options) / input.time
as SETTINGS above; group, inline, tooltip,
confirm are left out
ta.sma ta.ema ... ta.pivothigh the same names without ta.
math.abs math.max ... math.pi the same names without math.
math.sum(x, n) sum(x, n)
math.avg(a, b) avg(a, b)
na(x) isna(x)
str.tostring(x) / (x, "#.##") / (x, format.mintick) str(x) / str(round(x, 2)) / str(x, decimals)
bar_index, last_bar_index bar, lastbar
barstate.isfirst / islast isfirst / islast
timeframe.change("D"/"W"/"M"/"12M") changed(day/week/month/year)
ta.change(time("W")) != 0 changed(week)
dayofweek == dayofweek.monday dayofweek == monday
timestamp(y, m, d, h, min) date(y, m, d, h, min)
color.new(c, t) alpha(c, 1 - t / 100)
color.rgb(r, g, b, t) rgb(r, g, b, 1 - t / 100)
array.new<float>() with var state xs = list()
array.push(a, v) / array.get(a, i) / array.size(a) a.push(v) / a.get(i) / a.size()
array<string> of "H"/"L" a list of 1 and 0
switch if / else if, or nested ? :
f(x) => fn f(x) { return ... }
[a, b] = f(x) a, b = f(x)
label.new(x, y, text=t, style=label.style_label_down, color=c, textcolor=w, size=size.small)
label(x, y, t, color=c, textcolor=w, place=above, size=small)
line.new(x1, y1, x2, y2, color=c, width=2, style=line.style_dotted, extend=extend.both)
line(x1, y1, x2, y2, color=c, width=2, style=dotted, extend=both)
xloc=xloc.bar_time (x a time) barat(t) for x
label.style_none box=false
size.tiny/small/normal/large tiny small normal large
plot.style_line/stepline/circles/cross line steps dots dots
line.style_solid/dashed/dotted solid dashed dotted
table.new(position.top_right, ...) table("top right")
table.cell(t, c, r, text, text_color=x, bgcolor=y) cell(c, r, text, x, y)
NOT AVAILABLE: SAY SO, DO NOT FAKE IT
request.security and any other timeframe or symbol; strategy.* beyond the
orders above (pyramiding, several named entries at once, partial exits,
strategy.equity and the trade lists); alert() and alertcondition();
timenow and the clock (use the newest bar's time instead); polyline.*;
matrix.* and map.*; str.* functions other than str.tostring; syminfo.* other
than the price step; text lists; methods and types of your own; imports.
If a script relies on one of these at its heart, convert the rest and say
plainly what was left out.
A WHOLE CONVERSION, FOR SHAPE
Pine:
//@version=6
indicator("Swing labels", overlay=true, max_labels_count=500)
len = input.int(5, "Pivot length", minval=1)
showPct = input.bool(true, "Show %")
var array<float> prices = array.new<float>()
ph = ta.pivothigh(len, len)
pl = ta.pivotlow(len, len)
f_text(string tag, float move) => showPct ? tag + "\n" + str.tostring(move, "#.##") + "%" : tag
if not na(ph)
move = array.size(prices) > 0 ? (ph - array.get(prices, array.size(prices) - 1)) / array.get(prices, array.size(prices) - 1) * 100 : 0
label.new(bar_index[len], ph, f_text("H", move), style=label.style_label_down, color=color.new(color.green, 20), textcolor=color.white)
array.push(prices, ph)
if not na(pl)
move = array.size(prices) > 0 ? (pl - array.get(prices, array.size(prices) - 1)) / array.get(prices, array.size(prices) - 1) * 100 : 0
label.new(bar_index[len], pl, f_text("L", move), style=label.style_label_up, color=color.new(color.red, 20), textcolor=color.white)
array.push(prices, pl)
Frost Script:
input len = 5 min 1 max 100 "Pivot length"
input showPct = true "Show %"
state prices = list()
ph = pivothigh(len, len)
pl = pivotlow(len, len)
fn swingText(tag, move) {
return showPct ? tag + "\n" + str(round(move, 2)) + "%" : tag
}
if not isna(ph) {
move = prices.size() > 0 ? (ph - prices.last()) / prices.last() * 100 : 0
highLabel = label(bar - len, ph, swingText("H", move), color = alpha(green, 0.8), textcolor = white, place = above)
prices.push(ph)
}
if not isna(pl) {
move = prices.size() > 0 ? (pl - prices.last()) / prices.last() * 100 : 0
lowLabel = label(bar - len, pl, swingText("L", move), color = alpha(red, 0.8), textcolor = white, place = below)
prices.push(pl)
}
Now convert the Pine Script v6 indicator or strategy I give you next.
Overview
Swing labels places labels above pivot highs and below pivot lows to highlight key structural swing points. The indicator measures and displays the percentage price change from the previous swing point directly on the labels when enabled. Key settings allow adjusting the pivot lookback length and toggling the percentage calculation display.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Pivot length
int
5
len
Show %
bool
true
showPct
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult
This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up
AI Trend is an indicator that plots pivot points, trend lines, and support and resistance levels directly on the price chart. It marks high and low pivots based on user-defined length, draws trend lines that check for violations at specified points, and identi
Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin
This indicator plots Ichimoku Cloud elements on the price chart, including Tenkan-sen, Kijun-sen, Senkou Span A and B lines with optional Chikou Span. It signals trend changes via Tenkan-sen and Kijun-sen crosses and places arrows at Kijun-sen direction shifts
This indicator identifies local swing highs and swing lows to construct a Zig Zag pattern on the main price chart. It evaluates pivot points based on a customizable number of surrounding left and right bars. Using persistent variables, the script tracks previo