Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Automated - Fibs with Market orders

A Pine Script v4 strategy built on Highest (60), DEV (h, 60) and Lowest (60). It has 3 order rules, 3 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays 0.04% commission. 8 settings; defaults include Start Timestamp 1600976975, Start Delay 60 and Leverage 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 Automated - Fibs with Market orders repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Automated - Fibs with Market orders 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 entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
Can Automated - Fibs with Market orders be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does Automated - Fibs with Market orders use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Automated - Fibs with Market orders run in Zeal Terminal?
Yes
It compiles in 33 ms and runs 1,000 bars in 44 ms, in the browser.

BTCUSDT · 1D · default settings

  • Highest
  • DEV
  • Lowest
  • DEV
  • Lowest
  • Lowest
  • Highest
  • Crossover
  • 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)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$100,000$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. 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, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 97, 102, 110) so the engine trades the way the script says.
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, $100,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 stop loss

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

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

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 highest → ta.highest, dev → ta.dev, lowest → ta.lowest, crossover → ta.crossover, crossunder → ta.crossunder.

v4 → v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 3: //@version=4 → //@version=5
  • Line 27: highest → ta.highest
  • Line 28: dev → ta.dev
  • Line 30: lowest → ta.lowest
  • Line 31: dev → ta.dev
  • Line 36: lowest → ta.lowest
10 more edits
  • Line 36: highest → ta.highest
  • Line 37: lowest → ta.lowest
  • Line 38: highest → ta.highest
  • Line 82: crossover → ta.crossover
  • Line 84: crossunder → ta.crossunder
  • Line 85: crossunder → ta.crossunder
  • Line 97: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
  • Line 102: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
  • Line 108: crossover → ta.crossover
  • Line 110: strategy.entry(…, 0) → strategy.entry(…, strategy.short)
⋯// © CryptoRox-//@version=4+//@version=5//Paste the line below in your alerts to run the built-in commands.⋯lentt = input(60, "Pivot Length")-h = highest(lentt)+h = ta.highest(lentt)-h1 = dev(h, lentt) ? na : h+h1 = ta.dev(h, lentt) ? na : hhpivot = fixnan(h1)-l = lowest(lentt)+l = ta.lowest(lentt)-l1 = dev(l, lentt) ? na : l+l1 = ta.dev(l, lentt) ? na : llpivot = fixnan(l1)⋯transp = 60-a=(lowest(z)+highest(z))/2+a=(ta.lowest(z)+ta.highest(z))/2-b=lowest(z)+b=ta.lowest(z)-c=highest(z)+c=ta.highest(z)fib0 = (((hpivot - lpivot)) + lpivot)⋯signal = testPeriod and notna and not paused and not filled ? 1 : 0-neworder = crossover(signal, signal[1])+neworder = ta.crossover(signal, signal[1])moveorder = entry != entry[1] and signal and not neworder ? true : false-cancelorder = crossunder(signal, signal[1]) and not paused+cancelorder = ta.crossunder(signal, signal[1]) and not paused-filledorder = crossunder(low[1], entry[1]) and signal[1]+filledorder = ta.crossunder(low[1], entry[1]) and signal[1]last_profit = 0.0⋯    p = close+close*(tp/100)-    strategy.entry("Buy", 1, 1,  alert_message='Long|e=binancefuturestestnet s=btcusdt b=long q=0.0011 t=market')+    strategy.entry("Buy", strategy.long, 1,  alert_message='Long|e=binancefuturestestnet s=btcusdt b=long q=0.0011 t=market')if filledorder and size >= 1⋯    pause := time + 60000-    strategy.entry("Buy", 1, 1,  alert_message='Long|e=binancefuturestestnet s=btcusdt b=long q=0.0011 t=market')+    strategy.entry("Buy", strategy.long, 1,  alert_message='Long|e=binancefuturestestnet s=btcusdt b=long q=0.0011 t=market')// if cancelorder and not filledorder⋯    last_profit := profit-closeit = crossover(high, profit) and size >= 1+closeit = ta.crossover(high, profit) and size >= 1if closeit-    strategy.entry("Close ALL", 0, 0, alert_message='Close Long|e=binancefuturestestnet s=btcusdt b=long c=position t=market')+    strategy.entry("Close ALL", strategy.short, 0, alert_message='Close Long|e=binancefuturestestnet s=btcusdt b=long c=position t=market')    count := 0⋯

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 8: input() → input.bool()
  • Line 10: input() → input.int()
  • Line 12: input() → input.int()
  • Line 14: input() → input.int()
  • Line 15: input() → input.float()
  • Line 16: input() → input.float()
  • Line 17: input() → input.string()
  • Line 26: input() → input.int()
