Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

DELAYED FIBO

A Pine Script v5 strategy built on EMA (close, 14) and SMA (TR, 14). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 1000 in cash and pays 0.075 commission. 20 settings; defaults include From Day 1, From Month 1 and From Year 2020.

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 DELAYED FIBO repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
How did DELAYED FIBO do on BTCUSDT 1D with default settings?
−7.77%
From 26 Jan 2024 to 21 Oct 2026, over 18 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does DELAYED FIBO 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: 18 before, 1 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does DELAYED FIBO use a stop loss?
Yes
strategy.exit sets a stop on line 104.
Does DELAYED FIBO run in Zeal Terminal?
Yes
It compiles in 32 ms and runs 1,000 bars in 89 ms, in the browser.

BTCUSDT · 1D · default settings

  • FIBOTOP4
  • FIBOTOP3
  • FIBOTOP2
  • FIBOTOP1
  • FIBOBOT1
  • FIBOBOT2
  • FIBOBOT3
  • FIBOBOT4
  • 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 (20)
50,00075,000100,000125,000AprJulOct2025AprJulOct2026AprJulOct$922$2,025Equity from $1,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
−7.77%
−$77.65
Buy and hold
+102.5%
same period
Closed trades
18
13 won · 5 lost
Profitable
72.2%
of closed trades
Profit factor
0.64
gross profit ÷ gross loss
Max drawdown
16.32%
−$173.88

One run with the author's default settings, $1,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.

  • 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 102, 103. 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
From Day1int · min 1 · max 31start
From Month1int · min 1 · max 12start
From Year2020intstart
Thru Day1int · min 1 · max 31finish
Thru Month1int · min 1 · max 12finish
Thru Year2112intfinish
long distance level2intlsumV
short distance level1intlsumV ssumV
vrate level0.1floatvt
Fibonacci
EMAperiod14int · min 1 · max 500EMA
ATRperiod14int · min 1 · max 500ATR
Fibonacci Ratio 21.618floatR2
Fibonacci Ratio 32.618floatR3
Fibonacci Ratio 44.236floatR4
Long
FiboLongcross_FIBOBOT2(yellow)string · options ["cross_FIBOBOT1(green)", "cross_FIBOBOT2(yellow)", "cross_FIBOBOT3(blue)", "cross_FIBOBOT4(aqua)", "Disable"]line 72 line 74 line 76 line 79 line 81
Long Code
Long EnterLong Codestringentry AL
Long ExitLong Exit Codestringclose AL exit AL
🐳Long
TakeProfit StopLoss Aktif Ettrueboolline 96
Stop loss1.9float · min 0.1 · step 0.1exit AL
Take profit0.7float · min 0.1 · step 0.1exit AL

What it calculates

  • EMAclose, EMAperiod (14)EMA · line 42
  • SMATR, ATRperiod (14)ATR · line 45

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 dataEMAperiodEMAperiodsetting · 14ATRperiodATRperiodsetting · 14fromYearFrom Yearsetting · 2020fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 1thruYearThru Yearsetting · 2112thruMonthThru Monthsetting · 1thruDayThru Daysetting · 1volumevolumeprice dataldistance_levellong distance levelsetting · 2sdistance_levelshort distance levelsetting · 1vrate_levelvrate levelsetting · 0.1lowlowprice datahighhighprice dataF2Fibonacci Ratio 2setting · 1.618F3Fibonacci Ratio 3setting · 2.618F4Fibonacci Ratio 4setting · 4.236EMAEMA→ EMAATRSMA→ ATRstartstartvaluefinishfinishvaluesumdsumdvaluelsumVlsumVvaluessumVssumVvaluevratevratevaluevtvtvalueTR1TR1valueTRTRvalueR1R1valueR2R2valueR3R3valueR4R4valueFIBOTOP4, FIBOBOT4FIBOTOP4 · FIBOBOT42 valuesFIBOTOP3, FIBOBOT3FIBOTOP3 · FIBOBOT32 valuesFIBOTOP2, FIBOBOT2FIBOTOP2 · FIBOBOT22 valuesFIBOTOP1, FIBOBOT1FIBOTOP1 · FIBOBOT12 valueslongslongsvalue_prefmS_prefmSconditionentry:ALOpen ALstrategy.entryclose:ALClose ALstrategy.closeexit:ALexit ALstrategy.exitplot:61FIBOTOP4plotplot:62FIBOTOP3plotplot:63FIBOTOP2plotplot:64FIBOTOP1plotplot:65FIBOBOT1plotplot:66FIBOBOT2plotplot:67FIBOBOT3plotplot:68FIBOBOT4plot

