Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (16)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$9,070$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.
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

Verified

Same 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 ===⋯

Clean v5

VerifiedDownload the v5 script

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.

SettingDefaultType and rangeFeeds
Major Leledec Exhausion Bar :: Showtrueboolplotchar
Minor Leledec Exhausion Bar :: Showfalseboolplotchar
Major Leledec Exhausion Bar :: Sourceclosesourceunused
Major Leledec Exhausion Bar :: Bar count no6intmajor
Major Leledec Exhausion Bar :: Highest / Lowest30intmajor
Minor Leledec Exhausion Bar :: Bar count no5intminor
Minor Leledec Exhausion Bar :: Bar count no5intminor
bindexSindex1intbindex sindex
Close4intline 20 line 23
From Month1int (written input.integer) · min 1 · max 12start
From Day1int (written input.integer) · min 1 · max 31start
From Year2018int (written input.integer) · min 2017 · max 2030start
Thru Month12int (written input.integer) · min 1 · max 11finish
Thru Day1int (written input.integer) · min 1 · max 30finish
Thru Year2030int (written input.integer) · min 2017 · max 2030finish
Show Date Rangetrueboolunused

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.

bindexSindexbindexSindexsetting · 1maj_qualMajor Leledec Exhausion…setting · 6maj_lenMajor Leledec Exhausion…setting · 30min_qualMinor Leledec Exhausion…setting · 5min_lenMinor Leledec Exhausion…setting · 5lowlowprice datahighhighprice datafromYearFrom Yearsetting · 2018fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 1thruYearThru Yearsetting · 2030thruMonthThru Monthsetting · 12thruDayThru Daysetting · 1bindexbindexvaluesindexsindexvaluereturnreturnvaluemajormajorvalueminorminorvalueleledecMajorBullish, buySignalBasedOnMajorLeledecOnlyleledecMajorBullish · b…2 valuesleledecMajorBearishleledecMajorBearishvalueleledecMinorBullishleledecMinorBullishvalueleledecMinorBearish, sellSignalBasedOnMajorLeldecOnlyleledecMinorBearish · s…2 valuesstartstartvaluefinishfinishvalueentry:buyOpen buystrategy.entryentry:sellOpen sellstrategy.entryplotchar:38plotcharplotcharplotchar:39plotcharplotcharplotchar:40plotcharplotcharplotchar:41plotcharplotchar

Order rules

OrderFires whenBy defaultLine
Open buy longbuySignalBasedOnMajorLeledecOnlyOn62
Open sell shortsellSignalBasedOnMajorLeldecOnlyOn63

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.

5/5trades 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−6.4%+102.5%1644%0.5010.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−2.7%+5.5%2463%0.524.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−18.9%+9.8%1527%0.1226.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−4.9%+8.4%1060%0.297.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.8%+16.7%1753%1.059.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−6.5%+21.5%1644%0.289.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−10.8%+148.3%944%0.2617.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+2.7%+17.1%1669%1.823.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 market40%−$613.20
Sideways market667%$31.25
Falling market650%−$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.

0%13%
All 16 trades
SideEntryExitBarsP&L
short14 Feb 2024 49,699.6020 Apr 2024 63,818.0066−$285.57
long20 Apr 2024 63,818.007 May 2024 63,165.2017−$11.38
short7 May 2024 63,165.2012 Mar 2025 82,933.00309−$305.14
long12 Mar 2025 82,933.0021 Mar 2025 84,223.409$13.19
short21 Mar 2025 84,223.408 Apr 2025 79,163.2018$55.14
long8 Apr 2025 79,163.2014 Apr 2025 83,760.006$53.47
short14 Apr 2025 83,760.0023 Aug 2025 116,936.00131−$378.52
long23 Aug 2025 116,936.006 Sep 2025 110,660.0014−$50.36
short6 Sep 2025 110,660.0019 Nov 2025 92,960.8074$144.05
long19 Nov 2025 92,960.8029 Nov 2025 90,890.7010−$21.92
short29 Nov 2025 90,890.703 Feb 2026 78,738.6066$121.81
long3 Feb 2026 78,738.6016 Feb 2026 68,832.6013−$118.67
short16 Feb 2026 68,832.6024 May 2026 76,752.0097−$107.42
long24 May 2026 76,752.0027 May 2026 75,930.003−$11.11
short27 May 2026 75,930.002 Jul 2026 60,024.0036$189.23
long2 Jul 2026 60,024.0016 Jul 2026 64,756.3014$71.72

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 18 msYes 1,000 bars in 64 msNot measured
PineTSNo 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)