Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Fibonacci candle with Fibonacci ema strategy

A Pine Script v4 strategy built on EMA (volume_avg, 12), Crossover (volume_avg, ema_volume_avg) and Crossunder (volume_avg, ema_volume_avg). It has 2 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 0.1% commission. 5 settings; defaults include Length ema vol 12, K 9 and D 3.

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 Fibonacci candle with Fibonacci ema strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did Fibonacci candle with Fibonacci ema strategy do on BTCUSDT 1D with default settings?
+27.57%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Fibonacci candle with Fibonacci ema strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Fibonacci candle with Fibonacci ema strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Fibonacci candle with Fibonacci ema strategy run in Zeal Terminal?
Yes
It compiles in 18 ms and runs 1,000 bars in 46 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • Crossover
  • Crossunder
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • SMA
  • SMA
  • Winning trade
  • Losing trade
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (5)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,380$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 47) so the engine trades the way the script says.
Net profit
+27.57%
$275.75
Buy and hold
+102.5%
same period
Closed trades
3
1 won · 2 lost
Profitable
33.3%
of closed trades
Profit factor
2.21
gross profit ÷ gross loss
Max drawdown
28.28%
−$282.77

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

    ema(src, 55) ignores the settings line 22

    Line 22 hard-codes 55 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 55)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 1) ignores the settings line 23

    Line 23 hard-codes 1 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 1)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 2) ignores the settings line 24

    Line 24 hard-codes 2 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 2)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 3) ignores the settings line 25

    Line 25 hard-codes 3 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 3)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 5) ignores the settings line 26

    Line 26 hard-codes 5 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 5)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 8) ignores the settings line 27

    Line 27 hard-codes 8 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 8)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 13) ignores the settings line 28

    Line 28 hard-codes 13 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 13)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 21) ignores the settings line 29

    Line 29 hard-codes 21 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 21)ema(src, length_ema_vol)
  • Likely bug

    ema(src, 34) ignores the settings line 30

    Line 30 hard-codes 34 where line 16 uses “Length ema vol”. Changing those settings moves one band but not this one.

    ema(src, 34)ema(src, length_ema_vol)
  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    2 settings have no label

    In the settings dialog length_ema_vol (line 14), stoch_middle (line 42) 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 47, 48. The upgraded version below moves each call inside an if block.

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 ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder, sma → ta.sma, stoch → ta.stoch.
  • 2 strategy calls use the when = argument (line 47, 48). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 16: ema → ta.ema
  • Line 19: crossover → ta.crossover
  • Line 20: crossunder → ta.crossunder
  • Line 22: ema → ta.ema
  • Line 23: ema → ta.ema
11 more edits
  • Line 24: ema → ta.ema
  • Line 25: ema → ta.ema
  • Line 26: ema → ta.ema
  • Line 27: ema → ta.ema
  • Line 28: ema → ta.ema
  • Line 29: ema → ta.ema
  • Line 30: ema → ta.ema
  • Line 38: sma → ta.sma
  • Line 38: stoch → ta.stoch
  • Line 39: sma → ta.sma
  • Line 47: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
⋯// © SoftKill21-//@version=4+//@version=5strategy("Fibonacci candle", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯volume_avg =(volume[0] + volume[1] + volume[2] + volume[3] +volume[5] + volume[8] + volume[13]+ volume[21] + volume[34] + volume[55]) / 10-ema_volume_avg = ema(volume_avg,length_ema_vol)+ema_volume_avg = ta.ema(volume_avg,length_ema_vol)// plot(volume_avg,color=color.white)// plot(ema_volume_avg)-longvol = crossover(volume_avg,ema_volume_avg)+longvol = ta.crossover(volume_avg,ema_volume_avg)-shortvol = crossunder(volume_avg, ema_volume_avg)+shortvol = ta.crossunder(volume_avg, ema_volume_avg)src = avg_close//input(avg_close, title="Source")-out55 = ema(src, 55)+out55 = ta.ema(src, 55)-out1 = ema(src, 1)+out1 = ta.ema(src, 1)-out2 = ema(src, 2)+out2 = ta.ema(src, 2)-out3 = ema(src, 3)+out3 = ta.ema(src, 3)-out5 = ema(src, 5)+out5 = ta.ema(src, 5)-out8 = ema(src, 8)+out8 = ta.ema(src, 8)-out13 = ema(src, 13)+out13 = ta.ema(src, 13)-out21 = ema(src, 21)+out21 = ta.ema(src, 21)-out34 = ema(src, 34)+out34 = ta.ema(src, 34)avg_ema = (out55 + out1 + out2 + out3+ out5 + out8 + out13 + out21 + out34)/9⋯smoothK = input(3, title="Smooth", minval=1)-k = sma(stoch(close, high, low, periodK), smoothK)+k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)-d = sma(k, periodD)+d = ta.sma(k, periodD)avg_stoch = (k+d)/2⋯short = avg_open > avg_close and avg_close < avg_close[1] and avg_low < avg_low[1] and avg_close[1] < avg_close[2] and avg_low[1] < avg_low[2] and shortvol  and avg_stoch<stoch_middle-strategy.entry("long",1,when=long and avg_close > avg_ema)+strategy.entry("long",strategy.long,when=long and avg_close > avg_ema)strategy.close('long',when=short and avg_close < avg_ema)

