Pine Script v4 · Strategy
AMRS_LongOnly_PartTimer
A Pine Script v4 strategy built on EMA (close, 11) and Highest (high, 504). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 6 settings; defaults include Start Year 2000, Start Month 01 and Start Date 01.
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 AMRS_LongOnly_PartTimer repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did AMRS_LongOnly_PartTimer do on BTCUSDT 1D with default settings?
- 0.00%
- From 26 Jan 2024 to 21 Oct 2026, over 11 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can AMRS_LongOnly_PartTimer 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 AMRS_LongOnly_PartTimer use a stop loss?
- Yes
- strategy.exit sets a stop on line 40.
- Does AMRS_LongOnly_PartTimer run in Zeal Terminal?
- Yes
- It compiles in 14 ms and runs 1,000 bars in 35 ms, in the browser.
BTCUSDT · 1D · default settings
- Shape
- Shape
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 11
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. 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.
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 ema → ta.ema, highest → ta.highest.
Same 11 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: //@version=4 → //@version=5
- Line 8: input(type = input.integer) → input.int()
- Line 9: input(type = input.integer) → input.int()
- Line 10: input(type = input.integer) → input.int()
- Line 11: input(type = input.integer) → input.int()
- Line 12: input(type = input.integer) → input.int()
6 more edits
- Line 13: input(type = input.integer) → input.int()
- Line 14: ema → ta.ema
- Line 15: ema → ta.ema
- Line 16: ema → ta.ema
- Line 24: highest → ta.highest
- Line 27: highest → ta.highest
⋯//This script generates white arrow for each buying signal-//@version=4+//@version=5strategy("AMRS_LongOnly_PartTimer", overlay = true)//i_endTime = input(defval = timestamp("02 Jun 2021 15:30 +0000"), title = "End Time", type=input.time)-StartYear=input(defval = 2000, title ="Start Year", type=input.integer)+StartYear=input.int(defval = 2000, title ="Start Year")-StartMonth=input(defval = 01, title ="Start Month", type=input.integer)+StartMonth=input.int(defval = 01, title ="Start Month")-StartDate=input(defval = 01, title ="Start Date", type=input.integer)+StartDate=input.int(defval = 01, title ="Start Date")-endYear=input(defval = 2021, title ="End Year", type=input.integer)+endYear=input.int(defval = 2021, title ="End Year")-endMonth=input(defval = 06, title ="End Month", type=input.integer)+endMonth=input.int(defval = 06, title ="End Month")-endDate=input(defval = 03, title ="End Date", type=input.integer)+endDate=input.int(defval = 03, title ="End Date")-ema11=ema(close,11)+ema11=ta.ema(close,11)-ema13=ema(close,13)+ema13=ta.ema(close,13)-ema21=ema(close,21)+ema21=ta.ema(close,21)afterStartDate = (time >= timestamp(syminfo.timezone,StartYear, StartMonth, StartDate, 0, 0))⋯//a = security(syminfo.tickerid, 'M', ath(),lookahead=barmerge.lookahead_on)-newHigh = (high > highest(high,504)[1])+newHigh = (high > ta.highest(high,504)[1])//plot down arrows whenever it's a new highplotshape(newHigh, style=shape.triangleup, location=location.abovebar, color=color.green, size=size.tiny)-b=highest(high,504)[1]+b=ta.highest(high,504)[1]VarChk=((b-ema13)/b)*100⋯Clean v5
VerifiedNothing to change.
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: 11 before, 6 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.
⋯//This script generates white arrow for each buying signal-//@version=5+//@version=6strategy("AMRS_LongOnly_PartTimer", overlay = true)⋯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 |
|---|---|---|---|
| Start Year | 2000 | int (written input.integer) | afterStartDate |
| Start Month | 01 | int (written input.integer) | afterStartDate |
| Start Date | 01 | int (written input.integer) | afterStartDate |
| End Year | 2021 | int (written input.integer) | beforeEndDate |
| End Month | 06 | int (written input.integer) | beforeEndDate |
| End Date | 03 | int (written input.integer) | beforeEndDate |
What it calculates
- EMA (
ema,ta.emain v5)close, 11ema11 · line 14 - EMA (
ema,ta.emain v5)close, 13ema13 · line 15 - EMA (
ema,ta.emain v5)close, 21ema21 · line 16 - Highest (
highest,ta.highestin v5)high, 504b · line 27
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 Long long | (TrigLow and afterStartDate) | On | 39 |
| Exit exit stop | every bar | On | 40 |
| Close | (beforeEndDate) | On | 44 |
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% | 11 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 33 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 3 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 26 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 32 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 11 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 27 | 0% | — | 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 | 8 | 0% | $0.00 |
| Sideways market | 3 | 0% | $0.00 |
| 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 11 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 11 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 8 Jul 2025 108,263.00 | 8 Jul 2025 108,263.00 | 0 | $0.00 |
| long | 9 Jul 2025 108,923.00 | 9 Jul 2025 108,923.00 | 0 | $0.00 |
| long | 10 Jul 2025 111,234.00 | 10 Jul 2025 111,234.00 | 0 | $0.00 |
| long | 23 Jul 2025 119,954.00 | 23 Jul 2025 119,954.00 | 0 | $0.00 |
| long | 25 Jul 2025 118,341.00 | 25 Jul 2025 118,341.00 | 0 | $0.00 |
| long | 27 Jul 2025 117,920.00 | 27 Jul 2025 117,920.00 | 0 | $0.00 |
| long | 29 Jul 2025 118,062.00 | 29 Jul 2025 118,062.00 | 0 | $0.00 |
| long | 30 Jul 2025 117,951.00 | 30 Jul 2025 117,951.00 | 0 | $0.00 |
| long | 9 Aug 2025 116,675.00 | 9 Aug 2025 116,675.00 | 0 | $0.00 |
| long | 11 Aug 2025 119,294.00 | 11 Aug 2025 119,294.00 | 0 | $0.00 |
| long | 10 Oct 2025 121,662.00 | 10 Oct 2025 121,662.00 | 0 | $0.00 |
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 |
|---|---|---|---|---|---|
| AMRS_LongOnly_PartTimer this page | — | v4 strategy | 0.0% | 11 | 0.0% |
| BTC Good Signal by Majaztrades | ema highest | v4 strategy | −32.5% | 6 | 38.9% |
| Automated Bitcoin (BTC) Investment Strategy from Wunderbit by Wunderbit | ema highest | v4 strategy | −32.5% | 6 | 38.9% |
| CC Trend strategy 2- Downtrend Short by CheatCode1 | ema highest | v5 strategy | No trades on this market | ||
| Slight Swing Momentum Strategy. by fzj20020403 | highest ema | v5 strategy | +3.1% | 7 | 0.6% |
| Momentum Strategy by PrattyCharts | ema highest | v4 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 14 ms | Yes 1,000 bars in 35 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
“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/// © Part Timer//This script accepts from and to date parameter for backtesting. //This script generates white arrow for each buying signal//@version=4strategy("AMRS_LongOnly_PartTimer", overlay = true)//i_endTime = input(defval = timestamp("02 Jun 2021 15:30 +0000"), title = "End Time", type=input.time)StartYear=input(defval = 2000, title ="Start Year", type=input.integer)StartMonth=input(defval = 01, title ="Start Month", type=input.integer)StartDate=input(defval = 01, title ="Start Date", type=input.integer)endYear=input(defval = 2021, title ="End Year", type=input.integer)endMonth=input(defval = 06, title ="End Month", type=input.integer)endDate=input(defval = 03, title ="End Date", type=input.integer)ema11=ema(close,11)ema13=ema(close,13)ema21=ema(close,21)afterStartDate = (time >= timestamp(syminfo.timezone,StartYear, StartMonth, StartDate, 0, 0))//g=bar_index==1//ath()=> //a=0.0 //a:=g ? high : high>a[1] ? high:a[1] //a = security(syminfo.tickerid, 'M', ath(),lookahead=barmerge.lookahead_on)newHigh = (high > highest(high,504)[1])//plot down arrows whenever it's a new highplotshape(newHigh, style=shape.triangleup, location=location.abovebar, color=color.green, size=size.tiny)b=highest(high,504)[1]VarChk=((b-ema13)/b)*100TrigLow = (low <= ema13) and (low >= ema21) and (VarChk <= 10)plotshape(TrigLow, style=shape.triangleup, location=location.belowbar, color=color.white, size=size.tiny)ExitPrice=(ema21 - (ema21*0.05))DrawPrice=(b - (b*0.20))stopprice=0.0if (close <= ExitPrice) stopprice := ExitPriceif (close <= DrawPrice) stopprice := DrawPriceif (TrigLow and afterStartDate) strategy.entry("Long", strategy.long)strategy.exit("exit","Long", stop=stopprice)//beforeEndDate = (time < i_endTime)beforeEndDate = (time >= timestamp(syminfo.timezone,endYear, endMonth, endDate, 0, 0))if (beforeEndDate) strategy.close_all()