Strategy · Pine Script v4 · On the chart

A Strategy for Leledec

by hasnocool· code credited to Joy_Bangla

This Pine Script strategy identifies major and minor Leledec exhaustion bars by tracking consecutive price bar comparisons against past closes and checking local extremes over set lookback lengths.

View on GitHub

GitHub stars106on the repository
Pine versionv4older, still runs
Lines of code65
Settings16inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

65 lines of Pine Script v4 from A Strategy for Leledec.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

A Strategy for Leledec.pine
// 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=4
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")
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
    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 ? 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:na
leledecMajorBearish = major==-1?high:na
leledecMinorBullish = minor==1?low:na
leledecMinorBearish = minor==-1?high:na
buySignalBasedOnMajorLeledecOnly = major==1?low:na
sellSignalBasedOnMajorLeldecOnly = 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 window
finish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish window
window()  => 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)
 
Expand (84 lines)

Overview

A Strategy for Leledec overlays visual markers directly on the price chart for detected exhaustion points. Within a user-defined backtesting date range, the strategy enters long trades on major bullish exhaustion signals and short trades on minor bearish exhaustion signals. Inputs allow adjusting bar count qualifiers and lookback periods. The strategy does not include protective stop loss or take profit orders.

Details

Published by

hasnocool on GitHub

Code credit

Joy_Bangla, as written in the script's header

Type

Strategy, Pine Script v4

Draws

On the price chart

Category

Mean reversion, Candlestick patterns

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Major Leledec Exhausion Bar :: Showbooltruemaj
Minor Leledec Exhausion Bar :: Showboolfalsemin
Major Leledec Exhausion Bar :: SourcesourcecloseleledcSrc
Major Leledec Exhausion Bar :: Bar count noint6maj_qual
Major Leledec Exhausion Bar :: Highest / Lowestint30maj_len
Minor Leledec Exhausion Bar :: Bar count noint5min_qual
Minor Leledec Exhausion Bar :: Bar count noint5min_len
bindexSindexint1bindexSindex
Closeint4closeVal
From Monthint1fromMonth
From Dayint1fromDay
From Yearint2018fromYear
Show all 16 settings
SettingTypeDefaultVariable
Thru Monthint12thruMonth
Thru Dayint1thruDay
Thru Yearint2030thruYear
Show Date RangebooltrueshowDate
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

Exceeded Candle [Alorse] is a mean-reversion strategy that identifies candlestick engulfing patterns combined with Bollinger Bands filters. It enters a long position when a green candle surpasses the body of the previous red candle while price is below the mid

Strategy v4 Mean reversionCandlestick patterns
Updated 2 months ago · None stated GitHub repository of Exceeded candle [Alorse]
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy

STRG One Bar Pursuit

by harryguiacorn
219 stars

The STRG One Bar Pursuit strategy identifies single-bar momentum reversals by monitoring shifts between bullish and bearish candlesticks starting from the year 2024. It enters a long position when a bullish candle follows a bearish candle and enters a short po

Strategy v5 Candlestick patternsMean reversion
Updated 1 year ago · None stated GitHub repository of STRG One Bar Pursuit

BodyOutlier A003

by ruckard
13 stars

BodyOutlier A003 is a mean-reversion trading strategy designed for automated execution via Zignaly alerts. It identifies candlestick body outliers to place limit orders, buying at the low of unusually large bullish candles or selling at the high of large beari

Strategy v5 Candlestick patternsMean reversion
Updated 1 year ago · None stated GitHub repository of BodyOutlier A003

Markov Strategy

by Rohanom
9 stars

Markov Strategy is a mean-reversion quantitative strategy inspired by streak-based Markov chain analysis. Applied directly to the price chart, it monitors price action for consecutive downward closes. The strategy enters a long position after detecting six con

Strategy v5 Mean reversionCandlestick patterns
Updated 1 year ago · MIT GitHub repository of Markov Strategy

This strategy buys after a sharp down bar with a long lower wick. It opens one long when the lower wick exceeds the candle body by the pin-bar ratio and the one-bar close change falls past the decline threshold. Size defaults to the full account equity. While

Strategy v6 Candlestick patternsMean reversion Repaints
Updated 10 months ago · Apache-2.0 GitHub repository of youtube布欧量化策略-接针策略

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers