Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Repaint Demonstration in Security Function Call using Higher TF

A Pine Script v4 strategy built on Crossover (close, bigTFClose). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 1 setting; defaults include Future Sight: W.

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 Repaint Demonstration in Security Function Call using Higher TF repaint?
Yes
In a live replay, it did not match history on 24 of 26 trades, and it produced 30 trades that history does not have.
How did Repaint Demonstration in Security Function Call using Higher TF do on BTCUSDT 1D with default settings?
+133.82%
From 26 Jan 2024 to 21 Oct 2026, over 89 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Repaint Demonstration in Security Function Call using Higher TF be converted to Pine Script v5?
No
The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
Does Repaint Demonstration in Security Function Call using Higher TF use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Repaint Demonstration in Security Function Call using Higher TF run in Zeal Terminal?
Yes
It compiles in 6 ms and runs 1,000 bars in 25 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$238,532$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 13) so the engine trades the way the script says. 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 live re-run is not offered here: the script requests BINANCE:BTCUSDT W, which this page cannot load in your browser.
Net profit
+133.82%
$133,820.00
Buy and hold
+102.5%
same period
Closed trades
89
35 won · 54 lost
Profitable
39.3%
of closed trades
Profit factor
1.54
gross profit ÷ gross loss
Max drawdown
27.53%
−$57,171.90

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.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 13, 14. The upgraded version below moves each call inside an if block.

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 security → request.security, crossover → ta.crossover.
  • 2 strategy calls use the when = argument (line 13, 14). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

Trades differ: 89 before, 89 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 7: input(type = input.resolution) → input.timeframe()
  • Line 8: security → request.security
  • Line 9: crossover → ta.crossover
  • Line 10: crossover → ta.crossover
  • Line 13: strategy.entry(…, true) → strategy.entry(…, strategy.long)
⋯// © akrit8888-// @version=4+// @version=5// "This Script is for demonstration of repaint by using security function to lookup the Future" ⋯strategy("Repaint Demonstration in Security Function Call using Higher TF", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)-bigTF = input("W", "Future Sight: ", input.resolution)+bigTF = input.timeframe("W", "Future Sight: ")-bigTFClose = security(syminfo.tickerid, bigTF, close)+bigTFClose = request.security(syminfo.tickerid, bigTF, close)-buy = crossover(close, bigTFClose)+buy = ta.crossover(close, bigTFClose)-sell = crossover(bigTFClose, close)+sell = ta.crossover(bigTFClose, close)plot(close)plot(bigTFClose)-strategy.entry("L", true, when = buy)+strategy.entry("L", strategy.long, when = buy)strategy.close("L", when = sell)

Clean v5

Verified

Same 89 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 13: when = buy → if block
  • Line 14: when = sell → if block
⋯plot(bigTFClose)-strategy.entry("L", strategy.long, when = buy)+if buy+    strategy.entry("L", strategy.long)-strategy.close("L", when = sell)+if sell+    strategy.close("L")

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: 89 before, 74 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.

⋯// © akrit8888-// @version=5+// @version=6// "This Script is for demonstration of repaint by using security function to lookup the Future" ⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Future Sight: WstringbigTFClose

What it calculates

  • Crossover (crossover, ta.crossover in v5)close, bigTFClosebuy · line 9
  • Crossover (crossover, ta.crossover in v5)bigTFClose, closesell · line 10

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.

closecloseprice databigTFFuture Sight: setting · WbuyCrossover→ buysellCrossover→ sellbigTFClosebigTFClosevalueentry:LOpen Lstrategy.entryclose:LClose Lstrategy.closeplot:11plotplotplot:12plotplot

Order rules

OrderFires whenBy defaultLine
Open L longbuyOn13
Close LsellOn14

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

The live replay did not match history.

2/26trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe data1 security call(s), none with lookahead on.
  • 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

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+133.8%+102.5%8939%1.5427.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+15.0%+5.5%3722%1.5810.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+27.9%+9.8%9227%1.0850.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−7.6%+8.4%4810%0.8518.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+107.5%+16.7%9335%1.2061.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+35.4%+21.5%3722%1.9512.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+110.5%+148.3%9740%1.4126.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.9%+17.1%5217%1.0212.9%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): BINANCE:BTCUSDT W (Binance BTCUSDT 1w), fetched from Binance's public market data for each market.

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market3529%$26,472.70
Sideways market3145%$26,883.90
Falling market2348%$80,463.40

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

37.7%

