Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

[Pt] Premarket Breakout Strategy

A Pine Script v5 strategy built on RMA (ta.tr, 14), RSI (close, 14) and SMA or Stoch (3). It has 7 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 25 settings; defaults include Start Year 2011, Start Month 1 and Start Day 1.

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 [Pt] Premarket Breakout Strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did [Pt] Premarket Breakout Strategy 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 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Does [Pt] Premarket Breakout Strategy 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: 1 before, 0 after on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does [Pt] Premarket Breakout Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 125, 129.
Does [Pt] Premarket Breakout Strategy run in Zeal Terminal?
Yes
It compiles in 50 ms and runs 1,000 bars in 138 ms, in the browser.

BTCUSDT · 1D · default settings

  • Trade direction
  • 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 (25)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$4,000$8,101Equity from $4,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. 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.
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, $4,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

    2 settings have no label

    In the settings dialog t1_session (line 14), pm_session (line 40) show an empty name. The labels on this page come from the variable names.

Settings

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

SettingDefaultType and rangeFeeds
Trading window
Start Year2011inttimestart
Start Month1int · min 1 · max 12timestart
Start Day1int · min 1 · max 31timestart
Finish Year2050inttimefinish
Finish Month12int · min 1 · max 12timefinish
Finish Day31int · min 1 · max 31timefinish
Sessions
T1 session (no label in the script)0945-1545sessiont1
Pm session (no label in the script)0900-0930sessionpm_t
Trading Options
Margin Requirement / Leverage11float · step 0.1trade_amount
Reinvest profitfalseboolline 27
Reinvest percentage100floattrade_amount
Reward to Risk Ratio2.0float · step 0.1L_PT S_PT
Daily ATR
ATR period14int · min 1datr atr
% ATR to use for SL / PT1.6float · min 0.01 · max 100 · step 0.2percentage
Stochastic RSI
K3int · min 1k
D3int · min 1d
RSI LengthFor 1 min time frame, use default 14." + "\nFor 5 min time frame, use 3.14int · min 1rsi1
Stochastic LengthFor 1 min time frame, use default 14." + "\nFor 5 min time frame, use 3.14int · min 1k
RSI Sourceclosesourcersi1 up down
RSI Settings
RSI Length14int · min 1up down
Smooth period3intrsiSM
MA TypeSMAstring · options ["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"]rsiMA
MA Length100intrsiMA
Entry parameters
Stochastic K must be above before entry82intS_entry1
Stochastic K must be above before entry18intL_entry1

What it calculates

  • RMAta.tr, ATR period (14)datr · line 36
  • RMAta.tr, ATR period (14)atr · line 38
  • RSIRSI Source (close), RSI Length (14)rsi1 · line 56
  • SMA / Stochta.stoch(rsi1, rsi1, rsi1, lengthStoch), K (3)k · line 57
  • SMAk, D (3)d · line 58
  • RMA / Changemath.max(ta.change(src), 0), RSI Length (14)up · line 72
  • RMA / Change-math.min(ta.change(src), 0), RSI Length (14)down · line 73
  • SMArsi, Smooth period (3)rsiSM · line 75

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.

The script has 80 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long longL_entry1 and windowOn98
Open Short shortS_entry1 and windowOn101
Exit Exit stop and limitstrategy.opentrades.size(0) > 0On125
Close LongL_exit1On127
Exit Exit stop and limitstrategy.opentrades.size(0) < 0On129
Close ShortS_exit1On131
Close time(timeframe.period, "1555-1600:23456") or time(timeframe.period, "0755-0800:23456")On133

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 data1 request.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 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 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−4.2%+8.4%10%0.0014.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+2.2%+21.5%1100%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.6%+17.1%1100%—0.0%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (K 2, D 2) made 0.0% before 26 Dec 2025 and 0.0% after it, against 0.0% for the defaults. 0% of the 16 combinations made money in-sample and 0% out-of-sample.

Before 26 Dec 2025 · in-sample
D ↓ · K →2345
20%0%0%0%
30%0%0%0%
40%0%0%0%
50%0%0%0%
From 26 Dec 2025 · out-of-sample
D ↓ · K →2345
20%0%0%0%
30%0%0%0%
40%0%0%0%
50%0%0%0%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. 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
[Pt] Premarket Breakout Strategy this page—v5 strategy0.0%00.0%
Stoch-RSI 4h-1h-15min by MoonFlagrsi sma rma stochv4 strategyNo trades on this market
Crypto rsi cci mf stoch rsi oscillators all in one strategy by SoftKill21rma sma rsiv4 strategy+1.6%326.8%
Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System by exlux99rsi sma rmav4 strategy−0.0%30.0%
CCI Level Zone by Naruephatsma rsi stochv5 strategyNo trades on this market
AVWAP Strategy by asfbherorsi stoch smav5 strategydoes not run in Zeal Terminal

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.

  • 3 settings use the untyped input() (line 6, 9, 55). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 1 trades and the same P&L on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 9: input() → input.int()
  • Line 55: input() → input.source()
