Strategy · Pine Script v6 · On the chart

GBP/USD Market Structure [trugurpala]

by trugurpala

This strategy tracks GBP/USD market structure by storing confirmed pivot highs and lows.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code89
Settings5inputs
LicenceMIT
Last update2 months ago3 Aug 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

89 lines of Pine Script v6 from global-markets/20_gbpusd_structure.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

20_gbpusd_structure.pine
//@version=6
// GBP/USD — Market Structure + EMA Filter Strategy
// Author: Ugur Pala · github.com/trugurpala/pinescriptv6
// TradingView: https://tr.tradingview.com/u/trugurpala/
//
// TR: Pivot high/low kırılması ile market structure takibi.
//     EMA filtresi ile trend yönünde işlem alınır.
//     Cable (GBP/USD) için London seansında en etkili.
// EN: Market structure tracking via pivot high/low breakouts.
//     EMA filter ensures trading in trend direction.
//     Most effective during London session for Cable.
//
// Sembol / Symbol: FX:GBPUSD / OANDA:GBPUSD
// Önerilen TF / Recommended TF: 1H, 4H
strategy("GBP/USD Market Structure [trugurpala]",
    overlay           = true,
    initial_capital   = 10000,
    default_qty_type  = strategy.percent_of_equity,
    default_qty_value = 2,
    commission_type   = strategy.commission.percent,
    commission_value  = 0.006,
    slippage          = 1)

// ── Inputs ───────────────────────────────────────────────────────────────────
int   pivotLen  = input.int(5,   "Pivot Lookback", minval=2)
int   trendLen  = input.int(50,  "Trend EMA",      minval=10)
int   atrLen    = input.int(14,  "ATR",            minval=1)
float slMult    = input.float(1.5, "SL Mult",      step=0.1)
float tpMult    = input.float(2.5, "TP Mult",      step=0.1)

// ── London + NY Seans ─────────────────────────────────────────────────────────
bool inSession  = not na(time(timeframe.period, "0700-2000", "GMT"))

// ── Calculations ─────────────────────────────────────────────────────────────
float trendEma  = ta.ema(close, trendLen)
float atrVal    = ta.atr(atrLen)

float pivHigh   = ta.pivothigh(high, pivotLen, pivotLen)
float pivLow    = ta.pivotlow(low,   pivotLen, pivotLen)

var float lastPH = na
var float lastPL = na

if not na(pivHigh)
    lastPH := high[pivotLen]
if not na(pivLow)
    lastPL := low[pivotLen]

// Kırılma sinyalleri — trend yönünde
bool bullBreak = not na(lastPH)
                    and ta.crossover(close, lastPH)
                    and close > trendEma
                    and inSession
                    and strategy.position_size == 0

bool bearBreak = not na(lastPL)
                    and ta.crossunder(close, lastPL)
                    and close < trendEma
                    and inSession
                    and strategy.position_size == 0

// ── Entries ──────────────────────────────────────────────────────────────────
if bullBreak
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", "Long",
        stop  = close - slMult * atrVal,
        limit = close + tpMult * atrVal)

if bearBreak
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", "Short",
        stop  = close + slMult * atrVal,
        limit = close - tpMult * atrVal)

// ── Visuals ──────────────────────────────────────────────────────────────────
plot(trendEma, "Trend EMA", color.new(color.orange, 20), linewidth=2)
plotshape(not na(pivHigh), "Pivot High", shape.triangledown,
    location.abovebar, color.new(color.red,   40), size=size.tiny)
plotshape(not na(pivLow),  "Pivot Low",  shape.triangleup,
    location.belowbar, color.new(color.green, 40), size=size.tiny)
plotshape(bullBreak, "Long",  shape.triangleup,   location.belowbar, color.green, size=size.normal)
plotshape(bearBreak, "Short", shape.triangledown, location.abovebar, color.red,   size=size.normal)
bgcolor(not inSession ? color.new(color.gray, 96) : na)

// ── Alerts (alert() — strategy içinde çalışır) ───────────────────────────────
if bullBreak
    alert("GBP/USD Structure Break Long — " + str.tostring(close, "#.#####"), alert.freq_once_per_bar)
if bearBreak
    alert("GBP/USD Structure Break Short — " + str.tostring(close, "#.#####"), alert.freq_once_per_bar)

Overview

GBP/USD Market Structure [trugurpala] enters long when price crosses above the last pivot high while above a trend EMA, and short when price crosses below the last pivot low while below that EMA. Entries occur only during the London and New York window and only when the position is flat. ATR multiples set the stop and the take-profit. Pivot lookback, EMA length, ATR length, and those multiples are adjustable. It draws on the price chart. Comments recommend the one-hour and four-hour charts.

Details

Published by

trugurpala on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Trend, Breakout, Sessions & time

Markets

Forex

Timeframes

M15-H1, H4 and above

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

aialgorithmic-tradingclaude-codecodexcoding-agentsgithub-copilotopen-sourcepine-scriptpine-script-v6technical-analysis

Settings

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

SettingTypeDefaultVariable
Pivot Lookbackint5pivotLen
Trend EMAint50trendLen
ATRint14atrLen
SL Multfloat1.5slMult
TP Multfloat2.5tpMult
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

FYP Bot 1

by aleks-drozy
2 stars

This strategy executes trades based on a combination of Smart Money Concepts, including Inverse Fair Value Gaps (IFVG) and Change in State of Delivery (CISD) structure breaks. Entries require confluence between IFVG flips, structural CISD breaks, a 20-period e

Strategy v6 SMC / ICT / price actionTrend
Updated 2 months ago · MIT GitHub repository of FYP Bot 1

Try Trading Future

by dearvn
257 stars

This futures trading strategy combines Fair Value Gap (FVG) detection filtered by Average True Range (ATR) with multi-timeframe Exponential Moving Averages (8, 55, and 165 lengths). It identifies entry setups during a defined intraday trading session window wh

Strategy v5 SMC / ICT / price actionMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Try Trading Future
53 stars

This strategy enters long or short on the price chart when price is on the correct side of a 200-period EMA, MACD agrees, RSI is not at the opposing extreme, ADX exceeds a threshold, volume beats a 20-bar average, and close breaks the recent high or low. A tim

Strategy v6 TrendOscillators & momentum
Updated 2 months ago · MPL-2.0 GitHub repository of BTCUSD 5M Optimized Strategy
23 stars

This strategy evaluates breakout and trend opportunities on the price chart using a weighted composite score of volume, trend, and candlestick structure. It tracks volume spikes, fast and slow EMAs, higher-timeframe EMA trend alignment, opening ranges, and ses

Strategy v6 TrendVolume Repaints
Updated 3 weeks ago · Custom licence GitHub repository of TradingAlpha Point-Clip Strategy

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

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