The 95th percentile of the worst drawdown when the same 89 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 17.8% to 37.7%; the tick is what actually happened, 23.7%. Order luck alone moves it this much.

0%43%
All 89 trades
SideEntryExitBarsP&L
long30 Jan 2024 43,302.7020 Feb 2024 51,774.7021$19,564.70
long21 Feb 2024 52,258.8022 Feb 2024 51,849.401−$936.77
long27 Feb 2024 54,476.5017 Mar 2024 65,300.6019$23,570.70
long26 Mar 2024 69,880.002 Apr 2024 69,649.807−$468.41
long9 Apr 2024 71,620.0010 Apr 2024 69,146.001−$4,895.85
long11 Apr 2024 70,631.1013 Apr 2024 67,116.502−$6,808.79
long23 Apr 2024 66,819.3025 Apr 2024 64,289.602−$4,922.69
long30 Apr 2024 63,866.001 May 2024 60,672.001−$6,256.49
long5 May 2024 63,892.007 May 2024 63,165.202−$1,352.02
long14 May 2024 62,940.1029 May 2024 68,398.4015$10,189.40
long4 Jun 2024 68,809.9011 Jun 2024 69,540.007$1,354.79
long2 Jul 2024 62,900.003 Jul 2024 62,135.501−$1,568.44
long9 Jul 2024 56,714.6023 Jul 2024 67,532.0014$24,312.80
long9 Aug 2024 61,686.0015 Aug 2024 58,683.406−$7,388.14
long17 Aug 2024 58,874.6027 Aug 2024 62,834.0010$9,710.77
long3 Sep 2024 59,132.106 Sep 2024 56,180.003−$7,693.58
long10 Sep 2024 57,042.0017 Sep 2024 58,214.007$3,008.17
long18 Sep 2024 60,314.0024 Sep 2024 63,340.006$7,496.52
long25 Sep 2024 64,262.7026 Sep 2024 63,152.001−$2,712.08
long27 Sep 2024 65,174.001 Oct 2024 63,327.604−$4,368.64
long13 Oct 2024 63,206.2022 Oct 2024 67,377.509$9,888.36
long29 Oct 2024 69,962.205 Nov 2024 67,850.007−$4,822.17
long6 Nov 2024 69,372.0026 Nov 2024 93,010.0020$52,781.70
long5 Dec 2024 98,587.306 Dec 2024 96,945.601−$3,458.38
long7 Dec 2024 99,740.8010 Dec 2024 97,276.503−$5,045.93
long12 Dec 2024 101,125.0013 Dec 2024 100,004.001−$2,207.39
long14 Dec 2024 101,424.0019 Dec 2024 100,204.005−$2,369.76
long25 Dec 2024 98,663.6028 Dec 2024 94,299.003−$8,608.56
long29 Dec 2024 95,300.0031 Dec 2024 92,792.102−$4,894.68
long2 Jan 2025 94,591.808 Jan 2025 96,954.606$4,523.70
long15 Jan 2025 96,560.9028 Jan 2025 102,083.0013$10,615.10
long30 Jan 2025 103,733.001 Feb 2025 102,430.002−$2,466.26
long4 Feb 2025 101,329.006 Feb 2025 96,612.402−$9,018.59
long11 Feb 2025 97,430.8012 Feb 2025 95,778.201−$3,133.76
long13 Feb 2025 97,870.0018 Feb 2025 95,780.005−$3,878.44
long20 Feb 2025 96,644.4025 Feb 2025 91,552.905−$9,363.88
long12 Mar 2025 82,933.0029 Mar 2025 84,424.4017$3,027.94
long1 Apr 2025 82,550.009 Apr 2025 76,322.408−$12,930.80
long10 Apr 2025 82,615.2016 Apr 2025 83,644.006$1,973.41
long17 Apr 2025 84,030.4013 May 2025 102,791.0026$35,822.10
long21 May 2025 106,850.0028 May 2025 108,938.007$3,835.70
long3 Jun 2025 105,858.004 Jun 2025 105,377.001−$909.43
long10 Jun 2025 110,263.0013 Jun 2025 105,672.003−$8,294.39
long14 Jun 2025 106,067.0015 Jun 2025 105,415.001−$1,173.42
long17 Jun 2025 106,795.0018 Jun 2025 104,551.001−$3,985.49
long24 Jun 2025 105,334.001 Jul 2025 107,147.007$3,196.23
long3 Jul 2025 108,850.005 Jul 2025 107,984.002−$1,502.04
long10 Jul 2025 111,234.0016 Jul 2025 117,758.006$10,993.50
long18 Jul 2025 119,178.0019 Jul 2025 117,925.001−$2,085.78
long22 Jul 2025 117,380.0029 Jul 2025 118,062.007$1,140.73
long5 Aug 2025 115,055.006 Aug 2025 114,130.001−$1,588.19
long7 Aug 2025 114,992.0012 Aug 2025 118,686.005$6,292.52
long13 Aug 2025 120,134.0015 Aug 2025 118,295.002−$3,095.10
long2 Sep 2025 109,237.0023 Sep 2025 112,651.0021$6,221.51
long30 Sep 2025 114,312.008 Oct 2025 121,333.008$12,610.40
long14 Oct 2025 115,166.0015 Oct 2025 113,028.001−$4,045.45
long21 Oct 2025 110,532.0022 Oct 2025 108,298.001−$4,323.65
long24 Oct 2025 110,078.0028 Oct 2025 114,108.004$7,670.94
long11 Nov 2025 106,011.0012 Nov 2025 103,059.001−$6,049.24
long25 Nov 2025 88,300.002 Dec 2025 86,286.007−$4,816.70
long3 Dec 2025 91,277.906 Dec 2025 89,330.003−$4,403.71
long9 Dec 2025 90,634.4013 Dec 2025 90,268.404−$815.37
long21 Dec 2025 88,360.9023 Dec 2025 88,620.802$591.59
long31 Dec 2025 88,485.501 Jan 2026 87,648.201−$1,908.91
long2 Jan 2026 88,839.108 Jan 2026 91,364.206$5,679.74
long13 Jan 2026 91,296.2020 Jan 2026 92,631.007$3,004.58
long27 Jan 2026 88,347.1030 Jan 2026 84,650.203−$8,725.20
long3 Feb 2026 78,738.604 Feb 2026 75,770.201−$7,531.76
long17 Feb 2026 68,892.4018 Feb 2026 67,503.501−$3,875.94
long26 Feb 2026 67,988.0027 Feb 2026 67,485.201−$1,393.27
long3 Mar 2026 68,830.1019 Mar 2026 71,246.6016$6,564.65
long24 Mar 2026 70,906.4028 Mar 2026 66,407.304−$12,281.10
long31 Mar 2026 66,797.407 Apr 2026 68,853.707$5,580.12
long8 Apr 2026 71,924.2028 Apr 2026 77,371.3020$14,150.70
long3 May 2026 78,686.8012 May 2026 81,745.709$7,813.48
long21 May 2026 77,552.2023 May 2026 75,539.502−$5,419.37
long26 May 2026 77,322.0027 May 2026 75,930.001−$3,661.60
long12 Jun 2026 63,626.0017 Jun 2026 65,675.005$6,432.17
long23 Jun 2026 64,020.0024 Jun 2026 62,734.601−$4,139.49
long30 Jun 2026 60,260.201 Jul 2026 58,624.701−$5,483.02
long2 Jul 2026 60,024.008 Jul 2026 63,364.006$10,936.40
long11 Jul 2026 64,161.7014 Jul 2026 62,334.503−$5,908.54
long15 Jul 2026 65,044.0025 Jul 2026 64,140.0010−$2,801.43
long5 Aug 2026 64,106.6011 Aug 2026 63,970.006−$423.35
long18 Aug 2026 64,532.102 Sep 2026 77,439.0015$39,670.20
long4 Sep 2026 81,270.408 Sep 2026 79,112.004−$6,321.15
long15 Sep 2026 78,189.2016 Sep 2026 75,644.501−$7,540.60
long19 Sep 2026 80,883.9029 Sep 2026 83,500.0010$7,250.10
long2 Oct 2026 84,880.106 Oct 2026 85,766.904$2,417.67

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 6 msWith a workaround 1,000 bars in 25 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 13) so the engine trades the way the script says. 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.

“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/// © akrit8888// @version=4// "This Script is for demonstration of repaint by using security function to lookup the Future" // "And should NOT by any means be use in as a real trading strategy."strategy("Repaint Demonstration in Security Function Call using Higher TF", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)bigTF = input("W", "Future Sight: ", input.resolution)bigTFClose = security(syminfo.tickerid, bigTF, close)buy = crossover(close, bigTFClose)sell = crossover(bigTFClose, close)plot(close)plot(bigTFClose)strategy.entry("L", true, when = buy)strategy.close("L", when = sell)