Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Dazzling Bolts

A Pine Script v4 strategy built on SMA (close, 10), EMA (close, 55) and ATR (12). It has 6 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. 10 settings; defaults include SMMA Period 10, Source close and EMA Period 55.

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 Dazzling Bolts repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
How did Dazzling Bolts do on BTCUSDT 1D with default settings?
+8.45%
From 26 Jan 2024 to 21 Oct 2026, over 14 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Dazzling Bolts be converted to Pine Script v5?
No
The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
Does Dazzling Bolts use a stop loss?
Yes
strategy.exit sets a stop on line 38, 43.
Does Dazzling Bolts run in Zeal Terminal?
Yes
It compiles in 24 ms and runs 1,000 bars in 38 ms, in the browser.

BTCUSDT · 1D · default settings

  • Purple
  • Purple
  • 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 (10)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$111,664$202,527Equity from $100,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. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep.
Net profit
+8.45%
$8,451.72
Buy and hold
+102.5%
same period
Closed trades
14
7 won · 7 lost
Profitable
50.0%
of closed trades
Profit factor
1.22
gross profit ÷ gross loss
Max drawdown
13.04%
−$15,983.90

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.

  • Likely bug

    sma(close, smalength) ignores the settings line 16

    Line 16 hard-codes close where line 10 uses “Source”. Changing those settings moves one band but not this one.

    sma(close, smalength)sma(src, smalength)
  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    1 setting has no label

    In the settings dialog offsetemavalue (line 18) shows 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 transp =, which v5 removed line 21

    transp = on line 21, 22. v5 folds the transparency into the colour with color.new(c, transp).

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 sma → ta.sma, ema → ta.ema, floor → math.floor, atr → ta.atr, barssince → ta.barssince, crossover → ta.crossover, crossunder → ta.crossunder.

v4 → v5

Differs

