Strategy · Pine Script v6 · On the chart

DAX Gap Fade [trugurpala]

by trugurpala

This strategy trades opening gap fades on the DAX index during the European Xetra session.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code94
Settings4inputs
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

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

22_dax_gap_fade.pine
//@version=6
// DAX / FDAX Germany — Gap Fade + Xetra Session Strategy
// Author: Ugur Pala · github.com/trugurpala/pinescriptv6
// TradingView: https://tr.tradingview.com/u/trugurpala/
//
// TR: DAX'ın güniçi boşlukları (gap) kapatma eğiliminden faydalanır.
//     Xetra seansında (09:00-17:30 CET) çalışır.
//     NYSE açılışı volatilitesinden kaçınmak için 15:00 CET'te kapat.
// EN: Exploits DAX's strong tendency to fill intraday gaps.
//     Active during Xetra session (09:00-17:30 CET).
//     Positions closed at 15:00 CET to avoid NYSE open volatility.
//
// Sembol / Symbol: XETR:DAX / EUREX:FDAX1!
// Önerilen TF / Recommended TF: 5M, 15M
strategy("DAX Gap Fade [trugurpala]",
    overlay           = true,
    initial_capital   = 25000,
    default_qty_type  = strategy.fixed,
    default_qty_value = 1,
    commission_type   = strategy.commission.cash_per_contract,
    commission_value  = 5.0,
    slippage          = 2)

// ── Inputs ───────────────────────────────────────────────────────────────────
float gapMult    = input.float(0.3, "Min Gap (ATR mult)", step=0.1)
float atrMult    = input.float(1.5, "SL ATR Mult",        step=0.1)
float rrRatio    = input.float(1.5, "R:R Ratio",           step=0.1)
bool  closeEarly = input.bool(true, "Close at 15:00 CET (before NYSE)")

// ── Xetra Seans: 09:00–17:30 CET ─────────────────────────────────────────────
bool inXetra     = not na(time(timeframe.period, "0900-1730", "Europe/Berlin"))
bool xetraOpen   = not na(time(timeframe.period, "0900-0902", "Europe/Berlin"))
bool preNYSE     = closeEarly and not na(time(timeframe.period, "1500-1501", "Europe/Berlin"))
bool xetraClose  = inXetra[1] and not inXetra

if xetraClose or preNYSE
    strategy.close_all(comment="Session End")

// ── Gap Hesapla / Calculate Gap ───────────────────────────────────────────────
var float prevClose = na
var bool  gapUp     = false
var bool  gapDown   = false

float atrVal  = ta.atr(14)
float minGap  = gapMult * atrVal

// Gün başında gap belirle
if xetraOpen
    float gapSize = open - nz(prevClose, open)
    gapUp   := gapSize >  minGap
    gapDown := gapSize < -minGap
else if not inXetra
    gapUp   := false
    gapDown := false

// Önceki kapanışı sakla
if barstate.isconfirmed
    prevClose := close

// ── Sinyaller ────────────────────────────────────────────────────────────────
// Gap Up → Short (gap kapanacak, fiyat aşağı gelecek)
bool shortSignal = gapUp   and xetraOpen and strategy.position_size == 0
// Gap Down → Long (gap kapanacak, fiyat yukarı gelecek)
bool longSignal  = gapDown and xetraOpen and strategy.position_size == 0

// ── Entries ──────────────────────────────────────────────────────────────────
if longSignal
    float sl = open - atrMult * atrVal
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", "Long",
        stop  = sl,
        limit = open + rrRatio * (open - sl))

if shortSignal
    float sl = open + atrMult * atrVal
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", "Short",
        stop  = sl,
        limit = open - rrRatio * (sl - open))

// ── Visuals ──────────────────────────────────────────────────────────────────
plot(not na(prevClose) ? prevClose : na, "Prev Close",
    color.new(color.gray, 40), linewidth=1, style=plot.style_linebr)
