Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Fibonacci + RSI - Strategy

A Pine Script v4 strategy built on VWMA (hlc3, 200), Stdev (hlc3, 200) and RSI (close, 14). It has 4 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 commits 100% of equity and pays no commission. 8 settings; defaults include Stop Loss (%) 2, [RSI] Length 14 and [RSI] Over Sold % 30.

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 + RSI - 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 Fibonacci + RSI - Strategy do on BTCUSDT 1D with default settings?
+3.36%
From 26 Jan 2024 to 21 Oct 2026, over 2 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Fibonacci + RSI - 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 + RSI - Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 59, 60.
Does Fibonacci + RSI - Strategy run in Zeal Terminal?
Yes
It compiles in 15 ms and runs 1,000 bars in 43 ms, in the browser.

BTCUSDT · 1D · default settings

  • [Fibonacci Level] Basis
  • [Fibonacci Level] Short Target
  • [Fibonacci Level] Top
  • [Fibonacci Level] Long Target
  • [Fibonacci Level] Bottom
  • 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 (8)
50,000100,000AprJulOct2025AprJulOct2026AprJulOct$10,336$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. Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 56, 57) so the engine trades the way the script says.
Net profit
+3.36%
$336.46
Buy and hold
+102.5%
same period
Closed trades
2
1 won · 1 lost
Profitable
50.0%
of closed trades
Profit factor
17.24
gross profit ÷ gross loss
Max drawdown
19.16%
−$1,916.25

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 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

    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 56, 57, 59, 60. The upgraded version below moves each call inside an if block.

  • Note

    Uses long =, which v5 renamed line 56

    long = on line 56, 57. v5 writes it as direction = strategy.long or strategy.short.

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 vwma → ta.vwma, stdev → ta.stdev, rsi → ta.rsi, valuewhen → ta.valuewhen, crossover → ta.crossover, crossunder → ta.crossunder.
  • 4 strategy calls use the when = argument (line 56, 57, 59, 60). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 6: //@version=4 → //@version=5
  • Line 22: vwma → ta.vwma
  • Line 23: stdev → ta.stdev
  • Line 29: rsi → ta.rsi
  • Line 35: valuewhen → ta.valuewhen
  • Line 37: valuewhen → ta.valuewhen
4 more edits
  • Line 42: crossover → ta.crossover
  • Line 43: crossunder → ta.crossunder
  • Line 56: long = true → direction = strategy.long
  • Line 57: long = false → direction = strategy.short
⋯// If you have any modifications please tell me to update it-//@version=4+//@version=5strategy(title="Fibonacci + RSI - Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, currency=currency.USD)⋯// Calculate Fibonacci-basis = vwma(src, length)+basis = ta.vwma(src, length)-dev = mult * stdev(src, length)+dev = mult * ta.stdev(src, length)fu764= basis + (0.001*level*dev)⋯// Calculate RSI-vrsi = rsi(close, len)+vrsi = ta.rsi(close, len)// Calculate the Targets⋯bought = strategy.position_size[0] > strategy.position_size[1]-exit_long = valuewhen(bought, targetUp, 0)+exit_long = ta.valuewhen(bought, targetUp, 0)sold = strategy.position_size[0] < strategy.position_size[1]-exit_short = valuewhen(sold, targetDown, 0)+exit_short = ta.valuewhen(sold, targetDown, 0)// Calculate Stop Losses⋯// Conditions to Open Trades-openLong = low < fd1 and crossover(vrsi[1], overSold)+openLong = low < fd1 and ta.crossover(vrsi[1], overSold)-openShort = high > fu1 and crossunder(vrsi[1], overBought)+openShort = high > fu1 and ta.crossunder(vrsi[1], overBought)// Conditions to Close Trades⋯    // Entry Orders-    strategy.entry(id="Long", long=true, when=openLong and high < targetUp, limit=close)+    strategy.entry(id="Long", direction = strategy.long, when=openLong and high < targetUp, limit=close)-    strategy.entry(id="Short", long=false, when=openShort and low > targetDown, limit=close)+    strategy.entry(id="Short", direction = strategy.short, when=openShort and low > targetDown, limit=close)    // Exit Orders⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 11: input() → input.int()
  • Line 13: input() → input.int()
  • Line 14: input() → input.int()
  • Line 15: input() → input.int()
  • Line 17: input() → input.int()
  • Line 18: input() → input.source()
6 more edits
  • Line 19: input() → input.float()
  • Line 20: input() → input.int()
  • Line 56: when = openLong and high < targetUp → if block
  • Line 57: when = openShort and low > targetDown → if block
  • Line 59: when = closeLong and strategy.position_size > 0 → if block
  • Line 60: when = closeShort and strategy.position_size < 0 → if block
