Strategy · Pine Script v5 · On the chart

OTE (Optimal Trade Entry)

by muammeryldrm42

This strategy draws optimal trade entry zones on the price chart from confirmed swing pivots.

View on GitHub

GitHub stars7on the repository
Pine versionv5runs as is
Lines of code50
Settings4inputs
LicenceMIT
Last update3 months ago8 Jul 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

50 lines of Pine Script v5 from public/code/smc__ote.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

smc__ote.pine
//@version=5
strategy("OTE (Optimal Trade Entry)", overlay=true,
         default_qty_type=strategy.percent_of_equity, default_qty_value=10)

swingLb = input.int(10, "Swing LB")
fibLow  = input.float(0.62, "Fib Low")
fibHigh = input.float(0.79, "Fib High")
emaP    = input.int(200, "Trend EMA")

atrVal = ta.atr(14)
emaT   = ta.ema(close, emaP)
ph     = ta.pivothigh(swingLb, swingLb)
pl     = ta.pivotlow(swingLb, swingLb)

var float lastSH = na, var int lastSHIdx = na
var float lastSL = na, var int lastSLIdx = na
if not na(ph)
    lastSH := ph
    lastSHIdx := bar_index - swingLb
if not na(pl)
    lastSL := pl
    lastSLIdx := bar_index - swingLb

upImpulse = not na(lastSHIdx) and not na(lastSLIdx) and lastSHIdx > lastSLIdx
dnImpulse = not na(lastSHIdx) and not na(lastSLIdx) and lastSLIdx > lastSHIdx

oteHighL = upImpulse ? lastSH - (lastSH - lastSL) * fibLow  : na
oteLowL  = upImpulse ? lastSH - (lastSH - lastSL) * fibHigh : na
oteLowS  = dnImpulse ? lastSL + (lastSH - lastSL) * fibLow  : na
oteHighS = dnImpulse ? lastSL + (lastSH - lastSL) * fibHigh : na

longSig  = upImpulse and close >= oteLowL and close <= oteHighL and close > emaT
shortSig = dnImpulse and close >= oteLowS and close <= oteHighS and close < emaT

if longSig and strategy.position_size == 0
    sl   = lastSL - 0.3 * atrVal
    entry= (oteLowL + oteHighL) / 2
    risk = entry - sl
    strategy.entry("OTE L", strategy.long, limit=entry)
    strategy.exit("X", "OTE L", stop=sl, limit=lastSH)

if shortSig and strategy.position_size == 0
    sl   = lastSH + 0.3 * atrVal
    entry= (oteLowS + oteHighS) / 2
    risk = sl - entry
    strategy.entry("OTE S", strategy.short, limit=entry)
    strategy.exit("X", "OTE S", stop=sl, limit=lastSL)

plotshape(longSig,  "L", shape.triangleup,   location.belowbar, color.lime)
plotshape(shortSig, "S", shape.triangledown, location.abovebar, color.red)

Overview

A later swing high after a swing low defines an up impulse, and the reverse defines a down impulse. It then marks the 0.62 to 0.79 Fibonacci retracement of that swing. A long signal needs price inside the bullish zone and above the trend EMA; a short signal needs the bearish zone and price below the EMA. When flat, it places a limit order at the zone midpoint, a stop beyond the opposite swing by a fraction of ATR, and a take profit at the impulse extreme. Triangle markers show the signals.

Details

Published by

muammeryldrm42 on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance, Trend

Markets

Any symbol

Timeframes

Any timeframe

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

cryptofuturessodexsosovaluestrategyvaluechain

Settings

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

SettingTypeDefaultVariable
Swing LBint10swingLb
Fib Lowfloat0.62fibLow
Fib Highfloat0.79fibHigh
Trend EMAint200emaP
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

FilledValueGap A006

by ruckard
13 stars

This strategy enters trades in the opposite direction of filled value gaps, operating under the assumption that price action will resume the primary trend after filling a recent gap. It plots directly on the main price chart and supports MA-based trend filters

Strategy v5 SMC / ICT / price actionTrend
Updated 1 year ago · None stated GitHub repository of FilledValueGap A006

XXX

by MeridianAlgo
9 stars

This multi-timeframe scalping strategy plots moving averages alongside Smart Money Concepts elements on the price chart. It calculates trend signals using configurable moving average types like ALMA, Hull MA, or TEMA across alternate timeframes. It also plots

Strategy v5 TrendMoving averages Repaints
Updated 4 months ago · MIT GitHub repository of XXX

NQ 9:45-10:15 ICT Strategy

by eddiebelaval
7 stars

This ICT-based strategy trades during the 9:45 AM to 10:15 AM New York session window. It calculates a daily bias using a 20-period daily EMA and tracks previous day highs and lows to identify liquidity sweeps. The script refines order block entry levels and m

Strategy v6 SMC / ICT / price actionSessions & time Repaints
Updated 3 months ago · None stated GitHub repository of NQ 9:45-10:15 ICT Strategy
6 stars

This strategy detects key support and resistance zones based on candle wick rejections and liquidity sweeps. It filters trade setups using an exponential moving average and optional higher-timeframe trend confluence, while also permitting high-confidence count

Strategy v5 Support & resistanceSMC / ICT / price action
Updated 7 months ago · None stated GitHub repository of Wick Rejection S/R Strategy v3
5 stars

RG Structure is a pivot-constrained break-and-retest strategy that calculates dynamic trendlines, market structure changes, and regime states on the price chart. It identifies support and resistance lines through pivot points and evaluates break-and-retest sig

Strategy v6 TrendSupport & resistance
Updated 7 weeks ago · None stated GitHub repository of RG Structure Visual Edition

This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr

Strategy v6 BreakoutTrend
Updated today · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout

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