OPEN-SOURCE SCRIPT
Protection Price (Wenhua / TDX)

A short-term support and stop-loss reference line adapted from the Wenhua/TDX trading platform community formula.
— FORMULA —
Protection Price = ( Close[2] + Close[1] + Open ) / 3
That is, the average of the two prior bars' closes and the current bar's open.
— INTERPRETATION —
• When price holds above the line, short-term structure favors continuation of the prevailing trend.
• A clean break below the line, particularly with expanding range or volume, often precedes a deeper pullback.
• Useful as a soft stop-loss anchor for swing positions.
— TIMEFRAME NOTE —
This indicator was designed for daily charts, where the three input bars span three trading sessions and carry meaningful overnight gap information. On lower intraday timeframes (5m, 15m) the line will naturally track close to price, behaving like a three-bar smoothing — this is expected, not a bug. For a true daily-level Protection Price displayed on an intraday chart, request the daily series via request.security().
— BEST PAIRED WITH —
"D/K Strength + Smart Money Accumulation" sub-chart indicator for complete entry and exit context.
A faithful Pine v6 port of the original community formula.
— FORMULA —
Protection Price = ( Close[2] + Close[1] + Open ) / 3
That is, the average of the two prior bars' closes and the current bar's open.
— INTERPRETATION —
• When price holds above the line, short-term structure favors continuation of the prevailing trend.
• A clean break below the line, particularly with expanding range or volume, often precedes a deeper pullback.
• Useful as a soft stop-loss anchor for swing positions.
— TIMEFRAME NOTE —
This indicator was designed for daily charts, where the three input bars span three trading sessions and carry meaningful overnight gap information. On lower intraday timeframes (5m, 15m) the line will naturally track close to price, behaving like a three-bar smoothing — this is expected, not a bug. For a true daily-level Protection Price displayed on an intraday chart, request the daily series via request.security().
— BEST PAIRED WITH —
"D/K Strength + Smart Money Accumulation" sub-chart indicator for complete entry and exit context.
A faithful Pine v6 port of the original community formula.
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.