Pine Script v5 · Strategy
GMH - ATH 200d
A Pine Script v5 strategy built on Highest (200) and SMA (close, 90). It has 6 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. 11 settings; defaults include ATH Period 200, %Stoploss 10 and %Profit Target 1 50.
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 GMH - ATH 200d repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did GMH - ATH 200d do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. On ETHUSDT 1D it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
- Does GMH - ATH 200d run in Pine Script v6?
- Yes
- Same 10 trades and the same P&L on ETHUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
- Does GMH - ATH 200d use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does GMH - ATH 200d run in Zeal Terminal?
- Yes
- It compiles in 27 ms and runs 1,000 bars in 52 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 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, $10,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 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
2 settings have no label
In the settings dialog start_date (line 7), end_date (line 8) 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.
-
Note
Uses an argument v6 removed
when = on line 49, 52, 54, 56. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| Backtesting custom dates | true | bool | isPeriod |
| Start date (no label in the script) | timestamp("1 Jan 2019") | time | line 10 |
| End date (no label in the script) | timestamp("1 Jan 2025") | time | line 10 |
| ATH Period | 200 | int · min 5 · max 500 · step 1 | ath |
| %Stoploss | 10 | int · min 0 · max 100 · step 1 | close long |
| Close order 1/2 position when reach profit target | true | bool | close long |
| %Profit Target 1 | 50 | int · min 0 · max 2000 · step 1 | target1 pt_label |
| %Profit Target 2 | 100 | int · min 0 · max 2000 · step 1 | target2 pt_label |
| %Profit Target 3 | 300 | int · min 0 · max 2000 · step 1 | target3 pt_label |
| Close order all position when cross under SMA | true | bool | close long |
| sma_length | 90 | int · min 0 · max 300 · step 1 | sma |
What it calculates
- HighestATH Period (200)
ath · line 27 - SMAclose, sma_length (90)
sma · line 29
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 | close > ath | On | 49 |
| Close long | close < strategy.position_avg_price*(1-sl/100) | On | 52 |
| Close long | on_percent == true and close > target_price | On | 54 |
| Close long | on_cross == true and ta.crossunder(close,sma) == true | On | 56 |
| cancel_all | not isPeriod | On | 59 |
| Close | not isPeriod | On | 60 |
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% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −11.6% | +9.8% | 10 | 0% | 0.00 | 13.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 8 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −7.5% | +16.7% | 9 | 0% | 0.00 | 10.6% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 15 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −11.0% | +148.3% | 16 | 0% | 0.00 | 15.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 19 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 |
|---|---|---|---|---|---|
| GMH - ATH 200d this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| Forex Midpoint Stratejisi For Nasdaq by trademasterf | sma highest | v5 strategy | −2.1% | 15 | 6.3% |
| Bull Trend Filtered StochRSI (BTFS) by SnarkyPuppy | highest sma | v5 strategy | +36.9% | 21 | 21.5% |
| ChBrkOutStrategySMA by anshuanshu333 | sma highest | v4 strategy | −4.5% | 42 | 20.9% |
| Gap Reversion Strategy by TradeAutomation | sma highest | v5 strategy | No trades on this market | ||
| Slight Swing Momentum Strategy. by fzj20020403 | sma highest | v5 strategy | +3.1% | 7 | 0.6% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- 4 strategy calls use the when = argument (line 49, 52, 54, 56). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- No v6-only features. v6 is not needed to run this script.
Same 10 trades and the same P&L on ETHUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 49: when = close > ath → if block
- Line 52: when = close < strategy.position_avg_price*(1-sl/100) → if block
- Line 54: when = on_percent == true and close > target_price → if block
- Line 56: when = on_cross == true and ta.crossunder(close,sma) == true → if block
⋯// Long Condition-strategy.entry("long", strategy.long, stock_share, when = close > ath, comment = "buy" + " @" + str.tostring(close))+if close > ath+ strategy.entry("long", strategy.long, stock_share, comment = "buy" + " @" + str.tostring(close))// Close Condition// 1) by % stoploss-strategy.close("long", when = close < strategy.position_avg_price*(1-sl/100) , comment = "stoploss" + " @" + str.tostring(close) , qty_percent = 100)+if close < strategy.position_avg_price*(1-sl/100)+ strategy.close("long" , comment = "stoploss" + " @" + str.tostring(close) , qty_percent = 100)// 2) by target price-strategy.close("long", when = on_percent == true and close > target_price, comment = "hit target"+ pt_label + "%" + " @" + str.tostring(close) , qty_percent = 50)+if on_percent == true and close > target_price+ strategy.close("long", comment = "hit target"+ pt_label + "%" + " @" + str.tostring(close) , qty_percent = 50)// 3) by sma crossunder-strategy.close("long", when = on_cross == true and ta.crossunder(close,sma) == true, comment = "sma cross" + " @" + str.tostring(close) , qty_percent = 100)+if on_cross == true and ta.crossunder(close,sma) == true+ strategy.close("long", comment = "sma cross" + " @" + str.tostring(close) , qty_percent = 100)// END⋯Does it run in Pine Script v6?
Yes
Same 10 trades and the same P&L on ETHUSDT 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.
⋯// © gmhfund-//@version=5+//@version=6strategy(title='ATH Strategy',overlay=true ,default_qty_type=strategy.percent_of_equity ,initial_capital=10000, default_qty_value=100 ,currency=currency.USD)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 27 ms | Yes 1,000 bars in 52 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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/// © gmhfund//@version=5strategy(title='ATH Strategy',overlay=true ,default_qty_type=strategy.percent_of_equity ,initial_capital=10000, default_qty_value=100 ,currency=currency.USD)// Backtest Periodon_customPeriod = input.bool(true, "Backtesting custom dates")start_date = input.time(timestamp("1 Jan 2019"), "From")end_date = input.time(timestamp("1 Jan 2025"), "to")checkPeriod() => time >= start_date and time <= end_date ? true : falsetestPeriod = checkPeriod()isPeriod = on_customPeriod == true ? testPeriod : true//Inputbar_ath = input.int(200,"ATH Period",minval=5,maxval=500,step=1) // ATH dayssl = input.int(10,"%Stoploss",minval=0,maxval=100,step=1) // Stoploss %on_percent = input.bool(true,"Close order 1/2 position when reach profit target ") // Profit Target Mode : ONpt1 = input.int(50,"%Profit Target 1",minval=0,maxval=2000,step=1)pt2 = input.int(100,"%Profit Target 2",minval=0,maxval=2000,step=1)pt3 = input.int(300,"%Profit Target 3",minval=0,maxval=2000,step=1)on_cross = input.bool(true,"Close order all position when cross under SMA") // CrossUnder Mode : ONbar_sma = input.int(90,"sma_length",minval=0,maxval=300,step=1) // SMAvar target_price = 0.0var target1 = 0.0var target2 = 0.0var target3 = 0.0var stock_share = 0.0ath = ta.highest(bar_ath)[1] // Seeking price of highest bar , exclude current one plot(ath,color=color.white)sma = ta.sma(close,bar_sma)[1]plot(sma)// Price //if close > ath and strategy.position_size == 0 // Update target price when ATH condition occurred stock_share := math.floor(strategy.equity/close) target1 := close*(1+pt1/100) target2 := close*(1+pt2/100) target3 := close*(1+pt3/100)string pt_label = ""if strategy.position_size >= stock_share // Hold full position target_price := target1 pt_label := str.tostring(pt1)else if strategy.position_size >= stock_share/2 // Remain half position target_price := target2 pt_label := str.tostring(pt2)else if strategy.position_size >= stock_share/4 // Remain 1/4 position target_price := target3 pt_label := str.tostring(pt3) // Long Conditionstrategy.entry("long", strategy.long, stock_share, when = close > ath, comment = "buy" + " @" + str.tostring(close))// Close Condition// 1) by % stoplossstrategy.close("long", when = close < strategy.position_avg_price*(1-sl/100) , comment = "stoploss" + " @" + str.tostring(close) , qty_percent = 100)// 2) by target pricestrategy.close("long", when = on_percent == true and close > target_price, comment = "hit target"+ pt_label + "%" + " @" + str.tostring(close) , qty_percent = 50)// 3) by sma crossunderstrategy.close("long", when = on_cross == true and ta.crossunder(close,sma) == true, comment = "sma cross" + " @" + str.tostring(close) , qty_percent = 100)// ENDif not isPeriod strategy.cancel_all() strategy.close_all()