OPEN-SOURCE SCRIPT
McGinley Dynamic + LWPI Confluence

WHAT IT DOES
This overlay combines two complementary reads of the market into a single confluence framework: the McGinley Dynamic, an adaptive trend line that speeds up when price runs and slows down in quiet conditions, and the Larry Williams Proxy Index (LWPI), a volatility-scaled balance-of-power oscillator. A signal prints only when both engines agree: trend direction from the McGinley Dynamic, momentum confirmation from the LWPI.
WHY COMBINE THEM
Every fixed-length moving average lags by a constant amount, which makes it too slow in fast markets and too jumpy in slow ones. The McGinley Dynamic addresses that by scaling its own smoothing factor with the ratio of price to its previous value — but, like any trend line, it says nothing about who is actually in control of the move. The LWPI measures exactly that: the average open-to-close pressure normalized by ATR. On its own, however, the LWPI whipsaws inside strong trends. Each component covers the other's blind spot, which is the reason for the mashup: the McGinley Dynamic decides direction, the LWPI decides timing.
HOW IT WORKS
1. Trend engine — McGinley Dynamic:
MD = MD[1] + (price - MD[1]) / max(k * N * (price / MD[1])^4, 1)
The fourth-power ratio term automatically widens the divisor when price stretches away from the line, reducing overshoot and whipsaw versus EMAs of comparable length. Price above the line = bullish regime (line plots green), below = bearish (red).
2. Momentum engine — LWPI:
LWPI = 50 * SMA(open - close, N) / ATR(N) + 50
Readings below 50 mean closes are dominating opens relative to volatility (buyers in control); above 50, sellers are in control. Optional smoothing (SMA/EMA/WMA/RMA) is available for noisy symbols.
3. Confluence logic:
- Long state: price above McGinley Dynamic AND LWPI below 50
- Short state: price below McGinley Dynamic AND LWPI above 50
A triangle prints on the first bar a state becomes active. The optional candle coloring shows the full extent of each state; the dashboard in the top-right corner summarizes trend, momentum and confluence at a glance.
4. ATR reference bands:
Dotted bands at +/- ATR * multiplier around price provide volatility context, e.g. for evaluating whether a stop distance is realistic for the symbol and timeframe. They are informational and not part of the signal logic.
HOW TO USE IT
Works on any market and timeframe; it was designed with trending instruments in mind (crypto, FX majors, index futures). A simple workflow: read the regime from the line color, wait for the LWPI to hand momentum back to the trend side, and use the confluence triangle as your alert to start analyzing — not as an automatic entry. The three built-in alerts (long confluence, short confluence, trend flip) let you monitor multiple symbols without watching charts.
SETTINGS
All defaults are textbook values, not curve-fitted: McGinley length 14 with the standard 0.6 constant from the original formula, LWPI period 8, ATR 14 with a 2.0 multiplier. Every input is documented with tooltips.
CREDITS
The McGinley Dynamic concept belongs to John R. McGinley, CMT. The Larry Williams Proxy Index concept was popularized on TradingView by loxx, whose open-source work this script's momentum component builds on, with thanks.
DISCLAIMER
This is an educational tool for market analysis. It is not financial advice and no performance is implied or promised. Always do your own research.
This overlay combines two complementary reads of the market into a single confluence framework: the McGinley Dynamic, an adaptive trend line that speeds up when price runs and slows down in quiet conditions, and the Larry Williams Proxy Index (LWPI), a volatility-scaled balance-of-power oscillator. A signal prints only when both engines agree: trend direction from the McGinley Dynamic, momentum confirmation from the LWPI.
WHY COMBINE THEM
Every fixed-length moving average lags by a constant amount, which makes it too slow in fast markets and too jumpy in slow ones. The McGinley Dynamic addresses that by scaling its own smoothing factor with the ratio of price to its previous value — but, like any trend line, it says nothing about who is actually in control of the move. The LWPI measures exactly that: the average open-to-close pressure normalized by ATR. On its own, however, the LWPI whipsaws inside strong trends. Each component covers the other's blind spot, which is the reason for the mashup: the McGinley Dynamic decides direction, the LWPI decides timing.
HOW IT WORKS
1. Trend engine — McGinley Dynamic:
MD = MD[1] + (price - MD[1]) / max(k * N * (price / MD[1])^4, 1)
The fourth-power ratio term automatically widens the divisor when price stretches away from the line, reducing overshoot and whipsaw versus EMAs of comparable length. Price above the line = bullish regime (line plots green), below = bearish (red).
2. Momentum engine — LWPI:
LWPI = 50 * SMA(open - close, N) / ATR(N) + 50
Readings below 50 mean closes are dominating opens relative to volatility (buyers in control); above 50, sellers are in control. Optional smoothing (SMA/EMA/WMA/RMA) is available for noisy symbols.
3. Confluence logic:
- Long state: price above McGinley Dynamic AND LWPI below 50
- Short state: price below McGinley Dynamic AND LWPI above 50
A triangle prints on the first bar a state becomes active. The optional candle coloring shows the full extent of each state; the dashboard in the top-right corner summarizes trend, momentum and confluence at a glance.
4. ATR reference bands:
Dotted bands at +/- ATR * multiplier around price provide volatility context, e.g. for evaluating whether a stop distance is realistic for the symbol and timeframe. They are informational and not part of the signal logic.
HOW TO USE IT
Works on any market and timeframe; it was designed with trending instruments in mind (crypto, FX majors, index futures). A simple workflow: read the regime from the line color, wait for the LWPI to hand momentum back to the trend side, and use the confluence triangle as your alert to start analyzing — not as an automatic entry. The three built-in alerts (long confluence, short confluence, trend flip) let you monitor multiple symbols without watching charts.
SETTINGS
All defaults are textbook values, not curve-fitted: McGinley length 14 with the standard 0.6 constant from the original formula, LWPI period 8, ATR 14 with a 2.0 multiplier. Every input is documented with tooltips.
CREDITS
The McGinley Dynamic concept belongs to John R. McGinley, CMT. The Larry Williams Proxy Index concept was popularized on TradingView by loxx, whose open-source work this script's momentum component builds on, with thanks.
DISCLAIMER
This is an educational tool for market analysis. It is not financial advice and no performance is implied or promised. Always do your own research.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.