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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
We test strategies so you don't have to. Research: @backtestbay · Tools: backtestbay.gumroad.com
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
We test strategies so you don't have to. Research: @backtestbay · Tools: backtestbay.gumroad.com
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。