⋯    // Stop Loss %-loss_percent = input(title="Stop Loss (%)", minval=0.0, step=0.1, defval=2) * 0.001+loss_percent = input.int(title="Stop Loss (%)", minval=0.0, step=0.1, defval=2) * 0.001    // RSI Inputs-len = input(title="[RSI] Length", minval=0, step=1, defval=14)+len = input.int(title="[RSI] Length", minval=0, step=1, defval=14)-overSold = input(title="[RSI] Over Sold %", defval=30)+overSold = input.int(title="[RSI] Over Sold %", defval=30)-overBought = input(title="[RSI] Over Bought %", defval=70)+overBought = input.int(title="[RSI] Over Bought %", defval=70)    // Fibonacci Levels-length = input(title="[Fibonacci] Length", defval=200, minval=1)+length = input.int(title="[Fibonacci] Length", defval=200, minval=1)-src = input(hlc3, title="[Fibonacci] Source")+src = input.source(hlc3, title="[Fibonacci] Source")-mult = input(title="[Fibonacci] Multiplier", defval=3.0, minval=0.001, maxval=50)+mult = input.float(title="[Fibonacci] Multiplier", defval=3.0, minval=0.001, maxval=50)-level = input(title="[Fibonacci] Level", defval=764)+level = input.int(title="[Fibonacci] Level", defval=764)// Calculate Fibonacci⋯    // Entry Orders-    strategy.entry(id="Long", direction = strategy.long, when=openLong and high < targetUp, limit=close)+    if openLong and high < targetUp+        strategy.entry(id="Long", direction = strategy.long, limit=close)-    strategy.entry(id="Short", direction = strategy.short, when=openShort and low > targetDown, limit=close)+    if openShort and low > targetDown+        strategy.entry(id="Short", direction = strategy.short, limit=close)    // Exit Orders-    strategy.exit(id="Long", when=closeLong and strategy.position_size > 0, limit=exit_long, stop=stop_long)+    if closeLong and strategy.position_size > 0+        strategy.exit(id="Long", limit=exit_long, stop=stop_long)-    strategy.exit(id="Short", when=closeShort and strategy.position_size < 0, limit=exit_short, stop=stop_short)+    if closeShort and strategy.position_size < 0+        strategy.exit(id="Short", limit=exit_short, stop=stop_short)

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L50:C51: the argument 'title' is specified more than once. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// If you have any modifications please tell me to update it-//@version=5+//@version=6strategy(title="Fibonacci + RSI - Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, currency=currency.USD)⋯

Settings

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

SettingDefaultType and rangeFeeds
Stop Loss (%)2int · min 0.0 · step 0.1stop_long stop_short
[RSI] Length14int · min 0 · step 1vrsi
[RSI] Over Sold %30intopenLong
[RSI] Over Bought %70intopenShort
[Fibonacci] Length200int · min 1basis dev
[Fibonacci] Sourcehlc3sourcebasis dev
[Fibonacci] Multiplier3.0float · min 0.001 · max 50dev
[Fibonacci] Level764intfu764 fd764

What it calculates

  • VWMA (vwma, ta.vwma in v5)[Fibonacci] Source (hlc3), [Fibonacci] Length (200)basis · line 22
  • Stdev (stdev, ta.stdev in v5)[Fibonacci] Source (hlc3), [Fibonacci] Length (200)dev · line 23
  • RSI (rsi, ta.rsi in v5)close, [RSI] Length (14)vrsi · line 29
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, targetUp, 0exit_long · line 35
  • Valuewhen (valuewhen, ta.valuewhen in v5)sold, targetDown, 0exit_short · line 37

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.

hlc3hlc3price datalength[Fibonacci] Lengthsetting · 200mult[Fibonacci] Multipliersetting · 3.0closecloseprice datalen[RSI] Lengthsetting · 14level[Fibonacci] Levelsetting · 764loss_percentStop Loss (%)setting · 2lowlowprice dataoverSold[RSI] Over Sold %setting · 30highhighprice dataoverBought[RSI] Over Bought %setting · 70basisVWMA→ basisdevStdev→ devvrsiRSI→ vrsiexit_longValuewhen→ exit_longexit_shortValuewhen→ exit_shortfu764, fd764fu764 · fd7642 valuesfu1, fd1fu1 · fd12 valuestargetUptargetUpvaluetargetDowntargetDownvaluestop_long, stop_shortstop_long · stop_short2 valuestimeFiltertimeFilterconditionbought, soldbought · sold2 conditionsopenLongopenLongconditionopenShortopenShortconditioncloseLongcloseLongconditioncloseShortcloseShortconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryexit:Longexit Longstrategy.exitexit:Shortexit Shortstrategy.exitplot:48[Fibonacci Level] Basisplotplot:49[Fibonacci Level] Short…plotplot:50[Fibonacci Level] Topplotplot:51[Fibonacci Level] Long …plotplot:52[Fibonacci Level] Bottomplot