⋯// ******************** Trade Period **************************************-startY = input(title='Start Year', defval=2011, group = "Trading window")+startY = input.int(title='Start Year', defval=2011, group = "Trading window")startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Trading window")startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Trading window")-finishY = input(title='Finish Year', defval=2050, group = "Trading window")+finishY = input.int(title='Finish Year', defval=2050, group = "Trading window")finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Trading window")⋯lengthStoch = input.int(14, "Stochastic Length", minval=1, group = "Stochastic RSI", tooltip = TT_stochLen)-src = input(close, title="RSI Source")+src = input.source(close, title="RSI Source")rsi1 = ta.rsi(src, lengthRSI)⋯

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: 1 before, 0 after on ETHUSDT 4h, 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.

⋯// © PtGambler-//@version=5+//@version=6strategy("[Pt] Premarket Breakout Strategy", shorttitle="PM Break Strategy", overlay=true, pyramiding=1, initial_capital=4000, commission_type=strategy.commission.cash_per_contract, slippage = 3) ⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 50 msWith a workaround 1,000 bars in 138 msNot measured
PineTSNot testedNot testedNot measured

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.

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/// © PtGambler//@version=5strategy("[Pt] Premarket Breakout Strategy", shorttitle="PM Break Strategy", overlay=true, pyramiding=1, initial_capital=4000, commission_type=strategy.commission.cash_per_contract, slippage = 3) // ******************** Trade Period **************************************startY = input(title='Start Year', defval=2011, group = "Trading window")startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Trading window")startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Trading window")finishY = input(title='Finish Year', defval=2050, group = "Trading window")finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Trading window")finishD = input.int(title='Finish Day', defval=31, minval=1, maxval=31, group = "Trading window")timestart = timestamp(startY, startM, startD, 00, 00)timefinish = timestamp(finishY, finishM, finishD, 23, 59)t1_session = input.session("0945-1545", "Entry Session", group="Sessions") t1 = time(timeframe.period, t1_session)window = time >= timestart and time <= timefinish and t1 ? true : false margin_req = input.float(11, title="Margin Requirement / Leverage", step=0.1, group = "Trading Options")reinvest = input.bool(defval=false,title="Reinvest profit", group = "Trading Options")reinvest_percent = input.float(defval=100, title = "Reinvest percentage", group="Trading Options")//-------------------------------------------------------------------------------------profit = strategy.netprofittrade_amount = math.floor(strategy.initial_capital*margin_req / close) BSLE() =>    strategy.opentrades > 0 ? (bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades-1)) : naBSLEx() =>    strategy.opentrades == 0 ? (bar_index - strategy.closedtrades.exit_bar_index(strategy.closedtrades-1)) : naif strategy.netprofit > 0 and reinvest    trade_amount := math.floor((strategy.initial_capital+(profit*reinvest_percent*0.01))*margin_req/ close) else    trade_amount := math.floor(strategy.initial_capital*margin_req / close) // ***************************************************************************************************** Daily ATR *****************************************************atrlen = input.int(14, minval=1, title="ATR period", group = "Daily ATR")iPercent = input.float(1.6, minval=0.01, maxval=100, step=0.2, title="% ATR to use for SL / PT", group = "Daily ATR") percentage = iPercent * 0.01datr = request.security(syminfo.tickerid, "1D", ta.rma(ta.tr, atrlen))datrp = datr * percentageatr = ta.rma(ta.tr, atrlen)// --------------------------------------------- Pre-market Session HL ------------------------------------====pm_session = input.session("0900-0930", "Pre-Market Session", group="Sessions") pm_t = time(timeframe.period, pm_session)var pm_h = 0.0var pm_l = 9999.9if pm_t    pm_h := high > pm_h ? high : pm_h    pm_l := low < pm_l ? low : pm_lpm_range = pm_h - pm_lbgcolor(pm_t?color.new(color.white,95):na)// ------------------------------------------------ Stochastic RSI --------------------------------------------------------string TT_stochLen =    "For 1 min time frame, use default 14." + "\nFor 5 min time frame, use 3."smoothK = input.int(3, "K", minval=1, group = "Stochastic RSI")smoothD = input.int(3, "D", minval=1, group = "Stochastic RSI")lengthRSI = input.int(14, "RSI Length", minval=1, group = "Stochastic RSI", tooltip = TT_stochLen)lengthStoch = input.int(14, "Stochastic Length", minval=1, group = "Stochastic RSI", tooltip = TT_stochLen)src = input(close, title="RSI Source")rsi1 = ta.rsi(src, lengthRSI)k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)d = ta.sma(k, smoothD)// -------------------------------------------------------- RSI MA Cross -----------------------------------------------------ma(source, length, type) =>    switch type        "SMA" => ta.sma(source, length)        "Bollinger Bands" => ta.sma(source, length)        "EMA" => ta.ema(source, length)        "SMMA (RMA)" => ta.rma(source, length)        "WMA" => ta.wma(source, length)        "VWMA" => ta.vwma(source, length)len = input.int(14, minval=1, title="RSI Length", group="RSI Settings")len2 = input.int(3, title="Smooth period", group="RSI Settings")maType = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="RSI Settings")malen = input.int(100, title="MA Length", group="RSI Settings")up = ta.rma(math.max(ta.change(src), 0), len)down = ta.rma(-math.min(ta.change(src), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))rsiSM = ta.sma(rsi,len2)rsiMA = ma(rsi, malen, maType)rsi_bull = rsiSM > rsiMA and rsi > 50 and rsi > rsiSMrsi_bear = rsiSM < rsiMA and rsi < 50 and rsi < rsiSM// --------------------------------------------- Define Trend - PM HL breakout -------------------------------------------------------------------var trend = 0// reset trend at PMif pm_t    trend := 0else    trend := trend == 0 ? (close > pm_h ? 1 : close < pm_l ? -1 : 0) : trend    plot(trend,"Trade direction")//---------------------------------------------------------------------------------------------------------------stoch_h_limit = input.int(82, "Stochastic K must be above before entry", group="Entry parameters")stoch_l_limit = input.int(18, "Stochastic K must be above before entry", group="Entry parameters")plot(time(timeframe.period, "0930-1600:23456") or pm_t? pm_h : high, title="PM High", color= time(timeframe.period, "0930-1600:23456") or pm_t? color.blue : color.new(color.black,100), linewidth=2, trackprice = true)plot(time(timeframe.period, "0930-1600:23456") or pm_t? pm_l : low, title="PM Low", color= time(timeframe.period, "0930-1600:23456") or pm_t? color.orange : color.new(color.black,100), linewidth=2, trackprice = true)// ------------------------------------------------------------ Entry --------------------------------------------var traded = falseL_entry1 = trend == 1 and traded == false and d[1] < stoch_l_limit and ta.crossover(k,d)S_entry1 = trend == -1 and traded == false and d[1] > stoch_h_limit and ta.crossunder(k,d)if L_entry1 and window    strategy.entry("Long", strategy.long,trade_amount)    traded := trueif S_entry1 and window    strategy.entry("Short", strategy.short,trade_amount)    traded := true// ------------------------------------------------------------- SL & PT -------------------------------------------RRR = input.float(2.0, "Reward to Risk Ratio", step=0.1, group="Trading Options")entry_price = strategy.opentrades.entry_price(0)L_SL = entry_price > pm_h ? pm_l - datrp : entry_price - pm_range - datrpS_SL = entry_price < pm_l ? pm_h + datrp : entry_price + pm_range + datrpL_risk = entry_price - L_SLS_risk = S_SL - entry_priceL_PT = entry_price + L_risk * RRRS_PT = entry_price - S_risk * RRRp0 = plot(strategy.opentrades.size(0) == 0 ? close : entry_price, "Entry Price", color= strategy.opentrades.size(0) == 0 ? na : color.gray, linewidth=1)p1 = plot(strategy.opentrades.size(0) > 0? L_SL : low, "Long SL", color= (t1 or pm_t) and strategy.opentrades.size(0) > 0 and BSLE() > 0? color.red : color.new(color.black,100), linewidth=3)p2 = plot(strategy.opentrades.size(0) > 0? L_PT : high, "Long PT", color= (t1 or pm_t) and strategy.opentrades.size(0) > 0 and BSLE() > 0? color.green : color.new(color.black,100), linewidth=3)p3 = plot(strategy.opentrades.size(0) < 0? S_SL : high, "Long SL", color= (t1 or pm_t) and strategy.opentrades.size(0) < 0 and BSLE() > 0? color.red : color.new(color.black,100), linewidth=3)p4 = plot(strategy.opentrades.size(0) < 0? S_PT : low, "Long PT", color= (t1 or pm_t) and strategy.opentrades.size(0) < 0 and BSLE() > 0? color.green : color.new(color.black,100), linewidth=3)fill(p1, p0, color.new(color.red,95))fill(p2, p0, color.new(color.green,95))fill(p3, p0, color.new(color.red,95))fill(p4, p0, color.new(color.green,95))// ------------------------------------------ Exit ----------------------------------------------------------L_exit1 = d > 80 and strategy.opentrades.profit(0) <=0 and rsi_bearS_exit1 = d < 20 and strategy.opentrades.profit(0) <=0 and rsi_bullif strategy.opentrades.size(0) > 0    strategy.exit("Exit", "Long", limit=L_PT, stop=L_SL)    if L_exit1        strategy.close("Long", comment="Exit Early")if strategy.opentrades.size(0) < 0    strategy.exit("Exit", "Short", limit=S_PT, stop=S_SL)    if S_exit1        strategy.close("Short", comment="Exit Early")    if time(timeframe.period, "1555-1600:23456") or time(timeframe.period, "0755-0800:23456")    strategy.close_all()    traded := false    pm_h := 0.0    pm_l := 9999.9