Order rules

OrderFires whenBy defaultLine
Open AL longlongs and window()On102
Close ALta.cross(vt, FIBOTOP3)On103
Exit AL stop and limitevery barOn104

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.

5/5trades 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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−7.8%+102.5%1872%0.6416.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−1.2%+5.5%2374%0.909.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+16.6%+9.8%2365%1.6213.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−3.0%+8.4%2864%0.8715.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+3.5%+16.7%2365%1.0924.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−2.5%+21.5%2665%0.8613.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−10.1%+148.3%1258%0.5125.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+2.9%+17.1%2277%1.287.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 barsTradesWonP&L
Rising market1100%$10.41
Sideways market967%−$97.68
Falling market875%$9.62

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

How bad could the drawdown be?

17.1%

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

0%20%
All 18 trades
SideEntryExitBarsP&L
long1 May 2024 58,365.003 May 2024 59,060.602$10.41
long24 Jun 2024 60,293.3026 Jun 2024 61,806.002$23.57
long26 Jun 2024 60,865.0028 Jun 2024 61,706.502$12.31
long4 Jul 2024 57,050.006 Jul 2024 57,449.402$5.49
long7 Jul 2024 55,857.809 Jul 2024 56,714.602$13.83
long4 Aug 2024 58,161.006 Aug 2024 54,018.802−$72.67
long6 Sep 2024 53,963.008 Sep 2024 54,340.702$5.49
long24 Feb 2025 91,552.9026 Feb 2025 88,680.402−$32.85
long25 Sep 2025 108,994.0028 Sep 2025 109,757.003$5.49
long4 Nov 2025 101,497.006 Nov 2025 103,885.002$22.01
long14 Nov 2025 94,594.0016 Nov 2025 95,596.202$9.09
long17 Nov 2025 92,215.1019 Nov 2025 92,960.802$6.58
long20 Nov 2025 86,637.2022 Nov 2025 84,991.102−$20.49
long20 Jan 2026 88,427.7022 Jan 2026 89,454.702$10.11
long29 Jan 2026 84,650.2031 Jan 2026 83,041.802−$20.49
long1 Jun 2026 71,408.903 Jun 2026 66,760.802−$66.54
long9 Jun 2026 61,730.0011 Jun 2026 62,162.102$5.49
long25 Jun 2026 59,794.0027 Jun 2026 60,212.602$5.49

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
DELAYED FIBO this page—v5 strategy−7.8%1816.3%
MACD Long Strat by TheGrindTodayema smav4 strategy+24.0%7920.1%
Stock trending strategy by exlux99ema smav4 strategy+35.3%2114.7%
4-Hour Stochastic EMA Trend by slymnturkogluema smav4 strategyNo trades on this market
4X EMA and volume strategy by SoftKill21ema smav4 strategy+1.8%325.8%
Simple Momentum Strategy Based on SMA, EMA and Volume by slip_streamsma emav4 strategy+7.4%1827.4%

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.

  • 2 strategy calls use the when = argument (line 102, 103). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 6 settings use the untyped input() (line 46, 47, 48, 87, 88, 91). 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 18 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 46: input() → input.float()
  • Line 47: input() → input.float()
  • Line 48: input() → input.float()
  • Line 87: input() → input.string()
  • Line 88: input() → input.string()
  • Line 91: input() → input.bool()
  • Line 102: when = longs and window() → if block
  • Line 103: when = ta.cross(vt, FIBOTOP3) → if block