Clean v5

VerifiedDownload the v5 script

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

  • Line 14: input() → input.int()
  • Line 35: input() → input.int()
  • Line 36: input() → input.int()
  • Line 37: input() → input.int()
  • Line 42: input() → input.int()
  • Line 47: when = long and avg_close > avg_ema → if block
  • Line 48: when = short and avg_close < avg_ema → if block
⋯avg_open = (open[0] + open[1] + open[2] + open[3] +open[5] + open[8] + open[13]+ open[21] + open[34] + open[55]) / 10-length_ema_vol=input(12)+length_ema_vol=input.int(12)volume_avg =(volume[0] + volume[1] + volume[2] + volume[3] +volume[5] + volume[8] + volume[13]+ volume[21] + volume[34] + volume[55]) / 10⋯//stochastic    -periodK = input(9, title="K", minval=1)+periodK = input.int(9, title="K", minval=1)-periodD = input(3, title="D", minval=1)+periodD = input.int(3, title="D", minval=1)-smoothK = input(3, title="Smooth", minval=1)+smoothK = input.int(3, title="Smooth", minval=1)k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)⋯//plot(avg_stoch)-stoch_middle=input(40)+stoch_middle=input.int(40)//plot(50)⋯short = avg_open > avg_close and avg_close < avg_close[1] and avg_low < avg_low[1] and avg_close[1] < avg_close[2] and avg_low[1] < avg_low[2] and shortvol  and avg_stoch<stoch_middle-strategy.entry("long",strategy.long,when=long and avg_close > avg_ema)+if long and avg_close > avg_ema+    strategy.entry("long",strategy.long)-strategy.close('long',when=short and avg_close < avg_ema)+if short and avg_close < avg_ema+    strategy.close('long')

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: 3 before, 5 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.

⋯// © SoftKill21-//@version=5+//@version=6strategy("Fibonacci candle", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯

Settings

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

SettingDefaultType and rangeFeeds
Length ema vol (no label in the script)12intema_volume_avg
K9int · min 1k
D3int · min 1d
Smooth3int · min 1k
Stoch middle (no label in the script)40intlong short

What it calculates

  • EMA (ema, ta.ema in v5)volume_avg, Length ema vol (12)ema_volume_avg · line 16
  • Crossover (crossover, ta.crossover in v5)volume_avg, ema_volume_avglongvol · line 19
  • Crossunder (crossunder, ta.crossunder in v5)volume_avg, ema_volume_avgshortvol · line 20
  • EMA (ema, ta.ema in v5)src, 55out55 · line 22
  • EMA (ema, ta.ema in v5)src, 1out1 · line 23
  • EMA (ema, ta.ema in v5)src, 2out2 · line 24
  • EMA (ema, ta.ema in v5)src, 3out3 · line 25
  • EMA (ema, ta.ema in v5)src, 5out5 · line 26
  • EMA (ema, ta.ema in v5)src, 8out8 · line 27
  • EMA (ema, ta.ema in v5)src, 13out13 · line 28
  • EMA (ema, ta.ema in v5)src, 21out21 · line 29
  • EMA (ema, ta.ema in v5)src, 34out34 · line 30
  • SMA / Stoch (sma, ta.sma in v5)stoch(close, high, low, periodK), Smooth (3)k · line 38
  • SMA (sma, ta.sma in v5)k, D (3)d · line 39

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.

length_ema_volLength ema volsetting · 12lowlowprice datahighhighprice dataclosecloseprice dataperiodKKsetting · 9smoothKSmoothsetting · 3periodDDsetting · 3openopenprice datavolumevolumeprice datastoch_middleStoch middlesetting · 40ema_volume_avgEMA→ ema_volume_avglongvolCrossover→ longvolshortvolCrossunder→ shortvolout55EMA→ out55out1EMA→ out1out2EMA→ out2out3EMA→ out3out5EMA→ out5out8EMA→ out8out13EMA→ out13out21EMA→ out21out34EMA→ out34kSMA / Stoch→ kdSMA→ davg_closeavg_closevalueavg_highavg_highvalueavg_lowavg_lowvalueavg_openavg_openvaluevolume_avgvolume_avgvaluesrcsrcvalueavg_emaavg_emavalueavg_stochavg_stochvaluelonglongconditionshortshortconditionentry:longOpen longstrategy.entryclose:longClose longstrategy.close

