OPEN-SOURCE SCRIPT
Session King - ALMA with Session Filter

A session-gated trend strategy that restricts entries to high-liquidity
session windows using ALMA direction bias, with standardised ATR exits
(3 ATR stop, 6 ATR take profit — 2R fixed).
WHAT MAKES THIS ORIGINAL
Most trend strategies fire entries continuously throughout the trading day.
This strategy gates every entry through two independent filters before a
signal is accepted: a directional bias filter (ALMA) and a session timing
filter. Neither filter alone is the edge — the combination is. ALMA without
the session gate fires too many signals in low-liquidity periods. The session
gate without a directional filter trades noise in both directions. Together
they restrict entries to directional moves inside high-liquidity windows
where volume and participation are highest.
COMPONENTS
ALMA (Arnaud Legoux Moving Average, length 9): Direction baseline. Price
above ALMA = long bias; price below = short bias. ALMA applies Gaussian
weighting to reduce lag compared to EMAs of equivalent length, producing
fewer whipsaws at signal transitions.
Session Filter (toggleable): Entries are only permitted during defined
high-liquidity windows. London open (05:45-09:45 GMT), NY AM (12:00-16:00
GMT), and NY PM (19:00-21:00 GMT) can each be toggled independently.
Outside these windows the strategy does nothing. Most false signals in
forex and gold occur during low-volume inter-session periods.
TTM Squeeze (optional, off by default): Based on John Carter's published
TTM Squeeze concept. Compression detection (BB inside KC) is an independent
implementation using Pine built-ins only; Keltner Channel uses ATR via
Wilder's method. No momentum histogram is included — only the compression
gate is used. When Bollinger Bands contract inside the Keltner Channel the
market is in compression and entries are blocked. When BB expands back
outside the KC entries are permitted again. Enables lower-frequency,
post-compression entries when toggled on.
Exits: Fixed 3 ATR stop-loss and 6 ATR take-profit (2R) on every trade.
Position size is calculated so that 1% of equity is risked per trade at
the 3 ATR stop distance.
WHY THIS COMBINATION
ALMA provides direction bias with reduced lag. The session gate ensures
entries only occur when volume and institutional participation are highest.
Fixed ATR exits keep risk consistent across instruments and timeframes and
allow meaningful comparison of strategy performance across different market
conditions.
HOW TO USE
Enable the sessions that match your instrument. London + NY AM is the
default for forex and gold. Enable TTM Squeeze for lower-frequency,
higher-conviction setups. Best suited to 4H and 1H timeframes on XAUUSD,
GBPUSD, EURUSD, and major indices.
DEFAULT PROPERTIES
ATR Length: 14 | Stop: 3x ATR | Take Profit: 6x ATR (2R) | Risk: 1%
Commission: 0.01% per side | Slippage: 1 tick | Initial capital: 10,000
LIMITATIONS
Session filtering significantly reduces trade count. On 4H timeframes
expect 15-40 trades per year. To reach 100+ trades for a statistically
meaningful sample, backtest a minimum of 3-5 years on 1H or 8-10 years
on 4H. Past results do not guarantee future performance.
session windows using ALMA direction bias, with standardised ATR exits
(3 ATR stop, 6 ATR take profit — 2R fixed).
WHAT MAKES THIS ORIGINAL
Most trend strategies fire entries continuously throughout the trading day.
This strategy gates every entry through two independent filters before a
signal is accepted: a directional bias filter (ALMA) and a session timing
filter. Neither filter alone is the edge — the combination is. ALMA without
the session gate fires too many signals in low-liquidity periods. The session
gate without a directional filter trades noise in both directions. Together
they restrict entries to directional moves inside high-liquidity windows
where volume and participation are highest.
COMPONENTS
ALMA (Arnaud Legoux Moving Average, length 9): Direction baseline. Price
above ALMA = long bias; price below = short bias. ALMA applies Gaussian
weighting to reduce lag compared to EMAs of equivalent length, producing
fewer whipsaws at signal transitions.
Session Filter (toggleable): Entries are only permitted during defined
high-liquidity windows. London open (05:45-09:45 GMT), NY AM (12:00-16:00
GMT), and NY PM (19:00-21:00 GMT) can each be toggled independently.
Outside these windows the strategy does nothing. Most false signals in
forex and gold occur during low-volume inter-session periods.
TTM Squeeze (optional, off by default): Based on John Carter's published
TTM Squeeze concept. Compression detection (BB inside KC) is an independent
implementation using Pine built-ins only; Keltner Channel uses ATR via
Wilder's method. No momentum histogram is included — only the compression
gate is used. When Bollinger Bands contract inside the Keltner Channel the
market is in compression and entries are blocked. When BB expands back
outside the KC entries are permitted again. Enables lower-frequency,
post-compression entries when toggled on.
Exits: Fixed 3 ATR stop-loss and 6 ATR take-profit (2R) on every trade.
Position size is calculated so that 1% of equity is risked per trade at
the 3 ATR stop distance.
WHY THIS COMBINATION
ALMA provides direction bias with reduced lag. The session gate ensures
entries only occur when volume and institutional participation are highest.
Fixed ATR exits keep risk consistent across instruments and timeframes and
allow meaningful comparison of strategy performance across different market
conditions.
HOW TO USE
Enable the sessions that match your instrument. London + NY AM is the
default for forex and gold. Enable TTM Squeeze for lower-frequency,
higher-conviction setups. Best suited to 4H and 1H timeframes on XAUUSD,
GBPUSD, EURUSD, and major indices.
DEFAULT PROPERTIES
ATR Length: 14 | Stop: 3x ATR | Take Profit: 6x ATR (2R) | Risk: 1%
Commission: 0.01% per side | Slippage: 1 tick | Initial capital: 10,000
LIMITATIONS
Session filtering significantly reduces trade count. On 4H timeframes
expect 15-40 trades per year. To reach 100+ trades for a statistically
meaningful sample, backtest a minimum of 3-5 years on 1H or 8-10 years
on 4H. Past results do not guarantee future performance.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
We test strategies so you don't have to. Research: @backtestbay · Tools: backtestbay.gumroad.com
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
We test strategies so you don't have to. Research: @backtestbay · Tools: backtestbay.gumroad.com
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.