Trades differ: 14 before, 19 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 10: sma → ta.sma
  • Line 13: ema → ta.ema
  • Line 16: sma → ta.sma
  • Line 17: input(type = input.bool) → input.bool()
  • Line 21: transp = 0 → color.new(#ff33cc, 0)
10 more edits
  • Line 22: transp = 0 → color.new(#ff33cc, 0)
  • Line 23: floor → math.floor
  • Line 24: input(type = input.bool) → input.bool()
  • Line 25: input(type = input.bool) → input.bool()
  • Line 27: input(type = input.float) → input.float()
  • Line 28: atr → ta.atr
  • Line 33: barssince → ta.barssince
  • Line 35: barssince → ta.barssince
  • Line 39: crossover → ta.crossover
  • Line 44: crossunder → ta.crossunder
⋯// © greenmask9-//@version=4+//@version=5strategy("Dazzling Bolts", overlay=true)⋯smma = 0.0-smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len+smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len// 55 EMAemalength = input(55, title="EMA Period")-ema = ema(close, emalength)+ema = ta.ema(close, emalength)// 100 SMAsmalength = input(110, title="SMA Period")-sma = sma(close, smalength)+sma = ta.sma(close, smalength)-emaforce = input(title="Force trend with medium EMA", type=input.bool, defval=true)+emaforce = input.bool(title="Force trend with medium EMA", defval=true)offsetemavalue = input(defval = 6)⋯bearbounce = smma<ema and ema<sma and high[5]<ema and high[2]>ema and close[1]<ema and (ema[offsetemavalue]<sma or (not emaforce))-plotshape(bullbounce,  title= "Purple", location=location.belowbar, color=#ff33cc, transp=0, style=shape.triangleup, size=size.tiny, text="Bolts")+plotshape(bullbounce,  title= "Purple", location=location.belowbar, color=color.new(#ff33cc, 0), style=shape.triangleup, size=size.tiny, text="Bolts")-plotshape(bearbounce,  title= "Purple", location=location.abovebar, color=#ff33cc, transp=0, style=shape.triangledown, size=size.tiny, text="Bolts")+plotshape(bearbounce,  title= "Purple", location=location.abovebar, color=color.new(#ff33cc, 0), style=shape.triangledown, size=size.tiny, text="Bolts")-ordersize=floor(strategy.initial_capital/close)+ordersize=math.floor(strategy.initial_capital/close)-longs = input(title="Test longs", type=input.bool, defval=true)+longs = input.bool(title="Test longs", defval=true)-shorts = input(title="Test shorts", type=input.bool, defval=true)+shorts = input.bool(title="Test shorts", defval=true)atrlength = input(title="ATR length", defval=12)-atrm = input(title="ATR muliplier",type=input.float, defval=2)+atrm = input.float(title="ATR muliplier", defval=2)-atr = atr(atrlength)+atr = ta.atr(atrlength)target = close + atr*atrm⋯bullbuy = bullbounce and longs and strategy.opentrades==0-bb = barssince(bullbuy)+bb = ta.barssince(bullbuy)bearsell = bearbounce and shorts and strategy.opentrades==0-bs = barssince(bearsell)+bs = ta.barssince(bearsell)if (bullbuy)⋯    strategy.exit ("Bolts.close", from_entry="Boltsup", limit=target, stop=antitarget)-if (crossover(smma, sma))+if (ta.crossover(smma, sma))    strategy.close("Boltsup", qty_percent = 100, comment = "Bolts.crossover")⋯    strategy.exit("Bolts.close", from_entry="Boltsdown", limit=antitarget, stop=target)-if (crossunder(smma, sma))+if (ta.crossunder(smma, sma))    strategy.close("Boltsdown", qty_percent = 100, comment = "Bolts.crossover")⋯

Clean v5

Verified

Same 19 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 7: input() → input.int()
  • Line 8: input() → input.source()
  • Line 12: input() → input.int()
  • Line 15: input() → input.int()
  • Line 18: input() → input.int()
  • Line 26: input() → input.int()
⋯// 13 SMMA-len = input(10, minval=1, title="SMMA Period")+len = input.int(10, minval=1, title="SMMA Period")-src = input(close, title="Source")+src = input.source(close, title="Source")smma = 0.0⋯// 55 EMA-emalength = input(55, title="EMA Period")+emalength = input.int(55, title="EMA Period")ema = ta.ema(close, emalength)// 100 SMA-smalength = input(110, title="SMA Period")+smalength = input.int(110, title="SMA Period")sma = ta.sma(close, smalength)emaforce = input.bool(title="Force trend with medium EMA", defval=true)-offsetemavalue = input(defval = 6)+offsetemavalue = input.int(defval = 6)bullbounce = smma>ema and ema>sma and low[5]>ema and low[2]<ema and close[1]>ema and (ema[offsetemavalue]>sma or (not emaforce))⋯shorts = input.bool(title="Test shorts", defval=true)-atrlength = input(title="ATR length", defval=12)+atrlength = input.int(title="ATR length", defval=12)atrm = input.float(title="ATR muliplier", defval=2)⋯

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: 19 before, 14 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.

⋯// © greenmask9-//@version=5+//@version=6strategy("Dazzling Bolts", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
SMMA Period10int · min 1smma
Sourceclosesourcesmma
EMA Period55intema
SMA Period110intsma
Force trend with medium EMAtrueboolbullbounce bearbounce
Offsetemavalue (no label in the script)6intbullbounce bearbounce
Test longstrueboolbullbuy
Test shortstrueboolbearsell
ATR length12intatr
ATR muliplier2floattarget antitarget

What it calculates

  • SMA (sma, ta.sma in v5)Source (close), SMMA Period (10)smma · line 10
  • EMA (ema, ta.ema in v5)close, EMA Period (55)ema · line 13
  • SMA (sma, ta.sma in v5)close, SMA Period (110)sma · line 16
  • ATR (atr, ta.atr in v5)ATR length (12)atr · line 28
  • Barssince (barssince, ta.barssince in v5)bullbuybb · line 33
  • Barssince (barssince, ta.barssince in v5)bearsellbs · line 35

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.

closecloseprice datalenSMMA Periodsetting · 10emalengthEMA Periodsetting · 55smalengthSMA Periodsetting · 110high · low · closehigh · low · closeprice dataatrlengthATR lengthsetting · 12atrmATR mulipliersetting · 2lowlowprice dataoffsetemavalueOffsetemavaluesetting · 6highhighprice datasmmaSMA→ smmaemaEMA→ emasmaSMA→ smaatrATR→ atrbbBarssince→ bbbsBarssince→ bsordersizeordersizevaluetarget, antitargettarget · antitarget2 valuesbullbuybullbuyconditionbearsellbearsellconditionbullbouncebullbounceconditionbearbouncebearbounceconditionbulltarget, bullclose, bullstopColourbulltarget · bullclose +1entry:BoltsupOpen Boltsupstrategy.entryexit:Bolts.closeexit Bolts.closestrategy.exitclose:BoltsupClose Boltsupstrategy.closeentry:BoltsdownOpen Boltsdownstrategy.entryclose:BoltsdownClose Boltsdownstrategy.closeplotshape:21Purpleplotshapeplotshape:22Purpleplotshape

Order rules

OrderFires whenBy defaultLine
Open Boltsup long(bullbuy)On37
Exit Bolts.close stop and limit(bullbuy)On38
Close Boltsup(crossover(smma, sma))On40
Open Boltsdown short(bearsell)On42
Exit Bolts.close stop and limit(bearsell)On43
Close Boltsdown(crossunder(smma, sma))On45

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, and the live replay matched history.

4/4trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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 1D+8.5%+102.5%1450%1.2213.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−2.8%+5.5%1644%0.809.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−41.2%+9.8%1331%0.5050.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−7.1%+8.4%2045%0.7814.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−27.9%+16.7%1242%0.6733.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−4.9%+21.5%1443%0.8110.8%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−11.8%+148.3%2450%0.8937.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−10.6%+17.1%1741%0.5815.2%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 barsTradesWonP&L
Rising market367%$5,060.97
Sideways market850%$9,527.19
Falling market333%−$6,136.44

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

23.4%

The 95th percentile of the worst drawdown when the same 14 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 10.4% to 23.4%; the tick is what actually happened, 11.8%. Order luck alone moves it this much.

0%27%
All 14 trades
SideEntryExitBarsP&L
long14 Jun 2024 66,773.0024 Jun 2024 62,518.9010−$4,254.14
short24 Aug 2024 64,037.2027 Aug 2024 58,113.403$5,923.85
short17 Sep 2024 58,214.0019 Sep 2024 62,670.302−$4,456.33
long6 Oct 2024 62,058.0014 Oct 2024 66,076.108$4,018.12
long2 Jan 2025 94,591.806 Jan 2025 102,099.004$7,507.42
long12 Jan 2025 94,600.0017 Jan 2025 101,732.005$7,132.16
long5 Feb 2025 97,763.1025 Feb 2025 88,184.5020−$9,578.61
short5 Mar 2025 87,282.0011 Mar 2025 77,215.906$10,066.10
short5 Apr 2025 83,889.906 Apr 2025 77,227.101$6,662.74
short16 Apr 2025 83,644.0022 Apr 2025 91,433.306−$7,789.31
short9 Jan 2026 91,100.0013 Jan 2026 96,109.904−$5,009.87
short16 Mar 2026 72,815.3027 Mar 2026 66,878.7011$5,936.56
long21 May 2026 77,552.2028 May 2026 73,622.307−$3,929.94
short18 Jul 2026 63,931.7019 Aug 2026 67,708.7032−$3,777.04

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
Dazzling Bolts this page—v4 strategy+8.5%1413.0%
Oath by OrcChieftainema sma atr barssincev4 strategy+0.2%450.0%
ATR with EOM and VORTEX by SoftKill21atr ema smav4 strategy+66.2%2229.9%
cATRpillar Strategy by Obi-wanClintobeatr sma emav4 strategy+1.02827e+24%2788,097.2%
Optimized Zhaocaijinbao strategy by fzj20020403sma ema atrv5 strategy+15.6%129.8%
pomila by cryptostartegysma atr barssincev4 strategy−54.6%2586.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 24 msYes 1,000 bars in 38 msNot measured
PineTSNo 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/// © greenmask9//@version=4strategy("Dazzling Bolts", overlay=true)//max_bars_back=3000// 13 SMMAlen = input(10, minval=1, title="SMMA Period")src = input(close, title="Source")smma = 0.0smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len// 55 EMAemalength = input(55, title="EMA Period")ema = ema(close, emalength)// 100 SMAsmalength = input(110, title="SMA Period")sma = sma(close, smalength)emaforce = input(title="Force trend with medium EMA", type=input.bool, defval=true)offsetemavalue = input(defval = 6)bullbounce = smma>ema and ema>sma and low[5]>ema and low[2]<ema and close[1]>ema and (ema[offsetemavalue]>sma or (not emaforce))bearbounce = smma<ema and ema<sma and high[5]<ema and high[2]>ema and close[1]<ema and (ema[offsetemavalue]<sma or (not emaforce))plotshape(bullbounce,  title= "Purple", location=location.belowbar, color=#ff33cc, transp=0, style=shape.triangleup, size=size.tiny, text="Bolts")plotshape(bearbounce,  title= "Purple", location=location.abovebar, color=#ff33cc, transp=0, style=shape.triangledown, size=size.tiny, text="Bolts")ordersize=floor(strategy.initial_capital/close)longs = input(title="Test longs", type=input.bool, defval=true)shorts = input(title="Test shorts", type=input.bool, defval=true)atrlength = input(title="ATR length", defval=12)atrm = input(title="ATR muliplier",type=input.float, defval=2)atr = atr(atrlength)target = close + atr*atrmantitarget = close - (atr*atrm)//limits and stop do not move, no need to count bars from sincebullbuy = bullbounce and longs and strategy.opentrades==0bb = barssince(bullbuy)bearsell = bearbounce and shorts and strategy.opentrades==0bs = barssince(bearsell)if (bullbuy)    strategy.entry("Boltsup", strategy.long, ordersize)    strategy.exit ("Bolts.close", from_entry="Boltsup", limit=target, stop=antitarget)if (crossover(smma, sma))    strategy.close("Boltsup", qty_percent = 100, comment = "Bolts.crossover")if (bearsell)    strategy.entry("Boltsdown", strategy.short, ordersize)    strategy.exit("Bolts.close", from_entry="Boltsdown", limit=antitarget, stop=target)if (crossunder(smma, sma))    strategy.close("Boltsdown", qty_percent = 100, comment = "Bolts.crossover")if (bb<5)    bulltarget = line.new(bar_index[bb], target[bb], bar_index[0], target[bb], color=color.blue, width=2)    bullclose = line.new(bar_index[bb], close[bb], bar_index[0], close[bb], color=color.blue, width=2)    bullstop = line.new(bar_index[bb], antitarget[bb], bar_index[0], antitarget[bb], color=color.blue, width=2)if (bs<5)    bulltarget = line.new(bar_index[bs], antitarget[bs], bar_index[0], antitarget[bs], color=color.purple, width=2)    bullclose = line.new(bar_index[bs], close[bs], bar_index[0], close[bs], color=color.purple, width=2)    bullstop = line.new(bar_index[bs], target[bs], bar_index[0], target[bs], color=color.purple, width=2)