Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (11)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$10,000$20,253Equity from $10,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.
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.

SettingDefaultType and rangeFeeds
Backtesting custom datestrueboolisPeriod
Start date (no label in the script)timestamp("1 Jan 2019")timeline 10
End date (no label in the script)timestamp("1 Jan 2025")timeline 10
ATH Period200int · min 5 · max 500 · step 1ath
%Stoploss10int · min 0 · max 100 · step 1close long
Close order 1/2 position when reach profit target trueboolclose long
%Profit Target 150int · min 0 · max 2000 · step 1target1 pt_label
%Profit Target 2100int · min 0 · max 2000 · step 1target2 pt_label
%Profit Target 3300int · min 0 · max 2000 · step 1target3 pt_label
Close order all position when cross under SMAtrueboolclose long
sma_length90int · min 0 · max 300 · step 1sma

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.

bar_athATH Periodsetting · 200closecloseprice databar_smasma_lengthsetting · 90pt1%Profit Target 1setting · 50pt2%Profit Target 2setting · 100pt3%Profit Target 3setting · 300sl%Stoplosssetting · 10athHighest→ athsmaSMA→ smaisPeriodisPeriodvaluetarget_pricetarget_pricevaluetarget1target1valuetarget2target2valuetarget3target3valuestock_sharestock_sharevaluept_labelpt_labelvalueentry:longOpen longstrategy.entryclose:longClose longstrategy.closecancel_all:cancel_all strategy.cancel_allclose_all:close_all strategy.close_allplot:28plotplotplot:30plotplot

Order rules

OrderFires whenBy defaultLine
Open long longclose > athOn49
Close longclose < strategy.position_avg_price*(1-sl/100)On52
Close longon_percent == true and close > target_priceOn54
Close longon_cross == true and ta.crossunder(close,sma) == trueOn56
cancel_all not isPeriodOn59
Close not isPeriodOn60

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−11.6%+9.8%100%0.0013.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%80%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−7.5%+16.7%90%0.0010.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%150%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−11.0%+148.3%160%0.0015.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%190%—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.

ScriptSharesTypeNetTradesMax drawdown
GMH - ATH 200d this page—v5 strategy0.0%00.0%
Forex Midpoint Stratejisi For Nasdaq by trademasterfsma highestv5 strategy−2.1%156.3%
Bull Trend Filtered StochRSI (BTFS) by SnarkyPuppyhighest smav5 strategy+36.9%2121.5%
ChBrkOutStrategySMA by anshuanshu333sma highestv4 strategy−4.5%4220.9%
Gap Reversion Strategy by TradeAutomationsma highestv5 strategyNo trades on this market
Slight Swing Momentum Strategy. by fzj20020403sma highestv5 strategy+3.1%70.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.

Clean v5

VerifiedDownload the v5 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.

Download the v6 script

⋯// © 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

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 27 msYes 1,000 bars in 52 msNot measured
PineTSNot testedNot testedNot 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()