Pine Script v4 · Strategy
Take America Back Version 1.0
A Pine Script v4 strategy with no technical-analysis calculation. It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 3 settings; defaults include Quantity Value 20, Saved 0 and Fees .0025.
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 Take America Back Version 1.0 repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Take America Back Version 1.0 do on BTCUSDT 1D with default settings?
- +0.02%
- From 26 Jan 2024 to 21 Oct 2026, over 24 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Take America Back Version 1.0 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.
- Does Take America Back Version 1.0 use a stop loss?
- Yes
- strategy.exit sets a stop on line 35.
- Does Take America Back Version 1.0 run in Zeal Terminal?
- Yes
- It compiles in 15 ms and runs 1,000 bars in 27 ms, in the browser.
BTCUSDT · 1D · default settings
- Saved
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +0.02%
- $17.56
- Buy and hold
- +102.5%
- same period
- Closed trades
- 24
- 24 won · 0 lost
- Profitable
- 100.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.01%
- −$9.75
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 commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
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 37. 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 tostring → str.tostring.
- 1 strategy call uses the when = argument (line 37). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 24 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 28: tostring → str.tostring
- Line 29: tostring → str.tostring
- Line 37: strategy.entry(…, true) → strategy.entry(…, strategy.long)
⋯// © Crystal_Catalyst-//@version=4+//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯ saved := saved+(strategy.netprofit-strategy.netprofit[1])*(base-saved)/base-buy = "Take America Back" + tostring(strategy.opentrades)+buy = "Take America Back" + str.tostring(strategy.opentrades)-sell = "Take America Back" + tostring(strategy.opentrades-1)+sell = "Take America Back" + str.tostring(strategy.opentrades-1)if open>price and asset*open<default_qty_value⋯if open<price*(1-2*fees/(base/default_qty_value)) and base>default_qty_value+saved- strategy.entry(buy, true, limit=open, stop=open, qty=default_qty_value/close, when = close<price*(1-fees))+ strategy.entry(buy, strategy.long, limit=open, stop=open, qty=default_qty_value/close, when = close<price*(1-fees))plot(saved, title="Saved", color=color.black, style=plot.style_line)Same 24 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 14: input() → input.float()
- Line 37: when = close<price*(1-fees) → if block
⋯strategy("Take America Back Version 1.0", close_entries_rule="ANY")-default_qty_value=input(defval=20, title="Quantity Value")+default_qty_value=input.int(defval=20, title="Quantity Value")-var float saved=input(defval=0, title="Saved")+var float saved=input.int(defval=0, title="Saved")var price = close⋯var float ratio = na-fees = input(defval=.0025, title="Fees")+fees = input.float(defval=.0025, title="Fees")asset := (strategy.opentrades*default_qty_value+strategy.openprofit)/open⋯if open<price*(1-2*fees/(base/default_qty_value)) and base>default_qty_value+saved- strategy.entry(buy, strategy.long, limit=open, stop=open, qty=default_qty_value/close, when = close<price*(1-fees))+ if close<price*(1-fees)+ strategy.entry(buy, strategy.long, limit=open, stop=open, qty=default_qty_value/close)plot(saved, title="Saved", color=color.black, style=plot.style_line)Does it run in Pine Script v6?
Yes
Same 24 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.
⋯// © Crystal_Catalyst-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯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 |
|---|---|---|---|
| Quantity Value | 20 | int | asset base ratio exit sell entry buy line 30 line 32 line 34 line 36 |
| Saved | 0 | int | entry buy line 32 line 36 Saved |
| Fees | .0025 | float | exit sell entry buy line 34 line 36 |
What it calculates
No technical-analysis calculation: the script works on prices and settings directly.
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 |
|---|---|---|---|
| Exit sell stop and limit | open>(asset*price+default_qty_value*2*fees)/(asset*ratio) and asset*open>default_qty_value | On | 35 |
| Open buy long | close<price*(1-fees) | On | 37 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +0.0% | +102.5% | 24 | 100% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.0% | +5.5% | 4 | 100% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.0% | +9.8% | 7 | 100% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 7 | 100% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 8 | 100% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 11 | 100% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 24 | 100% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 8 | 100% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 19 | 100% | $13.62 |
| Sideways market | 5 | 100% | $3.94 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
0.0%
The 95th percentile of the worst drawdown when the same 24 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.
All 24 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 1 Feb 2024 42,580.00 | 4 Feb 2024 43,011.10 | 3 | $0.20 |
| long | 5 Feb 2024 42,582.90 | 9 Feb 2024 45,288.70 | 4 | $1.27 |
| long | 23 Feb 2024 51,288.40 | 28 Feb 2024 57,037.30 | 5 | $2.24 |
| long | 3 Mar 2024 61,987.30 | 5 Mar 2024 68,245.70 | 2 | $2.02 |
| long | 7 Mar 2024 66,074.00 | 8 Mar 2024 66,823.20 | 1 | $0.23 |
| long | 16 Mar 2024 69,499.80 | 31 Oct 2024 72,344.80 | 229 | $0.82 |
| long | 1 Nov 2024 70,292.00 | 8 Nov 2024 75,857.90 | 7 | $1.58 |
| long | 18 Nov 2024 89,856.00 | 21 Nov 2024 94,286.60 | 3 | $0.99 |
| long | 25 Nov 2024 97,672.40 | 8 Dec 2024 99,832.00 | 13 | $0.44 |
| long | 11 Dec 2024 96,593.00 | 13 Dec 2024 100,004.00 | 2 | $0.71 |
| long | 20 Dec 2024 97,461.90 | 19 Jan 2025 104,556.00 | 30 | $1.46 |
| long | 21 Jan 2025 101,332.00 | 22 Jan 2025 106,144.00 | 1 | $0.94 |
| long | 24 Jan 2025 103,707.00 | 26 Jan 2025 104,747.00 | 2 | $0.20 |
| long | 27 Jan 2025 102,620.00 | 20 May 2025 105,574.00 | 113 | $0.58 |
| long | 25 May 2025 107,318.00 | 27 May 2025 109,435.00 | 2 | $0.39 |
| long | 29 May 2025 107,782.00 | 11 Jun 2025 110,274.00 | 13 | $0.46 |
| long | 13 Jun 2025 105,672.00 | 5 Jul 2025 107,984.00 | 22 | $0.44 |
| long | 6 Jul 2025 107,984.00 | 8 Jul 2025 108,263.00 | 2 | $0.05 |
| long | 9 Jul 2025 108,923.00 | 10 Jul 2025 111,234.00 | 1 | $0.42 |
| long | 17 Jul 2025 117,758.00 | 18 Jul 2025 119,178.00 | 1 | $0.24 |
| long | 20 Jul 2025 117,840.00 | 24 Jul 2025 118,756.00 | 4 | $0.16 |
| long | 25 Jul 2025 118,341.00 | 14 Aug 2025 123,306.00 | 20 | $0.84 |
| long | 16 Aug 2025 117,342.00 | 4 Oct 2025 122,232.00 | 49 | $0.83 |
| long | 9 Oct 2025 121,333.00 | 10 Oct 2025 121,662.00 | 1 | $0.05 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 15 ms | With a workaround 1,000 bars in 27 ms | Not measured |
| PineTS | No 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 37) so the engine trades the way the script says.
“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/// © Crystal_Catalyst//@version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Crystal_Catalyst//@version=4strategy("Take America Back Version 1.0", close_entries_rule="ANY")default_qty_value=input(defval=20, title="Quantity Value")var float saved=input(defval=0, title="Saved")var price = closevar float asset = navar float base = navar float ratio = nafees = input(defval=.0025, title="Fees")asset := (strategy.opentrades*default_qty_value+strategy.openprofit)/openbase := strategy.initial_capital-strategy.opentrades*default_qty_value+strategy.netprofitratio := asset*open/(default_qty_value*strategy.opentrades)if ratio>1 ratio := 1var initial_asset = assetvar initial_base = basevar previous_asset = assetvar previous_base = baseif strategy.opentrades != strategy.opentrades[1] price := open[1]if strategy.netprofit>strategy.netprofit[1] saved := saved+(strategy.netprofit-strategy.netprofit[1])*(base-saved)/basebuy = "Take America Back" + tostring(strategy.opentrades)sell = "Take America Back" + tostring(strategy.opentrades-1)if open>price and asset*open<default_qty_value price := openif open<price and base<default_qty_value+saved price := openif open>(asset*price+default_qty_value*2*fees)/(asset*ratio) and asset*open>default_qty_value strategy.exit(sell, limit=open, stop=open)if open<price*(1-2*fees/(base/default_qty_value)) and base>default_qty_value+saved strategy.entry(buy, true, limit=open, stop=open, qty=default_qty_value/close, when = close<price*(1-fees))plot(saved, title="Saved", color=color.black, style=plot.style_line)