bgcolor(gapUp          ? color.new(color.red,   90) : na, title="Gap Up")
bgcolor(gapDown        ? color.new(color.green, 90) : na, title="Gap Down")
bgcolor(not inXetra    ? color.new(color.gray,  96) : na, title="Off Hours")
plotshape(longSignal,  "Long",  shape.triangleup,   location.belowbar, color.green, size=size.normal)
plotshape(shortSignal, "Short", shape.triangledown, location.abovebar, color.red,   size=size.normal)

// ── Alerts (alert() — strategy içinde çalışır) ───────────────────────────────
if longSignal
    alert("DAX Gap Down Fade Long — " + str.tostring(close, "#.##"), alert.freq_once_per_bar)
if shortSignal
    alert("DAX Gap Up Fade Short — " + str.tostring(close, "#.##"), alert.freq_once_per_bar)

Overview

At the 09:00 CET market open, it measures the opening price against the previous close relative to an ATR threshold. If a gap exceeds the threshold, it fades the move by going short on gaps up or long on gaps down. Trades use an ATR-based stop loss and take profit defined by a risk-to-reward ratio. An optional setting closes all positions at 15:00 CET prior to the NYSE open.

Details

Published by

trugurpala on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Mean reversion, Sessions & time, Volatility & bands

Markets

Indices

Timeframes

M1-M5, 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

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
Min Gap (ATR mult)float0.3gapMult
SL ATR Multfloat1.5atrMult
R:R Ratiofloat1.5rrRatio
Close at 15:00 CET (before NYSE)booltruecloseEarly
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

13 stars

This strategy overlays the price chart to trade DAX futures during European market hours. It calculates exponential and simple moving averages, RSI, MACD, Bollinger Bands, ATR, and realized volatility to simulate VIX levels. Trades execute when session time fi

Strategy v5 Sessions & timeOscillators & momentum
Updated 8 months ago · Custom licence GitHub repository of ClaudeHedge - DAX Session Strategy
3 stars

This strategy plots Bollinger bands and a simple moving average on the price chart. It opens a short when price crosses above the upper band while below the average, and a long when price crosses below the lower band while above the average. Entries are allowe

Strategy v5 Volatility & bandsMoving averages
Updated 2 years ago · None stated GitHub repository of 周末布林带策略

RSI Mean Reversion

by GifariKemal
3 stars

This strategy plots entry signals, stop loss, take profit levels, and an information panel directly on the price chart. It combines a relative strength index mean reversion model with ATR percentile thresholds to filter trades based on volatility conditions. T

Strategy v5 Oscillators & momentumVolatility & bands
Updated 3 days ago · MIT GitHub repository of RSI Mean Reversion

FTB Strategy

by Web3Degenerate
2 stars

The FTB Strategy is a short-only overlay strategy targeting EURUSD during the European session from 0200-0700. It enters short positions when filters confirm RSI overbought, a bullish prior bar close, or a high price level within lookback bars, combined with a

Strategy v5 Mean reversionSessions & time
Updated 2 years ago · None stated GitHub repository of FTB Strategy
2 stars

This mean-reversion trading strategy targets XAUUSD during the Asian trading session. It generates buy signals when price touches the lower Bollinger Band and RSI is oversold, and sell signals when price reaches the upper band and RSI is overbought. Trades are

Strategy v6 Mean reversionSessions & time
Updated 4 months ago · None stated GitHub repository of XAUUSD Mean Reversion Strategy

BB(10,2) + TP20 SameDay

by zraesdev-hub
1 stars

This strategy draws Bollinger Bands on the price chart and enters long when both the open and the close are below the lower band. Mode S1 exits the same day at a 20 percent take profit or forces a close if that target is missed. Mode S2 can hold for a set numb

Strategy v5 Volatility & bandsMean reversion
Updated 4 months ago · None stated GitHub repository of BB(10,2) + TP20 SameDay

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