Strategy · Pine Script v5 · On the chart

ESU2023-10M - V1

by dearvn· code credited to binancash

ESU2023-10M - V1 is an intraday trend-reversal strategy designed for index futures contracts on the price chart.

View on GitHub

GitHub stars257on the repository
Pine versionv5runs as is
Lines of code94
Settings5inputs
LicenceNone statedfile: MPL-2.0
Last update6 weeks ago11 Sep 2026

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

94 lines of Pine Script v5 from ESU2023-10M.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

ESU2023-10M.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © binancash

//@version=5
strategy("ESU2023-10M - V1", overlay=true, pyramiding=1, default_qty_type = strategy.fixed, default_qty_value = 1 )


stopPerCall = input(0.08, title='Stop Loss Call %') / 100 
takePerCall = input(0.02, title='Take Profit Call %') / 100

stopPerPut = input(0.07, title='Stop Loss Put %') / 100 
takePerPut = input(0.03, title='Take Profit Put %') / 100

longStop = strategy.position_avg_price * (1 - stopPerCall)
shortStop = strategy.position_avg_price * (1 + stopPerPut)
shortTake = strategy.position_avg_price * (1 - takePerPut)
longTake = strategy.position_avg_price * (1 + takePerCall)


//Inputs
ma_length = input(3)

//Three Bar High/Low Moving Average
ma_high = ta.sma(high, ma_length)
ma_low = ta.sma(low, ma_length)
plot(ma_high, linewidth = 1)
plot(ma_low, linewidth = 1)

//Trend Reversal - Up
trend_reversal_up = low[2] > low[1] and low[1] < low and high > high[1]
plotshape(trend_reversal_up ? 1: na, color = color.orange, location = location.belowbar, style = shape.arrowup, text = 'U')

//Trend Reversal - Down
trend_reversal_down = high[2] < high[1] and high[1] > high and low < low[1]
plotshape(trend_reversal_down ? -1: na, color = color.navy, location = location.abovebar, style = shape.arrowdown, text = 'D')

//Short Term Low
short_term_low = low[2] > low[1] and low[1] < low and high[1] < high[2] and high > high[1]
plotshape(short_term_low ? 1: na, color = #00EEEE, location = location.belowbar, style = shape.arrowup)

//Short Term High
short_term_high = high[2] < high[1] and high[1] > high and low[1] > low[2] and low < low[1]
plotshape(short_term_high ? -1: na, color = #00EEEE, location = location.abovebar, style = shape.arrowdown)

//Trend Change Point - Up
float trend_change_up = na
trend_change_up := high > high[1] ? 1 : na
line1 = short_term_low and trend_change_up
color_up = #FFEB3B
color up = na
up := trend_change_up ? color_up : na
plot(line1 ? high[1] : na, color = up, linewidth = 2)

plotshape(line1 ? low : na, title="Buy", text="Buy", style=shape.triangleup, location=location.belowbar, color=color.white, size=size.normal)


//Trend Change Point - Down
float trend_change_down = na
trend_change_down := low < low[1] ? 1 : na
line2 = short_term_high and trend_change_down
color_down = #E040FB
color down = na
down := trend_change_down ? color_down : na
plot(line2 ? low[1] : na, color=down, linewidth = 2)

plotshape(line2 ? high : na, title="Sell", text="Sell", style=shape.triangledown, location=location.abovebar, color=color.blue, size=size.normal)


//Bar Color Trend Change
coloryellow = #FFEB3B
colorfuchsia = #E040FB
barcolor(line1 ? coloryellow : line2 ? colorfuchsia : na)


if line1 and short_term_low
    strategy.entry("call", strategy.long)

if line2 and short_term_high
    strategy.entry("put", strategy.short)


if(strategy.position_size > 0 and (trend_reversal_down or trend_change_down))
    strategy.close(id="call")

if(strategy.position_size < 0 and (trend_reversal_up or trend_change_up))
    strategy.close(id="put")


if(strategy.position_size > 0)
    strategy.exit(id='call', limit=longTake,stop = longStop)
    //call_price := 0.0

if(strategy.position_size < 0)
    strategy.exit(id='put', limit=shortTake,stop = shortStop)

Overview

ESU2023-10M - V1 calculates a 3-period moving average of candle highs and lows alongside specific three-bar price action patterns to detect short-term swing highs and lows. Long and short trades enter when momentum confirms a local swing reversal. Positions exit either through defined percentage-based stop loss and take profit targets or early upon opposing trend reversal signals. Main settings configure percentage targets and the moving average length.

Details

Published by

dearvn on GitHub

Code credit

binancash, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Candlestick patterns

Markets

Indices

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

futures-markettradingviewtradovatetrading-futureses1best-indicator-tradingviewnq1trading-futurerus-stock-market

Settings

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

SettingTypeDefaultVariable
Stop Loss Call %float0.08stopPerCall
Take Profit Call %float0.02takePerCall
Stop Loss Put %float0.07stopPerPut
Take Profit Put %float0.03takePerPut
ma_lengthint3ma_length
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

Pin Bar Magic v1

by Alorse
330 stars

This strategy trades price action pin bar patterns aligned with moving average trend alignment on the main price chart. It defines uptrends or downtrends using a fan arrangement of three moving averages (6 EMA, 18 EMA, and 50 SMA). Entry conditions require a b

Strategy v4 Candlestick patternsTrend
Updated 2 months ago · None stated GitHub repository of Pin Bar Magic v1
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
106 stars

This strategy trades the three-candle strike pattern filtered by trend direction and time sessions. It calculates market regime using linear regression and exponential or smoothed moving averages to distinguish between ranging and trending conditions. Risk man

Strategy v5 Candlestick patternsTrend
Updated 2 years ago · GPL-3.0 GitHub repository of 3 Candle Strike Strategy

Consecutive Up/Down Strategy

by TWODS-CAPITAL
37 stars

This strategy tracks consecutive bullish and bearish candlestick closes relative to the preceding bar. It enters a long position when price closes higher for a specified number of consecutive bars, and enters a short position when price closes lower for a desi

Strategy v5 Candlestick patternsTrend
Updated 3 years ago · MIT GitHub repository of Consecutive Up/Down Strategy

DI Engulfing A002

by ruckard
13 stars

This strategy executes trades based on candlestick engulfing patterns aligned with a 200-period exponential moving average trend filter. It enters long positions when a bullish engulfing candle follows three consecutive bearish candles while price trades above

Strategy v5 Candlestick patternsTrend
Updated 1 year ago · None stated GitHub repository of DI Engulfing A002

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