Order rules

OrderFires whenBy defaultLine
Open Long longopenLong and high < targetUpOn56
Open Short shortopenShort and low > targetDownOn57
Exit Long stop and limitcloseLong and strategy.position_size > 0On59
Exit Short stop and limitcloseShort and strategy.position_size < 0On60

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 1D+3.4%+102.5%250%17.2419.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.9%+5.5%1100%—0.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.6%+8.4%1100%—2.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+9.9%+16.7%1100%—22.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+8.3%+148.3%367%25.7866.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.2%+17.1%10%0.000.5%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%$357.18
Sideways market0—$0.00
Falling market10%−$20.71

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

How bad could the drawdown be?

0.2%

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

0%1%
All 2 trades
SideEntryExitBarsP&L
short27 Nov 2024 91,965.2026 Feb 2025 88,680.4091$357.18
long20 Nov 2025 91,555.004 Dec 2025 91,371.9014−$20.71

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 + RSI - Strategy this page—v4 strategy+3.4%219.2%
Reinforced RSI - The Quant Science by thequantsciencersi valuewhenv5 strategy−3.9%73.9%
Volume and Moving average,will this model working in real-trade- by Ayden_Crsi stdev valuewhenv4 strategy−157,995.0%104,752.1%
RSI+PA+DCA Strategy by A3Shrsi valuewhenv4 strategy+22.3%465.1%
Bollinger band & Volume based strategy V2 by Ayden_Crsi stdev valuewhenv4 strategy−0.1%50.2%
Bottom catch strategy by footlzstdev rsiv4 strategy+3.9%37.1%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 56, 57) 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/// © MohamedYAbdelaziz// Intraday Trading// Best used for Short Timeframes [1-30 Minutes]// If you have any modifications please tell me to update it//@version=4strategy(title="Fibonacci + RSI - Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, currency=currency.USD)// InputstimeFilter = year >= 2000    // Stop Loss %loss_percent = input(title="Stop Loss (%)", minval=0.0, step=0.1, defval=2) * 0.001    // RSI Inputslen = input(title="[RSI] Length", minval=0, step=1, defval=14)overSold = input(title="[RSI] Over Sold %", defval=30)overBought = input(title="[RSI] Over Bought %", defval=70)    // Fibonacci Levelslength = input(title="[Fibonacci] Length", defval=200, minval=1)src = input(hlc3, title="[Fibonacci] Source")mult = input(title="[Fibonacci] Multiplier", defval=3.0, minval=0.001, maxval=50)level = input(title="[Fibonacci] Level", defval=764)// Calculate Fibonaccibasis = vwma(src, length)dev = mult * stdev(src, length)fu764= basis + (0.001*level*dev)fu1= basis + (1*dev)fd764= basis - (0.001*level*dev)fd1= basis - (1*dev)// Calculate RSIvrsi = rsi(close, len)// Calculate the TargetstargetUp = fd764targetDown = fu764    // Actual Targetsbought = strategy.position_size[0] > strategy.position_size[1]exit_long = valuewhen(bought, targetUp, 0)sold = strategy.position_size[0] < strategy.position_size[1]exit_short = valuewhen(sold, targetDown, 0)// Calculate Stop Lossesstop_long = strategy.position_avg_price * (1 - loss_percent)stop_short = strategy.position_avg_price * (1 + loss_percent)// Conditions to Open TradesopenLong = low < fd1 and crossover(vrsi[1], overSold)openShort = high > fu1 and crossunder(vrsi[1], overBought)// Conditions to Close TradescloseLong = high > exit_longcloseShort = low < exit_short // Plotsplot(basis, color=color.blue, linewidth=2, title="[Fibonacci Level] Basis")plot(fu764, color=color.white, linewidth=1, title="[Fibonacci Level] Short Target")plot(fu1, color=color.red, linewidth=2, title="1", title="[Fibonacci Level] Top")plot(fd764, color=color.white, linewidth=1, title="[Fibonacci Level] Long Target")plot(fd1, color=color.green, linewidth=2, title="1", title="[Fibonacci Level] Bottom")// Strategy Ordersif timeFilter    // Entry Orders    strategy.entry(id="Long", long=true, when=openLong and high < targetUp, limit=close)    strategy.entry(id="Short", long=false, when=openShort and low > targetDown, limit=close)    // Exit Orders    strategy.exit(id="Long", when=closeLong and strategy.position_size > 0, limit=exit_long, stop=stop_long)    strategy.exit(id="Short", when=closeShort and strategy.position_size < 0, limit=exit_short, stop=stop_short)