Pine Script v4 · Strategy
SuperTrend - Custom Screener and Dynamic Alerts
A Pine Script v4 strategy built on Supertrend (3, 10). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 2 settings; defaults include Mult 3 and Period 10.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does SuperTrend - Custom Screener and Dynamic Alerts repaint?
- Yes
- At least one pattern in the source can repaint: higher-timeframe data.
- How did SuperTrend - Custom Screener and Dynamic Alerts do on BTCUSDT 1D with default settings?
- −9.72%
- From 26 Jan 2024 to 21 Oct 2026, over 27 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can SuperTrend - Custom Screener and Dynamic Alerts be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- What alerts does SuperTrend - Custom Screener and Dynamic Alerts have?
- 2
- array.get(alert_strings, 0); array.get(alert_strings, 1).
- Does SuperTrend - Custom Screener and Dynamic Alerts use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs DJI D data, not available: not a Binance spot market Needs IXIC D data, not available: not a Binance spot market Needs SPX D data, not available: not a Binance spot market Needs RUT D data, not available: not a Binance spot market Needs AAPL D data, not available: not a Binance spot market Needs AMZN D data, not available: not a Binance spot market Needs FB D data, not available: not a Binance spot market Needs GOOG D data, not available: not a Binance spot market Needs NFLX D data, not available: not a Binance spot market Needs MSFT D data, not available: not a Binance spot market Needs NVDA D data, not available: not a Binance spot market Needs FDX D data, not available: not a Binance spot market Needs GLD D data, not available: not a Binance spot market Values that depend on it are empty on this chart.
| SuperTrend Sell | ▼▼ | |||
| Ticker | Close | DHigh | DLow | % Change |
- Net profit
- −9.72%
- −$9,717.39
- Buy and hold
- +102.5%
- same period
- Closed trades
- 27
- 9 won · 18 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 0.92
- gross profit ÷ gross loss
- Max drawdown
- 51.91%
- −$59,410.20
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
2 settings have no label
In the settings dialog mult (line 30), period (line 31) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames supertrend → ta.supertrend, security → request.security, tostring → str.tostring, round → math.round, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
VerifiedSame 27 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 30: input(type = input.float) → input.float()
- Line 31: input(type = input.integer) → input.int()
- Line 32: supertrend → ta.supertrend
- Line 46: security → request.security
- Line 48: security → request.security
30 more edits
- Line 49: tostring → str.tostring
- Line 49: round → math.round
- Line 49: tostring → str.tostring
- Line 49: round → math.round
- Line 53: crossover → ta.crossover
- Line 54: tostring → str.tostring
- Line 54: round → math.round
- Line 54: tostring → str.tostring
- Line 54: round → math.round
- Line 61: tostring → str.tostring
- Line 61: round → math.round
- Line 62: tostring → str.tostring
- Line 62: round → math.round
- Line 63: tostring → str.tostring
- Line 63: round → math.round
- Line 64: tostring → str.tostring
- Line 64: round → math.round
- Line 66: crossunder → ta.crossunder
- Line 67: tostring → str.tostring
- Line 67: round → math.round
- Line 67: tostring → str.tostring
- Line 67: round → math.round
- Line 73: tostring → str.tostring
- Line 73: round → math.round
- Line 74: tostring → str.tostring
- Line 74: round → math.round
- Line 75: tostring → str.tostring
- Line 75: round → math.round
- Line 76: tostring → str.tostring
- Line 76: round → math.round
⋯// © ralagh-//@version=4+//@version=5strategy("Supertrend", overlay = true, format=format.price, precision=2)⋯table.cell(table_id = DnTabl, column = 4, row = 1, text = "% Change")-mult = input(type=input.float, defval=3)+mult = input.float(defval=3)-period = input(type=input.integer, defval=10)+period = input.int(defval=10)-[superTrend, dir] = supertrend(mult, period)+[superTrend, dir] = ta.supertrend(mult, period)colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) : color.new(color.red, 100)⋯ - [cl_dp, hi_dp, lo_dp, chg_dp] = security(_ticker, 'D', [close, high, low, p_chg], lookahead = barmerge.lookahead_on)+ [cl_dp, hi_dp, lo_dp, chg_dp] = request.security(_ticker, 'D', [close, high, low, p_chg], lookahead = barmerge.lookahead_on) - [cl_p, ST_R] = security(_ticker, timeframe.period, [close, superTrend], lookahead = barmerge.lookahead_on)+ [cl_p, ST_R] = request.security(_ticker, timeframe.period, [close, superTrend], lookahead = barmerge.lookahead_on)- _msg = _ticker + "~Cls-" + tostring(round(cl_p * 100) / 100) + "/" + tostring(round(chg_dp * 100) / 100) + "% ,"+ _msg = _ticker + "~Cls-" + str.tostring(math.round(cl_p * 100) / 100) + "/" + str.tostring(math.round(chg_dp * 100) / 100) + "% ," ⋯//cl_p < ST_R (Downtrend)- if crossover(cl_p, ST_R) + if ta.crossover(cl_p, ST_R) - _msg := _msg + "PHi~" + tostring(round(hi_dp * 100) / 100) + ", PLo~" + tostring(round(lo_dp * 100) / 100) + "-ST▲"+ _msg := _msg + "PHi~" + str.tostring(math.round(hi_dp * 100) / 100) + ", PLo~" + str.tostring(math.round(lo_dp * 100) / 100) + "-ST▲" array.set(alert_strings, 0, array.get(alert_strings, 0) + "\n" + _msg)⋯ table.cell(table_id = UpTabl, column = 0, row = array.get(table_row_count, 0), text = _ticker)- table.cell(table_id = UpTabl, column = 1, row = array.get(table_row_count, 0), text = tostring(round(cl_p * 100) / 100), bgcolor=color.rgb(0, 200, 100))+ table.cell(table_id = UpTabl, column = 1, row = array.get(table_row_count, 0), text = str.tostring(math.round(cl_p * 100) / 100), bgcolor=color.rgb(0, 200, 100))- table.cell(table_id = UpTabl, column = 2, row = array.get(table_row_count, 0), text = tostring(round(hi_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100))+ table.cell(table_id = UpTabl, column = 2, row = array.get(table_row_count, 0), text = str.tostring(math.round(hi_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100))- table.cell(table_id = UpTabl, column = 3, row = array.get(table_row_count, 0), text = tostring(round(lo_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100))+ table.cell(table_id = UpTabl, column = 3, row = array.get(table_row_count, 0), text = str.tostring(math.round(lo_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100))- table.cell(table_id = UpTabl, column = 4, row = array.get(table_row_count, 0), text = tostring(round(chg_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100))+ table.cell(table_id = UpTabl, column = 4, row = array.get(table_row_count, 0), text = str.tostring(math.round(chg_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100)) - else if crossunder(cl_p, ST_R)+ else if ta.crossunder(cl_p, ST_R)- _msg := _msg + "PHi~" + tostring(round(hi_dp * 100) / 100) + ", PLo~" + tostring(round(lo_dp * 100) / 100) + "-ST▼"+ _msg := _msg + "PHi~" + str.tostring(math.round(hi_dp * 100) / 100) + ", PLo~" + str.tostring(math.round(lo_dp * 100) / 100) + "-ST▼" array.set(table_row_count, 1, array.get(table_row_count, 1) + 1)⋯ table.cell(table_id = DnTabl, column = 0, row = array.get(table_row_count, 1), text = _ticker)- table.cell(table_id = DnTabl, column = 1, row = array.get(table_row_count, 1), text = tostring(round(cl_p * 100) / 100), bgcolor=color.rgb(255, 0, 0))+ table.cell(table_id = DnTabl, column = 1, row = array.get(table_row_count, 1), text = str.tostring(math.round(cl_p * 100) / 100), bgcolor=color.rgb(255, 0, 0))- table.cell(table_id = DnTabl, column = 2, row = array.get(table_row_count, 1), text = tostring(round(hi_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0))+ table.cell(table_id = DnTabl, column = 2, row = array.get(table_row_count, 1), text = str.tostring(math.round(hi_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0))- table.cell(table_id = DnTabl, column = 3, row = array.get(table_row_count, 1), text = tostring(round(lo_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0))+ table.cell(table_id = DnTabl, column = 3, row = array.get(table_row_count, 1), text = str.tostring(math.round(lo_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0))- table.cell(table_id = DnTabl, column = 4, row = array.get(table_row_count, 1), text = tostring(round(chg_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0))+ table.cell(table_id = DnTabl, column = 4, row = array.get(table_row_count, 1), text = str.tostring(math.round(chg_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0)) ⋯Same 27 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 80: input() → input.string()
- Line 81: input() → input.string()
- Line 82: input() → input.string()
- Line 83: input() → input.string()
- Line 84: input() → input.string()
- Line 85: input() → input.string()
7 more edits
- Line 86: input() → input.string()
- Line 87: input() → input.string()
- Line 88: input() → input.string()
- Line 89: input() → input.string()
- Line 90: input() → input.string()
- Line 91: input() → input.string()
- Line 92: input() → input.string()
⋯f_SupCro(syminfo.tickerid)-f_SupCro(input('DJI', title=input.symbol)) +f_SupCro(input.string('DJI', title=input.symbol)) -f_SupCro(input('IXIC', title=input.symbol)) +f_SupCro(input.string('IXIC', title=input.symbol)) -f_SupCro(input('SPX', title=input.symbol)) +f_SupCro(input.string('SPX', title=input.symbol)) -f_SupCro(input('RUT', title=input.symbol)) +f_SupCro(input.string('RUT', title=input.symbol)) -f_SupCro(input('AAPL', title=input.symbol))+f_SupCro(input.string('AAPL', title=input.symbol))-f_SupCro(input('AMZN', title=input.symbol)) +f_SupCro(input.string('AMZN', title=input.symbol)) -f_SupCro(input('FB', title=input.symbol)) +f_SupCro(input.string('FB', title=input.symbol)) -f_SupCro(input('GOOG', title=input.symbol)) +f_SupCro(input.string('GOOG', title=input.symbol)) -f_SupCro(input('NFLX', title=input.symbol))+f_SupCro(input.string('NFLX', title=input.symbol))-f_SupCro(input('MSFT', title=input.symbol)) +f_SupCro(input.string('MSFT', title=input.symbol)) -f_SupCro(input('NVDA', title=input.symbol)) +f_SupCro(input.string('NVDA', title=input.symbol)) -f_SupCro(input('FDX', title=input.symbol)) +f_SupCro(input.string('FDX', title=input.symbol)) -f_SupCro(input('GLD', title=input.symbol))+f_SupCro(input.string('GLD', title=input.symbol))if array.get(alert_strings, 0) != ""⋯Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 27 before, 167 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © ralagh-//@version=5+//@version=6strategy("Supertrend", overlay = true, format=format.price, precision=2)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Mult (no label in the script) | 3 | float | superTrend dir |
| Period (no label in the script) | 10 | int (written input.integer) | superTrend dir |
What it calculates
- Supertrend (
supertrend,ta.supertrendin v5)Mult (3), Period (10)superTrend · line 32 - Supertrend (
supertrend,ta.supertrendin v5)Mult (3), Period (10)dir · line 32
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Buy long | (dir == -1 and dir == dir[1]) | On | 38 |
| Open Sell short | (dir == 1 and dir == dir[1]) | On | 40 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| (no title) | alert | array.get(alert_strings, 0) | 94 |
| (no title) | alert | array.get(alert_strings, 1) | 96 |
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- CheckHigher-timeframe data2 security call(s) use lookahead_on (line 46, 48). Without a [1] offset this reads future bars in history.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
Not run on other markets: the script requests DJI D, IXIC D, SPX D, RUT D, AAPL D, AMZN D, FB D, GOOG D, NFLX D, MSFT D, NVDA D, FDX D, GLD D, and that data is not available here (not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market). Its results would rest on empty values.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 8 | 38% | −$8,985.80 |
| Sideways market | 13 | 31% | $9,508.22 |
| Falling market | 6 | 33% | −$10,239.80 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
63.5%
The 95th percentile of the worst drawdown when the same 27 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 35.4% to 63.5%; the tick is what actually happened, 44.4%. Order luck alone moves it this much.
All 27 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 28 Jan 2024 42,120.60 | 11 Feb 2024 47,751.10 | 14 | −$5,630.45 |
| long | 11 Feb 2024 47,751.10 | 21 Mar 2024 67,840.50 | 39 | $20,089.40 |
| short | 21 Mar 2024 67,840.50 | 22 May 2024 70,148.30 | 62 | −$2,307.83 |
| long | 22 May 2024 70,148.30 | 23 Jun 2024 64,262.00 | 32 | −$5,886.33 |
| short | 23 Jun 2024 64,262.00 | 17 Jul 2024 65,044.00 | 24 | −$781.99 |
| long | 17 Jul 2024 65,044.00 | 5 Aug 2024 58,161.00 | 19 | −$6,883.00 |
| short | 5 Aug 2024 58,161.00 | 25 Aug 2024 64,157.00 | 20 | −$5,996.02 |
| long | 25 Aug 2024 64,157.00 | 7 Sep 2024 53,963.00 | 13 | −$10,194.00 |
| short | 7 Sep 2024 53,963.00 | 21 Sep 2024 63,201.10 | 14 | −$9,238.08 |
| long | 21 Sep 2024 63,201.10 | 25 Dec 2024 98,663.60 | 95 | $35,462.50 |
| short | 25 Dec 2024 98,663.60 | 19 Jan 2025 104,556.00 | 25 | −$5,892.65 |
| long | 19 Jan 2025 104,556.00 | 26 Feb 2025 88,680.40 | 38 | −$15,875.80 |
| short | 26 Feb 2025 88,680.40 | 4 Mar 2025 86,221.20 | 6 | $2,459.23 |
| long | 4 Mar 2025 86,221.20 | 12 Mar 2025 82,933.00 | 8 | −$3,288.17 |
| short | 12 Mar 2025 82,933.00 | 24 Apr 2025 93,691.10 | 43 | −$10,758.10 |
| long | 24 Apr 2025 93,691.10 | 24 Jun 2025 105,334.00 | 61 | $11,642.90 |
| short | 24 Jun 2025 105,334.00 | 11 Jul 2025 116,010.00 | 17 | −$10,676.10 |
| long | 11 Jul 2025 116,010.00 | 23 Aug 2025 116,936.00 | 43 | $925.99 |
| short | 23 Aug 2025 116,936.00 | 3 Oct 2025 120,529.00 | 41 | −$3,593.35 |
| long | 3 Oct 2025 120,529.00 | 12 Oct 2025 110,644.00 | 9 | −$9,884.95 |
| short | 12 Oct 2025 110,644.00 | 15 Jan 2026 96,951.80 | 95 | $13,692.60 |
| long | 15 Jan 2026 96,951.80 | 22 Jan 2026 89,454.70 | 7 | −$7,497.05 |
| short | 22 Jan 2026 89,454.70 | 6 Mar 2026 70,891.00 | 43 | $18,563.70 |
| long | 6 Mar 2026 70,891.00 | 31 Mar 2026 66,797.40 | 25 | −$4,093.64 |
| short | 31 Mar 2026 66,797.40 | 15 Apr 2026 74,131.60 | 15 | −$7,334.17 |
| long | 15 Apr 2026 74,131.60 | 24 May 2026 76,752.00 | 39 | $2,620.45 |
| short | 24 May 2026 76,752.00 | 23 Jul 2026 66,114.50 | 60 | $10,637.50 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| SuperTrend - Custom Screener and Dynamic Alerts this page | — | v4 strategy | −9.7% | 27 | 51.9% |
| Supertrend Strategy by Zeal Terminal | supertrend | v5 strategy | −4.0% | 26 | 9.2% |
| Supertrend - Long & Short -Sachin Ughade by hello_sachin | supertrend | v4 strategy | +185.8% | 57 | 163.4% |
| Multi Supertrend with no-repaint HTF option strategy by ramki_simple | supertrend | v4 strategy | −18.4% | 36 | 67.6% |
| Supertrend - Intraday by Pritesh-StocksDeveloper | supertrend | v5 strategy | No trades on this market | ||
| Supertrend by Zeal Terminal | supertrend | v5 indicator | indicator | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 55 ms | With a workaround 1,000 bars in 218 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
The engine and this page's reading of the source count a different number of settings, so one of them has missed one.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © ralagh//@version=4strategy("Supertrend", overlay = true, format=format.price, precision=2)alert_strings = array.new_string(2)array.set(alert_strings, 0, "")array.set(alert_strings, 1, "")table_row_count = array.new_int(5)array.set(table_row_count, 0, 1)array.set(table_row_count, 1, 1)array.set(table_row_count, 2, 1)array.set(table_row_count, 3, 1)array.set(table_row_count, 4, 1)var UpTabl = table.new(position = position.top_center, columns = 5, rows = 20, bgcolor = color.rgb(255,255,255), border_width = 2, frame_color= color.black, frame_width = 2)var DnTabl = table.new(position = position.bottom_center, columns = 5, rows = 20, bgcolor = color.rgb(255,255,255), border_width = 2, frame_color= color.black, frame_width = 2)table.cell(table_id = UpTabl, column = 1, row = 0, text = " SuperTrend Buy")table.cell(table_id = DnTabl, column = 1, row = 0, text = " SuperTrend Sell") table.cell(table_id = UpTabl, column = 2, row = 0, text = " ▲▲")table.cell(table_id = DnTabl, column = 2, row = 0, text = " ▼▼") table.cell(table_id = UpTabl, column = 0, row = 1, text = "Ticker")table.cell(table_id = UpTabl, column = 1, row = 1, text = "Close")table.cell(table_id = UpTabl, column = 2, row = 1, text = "DHigh") table.cell(table_id = UpTabl, column = 3, row = 1, text = "DLow") table.cell(table_id = UpTabl, column = 4, row = 1, text = "% Change") table.cell(table_id = DnTabl, column = 0, row = 1, text = "Ticker")table.cell(table_id = DnTabl, column = 1, row = 1, text = "Close") table.cell(table_id = DnTabl, column = 2, row = 1, text = "DHigh") table.cell(table_id = DnTabl, column = 3, row = 1, text = "DLow") table.cell(table_id = DnTabl, column = 4, row = 1, text = "% Change")mult = input(type=input.float, defval=3)period = input(type=input.integer, defval=10)[superTrend, dir] = supertrend(mult, period)colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) : color.new(color.red, 100)colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) : color.new(color.green, 100)plot(superTrend, color = colResistance, linewidth=2)plot(superTrend, color = colSupport, linewidth=2)if (dir == -1 and dir == dir[1]) strategy.entry("Buy", strategy.long, comment="Buy")if (dir == 1 and dir == dir[1]) strategy.entry("Sell", strategy.short, comment="Sell")f_SupCro(_ticker)=> p_chg = (close - close[1])/close[1] * 100 [cl_dp, hi_dp, lo_dp, chg_dp] = security(_ticker, 'D', [close, high, low, p_chg], lookahead = barmerge.lookahead_on) [cl_p, ST_R] = security(_ticker, timeframe.period, [close, superTrend], lookahead = barmerge.lookahead_on) _msg = _ticker + "~Cls-" + tostring(round(cl_p * 100) / 100) + "/" + tostring(round(chg_dp * 100) / 100) + "% ," //cl_p > ST_R (Uptrend)//cl_p < ST_R (Downtrend) if crossover(cl_p, ST_R) _msg := _msg + "PHi~" + tostring(round(hi_dp * 100) / 100) + ", PLo~" + tostring(round(lo_dp * 100) / 100) + "-ST▲" array.set(alert_strings, 0, array.get(alert_strings, 0) + "\n" + _msg) array.set(table_row_count, 0, array.get(table_row_count, 0) + 1) //alert(_msg + "-Sup▲", alert.freq_once_per_bar_close ) // For Individual Stock Alerts if barstate.islast table.cell(table_id = UpTabl, column = 0, row = array.get(table_row_count, 0), text = _ticker) table.cell(table_id = UpTabl, column = 1, row = array.get(table_row_count, 0), text = tostring(round(cl_p * 100) / 100), bgcolor=color.rgb(0, 200, 100)) table.cell(table_id = UpTabl, column = 2, row = array.get(table_row_count, 0), text = tostring(round(hi_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100)) table.cell(table_id = UpTabl, column = 3, row = array.get(table_row_count, 0), text = tostring(round(lo_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100)) table.cell(table_id = UpTabl, column = 4, row = array.get(table_row_count, 0), text = tostring(round(chg_dp * 100) / 100), bgcolor=color.rgb(0, 200, 100)) else if crossunder(cl_p, ST_R) _msg := _msg + "PHi~" + tostring(round(hi_dp * 100) / 100) + ", PLo~" + tostring(round(lo_dp * 100) / 100) + "-ST▼" array.set(table_row_count, 1, array.get(table_row_count, 1) + 1) array.set(alert_strings, 1, array.get(alert_strings, 1) + "\n" + _msg) //alert(_msg + "-Sup▼", alert.freq_once_per_bar_close) // For Individual Stock Alerts if barstate.islast table.cell(table_id = DnTabl, column = 0, row = array.get(table_row_count, 1), text = _ticker) table.cell(table_id = DnTabl, column = 1, row = array.get(table_row_count, 1), text = tostring(round(cl_p * 100) / 100), bgcolor=color.rgb(255, 0, 0)) table.cell(table_id = DnTabl, column = 2, row = array.get(table_row_count, 1), text = tostring(round(hi_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0)) table.cell(table_id = DnTabl, column = 3, row = array.get(table_row_count, 1), text = tostring(round(lo_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0)) table.cell(table_id = DnTabl, column = 4, row = array.get(table_row_count, 1), text = tostring(round(chg_dp * 100) / 100), bgcolor=color.rgb(255, 0, 0)) //plot(close, "Close", color=#8E1599)f_SupCro(syminfo.tickerid)f_SupCro(input('DJI', title=input.symbol)) f_SupCro(input('IXIC', title=input.symbol)) f_SupCro(input('SPX', title=input.symbol)) f_SupCro(input('RUT', title=input.symbol)) f_SupCro(input('AAPL', title=input.symbol))f_SupCro(input('AMZN', title=input.symbol)) f_SupCro(input('FB', title=input.symbol)) f_SupCro(input('GOOG', title=input.symbol)) f_SupCro(input('NFLX', title=input.symbol))f_SupCro(input('MSFT', title=input.symbol)) f_SupCro(input('NVDA', title=input.symbol)) f_SupCro(input('FDX', title=input.symbol)) f_SupCro(input('GLD', title=input.symbol))if array.get(alert_strings, 0) != "" alert(array.get(alert_strings, 0), alert.freq_once_per_bar_close)if array.get(alert_strings, 1) != "" alert(array.get(alert_strings, 1), alert.freq_once_per_bar_close)