OPEN-SOURCE SCRIPT
已更新 CNagda Anchor2Entry

CNagda Anchor2Entry Pine Script v6 overlay indicator pulls higher-timeframe (HTF) signal events to define anchor high/low levels and then projects visual entry labels on the lower-timeframe (LTF). It also draws auto-oriented Fibonacci retracement/extension levels for context, but it does not execute orders, stops, or targets—only visual guidance.
Inputs
Key inputs include Lookback Length for HTF scanning and a Signal Timeframe used with request.security to import HTF events onto the active chart.

Entry behavior can be set to “Confirm only” or “Wait candle,” trade side can be restricted to Buy/Sell/Both, and individual strategies (Buy WAIT/S1; Sell REV/S1/S2/S3) can be toggled.
HTF logic
The script defines WAIT/BUY setup and confirmation, SELL reversal on breaking the WAIT BUY low, and several volume/candle-based patterns (Sell S1/S2/S3, Buy S1).

It captures the associated highs/lows at those events with ta.valuewhen and imports them via request.security to form anchors (anc_hi/anc_lo) and “new trigger” booleans that gate label creation on the LTF.
Flip entries
When enabled, “Flip entries” generate contrarian labels based on breaking or confirming HTF anchors: crossing above anc_hi can trigger a flip-to-sell label, and crossing below anc_lo can trigger a flip-to-buy label.

The flip mode supports Immediate (on cross) or Confirm (on sustained break) to control how strict the trigger is.
Fibonacci drawing
User-specified Fib levels are parsed from a string, safely converted to floats, and drawn as dotted horizontal lines only when they fall inside an approximate visible viewport. Orientation (up or down) is decided automatically from pending signal direction and a simple context score (candle bias, trend, and price vs. mid), with efficient redraw/clear guards to avoid clutter.


Dynamic anchors
If HTF anchors are missing or too far from current price (checked with an ATR-based threshold), the script falls back to local swing highs/lows to keep the reference range relevant. This dynamic switch helps Fib levels and labels remain close to current market structure without manual intervention.
Signal labels
Labels are created only on confirmed bars to avoid repainting noise, with one “latest” label kept by deleting the previous one. The script places BUY/SELL labels for WAIT/CONFIRM, direct HTF patterns (Buy S1, Sell S1/S2/S3), and contrarian flip events, offset slightly from highs/lows with clear coloring and configurable sizes.
Visual context
Bars are softly colored (lime tint for bullish, orange tint for bearish) for quick context, and everything renders as an overlay on the price chart. Fib labels include a Δ readout (distance from current close), and line extension length, label sizes, and viewport padding are adjustable.
How to use
Set the Signal Timeframe and Lookback Length to establish which HTF structures and ranges will drive the anchors and entry conditions. Choose entry flow (Wait vs Confirm), enable Flip if contrarian triggers are desired, select the trade side, toggle strategies, and customize Fibonacci levels plus dynamic-anchor fallback for practical on-chart guidance.
Notes
This is a visual decision-support tool; it does not place trades, stops, or targets and should be validated on charts before live use. It is written for Pine Script v6 and relies heavily on request.security for HTF-to-LTF transfer of signals and anchors.
Inputs
Key inputs include Lookback Length for HTF scanning and a Signal Timeframe used with request.security to import HTF events onto the active chart.
Entry behavior can be set to “Confirm only” or “Wait candle,” trade side can be restricted to Buy/Sell/Both, and individual strategies (Buy WAIT/S1; Sell REV/S1/S2/S3) can be toggled.
HTF logic
The script defines WAIT/BUY setup and confirmation, SELL reversal on breaking the WAIT BUY low, and several volume/candle-based patterns (Sell S1/S2/S3, Buy S1).
It captures the associated highs/lows at those events with ta.valuewhen and imports them via request.security to form anchors (anc_hi/anc_lo) and “new trigger” booleans that gate label creation on the LTF.
Flip entries
When enabled, “Flip entries” generate contrarian labels based on breaking or confirming HTF anchors: crossing above anc_hi can trigger a flip-to-sell label, and crossing below anc_lo can trigger a flip-to-buy label.
The flip mode supports Immediate (on cross) or Confirm (on sustained break) to control how strict the trigger is.
Fibonacci drawing
User-specified Fib levels are parsed from a string, safely converted to floats, and drawn as dotted horizontal lines only when they fall inside an approximate visible viewport. Orientation (up or down) is decided automatically from pending signal direction and a simple context score (candle bias, trend, and price vs. mid), with efficient redraw/clear guards to avoid clutter.
Dynamic anchors
If HTF anchors are missing or too far from current price (checked with an ATR-based threshold), the script falls back to local swing highs/lows to keep the reference range relevant. This dynamic switch helps Fib levels and labels remain close to current market structure without manual intervention.
Signal labels
Labels are created only on confirmed bars to avoid repainting noise, with one “latest” label kept by deleting the previous one. The script places BUY/SELL labels for WAIT/CONFIRM, direct HTF patterns (Buy S1, Sell S1/S2/S3), and contrarian flip events, offset slightly from highs/lows with clear coloring and configurable sizes.
Visual context
Bars are softly colored (lime tint for bullish, orange tint for bearish) for quick context, and everything renders as an overlay on the price chart. Fib labels include a Δ readout (distance from current close), and line extension length, label sizes, and viewport padding are adjustable.
How to use
Set the Signal Timeframe and Lookback Length to establish which HTF structures and ranges will drive the anchors and entry conditions. Choose entry flow (Wait vs Confirm), enable Flip if contrarian triggers are desired, select the trade side, toggle strategies, and customize Fibonacci levels plus dynamic-anchor fallback for practical on-chart guidance.
Notes
This is a visual decision-support tool; it does not place trades, stops, or targets and should be validated on charts before live use. It is written for Pine Script v6 and relies heavily on request.security for HTF-to-LTF transfer of signals and anchors.
版本注释
Add Some New Improvement版本注释
Trendline Logic - Introduction and UsageTrendline Logic automatically identifies support and resistance trendlines on your chart and detects breakouts.
How it Works:
The indicator detects pivot points called Higher Lows and Lower Highs.
It connects these pivots to draw support (in green) and resistance (in red) trendlines on the chart.
These trendlines extend to the right (extend.right), meaning they are visible forward on the chart.
It notes when the price candle’s wick actually touches the trendline.
A breakout is considered valid only when at least 50% of the candle's body crosses to the other side of the trendline.
Once a breakout occurs, that trendline is automatically removed, and the indicator will create new trendlines based on new pivots.
Using this indicator, traders receive clear and accurate trendline breakout signals, helping in making better and easier trading decisions.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。