Order rules

OrderFires whenBy defaultLine
Open long longlong and avg_close > avg_emaOn47
Close longshort and avg_close < avg_emaOn48

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.

1/1trades 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+27.6%+102.5%333%2.2128.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−11.6%+5.5%714%0.1214.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−4.6%+9.8%333%0.9137.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+28.0%+8.4%333%6.208.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−17.9%+16.7%729%0.7841.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+15.3%+21.5%633%1.9710.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+31.8%+148.3%333%2.5836.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+16.4%+17.1%425%3.289.4%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 market0—$0.00
Sideways market250%$296.25
Falling market10%−$19.23

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

How bad could the drawdown be?

22.0%

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

0%25%
All 3 trades
SideEntryExitBarsP&L
long29 Jul 2024 68,249.908 Sep 2024 54,160.9041−$208.02
long15 Oct 2024 66,084.0030 Aug 2025 108,377.00319$504.27
long14 Apr 2026 74,418.0030 May 2026 73,460.8046−$19.23

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
Fibonacci candle with Fibonacci ema strategy this page—v4 strategy+27.6%328.3%
Stochastic Moving Average by LucasVivienstoch sma emav5 strategy+2.8%74.4%
OTT-Stoch-TP-SL by BigCoinHunterema sma stochv5 strategyNo trades on this market
Webhook Starter Kit [HullBuster] by tradingtudiema stoch smav4 strategydoes not run in Zeal Terminal
MACD Long Strat by TheGrindTodayema smav4 strategy+24.0%7920.1%
Stock trending strategy by exlux99ema smav4 strategy+35.3%2114.7%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 18 msWith a workaround 1,000 bars in 46 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 47) so the engine trades the way the script says.

“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/// © SoftKill21//@version=4strategy("Fibonacci candle", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )//plot of our fibonacci candle// Fibonacci // Fn = Fn-1 + Fn-2// F10 = 55// 0 1 2 3 5 8 13 21 34 55avg_close = (close[0] + close[1] + close[2] + close[3] +close[5] + close[8] + close[13]+ close[21] + close[34] + close[55]) / 10avg_high = (high[0] + high[1] + high[2] + high[3] +high[5] + high[8] + high[13]+ high[21] + high[34] + high[55]) / 10avg_low = (low[0] + low[1] + low[2] + low[3] +low[5] + low[8] + low[13]+ low[21] + low[34] + low[55]) / 10avg_open = (open[0] + open[1] + open[2] + open[3] +open[5] + open[8] + open[13]+ open[21] + open[34] + open[55]) / 10length_ema_vol=input(12)volume_avg =(volume[0] + volume[1] + volume[2] + volume[3] +volume[5] + volume[8] + volume[13]+ volume[21] + volume[34] + volume[55]) / 10ema_volume_avg = ema(volume_avg,length_ema_vol)// plot(volume_avg,color=color.white)// plot(ema_volume_avg)longvol = crossover(volume_avg,ema_volume_avg)shortvol = crossunder(volume_avg, ema_volume_avg)src = avg_close//input(avg_close, title="Source")out55 = ema(src, 55)out1 = ema(src, 1)out2 = ema(src, 2)out3 = ema(src, 3)out5 = ema(src, 5)out8 = ema(src, 8)out13 = ema(src, 13)out21 = ema(src, 21)out34 = ema(src, 34)avg_ema = (out55 + out1 + out2 + out3+ out5 + out8 + out13 + out21 + out34)/9//plot(avg_ema)//plotcandle(avg_open, avg_high, avg_low, avg_close, title='Title', color = avg_open < avg_close ? color.green : color.red, wickcolor=color.white)//stochastic    periodK = input(9, title="K", minval=1)periodD = input(3, title="D", minval=1)smoothK = input(3, title="Smooth", minval=1)k = sma(stoch(close, high, low, periodK), smoothK)d = sma(k, periodD)avg_stoch = (k+d)/2//plot(avg_stoch)stoch_middle=input(40)//plot(50)//long = avg_open < avg_close and avg_close > avg_close[1] and avg_high > avg_high[1] and  avg_close[1] > avg_close[2] and avg_high[1] > avg_high[2] and longvol and avg_stoch>stoch_middleshort = avg_open > avg_close and avg_close < avg_close[1] and avg_low < avg_low[1] and avg_close[1] < avg_close[2] and avg_low[1] < avg_low[2] and shortvol  and avg_stoch<stoch_middlestrategy.entry("long",1,when=long and avg_close > avg_ema)strategy.close('long',when=short and avg_close < avg_ema)