FVG Retest Entry Engine [trade_w_samet]🎯 FVG Retest Entry Engine
FVG Retest Entry Engine is a structured Fair Value Gap retest analysis indicator designed to help traders study confirmed gap reactions, structure alignment, filtered entry conditions, and multi-target visual trade models directly on the price chart.
This script focuses on one main concept:
FVG retest-based entry visualization.
It is not designed to be a simple buy/sell signal generator.
It is not designed to show every possible Fair Value Gap.
It is not designed to create constant chart noise.
Instead, the goal of FVG Retest Entry Engine is to detect confirmed structure events, identify eligible Fair Value Gaps, monitor their retests, apply configurable quality checkpoints, and visualize accepted setups using one entry level, one protective stop, and three take-profit levels.
The indicator includes:
• Bullish and bearish market-structure detection
• BOS and CHoCH classification
• Three-candle Fair Value Gap detection
• Internal FVG memory and invalidation handling
• Structure-linked FVG candidate selection
• FVG quality scoring and setup grading
• Armed-zone retest monitoring
• Multiple retest confirmation models
• Volume, Directional Force, and confirmed HTF bias filters
• FVG Retest Passport
• Blocker Lens state reporting
• Confirmed-close signal commitment
• Optional Live Preview dashboard state
• Gap-protected and ATR-based stop-loss models
• TP1, TP2, and TP3 risk-multiple projections
• Optional breakeven movement after TP1
• Active and historical TP / SL areas
• Executed FVG retest zones
• One-active-trade-at-a-time logic
• Mobile chart layout
• Multiple visual themes
• Advanced entry and lifecycle alerts
• JSON webhook support
• Compact bottom-right dashboard
The purpose of this script is to help users visually study where a structure event and an eligible Fair Value Gap combine with a confirmed retest condition.
It should be treated as a chart-analysis and educational decision-support tool.
It is not financial advice.
It is not an automated trading system.
It does not guarantee profitable trades.
It does not execute broker orders.
It does not replace personal analysis, risk management, or trade validation.
━━━━━━━━━━━━━━━━━━━━━━
📌 OVERVIEW
━━━━━━━━━━━━━━━━━━━━━━
At a high level, FVG Retest Entry Engine does the following:
• Detects confirmed bullish and bearish structure breaks.
• Classifies structure events as BOS or CHoCH.
• Detects bullish and bearish three-candle Fair Value Gaps.
• Stores valid FVG zones in internal memory.
• Tracks zone direction, boundaries, age, displacement, volume context, and prior interactions.
• Searches for an eligible FVG after a matching structure event.
• Scores and ranks available FVG candidates.
• Arms the best available zone for retest monitoring.
• Waits for the selected minimum retest delay.
• Detects the selected FVG retest pattern.
• Evaluates reaction quality and optional confluence filters.
• Assigns a setup grade such as A+, A, B, or FILTERED.
• Confirms final entry conditions only when the chart candle closes.
• Draws one Entry, one SL, and three TP levels.
• Tracks TP1, TP2, TP3, stop-loss, and breakeven events.
• Allows only one active trade projection at a time.
• Keeps completed trade areas when historical display is enabled.
• Marks completed models as bullish or bearish FVG Retest outcomes.
• Displays the current bias, engine state, and active levels in the dashboard.
• Provides entry, armed-zone, target, stop, breakeven, and webhook alert options.
The script is intentionally built as a structured process.
It does not include machine-learning prediction.
It does not include guaranteed performance claims.
It does not attempt to forecast every future market movement.
It provides a transparent way to study structure-linked FVG retests and their projected trade lifecycle.
━━━━━━━━━━━━━━━━━━━━━━
🧠 CORE IDEA
━━━━━━━━━━━━━━━━━━━━━━
The core idea behind FVG Retest Entry Engine is based on the relationship between market structure and Fair Value Gap reactions.
A Fair Value Gap represents a three-candle price imbalance.
A bullish FVG is formed when the current candle’s low is above the high from two candles earlier.
A bearish FVG is formed when the current candle’s high is below the low from two candles earlier.
The script does not treat every FVG as an entry.
Instead, it waits for a confirmed structure event and then searches for an eligible FVG that matches that directional context.
The selected FVG becomes an armed zone.
Price must later return to that zone and satisfy the chosen retest condition.
The engine can then evaluate:
• gap size relative to ATR
• formation displacement
• formation volume context
• FVG age
• prior zone interactions
• structure-break quality
• retest depth
• reaction-candle quality
• volume participation
• DI / ADX directional force
• confirmed higher-timeframe bias
• minimum setup grade
The goal is not to show more signals.
The goal is to create a documented and understandable process from structure event to confirmed FVG retest model.
━━━━━━━━━━━━━━━━━━━━━━
🧩 WHY THIS SCRIPT IS NOT A SIMPLE BUY/SELL INDICATOR
━━━━━━━━━━━━━━━━━━━━━━
FVG Retest Entry Engine is not intended to be used as a blind buy/sell system.
The script is structured as a visual review workflow:
Structure event is confirmed
→ matching FVG candidates are reviewed
→ one eligible FVG is selected
→ the FVG becomes armed
→ price returns to the armed zone
→ the retest pattern is checked
→ reaction quality is evaluated
→ enabled filters are checked
→ the setup receives a grade
→ the candle must close with all conditions still valid
→ Entry, SL, TP1, TP2, and TP3 are projected
→ the active model is monitored
→ the model closes at TP3, stop loss, targets complete, or breakeven
→ the completed FVG Retest model is archived visually
Each part has a specific purpose.
The structure system identifies a directional event.
The FVG memory system stores imbalance zones.
The candidate-ranking system selects a relevant gap instead of using every gap.
The armed-zone system separates observation from entry.
The retest logic defines what qualifies as a valid return.
The quality checkpoints reduce setups that fail enabled conditions.
The grading system summarizes internal setup quality.
The entry model provides visual planning levels.
The stop model creates a consistent risk reference.
The three-target model provides staged reward references.
The Blocker Lens explains the current engine state.
The Passport explains why an accepted setup qualified.
The alert system supports monitoring of confirmed events.
This makes the script a structured FVG retest analysis tool, not a guaranteed trade signal generator.
━━━━━━━━━━━━━━━━━━━━━━
⚙️ HOW THE SCRIPT WORKS
━━━━━━━━━━━━━━━━━━━━━━
The script operates through several connected stages.
First, it identifies confirmed swing highs and swing lows.
Price breaking a confirmed swing level can create a bullish or bearish structure event.
The break may be classified as BOS when it continues the current structure bias or CHoCH when it changes that bias.
The engine separately detects three-candle Fair Value Gaps and stores their contextual information.
bool tws_bullish_fvg = bar_index >= 2 and low > high
bool tws_bearish_fvg = bar_index >= 2 and high < low
float tws_bullish_fvg_top = low
float tws_bullish_fvg_bottom = high
float tws_bearish_fvg_top = low
float tws_bearish_fvg_bottom = high
float tws_bullish_fvg_size = tws_bullish_fvg_top - tws_bullish_fvg_bottom
float tws_bearish_fvg_size = tws_bearish_fvg_top - tws_bearish_fvg_bottom
When a structure event occurs, the engine reviews matching FVG candidates within the selected distance and timing limits.
The available candidates are compared using the active profile’s rules.
The selected zone becomes armed and remains under observation until:
• a confirmed retest creates an entry
• the setup expires
• the FVG is invalidated
• another structure search replaces it
Once price interacts with the armed zone, the selected retest model and reaction-quality conditions are checked.
Volume, DI / ADX, and higher-timeframe bias can also be required.
Only a setup that passes the active rules and remains valid at candle close can create a permanent entry model.
━━━━━━━━━━━━━━━━━━━━━━
🔵 BULLISH FVG RETEST LOGIC
━━━━━━━━━━━━━━━━━━━━━━
A bullish FVG Retest setup begins with bullish structure context.
The script requires a confirmed bullish BOS or CHoCH event and then searches for a directionally matching FVG candidate.
The selected zone must remain valid while the engine waits for price to return.
Depending on the chosen profile and retest model, bullish confirmation may require:
• wick contact with the zone
• real-body contact
• a close inside the zone
• a bullish reaction reclaim
• directional recovery above the zone midpoint
• a close above the relevant FVG edge
• a bullish rejection wick
The engine may then check:
• reaction strength
• volume participation
• positive DI dominance
• minimum ADX strength
• confirmed bullish HTF alignment
• minimum accepted grade
When every enabled condition remains valid at candle close, the script creates:
• a bullish FVG RETEST label
• an executed FVG retest box
• an entry reference at the confirmation close
• a protective stop below the setup reference
• TP1, TP2, and TP3 above entry
• blue reward visualization
• red risk visualization
This does not mean price must continue upward.
It means the script detected a bullish FVG retest condition that satisfied the selected rules at the time of confirmation.
━━━━━━━━━━━━━━━━━━━━━━
🔴 BEARISH FVG RETEST LOGIC
━━━━━━━━━━━━━━━━━━━━━━
A bearish FVG Retest setup begins with bearish structure context.
The script requires a confirmed bearish BOS or CHoCH event and then searches for a directionally matching FVG candidate.
The selected zone must remain valid while the engine waits for price to return.
Depending on the chosen profile and retest model, bearish confirmation may require:
• wick contact with the zone
• real-body contact
• a close inside the zone
• a bearish reaction reclaim
• directional recovery below the zone midpoint
• a close below the relevant FVG edge
• a bearish rejection wick
The engine may then check:
• reaction strength
• volume participation
• negative DI dominance
• minimum ADX strength
• confirmed bearish HTF alignment
• minimum accepted grade
When every enabled condition remains valid at candle close, the script creates:
• a bearish FVG RETEST label
• an executed FVG retest box
• an entry reference at the confirmation close
• a protective stop above the setup reference
• TP1, TP2, and TP3 below entry
• blue reward visualization
• red risk visualization
This does not mean price must continue downward.
It means the script detected a bearish FVG retest condition that satisfied the selected rules at the time of confirmation.
━━━━━━━━━━━━━━━━━━━━━━
💎 FVG QUALITY FILTER SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
The script includes a multi-layer FVG quality system to reduce unnecessary chart signals.
This is important because not every gap has the same context and not every retest should create an entry model.
The quality system may evaluate:
• minimum gap size relative to ATR
• displacement of the formation candle
• gap location inside the recent dealing range
• formation-volume context
• gap age
• previous interactions with the zone
• distance from the matching structure event
• structure-break strength
• reaction-candle strength
• volume participation on retest
• DI / ADX directional force
• confirmed HTF bias
• final setup grade
The exact behavior depends on the selected Engine Style.
Original Sync uses the first validated calibration and star-based acceptance logic.
Balanced Flow uses moderate filtering.
Precision Flow applies stricter FVG and retest requirements.
Fast Flow accepts more active conditions.
Position Flow uses wider structural and timing windows.
Custom Lab exposes the advanced thresholds for manual configuration.
The filter system does not guarantee better future outcomes.
It controls how selective the engine is before creating a confirmed visual model.
━━━━━━━━━━━━━━━━━━━━━━
📏 GAP / ATR FILTER
━━━━━━━━━━━━━━━━━━━━━━
The gap-width filter measures the detected FVG against ATR.
This helps the engine reject extremely small imbalance zones relative to current market volatility.
A higher minimum gap-width value makes FVG storage and candidate selection more selective.
A lower value allows smaller gaps to enter the internal memory.
The filter is volatility-adjusted because the same absolute price distance can have different meaning across symbols and timeframes.
The active threshold depends on the chosen profile or Custom Lab value.
A larger gap is not automatically a better setup.
Gap size is only one component of the complete selection and retest process.
━━━━━━━━━━━━━━━━━━━━━━
🕯️ DISPLACEMENT QUALITY FILTER
━━━━━━━━━━━━━━━━━━━━━━
The displacement filter evaluates the directional body of the candle associated with FVG formation.
The formation body is compared with ATR and converted into a bounded internal score.
This helps the script distinguish a stronger directional imbalance from a gap created during weak or narrow price action.
When the Gap Impulse Check is enabled, an FVG must satisfy the selected displacement threshold before it is stored as a valid candidate.
A higher threshold reduces the number of eligible FVGs.
A lower threshold accepts more moderate formations.
The displacement score is an internal quality measurement.
It does not predict whether the zone will hold in the future.
━━━━━━━━━━━━━━━━━━━━━━
📊 REACTION STRENGTH FILTER
━━━━━━━━━━━━━━━━━━━━━━
The reaction-strength filter evaluates the candle that interacts with the armed FVG.
The score can include:
• close location inside the candle
• directional wick quality
• body size relative to ATR
• bullish or bearish candle direction
• penetration depth inside the FVG
The purpose is to separate a basic touch from a more structured directional response.
A higher minimum reaction-strength value requires a clearer response from the zone.
A lower value accepts more retest conditions.
Original Sync can use its original reaction logic without the same adaptive score requirement.
The reaction score is not a win probability.
It is a standardized way to evaluate whether the retest candle matches the selected profile’s quality requirements.
━━━━━━━━━━━━━━━━━━━━━━
🧼 CONFIRMED RETEST FILTER
━━━━━━━━━━━━━━━━━━━━━━
The confirmed-retest layer requires price to satisfy the active retest model and remain valid at candle close.
Available Original Sync reaction patterns include:
• Any Wick Contact
• Real Body Contact
• Close Within Gap
• Reaction Reclaim
Available adaptive reaction models include:
• First Contact
• Directional Recovery
• Edge Reclaim
• Rejection Wick
First Contact accepts basic interaction with the zone.
Directional Recovery requires directional behavior after the interaction.
Edge Reclaim requires price to close through the relevant boundary.
Rejection Wick applies a stricter wick-and-close response.
The script can also use an interaction margin to tolerate minor boundary differences.
A minimum delay prevents the engine from confirming a retest too soon after the structure event.
An expiry window prevents stale armed zones from producing entries too far from their original context.
Final entry commitment remains bar-close based.
━━━━━━━━━━━━━━━━━━━━━━
🎯 ENTRY MODEL
━━━━━━━━━━━━━━━━━━━━━━
When an armed FVG retest passes all enabled conditions, the script creates a visual entry model.
The entry reference is the close of the candle that confirms the retest.
Permanent entries, labels, boxes, and entry alerts are committed only after candle close.
tws_preview_ready := tws_eval_zone_touched and tws_eval_reaction_pass and tws_direction_filters_pass and tws_eval_grade_pass
bool tws_confirmed_entry = tws_preview_ready and barstate.isconfirmed
if tws_confirmed_entry
tws_long_signal := tws_armed_direction == 1
tws_short_signal := tws_armed_direction == -1
tws_entry_event := true
tws_trade_active := true
tws_trade_direction := tws_armed_direction
tws_trade_open_bar := bar_index
tws_trade_entry := close
Confirmed Close mode waits for the candle to finish before the dashboard treats the setup as an entry.
Live Preview can show that current conditions are ready while the realtime candle is still open.
The preview may change intrabar because the candle is unfinished.
It does not create a permanent historical entry model unless the setup remains valid when the candle closes.
The entry is a visual analysis reference.
It is not a broker order and does not require the user to enter a trade.
━━━━━━━━━━━━━━━━━━━━━━
🛑 ATR STOP-LOSS MODEL
━━━━━━━━━━━━━━━━━━━━━━
The script includes two stop-placement models.
Gap-Protected Stop uses the selected FVG boundary plus an ATR-based protective buffer.
For bullish setups, the stop is projected below the FVG.
For bearish setups, the stop is projected above the FVG.
Volatility Stop projects the stop at an ATR multiple from entry.
A minimum stop-distance percentage can prevent extremely narrow visual stops.
float tws_raw_stop =
tws_stop_mode == "Gap-Protected Stop" ?
(
tws_trade_direction == 1 ?
tws_armed_bottom - tws_atr * tws_fvg_stop_buffer_atr :
tws_armed_top + tws_atr * tws_fvg_stop_buffer_atr
) :
(
tws_trade_direction == 1 ?
tws_trade_entry - tws_atr * tws_atr_stop_multiplier :
tws_trade_entry + tws_atr * tws_atr_stop_multiplier
)
float tws_raw_stop_distance = math.abs(tws_trade_entry - tws_raw_stop)
float tws_guaranteed_distance = tws_trade_entry * tws_minimum_stop_percent / 100.0
float tws_final_stop_distance = math.max(tws_raw_stop_distance, tws_guaranteed_distance)
ATR is used because volatility changes across markets and timeframes.
A wider stop changes the projected risk distance and therefore also changes all three target levels.
The displayed SL is a visual planning level only.
It does not place or manage a real broker stop order.
━━━━━━━━━━━━━━━━━━━━━━
🎯 TAKE-PROFIT RR MODEL
━━━━━━━━━━━━━━━━━━━━━━
The script uses three take-profit levels.
Each target is calculated from the distance between entry and the original stop.
float tws_trade_risk = math.abs(tws_trade_entry - tws_trade_original_stop)
tws_trade_tp1 := tws_trade_direction == 1 ? tws_trade_entry + tws_trade_risk * tws_tp1_r : tws_trade_entry - tws_trade_risk * tws_tp1_r
tws_trade_tp2 := tws_trade_direction == 1 ? tws_trade_entry + tws_trade_risk * tws_tp2_r : tws_trade_entry - tws_trade_risk * tws_tp2_r
tws_trade_tp3 := tws_trade_direction == 1 ? tws_trade_entry + tws_trade_risk * tws_tp3_r : tws_trade_entry - tws_trade_risk * tws_tp3_r
The default concept is:
TP1 = first risk-multiple target
TP2 = second risk-multiple target
TP3 = final risk-multiple target
The exact R values can be adjusted in Position Architecture.
The script also contains visual position-share percentages for TP1, TP2, and TP3.
These shares are used by the internal lifecycle model.
They do not represent a broker account, real position size, or verified financial performance.
The RR settings only control projected visual distances.
They should not be interpreted as recommendations or guaranteed objectives.
━━━━━━━━━━━━━━━━━━━━━━
📦 ACTIVE TP / SL BOX SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
When a confirmed FVG Retest entry appears, the script can draw a complete visual trade model.
The visual model includes:
• executed FVG retest zone
• entry line
• original stop line
• active stop line
• TP1 line
• TP2 line
• TP3 line
• red risk box
• blue reward box
• Entry price label
• SL price label
• TP1, TP2, and TP3 price labels
• bullish or bearish entry label
The active boxes extend to the right while the model is open.
When the model closes, the right edge is fixed at the closing candle.
If Keep Completed Trade Areas is enabled, completed boxes and lines remain visible for historical review.
The Completed Trade History Limit controls how many previous visual models are retained.
The TP area uses a blue-toned visual palette.
TP price labels use a different, darker background so they remain distinct from the reward box.
The SL area remains red for clearer risk separation.
━━━━━━━━━━━━━━━━━━━━━━
🚦 ONE ACTIVE TRADE AT A TIME
━━━━━━━━━━━━━━━━━━━━━━
The script includes one-active-trade-at-a-time logic.
If a trade model is active, the engine does not create another trade model until the current one closes.
The active model may close through:
• TP3
• targets complete
• stop loss
• breakeven exit
This design separates:
• FVG and structure detection
• trade-model creation permission
The engine can continue calculating market context while a model is active, but another entry model is not opened.
This helps prevent overlapping TP / SL areas and keeps the chart easier to interpret.
The one-active-model rule is a visual management decision.
It is not a restriction on the user’s personal trading activity.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ SAME-CANDLE TP / SL HANDLING
━━━━━━━━━━━━━━━━━━━━━━
If a target and the active stop are both touched on the same candle, standard OHLC data cannot reveal the true intrabar sequence.
The script therefore includes two selectable assumptions:
Protective First
Target First
Protective First assumes the stop is processed before target events.
Target First processes available target events before the stop check.
bool tws_conservative_mode =
tws_intrabar_priority == "Protective First"
if tws_conservative_mode and tws_stop_touched
tws_trade_remaining_percent := 0.0
tws_close_trade := true
tws_close_reason := tws_trade_active_stop == tws_trade_entry ? "BREAKEVEN" : "STOP LOSS"
tws_final_exit_price := tws_trade_active_stop
else
if not tws_tp1_reached and tws_tp1_touched
tws_tp1_reached := true
tws_tp1_event := true
Protective First is the more conservative bar-based assumption.
Target First is more optimistic.
Neither option reproduces exact tick-by-tick broker execution.
The model does not include spread, slippage, commissions, latency, or partial-fill behavior.
━━━━━━━━━━━━━━━━━━━━━━
🏷️ FVG RETEST LABELS
━━━━━━━━━━━━━━━━━━━━━━
The script uses clear directional FVG Retest labels.
Bullish entry labels use:
🟢 FVG RETEST
📈 LONG
Bearish entry labels use:
🔴 FVG RETEST
📉 SHORT
Entry labels can also display:
• grade
• setup score
• FVG age
• retest depth
• Passport information
Completed-model labels emphasize that the closed model originated from an FVG retest.
A completed bullish model can display:
🟢 BULLISH FVG RETEST
🔒 MODEL CLOSED
🎯 close reason
⭐ grade
TP1 / TP2 / TP3 status
A completed bearish model uses the corresponding bearish wording and color.
The labels do not display USD profit or account-profit claims.
All chart labels use bold and italic text formatting.
The signal-label size can be adjusted from the settings.
━━━━━━━━━━━━━━━━━━━━━━
📍 FVG ZONE DISPLAY MODES
━━━━━━━━━━━━━━━━━━━━━━
The FVG display system includes three modes:
Hidden
Selected Gap
All Active Gaps
Hidden mode removes active FVG memory boxes from the chart while allowing the engine to continue calculating them internally.
Selected Gap shows only the FVG currently armed for retest monitoring.
All Active Gaps displays every currently stored and valid FVG zone.
Show Executed FVG Retests separately controls whether the FVG zone that created an entry remains highlighted as part of the trade model.
The selected display mode affects visual presentation only.
It does not change the underlying FVG calculations.
For the cleanest chart, Selected Gap is generally the most focused mode.
All Active Gaps can be useful for research but may create more chart density.
━━━━━━━━━━━━━━━━━━━━━━
🧹 FVG INVALIDATION
━━━━━━━━━━━━━━━━━━━━━━
The script can automatically remove invalidated FVG zones.
A bullish FVG may be invalidated when confirmed price action closes through the zone in the opposite direction.
A bearish FVG may be invalidated when confirmed price action closes through its opposite boundary.
An armed zone can also be cleared when:
• its retest window expires
• the zone exceeds the permitted lifetime
• the internal memory limit removes an older gap
• the active structure search is replaced
When an armed FVG becomes invalid, the Blocker Lens can display FVG INVALIDATED.
When the retest window expires, it can display SETUP EXPIRED.
Removing invalidated or stale zones helps prevent outdated FVGs from creating later entries outside their intended context.
Users can disable automatic invalidation removal if they prefer to retain more zones visually.
━━━━━━━━━━━━━━━━━━━━━━
📟 DASHBOARD
━━━━━━━━━━━━━━━━━━━━━━
The script includes a compact dashboard positioned in the bottom-right corner.
The dashboard displays:
• BIAS
• STATE
• ENTRY
• TP1
• TP2
• TP3
• SL
BIAS uses the confirmed higher-timeframe filter when that filter is enabled and valid.
Otherwise, it reflects the current internal structure bias.
STATE is powered by the Blocker Lens.
Possible states include:
• WAITING STRUCTURE
• SCANNING FVG
• NO ELIGIBLE FVG
• FVG ARMED
• RETEST DELAY
• WAITING RETEST
• VOLUME BLOCK
• DI BLOCK
• HTF BLOCK
• WEAK REACTION
• GRADE BLOCK
• LIVE PREVIEW READY
• WAITING BAR CLOSE
• TRADE ACTIVE
• COOLDOWN
• SETUP EXPIRED
• FVG INVALIDATED
The dashboard size can be set to Micro, Compact, or Standard.
The dashboard is designed to summarize engine state and current price references.
It is not a performance report.
It is not a replacement for TradingView Strategy Tester.
━━━━━━━━━━━━━━━━━━━━━━
🚨 ALERT SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
FVG Retest Entry Engine includes advanced alert options for:
• FVG armed
• bullish FVG Retest entry
• bearish FVG Retest entry
• any FVG Retest entry
• TP1 reached
• TP2 reached
• TP3 reached
• breakeven activated
• stop loss
• breakeven exit
Alert packages include:
Off
Qualified Entries
Premium Entries
Full Lifecycle
Webhook JSON
Qualified Entries focuses on confirmed accepted entries.
Premium Entries applies stricter grade-based alert delivery.
Full Lifecycle includes entry and management events.
Webhook JSON sends structured event messages for external processing.
Alert Direction can be limited to Both Directions, Bullish Only, or Bearish Only.
Minimum Alert Grade can be set to All Qualified, A / A+, or A+ Only.
Alert filtering affects alert delivery only.
It does not change the chart’s signal calculations.
alertcondition(tws_armed_alert_event, title="trade_w_samet • FVG ARMED", message='trade_w_samet FVG ARMED | {{ticker}} | TF: {{interval}} | Score: {{plot("SIGNAL_SCORE")}}')
alertcondition(tws_entry_alert_event and tws_trade_direction == 1, title="trade_w_samet • BULLISH FVG RETEST", message='trade_w_samet BULLISH FVG RETEST | {{ticker}} | TF: {{interval}} | Score: {{plot("SIGNAL_SCORE")}} | Entry: {{plot("ENTRY")}} | SL: {{plot("SL")}} | TP1: {{plot("TP1")}} | TP2: {{plot("TP2")}} | TP3: {{plot("TP3")}}')
alertcondition(tws_entry_alert_event and tws_trade_direction == -1, title="trade_w_samet • BEARISH FVG RETEST", message='trade_w_samet BEARISH FVG RETEST | {{ticker}} | TF: {{interval}} | Score: {{plot("SIGNAL_SCORE")}} | Entry: {{plot("ENTRY")}} | SL: {{plot("SL")}} | TP1: {{plot("TP1")}} | TP2: {{plot("TP2")}} | TP3: {{plot("TP3")}}')
alertcondition(tws_tp1_alert_event, title="trade_w_samet • TP1 REACHED", message='trade_w_samet TP1 REACHED | {{ticker}} | TP1: {{plot("TP1")}}')
alertcondition(tws_stop_alert_event, title="trade_w_samet • STOP LOSS", message='trade_w_samet STOP LOSS | {{ticker}} | SL: {{plot("SL")}}')
Alerts are monitoring tools only.
They do not execute trades or place broker orders.
━━━━━━━━━━━━━━━━━━━━━━
🔔 HOW TO USE ALERTS
━━━━━━━━━━━━━━━━━━━━━━
A practical alert workflow:
1. Add FVG Retest Entry Engine to the chart.
2. Select the desired Engine Style and confirmation settings.
3. Open TradingView’s alert window.
4. Select the indicator as the alert condition.
5. Choose the desired entry or lifecycle condition.
6. Select the alert frequency appropriate for confirmed-candle monitoring.
7. Use the Alert Package, direction, and grade controls inside the indicator when needed.
8. Add a webhook URL only when using a compatible external workflow.
9. Test the alert configuration before depending on it.
10. Confirm every event with personal analysis and risk management.
For confirmed entry monitoring, users should avoid treating provisional realtime candle conditions as permanent signals.
Entry alerts are designed around the script’s confirmed event variables.
Alert delivery can still depend on TradingView servers, the user’s alert configuration, data availability, and any external webhook destination.
━━━━━━━━━━━━━━━━━━━━━━
🧪 HOW TO USE THE INDICATOR
━━━━━━━━━━━━━━━━━━━━━━
A practical workflow:
1. Add FVG Retest Entry Engine to a standard candlestick chart.
2. Begin with Original Sync or Balanced Flow.
3. Keep Signal Timing on Confirmed Close for the clearest workflow.
4. Use Selected Gap to keep the chart focused.
5. Observe the dashboard STATE value.
6. Wait for a confirmed structure event and an armed FVG.
7. Review the FVG zone before the retest occurs.
8. When price returns, allow the selected retest model and filters to complete.
9. Review the FVG Retest Passport when an entry appears.
10. Use the displayed Entry, SL, TP1, TP2, and TP3 as visual references only.
11. Evaluate whether the setup fits personal structure, liquidity, session, and risk rules.
12. Use alerts for monitoring rather than blind execution.
13. Review completed FVG Retest labels to understand the model lifecycle.
14. Test settings on the exact markets and timeframes personally studied.
The indicator is best used as a structured FVG retest review tool.
It should not be used as an automatic decision-maker.
━━━━━━━━━━━━━━━━━━━━━━
⚙️ SETTINGS REFERENCE
━━━━━━━━━━━━━━━━━━━━━━
⚡ Signal Blueprint
Engine Style
Controls the active configuration profile.
Available profiles:
Original Sync
Balanced Flow
Precision Flow
Fast Flow
Position Flow
Custom Lab
Allow Bullish Setups
Enables or disables bullish FVG Retest models.
Allow Bearish Setups
Enables or disables bearish FVG Retest models.
━━━━━━━━━━━━━━━━━━━━━━
🪪 Retest Experience
FVG Retest Passport
Controls whether Passport information is Off, Compact, or Detailed.
Show Blocker Lens
Shows or hides the engine STATE explanation in the dashboard.
Signal Timing
Selects Confirmed Close or Live Preview behavior.
Live Preview affects the dashboard’s provisional realtime state. Permanent entries remain candle-close confirmed.
━━━━━━━━━━━━━━━━━━━━━━
🧬 Original Sync Engine
Original Signal Calibration
Selects Manual Sync, Bitcoin Map, Ethereum Map, Solana Map, or Gold Map.
Structure Window
Controls pivot sensitivity in Manual Sync.
Minimum Gap Footprint — ATR
Controls the minimum FVG width.
Gap Lifetime
Controls how long stored FVGs remain eligible.
Gap Memory Capacity
Controls the number of stored zones.
Break-to-Gap Distance
Controls the maximum allowed distance between structure context and FVG eligibility.
After-Break Scan Window
Controls how long the engine continues searching after a break.
Reaction Pattern
Selects Any Wick Contact, Real Body Contact, Close Within Gap, or Reaction Reclaim.
Reaction Margin %
Adds tolerance around FVG boundaries.
Minimum Reaction Delay
Controls how many bars must pass before retest confirmation.
Reaction Expiry Bars
Controls how long the armed setup may wait.
Participation Multiplier
Controls the Original Sync volume requirement.
Minimum Directional Force
Controls the Original Sync ADX threshold.
Minimum Sync Rating
Controls the minimum accepted star rating.
Minimum Risk Distance %
Prevents extremely narrow stops.
━━━━━━━━━━━━━━━━━━━━━━
🧭 Structure Pulse
Structure Sensitivity
Controls pivot detection in Custom Lab.
Display Structure Tags
Shows or hides BOS / CHoCH labels.
Close-Lock Breaks
Requires a candle close beyond structure when enabled.
Break Momentum Check
Requires directional expansion on the break candle.
Break Body Threshold — ATR
Controls the required break-candle body size.
Break Clearance — ATR
Adds an ATR-based buffer beyond the structure level.
━━━━━━━━━━━━━━━━━━━━━━
🧱 Gap Intelligence
Minimum Gap Width — ATR
Controls the minimum stored FVG size.
Gap Impulse Check
Enables displacement filtering.
Minimum Gap Impulse
Controls the required formation displacement.
Minimum Gap Score
Controls the minimum candidate-quality score.
Allowed Prior Reactions
Controls how many previous zone interactions are accepted.
Gap Expiry Bars
Controls maximum FVG age.
Active Gap Capacity
Controls stored-zone capacity.
Maximum Structure Link
Controls the maximum structure-to-FVG distance.
Break Follow-Through Window
Controls post-break candidate scanning.
Delete Invalidated Gaps
Removes zones invalidated by confirmed opposite price action.
━━━━━━━━━━━━━━━━━━━━━━
🎯 Reaction Trigger
Reaction Model
Selects First Contact, Directional Recovery, Edge Reclaim, or Rejection Wick.
Gap Interaction Margin %
Adds tolerance around FVG boundaries.
Minimum Reaction Strength
Controls the required retest-candle score.
Reaction Delay Bars
Controls the minimum delay before retest confirmation.
Setup Expiry Bars
Controls how long the armed zone remains available.
Signal Cooldown Bars
Controls the delay after a completed model before another entry is permitted.
━━━━━━━━━━━━━━━━━━━━━━
🛂 Quality Checkpoints
Volume Participation Check
Enables or disables the retest-volume filter.
Volume Baseline Length
Controls the volume moving-average period.
Required Volume Expansion
Controls the required volume multiplier.
Directional Force Check
Enables or disables DI / ADX filtering.
Directional Force Length
Controls the DI period.
Trend Strength Smoothing
Controls ADX smoothing.
Minimum Trend Strength
Controls the required ADX value.
Higher-Timeframe Bias Check
Enables or disables HTF directional alignment.
Bias Timeframe
Selects the higher timeframe.
Bias Fast EMA
Controls the fast HTF EMA length.
Bias Slow EMA
Controls the slow HTF EMA length.
Minimum Setup Grade
Selects B Grade or Better, A Grade or Better, or A+ Only.
The HTF layer uses previous completed higher-timeframe values.
float tws_htf_close = request.security(
syminfo.tickerid,
tws_htf_timeframe,
close ,
barmerge.gaps_off,
barmerge.lookahead_on
)
float tws_htf_fast_ema = request.security(
syminfo.tickerid,
tws_htf_timeframe,
ta.ema(close, tws_htf_fast_length) ,
barmerge.gaps_off,
barmerge.lookahead_on
)
float tws_htf_slow_ema = request.security(
syminfo.tickerid,
tws_htf_timeframe,
ta.ema(close, tws_htf_slow_length) ,
barmerge.gaps_off,
barmerge.lookahead_on
)
━━━━━━━━━━━━━━━━━━━━━━
🛡️ Position Architecture
ATR Calculation Length
Controls ATR calculation.
Stop Placement Model
Selects Gap-Protected Stop or Volatility Stop.
Volatility Stop Multiplier
Controls ATR stop distance from entry.
Gap Stop Buffer — ATR
Controls the protective distance beyond the FVG.
Minimum Stop Distance %
Prevents extremely narrow risk zones.
TP1 Risk Multiple
Controls the first target distance.
TP2 Risk Multiple
Controls the second target distance.
TP3 Risk Multiple
Controls the final target distance.
TP1 Position Share %
Controls the internal visual share assigned to TP1.
TP2 Position Share %
Controls the internal visual share assigned to TP2.
TP3 Position Share %
Controls the internal visual share assigned to TP3.
Move Stop to Entry After TP1
Moves the active stop to entry after TP1 according to confirmed lifecycle rules.
Same-Candle Priority
Selects Protective First or Target First.
━━━━━━━━━━━━━━━━━━━━━━
🎨 Chart Design
Color System
Selects Obsidian Signal, Carbon Grid, Ivory Pulse, Neon Voltage, Acid Circuit, or Violet Flux.
Gap Display Mode
Selects Hidden, Selected Gap, or All Active Gaps.
Show Executed FVG Retests
Shows or hides the FVG zone used by a confirmed trade model.
Display TP / SL Areas
Shows or hides the reward and risk boxes.
Keep Completed Trade Areas
Keeps completed model boxes and lines.
Completed Trade History Limit
Controls the maximum historical visual models.
Active Area Projection
Controls the initial right-side projection length.
Chart Layout
Selects Desktop or Mobile.
Signal Label Size
Selects Micro, Compact, Standard, or Large.
Dashboard Size
Selects Micro, Compact, or Standard.
Display Bias EMA
Shows or hides the confirmed HTF fast EMA reference.
Display Setup Dashboard
Shows or hides the bottom-right dashboard.
━━━━━━━━━━━━━━━━━━━━━━
📡 Alert Center
Alert Package
Selects Off, Qualified Entries, Premium Entries, Full Lifecycle, or Webhook JSON.
Alert Direction
Selects Both Directions, Bullish Only, or Bearish Only.
Minimum Alert Grade
Selects All Qualified, A / A+, or A+ Only.
Alert When FVG Is Armed
Enables armed-zone alerts for compatible packages.
Alert When Stop Moves to Entry
Enables breakeven-activation alerts for compatible packages.
━━━━━━━━━━━━━━━━━━━━━━
🧠 WHAT MAKES THIS SCRIPT ORIGINAL
━━━━━━━━━━━━━━━━━━━━━━
FVG Retest Entry Engine uses familiar analytical concepts such as:
• Fair Value Gaps
• swing-point structure
• BOS and CHoCH
• ATR
• volume analysis
• DI / ADX
• higher-timeframe EMA bias
• risk/reward projection
• staged targets
• breakeven management
These concepts are not unique by themselves.
The originality of this script lies in how they are organized into a transparent FVG retest workflow:
Structure confirmation
→ directional FVG memory
→ contextual candidate comparison
→ selected armed zone
→ configurable retest validation
→ reaction-quality evaluation
→ optional volume, DI, and HTF checkpoints
→ setup grading
→ confirmed-close entry commitment
→ three-target visual management
→ optional breakeven movement
→ completed FVG Retest archiving
→ Blocker Lens state reporting
→ Passport explanation
→ lifecycle alerts
Distinctive implementation features include:
• structure-linked FVG selection instead of signaling every gap
• multiple Engine Style profiles
• Original Sync market calibrations
• an armed-zone state before entry
• candidate ranking using several FVG characteristics
• multiple retest models
• a visible reason when an entry is waiting or blocked
• a Passport explaining accepted setup context
• confirmed-close permanent signal commitment
• previous-completed HTF values
• executed FVG zone preservation
• three-stage target management
• Desktop and Mobile display modes
• alert filtering separated from chart calculations
This structure is designed to provide a focused and explainable review process without relying on hidden prediction claims.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ IMPORTANT PRACTICAL NOTES
━━━━━━━━━━━━━━━━━━━━━━
The script’s behavior depends heavily on settings and market conditions.
Signal frequency and visual output may change based on:
• Engine Style
• structure sensitivity
• close-based or wick-based breaks
• break momentum requirements
• minimum FVG width
• displacement filtering
• candidate-score threshold
• previous zone interactions
• FVG lifetime
• retest model
• reaction-strength threshold
• retest delay
• setup expiry
• volume filter settings
• DI / ADX settings
• HTF timeframe and EMA lengths
• minimum setup grade
• stop model
• target multiples
• signal cooldown
• timeframe
• symbol volatility
• market session
• available historical bars
A setting that appears clean on one market may behave differently on another.
A profile that produces suitable frequency on one timeframe may be too strict or too active on another.
Volume behavior can differ across asset classes and data providers.
Higher-timeframe filtering only operates as intended when the selected bias timeframe is genuinely higher than the chart timeframe.
Users should test the exact symbol, timeframe, profile, and session they personally study.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ LIMITATIONS AND SHORTCOMINGS
━━━━━━━━━━━━━━━━━━━━━━
This script has important limitations:
It does not guarantee profitable trades.
It does not predict future price movement.
It does not replace risk management.
It does not execute trades.
It does not place broker orders.
It does not include broker slippage.
It does not include commissions.
It does not include spreads.
It does not include execution delay.
It does not include partial-fill behavior.
It uses bar-based chart data.
Same-candle TP / SL order cannot be known from standard OHLC data.
Same-Candle Priority is a modeling assumption.
Live Preview can change intrabar because the realtime candle is unfinished.
Permanent entry models are committed only after bar close.
Confirmed pivots require future bars before becoming available as confirmed swing points.
The dashboard is not TradingView Strategy Tester.
The internal target-share model is not account-performance reporting.
Historical boxes and completed labels do not guarantee similar future behavior.
Setup grades are internal classifications, not win probabilities.
Filter settings do not guarantee improved future results.
Higher-timeframe values depend on selected timeframe and available data.
Data-feed revisions or chart-history differences can affect historical calculations.
Alert delivery depends on TradingView and the user’s alert configuration.
Webhook delivery also depends on the external destination.
One-active-trade logic is a visual management rule, not broker execution logic.
For these reasons, FVG Retest Entry Engine should be used as an educational decision-support and chart-analysis tool, not as a standalone automated trading strategy.
━━━━━━━━━━━━━━━━━━━━━━
👤 WHO THIS SCRIPT MAY BE USEFUL FOR
━━━━━━━━━━━━━━━━━━━━━━
This script may be useful for traders who:
• study Fair Value Gap retests
• use BOS and CHoCH context
• prefer selected FVGs instead of every raw gap
• want a visible armed-zone workflow
• want to understand why a setup is waiting or blocked
• prefer confirmed-close entries
• want a setup-grade framework
• want Entry, SL, TP1, TP2, and TP3 visualization
• want optional breakeven behavior
• want completed FVG Retest models preserved visually
• use higher-timeframe directional context
• want mobile-friendly chart presentation
• use lifecycle alerts for monitoring
• want a structured educational analysis framework
It may be less suitable for users who:
• want guaranteed buy/sell signals
• want a fully automated trading bot
• want every raw FVG to create an entry
• expect one profile to work on every market
• expect grades to represent guaranteed probability
• require exact tick-level execution simulation
• expect visual projections to match broker fills
• expect alerts to execute trades automatically
• want an indicator to replace independent decision-making
━━━━━━━━━━━━━━━━━━━━━━
🧭 BEST PRACTICE SUGGESTIONS
━━━━━━━━━━━━━━━━━━━━━━
For cleaner review:
• Start with Original Sync or Balanced Flow.
• Keep Signal Timing on Confirmed Close.
• Use Selected Gap to reduce chart clutter.
• Enable Blocker Lens while learning the engine workflow.
• Use Compact Passport for concise context.
• Use Detailed Passport when reviewing why a setup qualified.
• Review the armed FVG before the entry appears.
• Check whether the FVG retest agrees with personal market-structure analysis.
• Evaluate the displayed stop against nearby structure and volatility.
• Treat TP1, TP2, and TP3 as planning references only.
• Keep Protective First when a conservative same-candle assumption is preferred.
• Use Precision Flow when fewer, stricter setups are preferred.
• Use Fast Flow only after understanding its higher signal frequency.
• Use Custom Lab only after learning how each threshold affects the engine.
• Use Mobile layout on smaller screens.
• Use alerts for monitoring, not blind execution.
• Always apply independent analysis, risk management, and position sizing.
━━━━━━━━━━━━━━━━━━━━━━
🔓 PUBLICATION NOTE
━━━━━━━━━━━━━━━━━━━━━━
FVG Retest Entry Engine is published as an educational and visual market-analysis tool.
The purpose of this description is to explain:
• what the script does
• how structure events are confirmed
• how three-candle FVGs are detected
• how FVGs are stored and invalidated
• how structure and FVG candidates are linked
• how an FVG becomes armed
• how retest models work
• how reaction quality is evaluated
• how volume, DI / ADX, and HTF checkpoints operate
• how setup grades are assigned
• how Confirmed Close and Live Preview differ
• how Entry and stop levels are calculated
• how TP1, TP2, and TP3 are projected
• how breakeven and same-candle assumptions work
• how active and completed trade areas behave
• what the Passport and Blocker Lens show
• what the dashboard displays
• what the alert packages do
• what the limitations are
• how the indicator should and should not be used
The script is designed to support structured analysis.
It does not promise profitable results.
It does not remove market risk.
It does not execute trades.
It should not be used as a blind buy/sell system.
It is best used as a visual framework for reviewing structure-linked FVG retests and projected risk/reward behavior.
━━━━━━━━━━━━━━━━━━━━━━
🛡️ DISCLAIMER
━━━━━━━━━━━━━━━━━━━━━━
FVG Retest Entry Engine is provided for educational and informational purposes only.
It does not constitute financial, investment, trading, legal, or tax advice.
No indicator can guarantee future results.
Markets are uncertain, conditions change, and historical behavior does not ensure future performance.
Every user is responsible for their own analysis, validation, risk management, position sizing, alert configuration, trading decisions, and broker execution.
The structure labels, FVG zones, armed-zone states, Passport values, Blocker Lens messages, grades, scores, entry references, stop-loss levels, take-profit levels, TP / SL boxes, dashboard values, completed-model labels, and alerts are visual analysis tools only.
Use this script as a structured decision-support and visual review framework, not as a promise of profitability or a substitute for independent judgment.
Pine Script® indicator






















