Pine Script v4 · Strategy
Automated - Fibs with Limit only orders
A Pine Script v4 strategy built on Highest (60), DEV (h, 60) and Lowest (60). It has 6 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 Limit only 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 Limit only 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; it opened a long position that was still open on the last bar, so there is no result to report. It closed no trades on the other markets either. A backtest, not investment advice.
- Can Automated - Fibs with Limit only 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 Limit only orders use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Automated - Fibs with Limit only orders run in Zeal Terminal?
- Yes
- It compiles in 40 ms and runs 1,000 bars in 81 ms, in the browser.
BTCUSDT · 1D · default settings
- Entry
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −0.00%
- −$0.02
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- 0.00
- gross profit ÷ gross loss
- Max drawdown
- 0.01%
- −$12.61
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.
-
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, tostring → str.tostring.
v4 → v5
Not verifiedNeither 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
17 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 89: strategy.order(…, 1) → strategy.order(…, strategy.long)
- Line 89: tostring → str.tostring
- Line 91: strategy.order(…, 1) → strategy.order(…, strategy.long)
- Line 91: tostring → str.tostring
- Line 97: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
- Line 97: tostring → str.tostring
- Line 102: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
- Line 102: tostring → str.tostring
- Line 105: strategy.order(…, 1) → strategy.order(…, 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⋯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)) + strategy.order("New", strategy.long, 0.0001, alert_message='New Order|e=binancefuturestestnet s=btcusdt b=long q=0.0011 fp=' + str.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))+ strategy.order("Move", strategy.long, 0.0001, alert_message='Move Order|e=binancefuturestestnet s=btcusdt b=long c=order|e=binancefuturestestnet s=btcusdt b=long q=0.0011 fp=' + str.tostring(entry))if filledorder and size < 1⋯ p = close+close*(tp/100)- strategy.entry("Filled", 1, 1, alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + tostring(p))+ strategy.entry("Filled", strategy.long, 1, alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + str.tostring(p))if filledorder and size >= 1⋯ pause := time + 60000- strategy.entry("Filled", 1, 1, alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + tostring(profit))+ strategy.entry("Filled", strategy.long, 1, alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + str.tostring(profit))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')+ strategy.order("Cancel", strategy.long, 0.0001, alert_message='Cancel Order|e=binancefuturestestnet s=btcusdt b=long c=order')if 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='Profit')+ strategy.entry("Close ALL", strategy.short, 0, alert_message='Profit') count := 0⋯Clean v5
Not verifiedNeither 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Live | false | bool | testPeriod |
| Start Timestamp | 1600976975 | int | testPeriod |
| Start Delay | 60 | int | testPeriod |
| Leverage | 1 | int | tp dca |
| Take Profit % | 1.0 | float | profit p |
| DCA when < % | -1.0 | float | filled |
| Entry Level | 1 | string · 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 Length | 60 | int | h h1 l l1 |
What it calculates
- Highest (
highest,ta.highestin v5)Pivot Length (60)h · line 27 - DEV (
dev,ta.devin v5)h, Pivot Length (60)h1 · line 28 - Lowest (
lowest,ta.lowestin v5)Pivot Length (60)l · line 30 - DEV (
dev,ta.devin v5)l, Pivot Length (60)l1 · line 31 - Lowest / Highest (
lowest,ta.lowestin v5)za · line 36 - Lowest (
lowest,ta.lowestin v5)zb · line 37 - Highest (
highest,ta.highestin v5)zc · line 38 - Crossover (
crossover,ta.crossoverin 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| order New long | neworder and signal | On | 89 |
| order Move long | moveorder | On | 91 |
| Open Filled long | filledorder and size < 1 | On | 97 |
| Open Filled long | filledorder and size >= 1 | On | 102 |
| order Cancel long | cancelorder and not filledorder | On | 105 |
| Open Close ALL short | closeit | On | 110 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −0.0% | +102.5% | 0 | 0% | 0.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −0.0% | +5.5% | 0 | 0% | 0.00 | 12.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.0% | +9.8% | 0 | 0% | 0.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 0 | 0% | 0.00 | 0.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | 0.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 0 | 0% | 0.00 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.0% | +148.3% | 0 | 0% | 0.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 0 | 0% | 0.00 | 0.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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Automated - Fibs with Limit only orders this page | — | v4 strategy | −0.0% | 0 | 0.0% |
| Automated - Fibs with Market orders by CryptoRox | highest dev lowest | v4 strategy | No trades on this market | ||
| Alex Days HiLo Rajib by 14rajib | highest lowest | v4 strategy | No trades on this market | ||
| Donchian Strat EXMO by pskoroplas | highest lowest | v4 strategy | +12.1% | 22 | 68.0% |
| Average Highest High and Lowest Low Swinger Strategy by exlux99 | lowest highest | v4 strategy | +6.4% | 20 | 49.6% |
| Highest High and Lowest Low Channel Strategy by ceyhun | highest lowest | v5 strategy | −3.7% | 26 | 7.9% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 40 ms | With a workaround 1,000 bars in 81 ms | Not measured |
| PineTS | No 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 89, 91, 97, 102, 105, 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(title="Fibs limit only", shorttitle="Strategy", overlay=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("Filled", 1, 1, alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + tostring(p))if filledorder and size >= 1 fill := entry count := count+1 pause := time + 60000 strategy.entry("Filled", 1, 1, alert_message='Long Filled|e=binancefuturestestnet s=btcusdt b=short c=order|delay=1|e=binancefuturestestnet s=btcusdt b=long c=position q=100% ro=1 fp=' + tostring(profit))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='Profit') count := 0 fill := 0.0 last_profit := 0.0 //Plotsbottom = signal ? color.green : filled ? color.red : color.whiteplot(entry, "Entry", bottom)