⋯//Settings -testing = input(false, "Live")+testing = input.bool(false, "Live")//Use epochconverter or something similar to get the current timestamp.-starttime = input(1600976975, "Start Timestamp") * 1000+starttime = input.int(1600976975, "Start Timestamp") * 1000//Wait XX seconds from that timestamp before the strategy starts looking for an entry.-seconds = input(60, "Start Delay") * 1000+seconds = input.int(60, "Start Delay") * 1000testPeriod = testing ? time > starttime + seconds : 1-leverage = input(1, "Leverage")+leverage = input.int(1, "Leverage")-tp = input(1.0, "Take Profit %") / leverage+tp = input.float(1.0, "Take Profit %") / leverage-dca = input(-1.0, "DCA when < %") / leverage *-1+dca = input.float(-1.0, "DCA when < %") / leverage *-1-fibEntry = input("1", "Entry Level", options=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"])+fibEntry = input.string("1", "Entry Level", options=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"])//Strategy Calls⋯//Fibs-lentt = input(60, "Pivot Length")+lentt = input.int(60, "Pivot Length")h = ta.highest(lentt)⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © CryptoRox-//@version=5+//@version=6//Paste the line below in your alerts to run the built-in commands.⋯

Settings

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

SettingDefaultType and rangeFeeds
LivefalsebooltestPeriod
Start Timestamp1600976975inttestPeriod
Start Delay60inttestPeriod
Leverage1inttp dca
Take Profit %1.0floatprofit p
DCA when < %-1.0floatfilled
Entry Level1string · options ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]line 52 line 54 line 56 line 58 line 60 line 62 line 64 line 66 line 68 line 70
Pivot Length60inth h1 l l1

What it calculates

  • Highest (highest, ta.highest in v5)Pivot Length (60)h · line 27
  • DEV (dev, ta.dev in v5)h, Pivot Length (60)h1 · line 28
  • Lowest (lowest, ta.lowest in v5)Pivot Length (60)l · line 30
  • DEV (dev, ta.dev in v5)l, Pivot Length (60)l1 · line 31
  • Lowest / Highest (lowest, ta.lowest in v5)za · line 36
  • Lowest (lowest, ta.lowest in v5)zb · line 37
  • Highest (highest, ta.highest in v5)zc · line 38
  • Crossover (crossover, ta.crossover in v5)signal, signal[1]neworder · line 82

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.

lenttPivot Lengthsetting · 60timetimeprice datastarttimeStart Timestampsetting · 1600976975secondsStart Delaysetting · 60tpTake Profit %setting · 1.0dcaDCA when < %setting · -1.0closecloseprice datalowlowprice datahighhighprice datahHighest→ hh1DEV→ h1lLowest→ ll1DEV→ l1aLowest / Highest→ abLowest→ bcHighest→ cneworderCrossover→ newordertestPeriodtestPeriodvalueequity, avg, symbol, openTrades, closedTrades, sizeequity · avg +46 valueshpivothpivotvaluelpivotlpivotvaluefib0, fib1, fib2, fib3, fib4, fib5, fib6, fib7, fib8, fib9, fib10fib0 · fib1 +911 valuesnotnanotnavalueentryentryvalueprofitprofitvaluepausepausevaluefillfillvaluecountcountvaluefilledfilledvaluesignalsignalvaluemoveordermoveordervaluelast_profitlast_profitvalueppvaluefilledorderfilledorderconditioncloseitcloseitconditionpausedpausedconditioncancelordercancelorderconditionentry:BuyOpen Buystrategy.entryentry:Close ALLOpen Close ALLstrategy.entry

Order rules