⋯ATR = ta.sma(TR, ATRperiod)-F2 = input(defval=1.618, title='Fibonacci Ratio 2', group="Fibonacci")+F2 = input.float(defval=1.618, title='Fibonacci Ratio 2', group="Fibonacci")-F3 = input(defval=2.618, title='Fibonacci Ratio 3', group="Fibonacci")+F3 = input.float(defval=2.618, title='Fibonacci Ratio 3', group="Fibonacci")-F4 = input(defval=4.236, title='Fibonacci Ratio 4', group="Fibonacci")+F4 = input.float(defval=4.236, title='Fibonacci Ratio 4', group="Fibonacci")R1 = ATR⋯// === Bot Codes === { -enterlong = input("Long Code", title='Long Enter', group="Long Code")+enterlong = input.string("Long Code", title='Long Enter', group="Long Code")-exitlong = input("Long Exit Code", title='Long Exit', group="Long Code")+exitlong = input.string("Long Exit Code", title='Long Exit', group="Long Code")// }// === Extra === {-tpslacL=   input(true, title="TakeProfit StopLoss Aktif Et", group="🐳Long")+tpslacL=   input.bool(true, title="TakeProfit StopLoss Aktif Et", group="🐳Long")// }⋯////////////////////////////////////////////////////////////////////////////////////////////-strategy.entry("AL", strategy.long, when= longs and window(), alert_message=enterlong, comment="Long")+if longs and window()+    strategy.entry("AL", strategy.long, alert_message=enterlong, comment="Long")-strategy.close("AL",  when= ta.cross(vt, FIBOTOP3), alert_message = exitlong, comment="Cross")   +if ta.cross(vt, FIBOTOP3)+    strategy.close("AL", alert_message = exitlong, comment="Cross")   strategy.exit("AL",  profit = per(tpL), loss = per(stoplossL), trail_points=per(tpL+0.1) , trail_offset=trof, alert_message = exitlong, comment="TPorSL")

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: 18 before, 1 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.

