Pine Script v4 · Strategy
A Strategy for Leledec
A Pine Script v4 strategy with no technical-analysis calculation. It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10% of equity and pays 0.075 commission. 16 settings; defaults include Major Leledec Exhausion Bar :: Source close, Major Leledec Exhausion Bar :: Bar count no 6 and Major Leledec Exhausion Bar :: Highest / Lowest 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 A Strategy for Leledec 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 A Strategy for Leledec do on BTCUSDT 1D with default settings?
- −6.42%
- From 26 Jan 2024 to 21 Oct 2026, over 16 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can A Strategy for Leledec 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 A Strategy for Leledec use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does A Strategy for Leledec run in Zeal Terminal?
- Yes
- It compiles in 18 ms and runs 1,000 bars in 64 ms, in the browser.
BTCUSDT · 1D · default settings
- Char
- Char
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −6.42%
- −$642.19
- Buy and hold
- +102.5%
- same period
- Closed trades
- 16
- 7 won · 9 lost
- Profitable
- 43.8%
- of closed trades
- Profit factor
- 0.50
- gross profit ÷ gross loss
- Max drawdown
- 10.37%
- −$1,037.43
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A short 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
2 settings do nothing
“Major Leledec Exhausion Bar :: Source”, “Show Date Range” are declared but never read.
-
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.
-
Note
Uses an argument v6 removed
when = on line 62, 63. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 38
transp = on line 38, 39, 40, 41. v5 folds the transparency into the colour with color.new(c, transp).
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, lowest → ta.lowest.
- 2 strategy calls use the when = argument (line 62, 63). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 16 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 26: highest → ta.highest
- Line 30: lowest → ta.lowest
- Line 34: return is reserved in v5: renamed return_
- Line 38: transp = 0 → color.new(color.red, 0)
- Line 39: transp = 0 → color.new(color.lime, 0)
9 more edits
- Line 40: transp = 0 → color.new(color.red, 0)
- Line 41: transp = 0 → color.new(color.lime, 0)
- Line 49: input(type = input.integer) → input.int()
- Line 50: input(type = input.integer) → input.int()
- Line 51: input(type = input.integer) → input.int()
- Line 52: input(type = input.integer) → input.int()
- Line 53: input(type = input.integer) → input.int()
- Line 54: input(type = input.integer) → input.int()
- Line 56: input(type = input.bool) → input.bool()
⋯// © Joy_Bangla-//@version=4+//@version=5strategy("A Strategy for Leledec", shorttitle ="Leledec Strategy", overlay=true, commission_value=0.075, initial_capital=10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)⋯ sindex- if bindex > qual and close < open and high >= highest(high, len)+ if bindex > qual and close < open and high >= ta.highest(high, len) bindex := 0⋯ ret- if sindex > qual and close > open and low <= lowest(low, len)+ if sindex > qual and close > open and low <= ta.lowest(low, len) sindex := 0⋯ ret- return = ret+ return_ = ret- return+ return_major = lele(maj_qual, maj_len)minor=lele(min_qual,min_len)-plotchar(maj ? major == -1 ? high : na : na, char='•', location=location.absolute, color=color.red, transp=0, size=size.large)+plotchar(maj ? major == -1 ? high : na : na, char='•', location=location.absolute, color=color.new(color.red, 0), size=size.large)-plotchar(maj ? major == 1 ? low : na : na, char='•', location=location.absolute, color=color.lime, transp=0, size=size.large)+plotchar(maj ? major == 1 ? low : na : na, char='•', location=location.absolute, color=color.new(color.lime, 0), size=size.large)-plotchar(min ? (minor==1?high:na) : na, char='x', location=location.absolute, color=color.red, transp=0, size=size.small)+plotchar(min ? (minor==1?high:na) : na, char='x', location=location.absolute, color=color.new(color.red, 0), size=size.small)-plotchar(min ? (minor==-1?low:na) : na, char='x', location=location.absolute, color=color.lime, transp=0, size=size.small)+plotchar(min ? (minor==-1?low:na) : na, char='x', location=location.absolute, color=color.new(color.lime, 0), size=size.small)leledecMajorBullish = major==1?low:na⋯// === INPUT BACKTEST RANGE ===-fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromYear = input(defval = 2018, title = "From Year", type = input.integer, minval = 2017, maxval = 2030)+fromYear = input.int(defval = 2018, title = "From Year", minval = 2017, maxval = 2030)-thruMonth = input(defval = 12, title = "Thru Month", type = input.integer, minval = 1, maxval = 11)+thruMonth = input.int(defval = 12, title = "Thru Month", minval = 1, maxval = 11)-thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 30)+thruDay = input.int(defval = 1, title = "Thru Day", minval = 1, maxval = 30)-thruYear = input(defval = 2030, title = "Thru Year", type = input.integer, minval = 2017, maxval = 2030)+thruYear = input.int(defval = 2030, title = "Thru Year", minval = 2017, maxval = 2030)// === INPUT SHOW PLOT ===-showDate = input(defval = true, title = "Show Date Range", type = input.bool)+showDate = input.bool(defval = true, title = "Show Date Range")// === FUNCTION EXAMPLE ===⋯Same 16 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.bool()
- Line 6: input() → input.bool()
- Line 7: input() → input.source()
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
5 more edits
- Line 11: input() → input.int()
- Line 12: input() → input.int()
- Line 13: input() → input.int()
- Line 62: when = buySignalBasedOnMajorLeledecOnly → if block
- Line 63: when = sellSignalBasedOnMajorLeldecOnly → if block
⋯strategy("A Strategy for Leledec", shorttitle ="Leledec Strategy", overlay=true, commission_value=0.075, initial_capital=10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)-maj = input(true, "Major Leledec Exhausion Bar :: Show")+maj = input.bool(true, "Major Leledec Exhausion Bar :: Show")-min=input(false, "Minor Leledec Exhausion Bar :: Show")+min=input.bool(false, "Minor Leledec Exhausion Bar :: Show")-leledcSrc = input(close, "Major Leledec Exhausion Bar :: Source")+leledcSrc = input.source(close, "Major Leledec Exhausion Bar :: Source")-maj_qual = input(6, "Major Leledec Exhausion Bar :: Bar count no")+maj_qual = input.int(6, "Major Leledec Exhausion Bar :: Bar count no")-maj_len = input(30, "Major Leledec Exhausion Bar :: Highest / Lowest")+maj_len = input.int(30, "Major Leledec Exhausion Bar :: Highest / Lowest")-min_qual=input(5, "Minor Leledec Exhausion Bar :: Bar count no")+min_qual=input.int(5, "Minor Leledec Exhausion Bar :: Bar count no")-min_len=input(5, "Minor Leledec Exhausion Bar :: Bar count no")+min_len=input.int(5, "Minor Leledec Exhausion Bar :: Bar count no")-bindexSindex = input(1, "bindexSindex")+bindexSindex = input.int(1, "bindexSindex")-closeVal = input(4, "Close")+closeVal = input.int(4, "Close")lele(qual, len) =>⋯if (window())- strategy.entry("buy", strategy.long, when=buySignalBasedOnMajorLeledecOnly)+ if buySignalBasedOnMajorLeledecOnly+ strategy.entry("buy", strategy.long)- strategy.entry("sell", strategy.short, when=sellSignalBasedOnMajorLeldecOnly)+ if sellSignalBasedOnMajorLeldecOnly+ strategy.entry("sell", strategy.short)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: 16 before, 24 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.
⋯// © Joy_Bangla-//@version=5+//@version=6strategy("A Strategy for Leledec", shorttitle ="Leledec Strategy", overlay=true, commission_value=0.075, initial_capital=10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)⋯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 |
|---|---|---|---|
| Major Leledec Exhausion Bar :: Show | true | bool | plotchar |
| Minor Leledec Exhausion Bar :: Show | false | bool | plotchar |
| Major Leledec Exhausion Bar :: Source | close | source | unused |
| Major Leledec Exhausion Bar :: Bar count no | 6 | int | major |
| Major Leledec Exhausion Bar :: Highest / Lowest | 30 | int | major |
| Minor Leledec Exhausion Bar :: Bar count no | 5 | int | minor |
| Minor Leledec Exhausion Bar :: Bar count no | 5 | int | minor |
| bindexSindex | 1 | int | bindex sindex |
| Close | 4 | int | line 20 line 23 |
| From Month | 1 | int (written input.integer) · min 1 · max 12 | start |
| From Day | 1 | int (written input.integer) · min 1 · max 31 | start |
| From Year | 2018 | int (written input.integer) · min 2017 · max 2030 | start |
| Thru Month | 12 | int (written input.integer) · min 1 · max 11 | finish |
| Thru Day | 1 | int (written input.integer) · min 1 · max 30 | finish |
| Thru Year | 2030 | int (written input.integer) · min 2017 · max 2030 | finish |
| Show Date Range | true | bool | unused |
What it calculates
No technical-analysis calculation: the script works on prices and settings directly.
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 |
|---|---|---|---|
| Open buy long | buySignalBasedOnMajorLeledecOnly | On | 62 |
| Open sell short | sellSignalBasedOnMajorLeldecOnly | On | 63 |
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.
- 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 | −6.4% | +102.5% | 16 | 44% | 0.50 | 10.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −2.7% | +5.5% | 24 | 63% | 0.52 | 4.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −18.9% | +9.8% | 15 | 27% | 0.12 | 26.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −4.9% | +8.4% | 10 | 60% | 0.29 | 7.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.8% | +16.7% | 17 | 53% | 1.05 | 9.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −6.5% | +21.5% | 16 | 44% | 0.28 | 9.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −10.8% | +148.3% | 9 | 44% | 0.26 | 17.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +2.7% | +17.1% | 16 | 69% | 1.82 | 3.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 4 | 0% | −$613.20 |
| Sideways market | 6 | 67% | $31.25 |
| Falling market | 6 | 50% | −$59.54 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
11.4%
The 95th percentile of the worst drawdown when the same 16 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 6.6% to 11.4%; the tick is what actually happened, 9.1%. Order luck alone moves it this much.
All 16 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 14 Feb 2024 49,699.60 | 20 Apr 2024 63,818.00 | 66 | −$285.57 |
| long | 20 Apr 2024 63,818.00 | 7 May 2024 63,165.20 | 17 | −$11.38 |
| short | 7 May 2024 63,165.20 | 12 Mar 2025 82,933.00 | 309 | −$305.14 |
| long | 12 Mar 2025 82,933.00 | 21 Mar 2025 84,223.40 | 9 | $13.19 |
| short | 21 Mar 2025 84,223.40 | 8 Apr 2025 79,163.20 | 18 | $55.14 |
| long | 8 Apr 2025 79,163.20 | 14 Apr 2025 83,760.00 | 6 | $53.47 |
| short | 14 Apr 2025 83,760.00 | 23 Aug 2025 116,936.00 | 131 | −$378.52 |
| long | 23 Aug 2025 116,936.00 | 6 Sep 2025 110,660.00 | 14 | −$50.36 |
| short | 6 Sep 2025 110,660.00 | 19 Nov 2025 92,960.80 | 74 | $144.05 |
| long | 19 Nov 2025 92,960.80 | 29 Nov 2025 90,890.70 | 10 | −$21.92 |
| short | 29 Nov 2025 90,890.70 | 3 Feb 2026 78,738.60 | 66 | $121.81 |
| long | 3 Feb 2026 78,738.60 | 16 Feb 2026 68,832.60 | 13 | −$118.67 |
| short | 16 Feb 2026 68,832.60 | 24 May 2026 76,752.00 | 97 | −$107.42 |
| long | 24 May 2026 76,752.00 | 27 May 2026 75,930.00 | 3 | −$11.11 |
| short | 27 May 2026 75,930.00 | 2 Jul 2026 60,024.00 | 36 | $189.23 |
| long | 2 Jul 2026 60,024.00 | 16 Jul 2026 64,756.30 | 14 | $71.72 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | Yes 1,000 bars in 64 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not 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. 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/// © Joy_Bangla//@version=4strategy("A Strategy for Leledec", shorttitle ="Leledec Strategy", overlay=true, commission_value=0.075, initial_capital=10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)maj = input(true, "Major Leledec Exhausion Bar :: Show")min=input(false, "Minor Leledec Exhausion Bar :: Show")leledcSrc = input(close, "Major Leledec Exhausion Bar :: Source")maj_qual = input(6, "Major Leledec Exhausion Bar :: Bar count no")maj_len = input(30, "Major Leledec Exhausion Bar :: Highest / Lowest")min_qual=input(5, "Minor Leledec Exhausion Bar :: Bar count no")min_len=input(5, "Minor Leledec Exhausion Bar :: Bar count no")bindexSindex = input(1, "bindexSindex")closeVal = input(4, "Close")lele(qual, len) => bindex = 0 sindex = 0 bindex := nz(bindex[bindexSindex], 0) sindex := nz(sindex[bindexSindex], 0) ret = 0 if close > close[closeVal] bindex := bindex + 1 bindex if close < close[closeVal] sindex := sindex + 1 sindex if bindex > qual and close < open and high >= highest(high, len) bindex := 0 ret := -1 ret if sindex > qual and close > open and low <= lowest(low, len) sindex := 0 ret := 1 ret return = ret returnmajor = lele(maj_qual, maj_len)minor=lele(min_qual,min_len)plotchar(maj ? major == -1 ? high : na : na, char='•', location=location.absolute, color=color.red, transp=0, size=size.large)plotchar(maj ? major == 1 ? low : na : na, char='•', location=location.absolute, color=color.lime, transp=0, size=size.large)plotchar(min ? (minor==1?high:na) : na, char='x', location=location.absolute, color=color.red, transp=0, size=size.small)plotchar(min ? (minor==-1?low:na) : na, char='x', location=location.absolute, color=color.lime, transp=0, size=size.small)leledecMajorBullish = major==1?low:naleledecMajorBearish = major==-1?high:naleledecMinorBullish = minor==1?low:naleledecMinorBearish = minor==-1?high:nabuySignalBasedOnMajorLeledecOnly = major==1?low:nasellSignalBasedOnMajorLeldecOnly = minor==-1?high:na// === INPUT BACKTEST RANGE ===fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)fromYear = input(defval = 2018, title = "From Year", type = input.integer, minval = 2017, maxval = 2030)thruMonth = input(defval = 12, title = "Thru Month", type = input.integer, minval = 1, maxval = 11)thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 30)thruYear = input(defval = 2030, title = "Thru Year", type = input.integer, minval = 2017, maxval = 2030)// === INPUT SHOW PLOT ===showDate = input(defval = true, title = "Show Date Range", type = input.bool)// === FUNCTION EXAMPLE ===start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start windowfinish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish windowwindow() => time >= start and time <= finish ? true : false // create function "within window of time"if (window()) strategy.entry("buy", strategy.long, when=buySignalBasedOnMajorLeledecOnly) strategy.entry("sell", strategy.short, when=sellSignalBasedOnMajorLeldecOnly)