OrderFires whenBy defaultLine
Open Buy longfilledorder and size < 1On97
Open Buy longfilledorder and size >= 1On102
Open Close ALL shortcloseitOn110

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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.0%+5.5%00%0.0012.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.0%+8.4%00%0.000.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%00%0.000.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%00%0.000.2%8 May 2026 – 21 Oct 2026

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
Automated - Fibs with Market orders this page—v4 strategy0.0%00.0%
Automated - Fibs with Limit only orders by CryptoRoxhighest dev lowestv4 strategyNo trades on this market
Alex Days HiLo Rajib by 14rajibhighest lowestv4 strategyNo trades on this market
Donchian Strat EXMO by pskoroplashighest lowestv4 strategy+12.1%2268.0%
Average Highest High and Lowest Low Swinger Strategy by exlux99lowest highestv4 strategy+6.4%2049.6%
Highest High and Lowest Low Channel Strategy by ceyhunhighest lowestv5 strategy−3.7%267.9%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 97, 102, 110) 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/// © CryptoRox//@version=4//Paste the line below in your alerts to run the built-in commands.//{{strategy.order.alert_message}}strategy("Automated - Fibs with Market orders", "Strategy", true, precision=8, pyramiding=1000, commission_type=strategy.commission.percent, commission_value=0.04)//Settings testing = input(false, "Live")//Use epochconverter or something similar to get the current timestamp.starttime = input(1600976975, "Start Timestamp") * 1000//Wait XX seconds from that timestamp before the strategy starts looking for an entry.seconds = input(60, "Start Delay") * 1000testPeriod = testing ? time > starttime + seconds : 1leverage = input(1, "Leverage")tp = input(1.0, "Take Profit %") / leveragedca = input(-1.0, "DCA when < %") / leverage *-1fibEntry = input("1", "Entry Level", options=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"])//Strategy Callsequity = strategy.equityavg = strategy.position_avg_pricesymbol = syminfo.tickeridopenTrades = strategy.opentradesclosedTrades = strategy.closedtradessize = strategy.position_size//Fibslentt = input(60, "Pivot Length")h = highest(lentt)h1 = dev(h, lentt) ? na : hhpivot = fixnan(h1)l = lowest(lentt)l1 = dev(l, lentt) ? na : llpivot = fixnan(l1)z = 400p_offset= 2transp = 60a=(lowest(z)+highest(z))/2b=lowest(z)c=highest(z)fib0 = (((hpivot - lpivot)) + lpivot)fib1 = (((hpivot - lpivot)*.21) + lpivot)fib2 = (((hpivot - lpivot)*.3) + lpivot)fib3 = (((hpivot - lpivot)*.5) + lpivot)fib4 = (((hpivot - lpivot)*.62) + lpivot)fib5 = (((hpivot - lpivot)*.7) + lpivot)fib6 = (((hpivot - lpivot)* 1.00) + lpivot)fib7 = (((hpivot - lpivot)* 1.27) + lpivot)fib8 = (((hpivot - lpivot)* 2) + lpivot)fib9 = (((hpivot - lpivot)* -.27) + lpivot)fib10 = (((hpivot - lpivot)* -1) + lpivot)notna = nz(fib10[60])entry = 0.0if fibEntry == "1"    entry := fib10if fibEntry == "2"    entry := fib9if fibEntry == "3"    entry := fib0if fibEntry == "4"    entry := fib1if fibEntry == "5"    entry := fib2if fibEntry == "6"    entry := fib3if fibEntry == "7"    entry := fib4if fibEntry == "8"    entry := fib5if fibEntry == "9"    entry := fib6if fibEntry == "10"    entry := fib7profit = avg+avg*(tp/100)pause = 0pause := nz(pause[1])paused = time < pausefill = 0.0fill := nz(fill[1])count = 0.0count := nz(fill[1])filled = count > 0 ? entry > fill-fill/100*dca : 0signal = testPeriod and notna and not paused and not filled ? 1 : 0neworder = crossover(signal, signal[1])moveorder = entry != entry[1] and signal and not neworder ? true : falsecancelorder = crossunder(signal, signal[1]) and not pausedfilledorder = crossunder(low[1], entry[1]) and signal[1]last_profit = 0.0last_profit := nz(last_profit[1])// if neworder and signal//     strategy.order("New", 1, 0.0001, alert_message='New Order|e=binancefuturestestnet s=btcusdt b=long q=0.0011 fp=' + tostring(entry)) // if moveorder//     strategy.order("Move", 1, 0.0001, alert_message='Move Order|e=binancefuturestestnet s=btcusdt b=long c=order|e=binancefuturestestnet s=btcusdt b=long q=0.0011 fp=' + tostring(entry))if filledorder and size < 1    fill := entry    count := count+1     pause := time + 60000    p = close+close*(tp/100)    strategy.entry("Buy", 1, 1,  alert_message='Long|e=binancefuturestestnet s=btcusdt b=long q=0.0011 t=market')if filledorder and size >= 1    fill := entry    count := count+1     pause := time + 60000    strategy.entry("Buy", 1, 1,  alert_message='Long|e=binancefuturestestnet s=btcusdt b=long q=0.0011 t=market')// if cancelorder and not filledorder//     pause := time + 60000//     strategy.order("Cancel", 1, 0.0001,  alert_message='Cancel Order|e=binancefuturestestnet s=btcusdt b=long c=order')if filledorder    last_profit := profitcloseit = crossover(high, profit) and size >= 1if closeit    strategy.entry("Close ALL", 0, 0, alert_message='Close Long|e=binancefuturestestnet s=btcusdt b=long c=position t=market')    count := 0    fill := 0.0    last_profit := 0.0    //Plots// bottom = signal ? color.green : filled ? color.red : color.white// plot(entry, "Entry", bottom)