⋯// © drhakankilic-//@version=5+//@version=6strategy("FIBONACCI BANDS Long Strategy", shorttitle="FBANDS L Strategy", overlay=true, pyramiding=1, initial_capital = 1000,  default_qty_type = strategy.cash, default_qty_value = 1000, ⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 32 msYes 1,000 bars in 89 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/// © drhakankilic//@version=5strategy("FIBONACCI BANDS Long Strategy", shorttitle="FBANDS L Strategy", overlay=true, pyramiding=1, initial_capital = 1000,  default_qty_type = strategy.cash, default_qty_value = 1000,  process_orders_on_close=true, commission_value=0.075, max_bars_back=500, max_lines_count=500, currency = 'USD')// === Date === { //Backtest datesfromDay = input.int(defval=1, title='From Day',minval=1,maxval=31)fromMonth = input.int(defval=1, title='From Month',minval=1,maxval=12)fromYear = input.int(defval=2020, title='From Year')thruDay = input.int(defval=1, title='Thru Day',minval=1,maxval=31)thruMonth = input.int(defval=1, title='Thru Month',minval=1,maxval=12)thruYear = input.int(defval=2112, title='Thru Year')showDate = true  // input(defval=true, title="Show Date Range")start = timestamp(fromYear, fromMonth, fromDay, 00, 00)  // backtest start windowfinish = timestamp(thruYear, thruMonth, thruDay, 23, 59)  // backtest finish windowwindow() =>  // create function "within window of time"    time >= start and time <= finish ? true : false// }// === Line === { sumd(series, distance) =>    sumd = 0.0    for i = 0 to distance        sumd := sumd + series[i]    sumdldistance_level = input.int(title="long distance level",  defval=2)sdistance_level = input.int(title="short distance level", defval=1)    lsumV = sumd(volume,ldistance_level+sdistance_level)ssumV = sumd(volume,sdistance_level) lsumV:=lsumV-ssumVvrate = ssumV/lsumVvrate_level = input.float(title="vrate level", defval=0.1)vt = close*(vrate>vrate_level?1:0)if(vt==0)     vt:=vt[1]// plot(vt, color=color.blue, title="MPT")// plot(close, color=color.red,title="PRICE")// }// === FIBONACCI BANDS === {EMAperiod = input.int(14, title='EMAperiod', minval=1, maxval=500, group="Fibonacci")ATRperiod = input.int(14, title='ATRperiod', minval=1, maxval=500, group="Fibonacci")EMA = ta.ema(close, EMAperiod)TR1 = math.max(high - low, math.abs(high - close[1]))TR = math.max(TR1, math.abs(low - close[1]))ATR = ta.sma(TR, ATRperiod)F2 = input(defval=1.618, title='Fibonacci Ratio 2', group="Fibonacci")F3 = input(defval=2.618, title='Fibonacci Ratio 3', group="Fibonacci")F4 = input(defval=4.236, title='Fibonacci Ratio 4', group="Fibonacci")R1 = ATRR2 = ATR * F2R3 = ATR * F3R4 = ATR * F4FIBOTOP4 = EMA + R4FIBOTOP3 = EMA + R3FIBOTOP2 = EMA + R2FIBOTOP1 = EMA + R1FIBOBOT1 = EMA - R1FIBOBOT2 = EMA - R2FIBOBOT3 = EMA - R3FIBOBOT4 = EMA - R4plot(FIBOTOP4, title='FIBOTOP4', linewidth=1, color=color.new(color.orange, 0))plot(FIBOTOP3, title='FIBOTOP3', linewidth=1, color=color.new(color.aqua, 20))plot(FIBOTOP2, title='FIBOTOP2', linewidth=1, color=color.new(color.gray, 40))plot(FIBOTOP1, title='FIBOTOP1', linewidth=1, color=color.new(color.purple, 40))plot(FIBOBOT1, title='FIBOBOT1', linewidth=1, color=color.new(color.green, 40))plot(FIBOBOT2, title='FIBOBOT2', linewidth=1, color=color.new(color.yellow, 40))plot(FIBOBOT3, title='FIBOBOT3', linewidth=1, color=color.new(color.blue, 20))plot(FIBOBOT4, title='FIBOBOT4', linewidth=1, color=color.new(color.aqua, 0))// plot(EMA[1], style=plot.style_cross, title='EMA', color=color.new(color.red, 0))prefmS = input.string(title="FiboLong", options=["cross_FIBOBOT1(green)", "cross_FIBOBOT2(yellow)", "cross_FIBOBOT3(blue)", "cross_FIBOBOT4(aqua)", "Disable"] , defval="cross_FIBOBOT2(yellow)", group="Long")_prefmS = false if (prefmS == "cross_FIBOBOT1(green)" )    _prefmS := ta.crossunder(vt, FIBOBOT1)if (prefmS == "cross_FIBOBOT2(yellow)" )    _prefmS := ta.crossunder(vt, FIBOBOT2)if (prefmS == "cross_FIBOBOT3(blue)" )    _prefmS := ta.crossunder(vt, FIBOBOT3)  if (prefmS == "cross_FIBOBOT4(aqua)" )    _prefmS := ta.crossunder(vt, FIBOBOT4)if (prefmS == "Disable" )    _prefmS := low<low[1] or low>low[1]  // }longs= _prefmS//// === Bot Codes === { enterlong = input("Long Code", title='Long Enter', group="Long Code")exitlong = input("Long Exit Code", title='Long Exit', group="Long Code")// }// === Extra === {tpslacL=   input(true, title="TakeProfit StopLoss Aktif Et", group="🐳Long")// }////////////////////////////////////////////////////////////////////////////////////////////TPSL// === TP SL === {per(pcnt) =>       strategy.position_size > 0 and tpslacL  ? math.round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)trof      = 0stoplossL  = input.float(title=" Stop loss", defval= 1.9, minval=0.1, step=0.1, group="🐳Long")tpL        = input.float(title=" Take profit", defval= 0.7, minval=0.1, step=0.1, group="🐳Long")// }////////////////////////////////////////////////////////////////////////////////////////////strategy.entry("AL", strategy.long, when= longs and window(), alert_message=enterlong, comment="Long")strategy.close("AL",  when= ta.cross(vt, FIBOTOP3), alert_message = exitlong, comment="Cross")   strategy.exit("AL",  profit = per(tpL), loss = per(stoplossL), trail_points=per(tpL+0.1) , trail_offset=trof, alert_message = exitlong, comment="TPorSL")