OPEN-SOURCE SCRIPT
MACD Momentum Entry Engine [trade_w_samet]

🎯 MACD Momentum Entry Engine [trade_w_samet]
MACD Momentum Entry Engine [trade_w_samet] is a structured momentum-analysis and visual trade-model indicator designed to help traders study confirmed MACD events, momentum quality, directional persistence, market regime, trend alignment, candle confirmation, and multi-target risk references directly from one coordinated workflow.
The script is built around one central idea:
A MACD event should not automatically become an entry signal.
Instead of treating every MACD crossover as equally meaningful, the engine first identifies the type of momentum event, then evaluates its strength, expansion, slope, acceleration, market environment, candle quality, directional persistence, and optional trend alignment before a permanent LONG or SHORT setup is accepted.
The indicator includes:
• Configurable MACD fast, slow, and signal lengths
• EMA, SMA, RMA, and WMA calculation options
• Early Trigger and Momentum Confirmed entry timing
• Reversal, Continuation, Zero-Line Reclaim, and Momentum Expansion setups
• A transparent 0–100 Momentum Quality Score
• Alignment, histogram strength, expansion, slope, and acceleration scoring
• Loose, Balanced, Strict, and Off quality modes
• A separate 0–100 Anti-Chop Market Regime Score
• ADX, price efficiency, EMA separation, and volatility-expansion analysis
• A separate 0–100 Entry Qualification Score
• Candle body, close location, MACD separation, persistence, impulse, and trigger-context analysis
• A final composite setup score
• A+, A, B, and C internal setup grades
• Optional chart EMA, confirmed higher-timeframe EMA, and combined trend bias
• Confirmed higher-timeframe calculations
• Zero-line directional filtering
• ATR-normalized absolute histogram-strength filtering
• Internal signal cooldown and same-bar re-entry protection
• One-active-trade-at-a-time visual management
• ATR-based and XAUUSD fixed-pip risk models
• Three visual take-profit levels
• Stop First and Targets First same-bar assumptions
• Equal-third internal trade-model accounting
• Active Entry, TP1, TP2, TP3, and SL lines
• Active reward and risk boxes on the main chart
• TP3-only historical trade-model preservation
• Separate SL, Closed TP1, Closed TP2, and TP3 result labels
• Adjustable LONG, SHORT, and result-label sizes
• MACD histogram, line, signal line, momentum background, and anti-chop background
• Neon LONG and SHORT dots directly on the MACD line
• A compact main-chart dashboard
• XAUUSD symbol verification and mismatch warning
• Static TradingView alert conditions
• Detailed dynamic alert() messages
• Data Window diagnostics
• Confirmed-close permanent signals
The purpose of this script is to provide a structured way to study when a MACD event is supported by broader momentum and market context.
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, position sizing, or risk management.

━━━━━━━━━━━━━━━━━━━━━━
📌 OVERVIEW
━━━━━━━━━━━━━━━━━━━━━━
At a high level, MACD Momentum Entry Engine does the following:
• Calculates a configurable MACD using the selected average types.
• Separates the visual histogram scale from the calculation scale.
• Detects confirmed MACD crossovers and zero-line events.
• Identifies Reversal, Continuation, Zero-Line Reclaim, and Expansion setup types.
• Optionally accepts the event immediately through Early Trigger mode.
• Optionally arms the setup and waits for renewed momentum through Momentum Confirmed mode.
• Measures momentum alignment, histogram strength, histogram expansion, MACD slope, and acceleration.
• Produces separate bullish and bearish 0–100 Momentum Quality Scores.
• Measures market regime using ADX, directional efficiency, EMA separation, and volatility expansion.
• Produces a separate 0–100 Market Regime Score.
• Evaluates candle direction, body quality, close location, MACD separation, persistence, and price impulse.
• Produces separate bullish and bearish Entry Qualification Scores.
• Combines momentum, regime, and entry quality into a final composite score.
• Assigns an internal A+, A, B, or C grade.
• Applies optional chart EMA and confirmed higher-timeframe EMA bias.
• Applies zero-line, absolute-strength, cooldown, and trade-slot controls.
• Confirms permanent LONG and SHORT signals only after candle close.
• Opens one visual trade model from the confirmed signal-bar close.
• Calculates Entry, Stop Loss, TP1, TP2, and TP3.
• Tracks targets and stop events from the next candle onward.
• Applies the selected same-bar processing assumption.
• Preserves completed TP3 models when historical display is enabled.
• Removes trade drawings after SL, Closed TP1, or Closed TP2 outcomes.
• Converts the original entry label into the final result for non-TP3 outcomes.
• Adds a separate electric-purple FULL TARGET label for TP3 outcomes.
• Displays Momentum, Trend, Regime, Trade, Last Result, and Protection states in the bottom-right dashboard.
• Provides static and dynamic alert options.
• Exposes diagnostic values through TradingView’s Data Window.
The indicator does not use machine-learning prediction.
Its scores are not probabilities.
Its labels do not promise future direction.
The script is a rule-based educational momentum framework that explains how a raw MACD event becomes an accepted or rejected setup.
━━━━━━━━━━━━━━━━━━━━━━
🧠 CORE IDEA
━━━━━━━━━━━━━━━━━━━━━━
The core idea behind MACD Momentum Entry Engine is that a crossover alone contains limited context.
A basic crossover only confirms that one MACD line has moved through another.
It does not automatically explain:
• whether the histogram is expanding
• whether momentum is accelerating
• whether the move is occurring in a directional or choppy market
• whether the signal candle supports the direction
• whether MACD separation is meaningful relative to recent behavior
• whether momentum has persisted
• whether price is aligned with an optional trend filter
• whether a recent signal already occurred
• whether a visual trade model is already active
The engine therefore uses a staged sequence:
MACD event
→ setup classification
→ momentum-quality scoring
→ optional trend-bias validation
→ anti-chop regime scoring
→ entry qualification
→ additional signal filters
→ confirmed signal
→ visual trade model
→ TP / SL lifecycle
→ result handling
For bullish conditions, the script studies upward MACD transitions, positive histogram alignment, renewed expansion, positive slope, positive acceleration, bullish candle behavior, and directional persistence.
For bearish conditions, the same process is mirrored.
The purpose is not to find the largest possible number of signals.
The purpose is to make the acceptance process visible, configurable, and understandable.
━━━━━━━━━━━━━━━━━━━━━━
🧩 WHY THIS SCRIPT IS NOT A SIMPLE BUY/SELL INDICATOR
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine is not designed to be used as a blind buy/sell system.
A raw MACD event must move through multiple stages:
A crossover or momentum event appears
→ the event is classified
→ the momentum-quality layer is evaluated
→ the trend-bias layer is evaluated
→ the anti-chop layer is evaluated
→ the candle and entry-quality layer is evaluated
→ zero-line and absolute-strength filters are checked
→ cooldown and active-trade restrictions are checked
→ the setup must remain valid at candle close
→ a permanent LONG or SHORT setup is printed
→ Entry, SL, TP1, TP2, and TP3 are projected
→ the trade model is monitored from the following candle
→ the model closes at TP3 or Stop
→ the final chart result is preserved or cleaned
Each module serves a different purpose.
The MACD core defines the momentum relationship.
The setup engine identifies what kind of event occurred.
The momentum-quality engine measures the internal strength of that event.
The anti-chop engine measures whether the broader environment is directional enough for the selected mode.
The entry-qualification engine evaluates the signal candle and immediate price response.
The trend-bias engine optionally restricts direction.
The trade engine standardizes the visual risk framework.
The dashboard explains the current engine state.
This makes the script a coordinated momentum-analysis workflow rather than a basic crossover marker.
━━━━━━━━━━━━━━━━━━━━━━
⚙️ HOW THE SCRIPT WORKS
━━━━━━━━━━━━━━━━━━━━━━
The script operates through connected calculation stages.
First, it calculates every supported moving-average type on every candle.
The selected average type is then used for the fast MACD average, slow MACD average, and signal average.
The MACD line is the difference between the selected fast and slow averages.
The histogram is the difference between the MACD line and the signal line.
Pine Script®
The histogram visual multiplier changes only the displayed column length.
It does not change:
• the MACD line
• the signal line
• the histogram used by calculations
• quality scores
• setup detection
• trade results
After the MACD core is calculated, the engine measures:
• absolute histogram strength
• one-bar histogram expansion
• MACD slope
• momentum acceleration
• adaptive baselines for each measurement
The setup engine then checks the enabled event types.
The quality, trend, regime, qualification, and additional-filter stages determine whether the setup is eligible.
A final permanent signal is accepted only after the candle closes and every enabled condition remains valid.
━━━━━━━━━━━━━━━━━━━━━━
🟢 BULLISH MACD MOMENTUM LOGIC
━━━━━━━━━━━━━━━━━━━━━━
A bullish setup begins with one of four enabled event types.
Bullish Reversal
A bullish MACD crossover occurs while the MACD line remains below zero.
This represents a momentum turn from the negative side of the zero line.
Bullish Continuation
A bullish MACD crossover occurs while the MACD line is at or above zero.
This represents renewed bullish alignment on the positive side.
Bullish Zero-Line Reclaim
The MACD line crosses above zero while:
• MACD is above the signal line
• the histogram is positive
• the bar is confirmed
Bullish Momentum Expansion
The histogram resumes positive expansion after a short contraction while:
• MACD remains above the signal line
• MACD slope is positive
• no new crossover is being used on the same bar
• no new zero-line cross is being used on the same bar
The event must then pass the active momentum-quality requirement.
When enabled, it must also pass:
• chart EMA bias
• confirmed higher-timeframe EMA bias
• EMA slope confirmation
• ATR distance from the trend EMA
• anti-chop regime requirement
• entry qualification
• bullish candle direction
• minimum MACD separation
• momentum persistence
• zero-line direction
• absolute histogram strength
• cooldown
• active-trade availability
The final signal uses confirmed-bar logic.
Pine Script®
When every active rule passes, the script can display:
• a neon green dot on the MACD line
• a LONG label on the main chart
• setup type, grade, and score information
• a visual Entry, SL, TP1, TP2, and TP3 model
This confirms that the configured bullish momentum conditions were valid at candle close.
It does not mean price must continue upward.
━━━━━━━━━━━━━━━━━━━━━━
🔴 BEARISH MACD MOMENTUM LOGIC
━━━━━━━━━━━━━━━━━━━━━━
A bearish setup mirrors the bullish process.
Bearish Reversal
A bearish MACD crossover occurs while the MACD line remains above zero.
This represents a momentum turn from the positive side of the zero line.
Bearish Continuation
A bearish MACD crossover occurs while the MACD line is at or below zero.
This represents renewed bearish alignment on the negative side.
Bearish Zero-Line Reclaim
The MACD line crosses below zero while:
• MACD is below the signal line
• the histogram is negative
• the bar is confirmed
Bearish Momentum Expansion
The histogram resumes negative expansion after a short contraction while:
• MACD remains below the signal line
• MACD slope is negative
• no new bearish crossover is being used on the same bar
• no new bearish zero-line cross is being used on the same bar
The setup must then pass the same quality, trend, regime, candle, separation, persistence, strength, cooldown, and trade-slot controls.
A permanent SHORT signal appears only when all active conditions remain valid at candle close.
The script can then display:
• a neon red dot on the MACD line
• a SHORT label on the main chart
• setup type, grade, and score information
• Entry, SL, TP1, TP2, and TP3 references
This confirms that the configured bearish momentum conditions were valid at candle close.
It does not guarantee continued downside movement.
━━━━━━━━━━━━━━━━━━━━━━
💎 MACD MOMENTUM QUALITY FILTER SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
The script includes a separate bullish and bearish Momentum Quality Score.
The quality layer evaluates five components.
Alignment — maximum 20 points
Bullish alignment requires:
• MACD above the signal line
• positive histogram
Bearish alignment requires:
• MACD below the signal line
• negative histogram
Histogram Strength — maximum 25 points
The absolute histogram value is compared with an adaptive EMA baseline.
This measures whether current separation is meaningful relative to recent MACD behavior.
Histogram Expansion — maximum 20 points
The engine measures the one-bar change in absolute histogram strength.
Points are awarded only when the histogram is expanding in the setup direction.
MACD Slope — maximum 20 points
Bullish setups require positive slope for this component.
Bearish setups require negative slope.
The slope magnitude is compared with its own adaptive baseline.
Momentum Acceleration — maximum 15 points
Acceleration measures the change in MACD slope.
Positive acceleration supports bullish scoring.
Negative acceleration supports bearish scoring.
Pine Script®
The available quality modes are:
Off
Removes the minimum Momentum Quality Score restriction.
Loose
Requires a minimum score of 45.
Balanced
Requires a minimum score of 60.
Strict
Requires a minimum score of 75 and is the default.
The score is not a win rate.
It is not a probability.
It measures how closely the current MACD event matches the engine’s momentum-strength framework.
━━━━━━━━━━━━━━━━━━━━━━
📏 VOLATILITY / ATR NORMALIZATION FILTER
━━━━━━━━━━━━━━━━━━━━━━
The indicator uses ATR normalization to compare certain values across changing volatility conditions.
The Absolute Strength Filter calculates:
Absolute Histogram Strength = |Histogram| / ATR × 100.
This value is used as an additional minimum-strength condition.
The default settings are:
• Normalization ATR Length: 14
• Minimum Absolute Strength: 1.0
• Use Absolute Strength Filter: enabled
ATR normalization helps reduce dependence on the raw numerical scale of a market.
For example, a raw MACD histogram value cannot be compared directly across instruments with very different prices and volatility.
Normalization places the histogram in relation to the instrument’s recent ATR.
The same ATR framework is also used by:
• optional price-to-EMA trend buffers
• EMA-separation regime measurement
• price-impulse scoring
• ATR-based trade management
ATR normalization does not make one configuration universal.
Symbols, sessions, exchanges, and data feeds can still behave differently.
━━━━━━━━━━━━━━━━━━━━━━
🕯️ DISPLACEMENT QUALITY FILTER
━━━━━━━━━━━━━━━━━━━━━━
The entry-qualification engine evaluates whether the signal candle shows enough directional response.
The Candle component contributes up to 25 points.
It is divided into:
Directional Body — maximum 12.5 points
For bullish setups, the engine measures the positive candle body relative to the full candle range.
For bearish setups, it measures the negative body.
Close Location — maximum 12.5 points
Bullish setups receive more points when the close is nearer the candle high.
Bearish setups receive more points when the close is nearer the candle low.
Price Impulse contributes up to 15 additional points.
The engine compares the one-bar directional price movement with ATR.
A bullish price impulse measures positive close-to-close displacement.
A bearish price impulse measures negative close-to-close displacement.
This layer does not predict the next candle.
It measures whether the completed signal candle supports the direction of the MACD event.
━━━━━━━━━━━━━━━━━━━━━━
📊 REACTION STRENGTH FILTER
━━━━━━━━━━━━━━━━━━━━━━
The engine includes a separate Entry Qualification Score.
Its components are:
Candle Quality — maximum 25 points
Combines directional body and close location.
MACD Separation — maximum 25 points
Measures current histogram separation relative to its adaptive baseline.
Momentum Persistence — maximum 20 points
Measures how long directional MACD and histogram alignment has remained active.
Price Impulse — maximum 15 points
Measures directional close-to-close movement relative to ATR.
Trigger Context — maximum 15 points
Confirms that an eligible setup event is currently active.
The total is limited to 0–100.
Available modes are:
Off
Removes the minimum Entry Qualification Score restriction.
Loose
Requires a minimum score of 45.
Balanced
Requires a minimum score of 60.
Strict
Requires a minimum score of 75 and is the default.
The final signal also uses internal candle-direction, separation, and persistence requirements.
These internal parameters remain active in the background to keep the public settings menu cleaner.
The Entry Qualification Score is not a verified accuracy figure.
It describes the quality of the completed entry context according to the script’s rules.
━━━━━━━━━━━━━━━━━━━━━━
🧼 CONFIRMED SIGNAL FILTER
━━━━━━━━━━━━━━━━━━━━━━
Permanent LONG and SHORT signals wait for candle close.
The engine uses confirmed-bar checks on:
• MACD crossovers
• zero-line crossings
• expansion triggers
• momentum confirmation
• final LONG and SHORT conditions
The higher-timeframe trend layer also uses previous completed higher-timeframe values.
Pine Script®
This approach prevents an unfinished higher-timeframe candle from becoming the permanent trend reference.
Entry Timing provides two workflows.
Early Trigger
Uses the confirmed setup event directly.
Momentum Confirmed
Arms the setup and waits for a later confirmed candle with:
• continued MACD alignment
• directional histogram
• renewed histogram expansion
• directional MACD slope
The confirmation opportunity is temporary.
If renewed momentum does not appear inside the internal window, the armed setup expires.
The script does not plot final signals into earlier candles.
Historical results can still change when:
• settings change
• symbol data changes
• timeframe changes
• the data provider revises history
• the available chart-history range changes
━━━━━━━━━━━━━━━━━━━━━━
🎯 ENTRY MODEL
━━━━━━━━━━━━━━━━━━━━━━
When a final LONG or SHORT setup passes every enabled condition, the trade engine can create a visual trade model.
The Entry reference is the close of the confirmed signal candle.
For a LONG model:
• Stop is below Entry
• TP1 is above Entry
• TP2 is above TP1
• TP3 is above TP2
For a SHORT model:
• Stop is above Entry
• TP1 is below Entry
• TP2 is below TP1
• TP3 is below TP2
Pine Script®
The model begins checking TP and SL from the following candle.
This prevents the signal candle’s earlier high or low from being treated as though it occurred after the close-based entry.
The engine stores:
• direction
• entry bar
• entry price
• stop price
• TP1 price
• TP2 price
• TP3 price
• initial risk
• target R values
• TP1 and TP2 progress
• setup type
• setup grade
• risk model
• original signal label
The displayed model is an educational chart reference.
It is not a broker order.
━━━━━━━━━━━━━━━━━━━━━━
🛑 ATR STOP-LOSS MODEL
━━━━━━━━━━━━━━━━━━━━━━
The indicator includes two risk models.
ATR Based
Stop distance is calculated as:
ATR × ATR Stop Multiplier.
The default settings are:
• ATR Length: 14
• ATR Stop Multiplier: 1.50
• TP1: 0.50R
• TP2: 1.00R
• TP3: 1.50R
The minimum distance is protected by the symbol’s minimum tick.
XAUUSD Fixed Pips
Stop and target distances use:
Selected Pips × XAUUSD Pip Size.
The default settings are:
• Pip Size: 0.01
• Stop Loss: 1000 pips
• TP1: 500 pips
• TP2: 1000 pips
• TP3: 1500 pips
Under the common 0.01 convention, those values correspond to:
• Stop distance: 10.00 price units
• TP1 distance: 5.00 price units
• TP2 distance: 10.00 price units
• TP3 distance: 15.00 price units
Broker conventions can differ.
Users should verify their symbol specification before relying on fixed-pip distances.
The XAUUSD protection system checks the symbol.
The dashboard shows:
• ✅ XAUUSD VERIFIED when XAUUSD Fixed Pips is used on a recognized XAUUSD symbol
• ⚠️ CHECK SYMBOL when the mode is used on another symbol
• 🛡️ ATR MODE when ATR Based is selected
The warning does not block calculations.
It tells the user to verify pip size and target distances.
━━━━━━━━━━━━━━━━━━━━━━
🎯 TAKE-PROFIT RR MODEL
━━━━━━━━━━━━━━━━━━━━━━
The visual model contains three take-profit levels.
ATR Based mode calculates targets from the initial stop distance:
TP1 Distance = Initial Risk × TP1 RR.
TP2 Distance = Initial Risk × TP2 RR.
TP3 Distance = Initial Risk × TP3 RR.
XAUUSD Fixed Pips mode uses independent fixed target distances.
The script enforces the following order:
TP1 < TP2 < TP3.
If a selected value would violate that order, the next target is moved at least one minimum tick beyond the prior target.
The trade model internally treats the position as three equal portions.
Each target represents one-third of the model.
If Stop is reached after TP1 or TP2, the script calculates an internal net-R result from:
• the portions already modeled as closed at reached targets
• the remaining portion or portions modeled at Stop
This internal calculation supports Data Window counters.
It is not broker-verified performance.
It does not account for:
• spread
• commission
• slippage
• latency
• partial-fill differences
• financing
• order rejection
• execution venue behavior
━━━━━━━━━━━━━━━━━━━━━━
📦 ACTIVE TP / SL BOX SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
When a confirmed trade model opens, the script can draw on the main chart:
• Entry line
• TP1 line
• TP2 line
• TP3 line
• Stop Loss line
• TP1 reward box
• TP2 reward box
• TP3 reward box
• SL risk box
• LONG or SHORT label
The Entry line is white.
The TP lines are green and initially dashed.
The SL line is red and solid.
The SL box uses a solid border.
When a target is reached:
• the corresponding box becomes more visible
• the corresponding target line becomes solid
• the target line becomes thicker
• the dynamic target alert can fire
When TP3 is reached:
• the complete model closes
• the original LONG or SHORT label remains
• a separate electric-purple TP3 FULL TARGET label appears
• the trade model can remain historically visible
When the model closes at Stop before TP3:
• all active boxes are deleted
• all active trade lines are deleted
• the original LONG or SHORT label is converted into the final result
• the final result becomes SL, CLOSED TP1, or CLOSED TP2
Only TP3 outcomes can retain completed historical boxes and lines.
This is a chart-cleanliness decision.
It does not imply that other outcomes did not occur.
━━━━━━━━━━━━━━━━━━━━━━
🚦 ONE ACTIVE TRADE AT A TIME
━━━━━━━━━━━━━━━━━━━━━━
The script uses one-active-trade-at-a-time visual management.
When the trade engine is enabled:
• a new trade model cannot open while another model is active
• a new trade cannot open on the same candle that closed the previous model
• the internal setup engine continues calculating
• permanent signals are restricted by trade-slot availability
This prevents overlapping Entry, TP, and SL structures.
It also keeps the trade lifecycle easier to interpret.
When the trade engine is disabled, qualified signals can still be evaluated without opening a visual trade model.
The one-active-model rule is a visual and analytical design choice.
It does not restrict the user’s personal trading activity.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ SAME-CANDLE TP / SL HANDLING
━━━━━━━━━━━━━━━━━━━━━━
Trade monitoring begins after the entry candle.
If a later historical candle touches both Stop and one or more targets, standard OHLC data does not reveal the exact intrabar sequence.
The indicator therefore provides two assumptions.
Stop First
If Stop and a target are both touched on the same candle, Stop is processed first.
This is the default and more conservative assumption.
Targets First
Reached targets are processed before Stop.
If TP3 is reached, the model closes at TP3.
Otherwise, remaining portions can close at Stop.
Neither mode reconstructs tick-level execution.
The indicator does not know:
• whether the high occurred before the low
• the bid/ask path
• actual fill sequence
• spread at the time
• slippage
• queue priority
• partial fills
The selected same-bar rule is a modeling assumption required by the limits of OHLC candles.
━━━━━━━━━━━━━━━━━━━━━━
🏷️ MACD MOMENTUM LABELS
━━━━━━━━━━━━━━━━━━━━━━
The indicator uses separate entry and result labels.
Entry labels display:
🚀 LONG
or:
🔴 SHORT
Entry Label Content provides:
Direction Only
Displays only LONG or SHORT.
Grade
Displays direction and setup grade.
Score + Grade
Displays direction, grade, and rounded composite score.
The default is Score + Grade.
LONG and SHORT label sizes can be adjusted independently.
Both default to Small.
The label tooltip contains:
• setup direction
• setup type
• setup grade
• composite score
• Momentum Quality Score
• Entry Qualification Score
• Market Regime Score
• trend-bias state
Result labels include:
🛑 SL
⚠️ CLOSED TP1
✅ CLOSED TP2
🏆 TP3 HIT
✅ FULL TARGET
SL, Closed TP1, and Closed TP2 transform the original entry label.
TP3 creates a separate result label and preserves the original entry label.
All chart-label text uses bold and italic formatting.
━━━━━━━━━━━━━━━━━━━━━━
📍 MACD DISPLAY MODES
━━━━━━━━━━━━━━━━━━━━━━
The indicator operates in a separate MACD pane while selected trade visuals, entry labels, and the dashboard are forced onto the main price chart.
The MACD pane can display:
MACD Line
A white line representing the difference between the selected fast and slow averages.
Signal Line
A red line representing the selected signal smoothing.
Histogram
Color changes communicate momentum condition:
• stronger green for bullish expansion
• softer green for bullish contraction
• stronger red for bearish expansion
• softer red for bearish contraction
Histogram Visual Length
The default multiplier is 1.60.
This changes visual column length only.
It does not affect calculations.
Neon Signal Dots
Qualified LONG setups produce a neon green glow and center dot on the MACD line.
Qualified SHORT setups produce a neon red glow and center dot.
Momentum Background
The pane background changes according to strong or weak bullish and bearish momentum states.
Anti-Chop Background
A neutral gray background can identify conditions blocked by the Anti-Chop Engine.
Each major visual element can be shown or hidden independently.
━━━━━━━━━━━━━━━━━━━━━━
🧹 SETUP INVALIDATION
━━━━━━━━━━━━━━━━━━━━━━
Not every raw MACD event remains eligible.
A setup can be rejected or expire because:
• its momentum score is below the selected threshold
• trend bias does not permit the direction
• the market regime is below the active Anti-Chop threshold
• the Entry Qualification Score is insufficient
• candle direction does not support the setup
• MACD separation is insufficient
• directional persistence is insufficient
• the zero-line filter blocks the direction
• normalized histogram strength is too low
• the signal cooldown is active
• another visual trade is active
• a trade closed on the current candle
• Momentum Confirmed mode does not receive renewed expansion in time
• an opposite raw setup replaces the armed direction
The internal cooldown is eight bars.
Momentum Confirmed mode uses a temporary internal confirmation window.
These background controls are intentionally not exposed as advanced public inputs.
They remain part of the engine’s consistency rules.
A rejected event is not displayed as a permanent entry signal.
━━━━━━━━━━━━━━━━━━━━━━
📟 DASHBOARD
━━━━━━━━━━━━━━━━━━━━━━
The indicator includes a compact dashboard in the bottom-right corner of the main price chart.
The dashboard displays:
Momentum
Possible states include:
• STRONG LONG
• LONG
• STRONG SHORT
• SHORT
• NEUTRAL
Trend
Possible states include:
• BULLISH
• BEARISH
• NEUTRAL
• OFF
Regime
Possible states include:
• TRENDING
• DEVELOPING
• CHOP
• OFF
Trade
Possible states include:
• WAITING
• LONG ACTIVE
• LONG TP1 REACHED
• LONG TP2 REACHED
• SHORT ACTIVE
• SHORT TP1 REACHED
• SHORT TP2 REACHED
Last
Displays the most recent closed model result:
• SL
• CLOSED TP1
• CLOSED TP2
• TP3
Protection
Displays:
• ATR MODE
• XAUUSD VERIFIED
• CHECK SYMBOL
The dashboard is not TradingView Strategy Tester.
It does not display audited brokerage results.
Its states are based on the indicator’s own rule-based calculations.
━━━━━━━━━━━━━━━━━━━━━━
🚨 ALERT SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine includes static TradingView alert conditions for:
• MACD Momentum LONG
• MACD Momentum SHORT
• TP1
• TP2
• TP3
• Stop Loss
• XAUUSD Mode Warning
The XAUUSD warning condition is limited to a qualified entry bar when Fixed Pips mode is active on a non-XAUUSD symbol.
The script also includes detailed dynamic alert() messages.
Dynamic Entry messages can include:
• direction
• symbol
• timeframe
• setup type
• setup grade
• composite score
• risk model
• Entry
• Stop Loss
• TP1
• TP2
• TP3
• XAUUSD mismatch warning when relevant
Dynamic target messages can include:
• target name
• direction
• symbol
• timeframe
• reached target price
• Entry
• Stop Loss
• TP1
• TP2
• TP3
Dynamic stop messages can include:
• final result
• direction
• symbol
• timeframe
• Entry
• exit price
• Stop Loss
• whether TP1 or TP2 was reached first
Alerts are monitoring tools.
They do not place or manage broker orders.
━━━━━━━━━━━━━━━━━━━━━━
🔔 HOW TO USE ALERTS
━━━━━━━━━━━━━━━━━━━━━━
For static conditions:
1. Add MACD Momentum Entry Engine [trade_w_samet] to the chart.
2. Open TradingView’s Create Alert window.
3. Select the indicator as the condition.
4. Choose LONG, SHORT, TP1, TP2, TP3, SL, or XAUUSD Mode Warning.
5. Select a frequency appropriate for confirmed-candle monitoring.
6. Test the alert before relying on it.
For detailed dynamic messages:
1. Enable Detailed Dynamic Alerts in the indicator settings.
2. Open TradingView’s Create Alert window.
3. Select MACD Momentum Entry Engine [trade_w_samet].
4. Select Any alert() function call.
5. Configure the delivery method.
6. Test the complete message format.
Alert delivery can depend on:
• TradingView servers
• the selected symbol
• the selected timeframe
• market-data availability
• realtime feed status
• user alert configuration
• webhook or external-service availability
Creating an alert does not guarantee broker execution.
━━━━━━━━━━━━━━━━━━━━━━
🧪 HOW TO USE THE INDICATOR
━━━━━━━━━━━━━━━━━━━━━━
A practical workflow:
1. Add MACD Momentum Entry Engine [trade_w_samet] to a standard candlestick chart.
2. Begin with the default MACD values of 12, 26, and 9.
3. Keep Entry Timing on Early Trigger while learning the setup types.
4. Keep Momentum Quality on Strict for the default selective profile.
5. Keep Anti-Chop on Strict.
6. Keep Entry Qualification on Strict.
7. Observe whether the event is Reversal, Continuation, Zero Reclaim, or Expansion.
8. Review the MACD histogram, line relationship, and neon signal dot.
9. Review the main-chart LONG or SHORT label.
10. Open the label tooltip to inspect the scores and setup type.
11. Review Momentum, Trend, Regime, Trade, Last Result, and Protection in the dashboard.
12. Verify the selected risk model.
13. When using XAUUSD Fixed Pips, confirm XAUUSD VERIFIED.
14. Treat Entry, SL, TP1, TP2, and TP3 as planning references.
15. Use alerts for monitoring rather than blind execution.
16. Compare every setup with personal structure, session, volatility, and risk rules.
17. Test the exact symbol, timeframe, session, and data feed personally used.
The indicator is designed for structured review.
It should not be treated as an automatic decision-maker.
━━━━━━━━━━━━━━━━━━━━━━
⚙️ SETTINGS REFERENCE
━━━━━━━━━━━━━━━━━━━━━━
⚙️ MACD Core
Calculation Source
Selects the price source used by the MACD calculation.
Fast Length
Controls the fast average.
Default: 12.
Slow Length
Controls the slow average.
Default: 26.
Signal Length
Controls signal-line smoothing.
Default: 9.
MACD Average Type
Selects EMA, SMA, RMA, or WMA for the fast and slow averages.
Signal Average Type
Selects EMA, SMA, RMA, or WMA for the signal line.
━━━━━━━━━━━━━━━━━━━━━━
🎯 Entry Engine
Entry Timing
Early Trigger accepts the confirmed setup event directly.
Momentum Confirmed waits for renewed directional histogram expansion and MACD continuation after the setup is armed.
━━━━━━━━━━━━━━━━━━━━━━
🧠 Momentum Quality Engine
Quality Filter
Selects Off, Loose, Balanced, or Strict.
Strict is the default.
The score combines:
• alignment
• histogram strength
• histogram expansion
• MACD slope
• momentum acceleration
━━━━━━━━━━━━━━━━━━━━━━
📈 Trend Bias Engine
Trend Bias Mode
Selects:
• Off
• Chart EMA
• Higher Timeframe EMA
• Combined EMA
Off is the default.
Trend EMA Length
Controls the chart and higher-timeframe EMA.
Default: 200.
Chart EMA Slope Lookback
Controls the chart-bar lookback used to evaluate EMA direction.
Require EMA Slope Confirmation
Requires a rising EMA for LONG and falling EMA for SHORT.
Higher Timeframe
Selects the confirmed higher-timeframe context.
Default: 60 minutes.
Price-to-EMA ATR Buffer
Requires an optional minimum ATR-normalized distance between price and the trend EMA.
Zero disables the distance requirement.
━━━━━━━━━━━━━━━━━━━━━━
🧱 Anti-Chop Engine
Anti-Chop Filter
Selects Off, Loose, Balanced, or Strict.
Strict is the default.
The regime score combines:
• ADX — 35 points
• price efficiency — 30 points
• EMA separation — 20 points
• volatility expansion — 15 points
━━━━━━━━━━━━━━━━━━━━━━
✅ Entry Qualification Engine
Enable Reversal Setups
Allows MACD crossovers on the opposite side of zero.
Enable Continuation Setups
Allows MACD crossovers on the directional side of zero.
Enable Zero-Line Reclaims
Allows confirmed MACD zero-line crossings with aligned histogram and signal-line conditions.
Enable Momentum Expansions
Allows renewed histogram expansion after contraction while MACD alignment remains valid.
Entry Qualification Filter
Selects Off, Loose, Balanced, or Strict.
Strict is the default.
The score combines:
• candle quality
• MACD separation
• persistence
• price impulse
• trigger context
━━━━━━━━━━━━━━━━━━━━━━
💼 Trade Management Engine
Enable Trade Engine
Enables the one-active-trade-at-a-time visual model.
Risk Model
Selects ATR Based or XAUUSD Fixed Pips.
XAUUSD Fixed Pips is the default.
ATR Length
Controls ATR for the adaptive model.
ATR Stop Multiplier
Controls stop distance in ATR mode.
ATR TP1 Risk/Reward
Controls TP1 distance in ATR mode.
ATR TP2 Risk/Reward
Controls TP2 distance in ATR mode.
ATR TP3 Risk/Reward
Controls TP3 distance in ATR mode.
XAUUSD Pip Size
Controls the price-unit value of one selected pip.
XAUUSD Stop-Loss Pips
Controls fixed Stop distance.
XAUUSD TP1 Pips
Controls fixed TP1 distance.
XAUUSD TP2 Pips
Controls fixed TP2 distance.
XAUUSD TP3 Pips
Controls fixed TP3 distance.
Same-Bar Resolution
Selects Stop First or Targets First.
Show Active TP / SL Zones
Shows Entry, targets, Stop, boxes, and lines on the main chart.
Keep Historical TP3 Zones
Preserves completed TP3 models.
Historical TP3 Trade Limit
Limits completed TP3 models retained on the chart.
Trade Result Labels
Enables SL, Closed TP1, Closed TP2, and TP3 result labels.
SL Label Size
Controls SL result size.
Closed TP1 Label Size
Controls Closed TP1 result size.
Closed TP2 Label Size
Controls Closed TP2 result size.
TP3 Label Size
Controls the separate FULL TARGET label size.
━━━━━━━━━━━━━━━━━━━━━━
🛡️ Signal Filters
Zero-Line Filter
Off allows both sides of zero.
Trend Direction requires LONG above zero and SHORT below zero.
Trend Direction is the default.
Use Absolute Strength Filter
Enables ATR-normalized minimum histogram strength.
Normalization ATR Length
Controls normalization.
Minimum Absolute Strength
Controls the required normalized histogram value.
━━━━━━━━━━━━━━━━━━━━━━
🎨 Visual Settings
Show MACD Line
Shows or hides the MACD line.
Show Signal Line
Shows or hides the signal line.
Show Histogram
Shows or hides histogram columns.
Histogram Visual Length
Changes histogram display scale without changing calculations.
Show MACD Neon Signal Dots
Shows qualified LONG and SHORT dots on the MACD line.
Show Momentum Background
Shows directional momentum background states.
Highlight Blocked Chop Conditions
Shows a neutral background when Anti-Chop blocks entries.
Show LONG / SHORT Labels
Shows or hides main-chart entry labels.
Entry Label Content
Selects Direction Only, Grade, or Score + Grade.
LONG Label Size
Controls LONG label size.
SHORT Label Size
Controls SHORT label size.
━━━━━━━━━━━━━━━━━━━━━━
📟 Mini Dashboard
Show Mini Dashboard
Shows or hides the compact bottom-right main-chart dashboard.
━━━━━━━━━━━━━━━━━━━━━━
🔔 Dynamic Alerts
Enable Detailed Dynamic Alerts
Enables runtime alert() messages.
For these messages, create the TradingView alert using:
Any alert() function call.
Input values are hidden from the status line.
MACD plot values are also prevented from creating status-line or price-scale labels, while diagnostic values remain available in the Data Window.
━━━━━━━━━━━━━━━━━━━━━━
🧠 WHAT MAKES THIS SCRIPT ORIGINAL
━━━━━━━━━━━━━━━━━━━━━━
MACD, moving averages, ATR, ADX, and trend filters are familiar technical-analysis concepts.
These concepts are not unique by themselves.
The originality of MACD Momentum Entry Engine lies in the coordinated process applied to a MACD event:
Configurable MACD event
→ setup-type classification
→ adaptive momentum-strength baselines
→ five-component Momentum Quality Score
→ optional confirmed trend-bias layer
→ four-component Anti-Chop Regime Score
→ five-component Entry Qualification Score
→ final composite score and grade
→ zero-line and normalized-strength validation
→ confirmed-close signal
→ one-active multi-target trade lifecycle
→ TP3-only historical preservation
→ non-TP3 visual cleanup
→ dynamic alerts
→ main-chart diagnostic dashboard
→ XAUUSD mode verification
Distinctive implementation features include:
• four separate setup families
• different logic for Reversal and Continuation crossovers
• zero-line reclaim detection
• renewed expansion detection without requiring a fresh crossover
• adaptive baselines for strength, expansion, slope, and acceleration
• separate bullish and bearish scoring
• a Momentum Quality Score independent from Entry Qualification
• an Anti-Chop Score independent from momentum quality
• confirmed previous higher-timeframe EMA values
• a 70/30 final composite structure
• A+, A, B, and C grades
• visual-only histogram scaling
• equal-third multi-target internal accounting
• same-candle processing assumptions
• XAUUSD symbol verification
• separate result behavior for TP3 and non-TP3 outcomes
• detailed Data Window diagnostics
The script is not a simple combination of unrelated indicators.
Every module supports the same objective: determining whether a confirmed MACD event has enough momentum, market, and entry context to become a permanent visual setup.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ IMPORTANT PRACTICAL NOTES
━━━━━━━━━━━━━━━━━━━━━━
Signal frequency depends on:
• fast, slow, and signal lengths
• selected average types
• Entry Timing
• enabled setup families
• Momentum Quality mode
• Trend Bias mode
• EMA length
• higher timeframe
• EMA slope requirement
• price-to-EMA buffer
• Anti-Chop mode
• Entry Qualification mode
• zero-line filter
• absolute-strength threshold
• symbol
• timeframe
• session
• volatility
• available history
• data provider
• active-trade state
Strict modes reduce accepted signals.
They do not guarantee better results.
Trend Bias Off allows the momentum engine to evaluate both directions without EMA permission.
Higher Timeframe EMA and Combined EMA should use a timeframe meaningfully above the chart timeframe.
XAUUSD Fixed Pips is designed around a selectable pip convention.
The default 0.01 value may not match every broker or synthetic symbol.
Momentum Confirmed produces later and potentially fewer signals than Early Trigger.
Histogram Visual Length does not alter logic.
Changing settings recalculates historical signals and trade models.
A setup that looks different after changing the chart range may be affected by available historical data and adaptive baselines.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ LIMITATIONS AND SHORTCOMINGS
━━━━━━━━━━━━━━━━━━━━━━
This script has important limitations:
It does not guarantee profitable trades.
It does not predict future price movement.
It does not execute orders.
It does not place broker stops or targets.
It does not include spread.
It does not include commission.
It does not include slippage.
It does not include latency.
It does not model partial fills.
It does not model financing or swap.
It uses bar-based OHLC data.
Historical candles do not reveal exact intrabar order.
Stop First and Targets First are assumptions.
The setup score is not a win probability.
A+ is not a guaranteed outcome.
The Anti-Chop Score cannot identify every ranging condition.
Trend filters can delay or block valid reversals.
Trend Bias Off can allow countertrend signals.
ATR normalization does not make settings universal.
Fixed-pip conventions can differ between brokers.
XAUUSD symbol detection cannot verify a broker’s contract specification.
The dashboard is not TradingView Strategy Tester.
Data Window counters are not audited account performance.
The internal R model assumes three equal portions.
The internal model does not represent real position sizing.
One-active-trade logic is a visual-management rule.
Alert delivery depends on TradingView and user configuration.
Changing settings changes historical calculations.
Changing symbol, exchange, session, timeframe, or feed can change signals.
Adaptive baselines depend on available chart history.
Confirmed higher-timeframe values reduce unfinished-HTF changes but introduce delay.
Permanent signals wait for candle close and therefore do not capture the earliest intrabar moment.
For these reasons, the indicator should be used as an educational decision-support tool, not as a standalone automated strategy.
━━━━━━━━━━━━━━━━━━━━━━
👤 WHO THIS SCRIPT MAY BE USEFUL FOR
━━━━━━━━━━━━━━━━━━━━━━
This script may be useful for traders who:
• already understand basic MACD behavior
• want more context than a raw crossover
• study momentum expansion and contraction
• distinguish reversal, continuation, zero-line, and expansion events
• want transparent setup scoring
• want an anti-chop layer
• want optional chart and higher-timeframe trend context
• prefer confirmed-close signals
• want Entry, SL, and three target references
• use XAUUSD and want configurable fixed-pip distances
• want symbol-mismatch warnings
• want a compact dashboard
• want detailed alerts
• want diagnostic Data Window values
• prefer one active visual model at a time
It may be less suitable for users who:
• want guaranteed signals
• want a fully automated trading bot
• want every MACD crossover displayed
• expect a score to equal probability
• expect one setting to work on every market
• require exact tick-level execution
• want Strategy Tester results from an indicator
• want the indicator to replace personal judgment
• expect alerts to execute broker orders automatically
━━━━━━━━━━━━━━━━━━━━━━
🧭 BEST PRACTICE SUGGESTIONS
━━━━━━━━━━━━━━━━━━━━━━
For the default selective profile:
• use standard candlesticks
• begin with MACD 12 / 26 / 9
• keep Entry Timing on Early Trigger
• keep Momentum Quality on Strict
• keep Anti-Chop on Strict
• keep Entry Qualification on Strict
• keep the Zero-Line Filter on Trend Direction
• keep Absolute Strength enabled
• keep all four setup families enabled while learning
• use the dashboard to identify blocked regime conditions
• verify the selected risk model before reviewing trade levels
• use Stop First for conservative historical same-bar handling
• confirm XAUUSD VERIFIED when using Fixed Pips
• use alerts for monitoring rather than blind execution
For additional frequency:
• change Momentum Quality from Strict to Balanced
• change Anti-Chop from Strict to Balanced
• change Entry Qualification from Strict to Balanced
• disable the Zero-Line Filter
• disable Absolute Strength
• keep Trend Bias Off
• use Early Trigger
For additional directional restriction:
• use Chart EMA, Higher Timeframe EMA, or Combined EMA
• enable EMA slope confirmation
• add a Price-to-EMA ATR Buffer
• use a higher timeframe above the chart timeframe
• use Momentum Confirmed instead of Early Trigger
Always:
• wait for the setup candle to close
• review the setup type
• review the score components
• verify market structure independently
• review session and volatility
• verify the stop distance
• use personal position sizing
• test the exact symbol and timeframe
• understand the same-bar assumption
• treat all projected levels as analytical references
━━━━━━━━━━━━━━━━━━━━━━
🔓 PUBLICATION NOTE
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine [trade_w_samet] is published as an educational momentum-analysis and visual trade-model tool.
The purpose of this description is to explain:
• how the configurable MACD core is calculated
• how average types affect the MACD and signal lines
• how setup events are classified
• how Reversal setups work
• how Continuation setups work
• how Zero-Line Reclaim setups work
• how Momentum Expansion setups work
• how Early Trigger and Momentum Confirmed differ
• how the Momentum Quality Score is constructed
• how adaptive momentum baselines work
• how the Anti-Chop Score is constructed
• how the Entry Qualification Score is constructed
• how final composite scores and grades are assigned
• how chart and confirmed higher-timeframe trend filters work
• how zero-line and absolute-strength filters work
• when permanent signals appear
• how the one-active-trade model works
• how Entry and Stop are calculated
• how TP1, TP2, and TP3 are calculated
• how same-candle ambiguity is handled
• how historical TP3 visuals are retained
• how non-TP3 visuals are cleaned
• how result labels behave
• what the dashboard displays
• how XAUUSD protection works
• what static and dynamic alerts contain
• what diagnostic values are available
• what the timing limitations are
• what the model does not simulate
• why familiar MACD concepts are organized into an original workflow
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 LONG/SHORT system.
MAIN CHART SCREENSHOT PLAN
Use one clean standard candlestick chart.
Show the indicator with its default settings.
The screenshot should contain:
• complete symbol and timeframe information
• the indicator name
• visible standard price candles
• one clear LONG or SHORT label
• one active or completed Entry / TP / SL model
• the white Entry line
• green TP1, TP2, and TP3 levels
• the red SL area and solid SL line
• the MACD pane
• the white MACD line
• the red signal line
• the green/red histogram
• one neon MACD signal dot
• the bottom-right main-chart dashboard
• the Protection state
Do not include:
• other indicators
• manual drawings
• unrelated labels
• social-media links
• pricing information
• promotional claims
• account-profit screenshots
• win-rate claims
• non-standard candles
• hidden symbol or timeframe information
• excessive zoom
• decorative graphics unrelated to the script
The screenshot should demonstrate normal default behavior and make the relationship between the MACD event, main-chart signal, trade model, and dashboard easy to understand.
━━━━━━━━━━━━━━━━━━━━━━
🛡️ DISCLAIMER
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine [trade_w_samet] 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.
Momentum changes.
Volatility changes.
Liquidity changes.
Historical chart behavior does not ensure future performance.
Every user is responsible for their own:
• analysis
• validation
• risk management
• position sizing
• alert configuration
• trading decisions
• broker execution
• legal obligations
• tax obligations
The MACD line, signal line, histogram, momentum states, setup types, quality scores, regime scores, entry scores, composite scores, grades, trend states, LONG and SHORT labels, Entry references, Stop Loss levels, take-profit levels, boxes, result labels, Data Window values, dashboard states, internal counters, and alerts are visual analysis tools only.
The displayed Entry is not a guaranteed fill.
The displayed Stop Loss is not a broker order.
The displayed TP1, TP2, and TP3 levels are not guaranteed objectives.
The Momentum Quality Score is not a win probability.
The Entry Qualification Score is not a probability.
The Market Regime Score is not a guarantee that a market is trending.
The A+, A, B, and C grades are not promises of performance.
The internal trade model does not include spread, commissions, slippage, latency, order-book conditions, contract specifications, or partial fills.
Use this script as a structured MACD momentum-review and decision-support framework, not as a promise of profitability or a substitute for independent judgment.
MACD Momentum Entry Engine [trade_w_samet] is a structured momentum-analysis and visual trade-model indicator designed to help traders study confirmed MACD events, momentum quality, directional persistence, market regime, trend alignment, candle confirmation, and multi-target risk references directly from one coordinated workflow.
The script is built around one central idea:
A MACD event should not automatically become an entry signal.
Instead of treating every MACD crossover as equally meaningful, the engine first identifies the type of momentum event, then evaluates its strength, expansion, slope, acceleration, market environment, candle quality, directional persistence, and optional trend alignment before a permanent LONG or SHORT setup is accepted.
The indicator includes:
• Configurable MACD fast, slow, and signal lengths
• EMA, SMA, RMA, and WMA calculation options
• Early Trigger and Momentum Confirmed entry timing
• Reversal, Continuation, Zero-Line Reclaim, and Momentum Expansion setups
• A transparent 0–100 Momentum Quality Score
• Alignment, histogram strength, expansion, slope, and acceleration scoring
• Loose, Balanced, Strict, and Off quality modes
• A separate 0–100 Anti-Chop Market Regime Score
• ADX, price efficiency, EMA separation, and volatility-expansion analysis
• A separate 0–100 Entry Qualification Score
• Candle body, close location, MACD separation, persistence, impulse, and trigger-context analysis
• A final composite setup score
• A+, A, B, and C internal setup grades
• Optional chart EMA, confirmed higher-timeframe EMA, and combined trend bias
• Confirmed higher-timeframe calculations
• Zero-line directional filtering
• ATR-normalized absolute histogram-strength filtering
• Internal signal cooldown and same-bar re-entry protection
• One-active-trade-at-a-time visual management
• ATR-based and XAUUSD fixed-pip risk models
• Three visual take-profit levels
• Stop First and Targets First same-bar assumptions
• Equal-third internal trade-model accounting
• Active Entry, TP1, TP2, TP3, and SL lines
• Active reward and risk boxes on the main chart
• TP3-only historical trade-model preservation
• Separate SL, Closed TP1, Closed TP2, and TP3 result labels
• Adjustable LONG, SHORT, and result-label sizes
• MACD histogram, line, signal line, momentum background, and anti-chop background
• Neon LONG and SHORT dots directly on the MACD line
• A compact main-chart dashboard
• XAUUSD symbol verification and mismatch warning
• Static TradingView alert conditions
• Detailed dynamic alert() messages
• Data Window diagnostics
• Confirmed-close permanent signals
The purpose of this script is to provide a structured way to study when a MACD event is supported by broader momentum and market context.
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, position sizing, or risk management.
━━━━━━━━━━━━━━━━━━━━━━
📌 OVERVIEW
━━━━━━━━━━━━━━━━━━━━━━
At a high level, MACD Momentum Entry Engine does the following:
• Calculates a configurable MACD using the selected average types.
• Separates the visual histogram scale from the calculation scale.
• Detects confirmed MACD crossovers and zero-line events.
• Identifies Reversal, Continuation, Zero-Line Reclaim, and Expansion setup types.
• Optionally accepts the event immediately through Early Trigger mode.
• Optionally arms the setup and waits for renewed momentum through Momentum Confirmed mode.
• Measures momentum alignment, histogram strength, histogram expansion, MACD slope, and acceleration.
• Produces separate bullish and bearish 0–100 Momentum Quality Scores.
• Measures market regime using ADX, directional efficiency, EMA separation, and volatility expansion.
• Produces a separate 0–100 Market Regime Score.
• Evaluates candle direction, body quality, close location, MACD separation, persistence, and price impulse.
• Produces separate bullish and bearish Entry Qualification Scores.
• Combines momentum, regime, and entry quality into a final composite score.
• Assigns an internal A+, A, B, or C grade.
• Applies optional chart EMA and confirmed higher-timeframe EMA bias.
• Applies zero-line, absolute-strength, cooldown, and trade-slot controls.
• Confirms permanent LONG and SHORT signals only after candle close.
• Opens one visual trade model from the confirmed signal-bar close.
• Calculates Entry, Stop Loss, TP1, TP2, and TP3.
• Tracks targets and stop events from the next candle onward.
• Applies the selected same-bar processing assumption.
• Preserves completed TP3 models when historical display is enabled.
• Removes trade drawings after SL, Closed TP1, or Closed TP2 outcomes.
• Converts the original entry label into the final result for non-TP3 outcomes.
• Adds a separate electric-purple FULL TARGET label for TP3 outcomes.
• Displays Momentum, Trend, Regime, Trade, Last Result, and Protection states in the bottom-right dashboard.
• Provides static and dynamic alert options.
• Exposes diagnostic values through TradingView’s Data Window.
The indicator does not use machine-learning prediction.
Its scores are not probabilities.
Its labels do not promise future direction.
The script is a rule-based educational momentum framework that explains how a raw MACD event becomes an accepted or rejected setup.
━━━━━━━━━━━━━━━━━━━━━━
🧠 CORE IDEA
━━━━━━━━━━━━━━━━━━━━━━
The core idea behind MACD Momentum Entry Engine is that a crossover alone contains limited context.
A basic crossover only confirms that one MACD line has moved through another.
It does not automatically explain:
• whether the histogram is expanding
• whether momentum is accelerating
• whether the move is occurring in a directional or choppy market
• whether the signal candle supports the direction
• whether MACD separation is meaningful relative to recent behavior
• whether momentum has persisted
• whether price is aligned with an optional trend filter
• whether a recent signal already occurred
• whether a visual trade model is already active
The engine therefore uses a staged sequence:
MACD event
→ setup classification
→ momentum-quality scoring
→ optional trend-bias validation
→ anti-chop regime scoring
→ entry qualification
→ additional signal filters
→ confirmed signal
→ visual trade model
→ TP / SL lifecycle
→ result handling
For bullish conditions, the script studies upward MACD transitions, positive histogram alignment, renewed expansion, positive slope, positive acceleration, bullish candle behavior, and directional persistence.
For bearish conditions, the same process is mirrored.
The purpose is not to find the largest possible number of signals.
The purpose is to make the acceptance process visible, configurable, and understandable.
━━━━━━━━━━━━━━━━━━━━━━
🧩 WHY THIS SCRIPT IS NOT A SIMPLE BUY/SELL INDICATOR
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine is not designed to be used as a blind buy/sell system.
A raw MACD event must move through multiple stages:
A crossover or momentum event appears
→ the event is classified
→ the momentum-quality layer is evaluated
→ the trend-bias layer is evaluated
→ the anti-chop layer is evaluated
→ the candle and entry-quality layer is evaluated
→ zero-line and absolute-strength filters are checked
→ cooldown and active-trade restrictions are checked
→ the setup must remain valid at candle close
→ a permanent LONG or SHORT setup is printed
→ Entry, SL, TP1, TP2, and TP3 are projected
→ the trade model is monitored from the following candle
→ the model closes at TP3 or Stop
→ the final chart result is preserved or cleaned
Each module serves a different purpose.
The MACD core defines the momentum relationship.
The setup engine identifies what kind of event occurred.
The momentum-quality engine measures the internal strength of that event.
The anti-chop engine measures whether the broader environment is directional enough for the selected mode.
The entry-qualification engine evaluates the signal candle and immediate price response.
The trend-bias engine optionally restricts direction.
The trade engine standardizes the visual risk framework.
The dashboard explains the current engine state.
This makes the script a coordinated momentum-analysis workflow rather than a basic crossover marker.
━━━━━━━━━━━━━━━━━━━━━━
⚙️ HOW THE SCRIPT WORKS
━━━━━━━━━━━━━━━━━━━━━━
The script operates through connected calculation stages.
First, it calculates every supported moving-average type on every candle.
The selected average type is then used for the fast MACD average, slow MACD average, and signal average.
The MACD line is the difference between the selected fast and slow averages.
The histogram is the difference between the MACD line and the signal line.
The histogram visual multiplier changes only the displayed column length.
It does not change:
• the MACD line
• the signal line
• the histogram used by calculations
• quality scores
• setup detection
• trade results
After the MACD core is calculated, the engine measures:
• absolute histogram strength
• one-bar histogram expansion
• MACD slope
• momentum acceleration
• adaptive baselines for each measurement
The setup engine then checks the enabled event types.
The quality, trend, regime, qualification, and additional-filter stages determine whether the setup is eligible.
A final permanent signal is accepted only after the candle closes and every enabled condition remains valid.
━━━━━━━━━━━━━━━━━━━━━━
🟢 BULLISH MACD MOMENTUM LOGIC
━━━━━━━━━━━━━━━━━━━━━━
A bullish setup begins with one of four enabled event types.
Bullish Reversal
A bullish MACD crossover occurs while the MACD line remains below zero.
This represents a momentum turn from the negative side of the zero line.
Bullish Continuation
A bullish MACD crossover occurs while the MACD line is at or above zero.
This represents renewed bullish alignment on the positive side.
Bullish Zero-Line Reclaim
The MACD line crosses above zero while:
• MACD is above the signal line
• the histogram is positive
• the bar is confirmed
Bullish Momentum Expansion
The histogram resumes positive expansion after a short contraction while:
• MACD remains above the signal line
• MACD slope is positive
• no new crossover is being used on the same bar
• no new zero-line cross is being used on the same bar
The event must then pass the active momentum-quality requirement.
When enabled, it must also pass:
• chart EMA bias
• confirmed higher-timeframe EMA bias
• EMA slope confirmation
• ATR distance from the trend EMA
• anti-chop regime requirement
• entry qualification
• bullish candle direction
• minimum MACD separation
• momentum persistence
• zero-line direction
• absolute histogram strength
• cooldown
• active-trade availability
The final signal uses confirmed-bar logic.
When every active rule passes, the script can display:
• a neon green dot on the MACD line
• a LONG label on the main chart
• setup type, grade, and score information
• a visual Entry, SL, TP1, TP2, and TP3 model
This confirms that the configured bullish momentum conditions were valid at candle close.
It does not mean price must continue upward.
━━━━━━━━━━━━━━━━━━━━━━
🔴 BEARISH MACD MOMENTUM LOGIC
━━━━━━━━━━━━━━━━━━━━━━
A bearish setup mirrors the bullish process.
Bearish Reversal
A bearish MACD crossover occurs while the MACD line remains above zero.
This represents a momentum turn from the positive side of the zero line.
Bearish Continuation
A bearish MACD crossover occurs while the MACD line is at or below zero.
This represents renewed bearish alignment on the negative side.
Bearish Zero-Line Reclaim
The MACD line crosses below zero while:
• MACD is below the signal line
• the histogram is negative
• the bar is confirmed
Bearish Momentum Expansion
The histogram resumes negative expansion after a short contraction while:
• MACD remains below the signal line
• MACD slope is negative
• no new bearish crossover is being used on the same bar
• no new bearish zero-line cross is being used on the same bar
The setup must then pass the same quality, trend, regime, candle, separation, persistence, strength, cooldown, and trade-slot controls.
A permanent SHORT signal appears only when all active conditions remain valid at candle close.
The script can then display:
• a neon red dot on the MACD line
• a SHORT label on the main chart
• setup type, grade, and score information
• Entry, SL, TP1, TP2, and TP3 references
This confirms that the configured bearish momentum conditions were valid at candle close.
It does not guarantee continued downside movement.
━━━━━━━━━━━━━━━━━━━━━━
💎 MACD MOMENTUM QUALITY FILTER SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
The script includes a separate bullish and bearish Momentum Quality Score.
The quality layer evaluates five components.
Alignment — maximum 20 points
Bullish alignment requires:
• MACD above the signal line
• positive histogram
Bearish alignment requires:
• MACD below the signal line
• negative histogram
Histogram Strength — maximum 25 points
The absolute histogram value is compared with an adaptive EMA baseline.
This measures whether current separation is meaningful relative to recent MACD behavior.
Histogram Expansion — maximum 20 points
The engine measures the one-bar change in absolute histogram strength.
Points are awarded only when the histogram is expanding in the setup direction.
MACD Slope — maximum 20 points
Bullish setups require positive slope for this component.
Bearish setups require negative slope.
The slope magnitude is compared with its own adaptive baseline.
Momentum Acceleration — maximum 15 points
Acceleration measures the change in MACD slope.
Positive acceleration supports bullish scoring.
Negative acceleration supports bearish scoring.
The available quality modes are:
Off
Removes the minimum Momentum Quality Score restriction.
Loose
Requires a minimum score of 45.
Balanced
Requires a minimum score of 60.
Strict
Requires a minimum score of 75 and is the default.
The score is not a win rate.
It is not a probability.
It measures how closely the current MACD event matches the engine’s momentum-strength framework.
━━━━━━━━━━━━━━━━━━━━━━
📏 VOLATILITY / ATR NORMALIZATION FILTER
━━━━━━━━━━━━━━━━━━━━━━
The indicator uses ATR normalization to compare certain values across changing volatility conditions.
The Absolute Strength Filter calculates:
Absolute Histogram Strength = |Histogram| / ATR × 100.
This value is used as an additional minimum-strength condition.
The default settings are:
• Normalization ATR Length: 14
• Minimum Absolute Strength: 1.0
• Use Absolute Strength Filter: enabled
ATR normalization helps reduce dependence on the raw numerical scale of a market.
For example, a raw MACD histogram value cannot be compared directly across instruments with very different prices and volatility.
Normalization places the histogram in relation to the instrument’s recent ATR.
The same ATR framework is also used by:
• optional price-to-EMA trend buffers
• EMA-separation regime measurement
• price-impulse scoring
• ATR-based trade management
ATR normalization does not make one configuration universal.
Symbols, sessions, exchanges, and data feeds can still behave differently.
━━━━━━━━━━━━━━━━━━━━━━
🕯️ DISPLACEMENT QUALITY FILTER
━━━━━━━━━━━━━━━━━━━━━━
The entry-qualification engine evaluates whether the signal candle shows enough directional response.
The Candle component contributes up to 25 points.
It is divided into:
Directional Body — maximum 12.5 points
For bullish setups, the engine measures the positive candle body relative to the full candle range.
For bearish setups, it measures the negative body.
Close Location — maximum 12.5 points
Bullish setups receive more points when the close is nearer the candle high.
Bearish setups receive more points when the close is nearer the candle low.
Price Impulse contributes up to 15 additional points.
The engine compares the one-bar directional price movement with ATR.
A bullish price impulse measures positive close-to-close displacement.
A bearish price impulse measures negative close-to-close displacement.
This layer does not predict the next candle.
It measures whether the completed signal candle supports the direction of the MACD event.
━━━━━━━━━━━━━━━━━━━━━━
📊 REACTION STRENGTH FILTER
━━━━━━━━━━━━━━━━━━━━━━
The engine includes a separate Entry Qualification Score.
Its components are:
Candle Quality — maximum 25 points
Combines directional body and close location.
MACD Separation — maximum 25 points
Measures current histogram separation relative to its adaptive baseline.
Momentum Persistence — maximum 20 points
Measures how long directional MACD and histogram alignment has remained active.
Price Impulse — maximum 15 points
Measures directional close-to-close movement relative to ATR.
Trigger Context — maximum 15 points
Confirms that an eligible setup event is currently active.
The total is limited to 0–100.
Available modes are:
Off
Removes the minimum Entry Qualification Score restriction.
Loose
Requires a minimum score of 45.
Balanced
Requires a minimum score of 60.
Strict
Requires a minimum score of 75 and is the default.
The final signal also uses internal candle-direction, separation, and persistence requirements.
These internal parameters remain active in the background to keep the public settings menu cleaner.
The Entry Qualification Score is not a verified accuracy figure.
It describes the quality of the completed entry context according to the script’s rules.
━━━━━━━━━━━━━━━━━━━━━━
🧼 CONFIRMED SIGNAL FILTER
━━━━━━━━━━━━━━━━━━━━━━
Permanent LONG and SHORT signals wait for candle close.
The engine uses confirmed-bar checks on:
• MACD crossovers
• zero-line crossings
• expansion triggers
• momentum confirmation
• final LONG and SHORT conditions
The higher-timeframe trend layer also uses previous completed higher-timeframe values.
This approach prevents an unfinished higher-timeframe candle from becoming the permanent trend reference.
Entry Timing provides two workflows.
Early Trigger
Uses the confirmed setup event directly.
Momentum Confirmed
Arms the setup and waits for a later confirmed candle with:
• continued MACD alignment
• directional histogram
• renewed histogram expansion
• directional MACD slope
The confirmation opportunity is temporary.
If renewed momentum does not appear inside the internal window, the armed setup expires.
The script does not plot final signals into earlier candles.
Historical results can still change when:
• settings change
• symbol data changes
• timeframe changes
• the data provider revises history
• the available chart-history range changes
━━━━━━━━━━━━━━━━━━━━━━
🎯 ENTRY MODEL
━━━━━━━━━━━━━━━━━━━━━━
When a final LONG or SHORT setup passes every enabled condition, the trade engine can create a visual trade model.
The Entry reference is the close of the confirmed signal candle.
For a LONG model:
• Stop is below Entry
• TP1 is above Entry
• TP2 is above TP1
• TP3 is above TP2
For a SHORT model:
• Stop is above Entry
• TP1 is below Entry
• TP2 is below TP1
• TP3 is below TP2
The model begins checking TP and SL from the following candle.
This prevents the signal candle’s earlier high or low from being treated as though it occurred after the close-based entry.
The engine stores:
• direction
• entry bar
• entry price
• stop price
• TP1 price
• TP2 price
• TP3 price
• initial risk
• target R values
• TP1 and TP2 progress
• setup type
• setup grade
• risk model
• original signal label
The displayed model is an educational chart reference.
It is not a broker order.
━━━━━━━━━━━━━━━━━━━━━━
🛑 ATR STOP-LOSS MODEL
━━━━━━━━━━━━━━━━━━━━━━
The indicator includes two risk models.
ATR Based
Stop distance is calculated as:
ATR × ATR Stop Multiplier.
The default settings are:
• ATR Length: 14
• ATR Stop Multiplier: 1.50
• TP1: 0.50R
• TP2: 1.00R
• TP3: 1.50R
The minimum distance is protected by the symbol’s minimum tick.
XAUUSD Fixed Pips
Stop and target distances use:
Selected Pips × XAUUSD Pip Size.
The default settings are:
• Pip Size: 0.01
• Stop Loss: 1000 pips
• TP1: 500 pips
• TP2: 1000 pips
• TP3: 1500 pips
Under the common 0.01 convention, those values correspond to:
• Stop distance: 10.00 price units
• TP1 distance: 5.00 price units
• TP2 distance: 10.00 price units
• TP3 distance: 15.00 price units
Broker conventions can differ.
Users should verify their symbol specification before relying on fixed-pip distances.
The XAUUSD protection system checks the symbol.
The dashboard shows:
• ✅ XAUUSD VERIFIED when XAUUSD Fixed Pips is used on a recognized XAUUSD symbol
• ⚠️ CHECK SYMBOL when the mode is used on another symbol
• 🛡️ ATR MODE when ATR Based is selected
The warning does not block calculations.
It tells the user to verify pip size and target distances.
━━━━━━━━━━━━━━━━━━━━━━
🎯 TAKE-PROFIT RR MODEL
━━━━━━━━━━━━━━━━━━━━━━
The visual model contains three take-profit levels.
ATR Based mode calculates targets from the initial stop distance:
TP1 Distance = Initial Risk × TP1 RR.
TP2 Distance = Initial Risk × TP2 RR.
TP3 Distance = Initial Risk × TP3 RR.
XAUUSD Fixed Pips mode uses independent fixed target distances.
The script enforces the following order:
TP1 < TP2 < TP3.
If a selected value would violate that order, the next target is moved at least one minimum tick beyond the prior target.
The trade model internally treats the position as three equal portions.
Each target represents one-third of the model.
If Stop is reached after TP1 or TP2, the script calculates an internal net-R result from:
• the portions already modeled as closed at reached targets
• the remaining portion or portions modeled at Stop
This internal calculation supports Data Window counters.
It is not broker-verified performance.
It does not account for:
• spread
• commission
• slippage
• latency
• partial-fill differences
• financing
• order rejection
• execution venue behavior
━━━━━━━━━━━━━━━━━━━━━━
📦 ACTIVE TP / SL BOX SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
When a confirmed trade model opens, the script can draw on the main chart:
• Entry line
• TP1 line
• TP2 line
• TP3 line
• Stop Loss line
• TP1 reward box
• TP2 reward box
• TP3 reward box
• SL risk box
• LONG or SHORT label
The Entry line is white.
The TP lines are green and initially dashed.
The SL line is red and solid.
The SL box uses a solid border.
When a target is reached:
• the corresponding box becomes more visible
• the corresponding target line becomes solid
• the target line becomes thicker
• the dynamic target alert can fire
When TP3 is reached:
• the complete model closes
• the original LONG or SHORT label remains
• a separate electric-purple TP3 FULL TARGET label appears
• the trade model can remain historically visible
When the model closes at Stop before TP3:
• all active boxes are deleted
• all active trade lines are deleted
• the original LONG or SHORT label is converted into the final result
• the final result becomes SL, CLOSED TP1, or CLOSED TP2
Only TP3 outcomes can retain completed historical boxes and lines.
This is a chart-cleanliness decision.
It does not imply that other outcomes did not occur.
━━━━━━━━━━━━━━━━━━━━━━
🚦 ONE ACTIVE TRADE AT A TIME
━━━━━━━━━━━━━━━━━━━━━━
The script uses one-active-trade-at-a-time visual management.
When the trade engine is enabled:
• a new trade model cannot open while another model is active
• a new trade cannot open on the same candle that closed the previous model
• the internal setup engine continues calculating
• permanent signals are restricted by trade-slot availability
This prevents overlapping Entry, TP, and SL structures.
It also keeps the trade lifecycle easier to interpret.
When the trade engine is disabled, qualified signals can still be evaluated without opening a visual trade model.
The one-active-model rule is a visual and analytical design choice.
It does not restrict the user’s personal trading activity.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ SAME-CANDLE TP / SL HANDLING
━━━━━━━━━━━━━━━━━━━━━━
Trade monitoring begins after the entry candle.
If a later historical candle touches both Stop and one or more targets, standard OHLC data does not reveal the exact intrabar sequence.
The indicator therefore provides two assumptions.
Stop First
If Stop and a target are both touched on the same candle, Stop is processed first.
This is the default and more conservative assumption.
Targets First
Reached targets are processed before Stop.
If TP3 is reached, the model closes at TP3.
Otherwise, remaining portions can close at Stop.
Neither mode reconstructs tick-level execution.
The indicator does not know:
• whether the high occurred before the low
• the bid/ask path
• actual fill sequence
• spread at the time
• slippage
• queue priority
• partial fills
The selected same-bar rule is a modeling assumption required by the limits of OHLC candles.
━━━━━━━━━━━━━━━━━━━━━━
🏷️ MACD MOMENTUM LABELS
━━━━━━━━━━━━━━━━━━━━━━
The indicator uses separate entry and result labels.
Entry labels display:
🚀 LONG
or:
🔴 SHORT
Entry Label Content provides:
Direction Only
Displays only LONG or SHORT.
Grade
Displays direction and setup grade.
Score + Grade
Displays direction, grade, and rounded composite score.
The default is Score + Grade.
LONG and SHORT label sizes can be adjusted independently.
Both default to Small.
The label tooltip contains:
• setup direction
• setup type
• setup grade
• composite score
• Momentum Quality Score
• Entry Qualification Score
• Market Regime Score
• trend-bias state
Result labels include:
🛑 SL
⚠️ CLOSED TP1
✅ CLOSED TP2
🏆 TP3 HIT
✅ FULL TARGET
SL, Closed TP1, and Closed TP2 transform the original entry label.
TP3 creates a separate result label and preserves the original entry label.
All chart-label text uses bold and italic formatting.
━━━━━━━━━━━━━━━━━━━━━━
📍 MACD DISPLAY MODES
━━━━━━━━━━━━━━━━━━━━━━
The indicator operates in a separate MACD pane while selected trade visuals, entry labels, and the dashboard are forced onto the main price chart.
The MACD pane can display:
MACD Line
A white line representing the difference between the selected fast and slow averages.
Signal Line
A red line representing the selected signal smoothing.
Histogram
Color changes communicate momentum condition:
• stronger green for bullish expansion
• softer green for bullish contraction
• stronger red for bearish expansion
• softer red for bearish contraction
Histogram Visual Length
The default multiplier is 1.60.
This changes visual column length only.
It does not affect calculations.
Neon Signal Dots
Qualified LONG setups produce a neon green glow and center dot on the MACD line.
Qualified SHORT setups produce a neon red glow and center dot.
Momentum Background
The pane background changes according to strong or weak bullish and bearish momentum states.
Anti-Chop Background
A neutral gray background can identify conditions blocked by the Anti-Chop Engine.
Each major visual element can be shown or hidden independently.
━━━━━━━━━━━━━━━━━━━━━━
🧹 SETUP INVALIDATION
━━━━━━━━━━━━━━━━━━━━━━
Not every raw MACD event remains eligible.
A setup can be rejected or expire because:
• its momentum score is below the selected threshold
• trend bias does not permit the direction
• the market regime is below the active Anti-Chop threshold
• the Entry Qualification Score is insufficient
• candle direction does not support the setup
• MACD separation is insufficient
• directional persistence is insufficient
• the zero-line filter blocks the direction
• normalized histogram strength is too low
• the signal cooldown is active
• another visual trade is active
• a trade closed on the current candle
• Momentum Confirmed mode does not receive renewed expansion in time
• an opposite raw setup replaces the armed direction
The internal cooldown is eight bars.
Momentum Confirmed mode uses a temporary internal confirmation window.
These background controls are intentionally not exposed as advanced public inputs.
They remain part of the engine’s consistency rules.
A rejected event is not displayed as a permanent entry signal.
━━━━━━━━━━━━━━━━━━━━━━
📟 DASHBOARD
━━━━━━━━━━━━━━━━━━━━━━
The indicator includes a compact dashboard in the bottom-right corner of the main price chart.
The dashboard displays:
Momentum
Possible states include:
• STRONG LONG
• LONG
• STRONG SHORT
• SHORT
• NEUTRAL
Trend
Possible states include:
• BULLISH
• BEARISH
• NEUTRAL
• OFF
Regime
Possible states include:
• TRENDING
• DEVELOPING
• CHOP
• OFF
Trade
Possible states include:
• WAITING
• LONG ACTIVE
• LONG TP1 REACHED
• LONG TP2 REACHED
• SHORT ACTIVE
• SHORT TP1 REACHED
• SHORT TP2 REACHED
Last
Displays the most recent closed model result:
• SL
• CLOSED TP1
• CLOSED TP2
• TP3
Protection
Displays:
• ATR MODE
• XAUUSD VERIFIED
• CHECK SYMBOL
The dashboard is not TradingView Strategy Tester.
It does not display audited brokerage results.
Its states are based on the indicator’s own rule-based calculations.
━━━━━━━━━━━━━━━━━━━━━━
🚨 ALERT SYSTEM
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine includes static TradingView alert conditions for:
• MACD Momentum LONG
• MACD Momentum SHORT
• TP1
• TP2
• TP3
• Stop Loss
• XAUUSD Mode Warning
The XAUUSD warning condition is limited to a qualified entry bar when Fixed Pips mode is active on a non-XAUUSD symbol.
The script also includes detailed dynamic alert() messages.
Dynamic Entry messages can include:
• direction
• symbol
• timeframe
• setup type
• setup grade
• composite score
• risk model
• Entry
• Stop Loss
• TP1
• TP2
• TP3
• XAUUSD mismatch warning when relevant
Dynamic target messages can include:
• target name
• direction
• symbol
• timeframe
• reached target price
• Entry
• Stop Loss
• TP1
• TP2
• TP3
Dynamic stop messages can include:
• final result
• direction
• symbol
• timeframe
• Entry
• exit price
• Stop Loss
• whether TP1 or TP2 was reached first
Alerts are monitoring tools.
They do not place or manage broker orders.
━━━━━━━━━━━━━━━━━━━━━━
🔔 HOW TO USE ALERTS
━━━━━━━━━━━━━━━━━━━━━━
For static conditions:
1. Add MACD Momentum Entry Engine [trade_w_samet] to the chart.
2. Open TradingView’s Create Alert window.
3. Select the indicator as the condition.
4. Choose LONG, SHORT, TP1, TP2, TP3, SL, or XAUUSD Mode Warning.
5. Select a frequency appropriate for confirmed-candle monitoring.
6. Test the alert before relying on it.
For detailed dynamic messages:
1. Enable Detailed Dynamic Alerts in the indicator settings.
2. Open TradingView’s Create Alert window.
3. Select MACD Momentum Entry Engine [trade_w_samet].
4. Select Any alert() function call.
5. Configure the delivery method.
6. Test the complete message format.
Alert delivery can depend on:
• TradingView servers
• the selected symbol
• the selected timeframe
• market-data availability
• realtime feed status
• user alert configuration
• webhook or external-service availability
Creating an alert does not guarantee broker execution.
━━━━━━━━━━━━━━━━━━━━━━
🧪 HOW TO USE THE INDICATOR
━━━━━━━━━━━━━━━━━━━━━━
A practical workflow:
1. Add MACD Momentum Entry Engine [trade_w_samet] to a standard candlestick chart.
2. Begin with the default MACD values of 12, 26, and 9.
3. Keep Entry Timing on Early Trigger while learning the setup types.
4. Keep Momentum Quality on Strict for the default selective profile.
5. Keep Anti-Chop on Strict.
6. Keep Entry Qualification on Strict.
7. Observe whether the event is Reversal, Continuation, Zero Reclaim, or Expansion.
8. Review the MACD histogram, line relationship, and neon signal dot.
9. Review the main-chart LONG or SHORT label.
10. Open the label tooltip to inspect the scores and setup type.
11. Review Momentum, Trend, Regime, Trade, Last Result, and Protection in the dashboard.
12. Verify the selected risk model.
13. When using XAUUSD Fixed Pips, confirm XAUUSD VERIFIED.
14. Treat Entry, SL, TP1, TP2, and TP3 as planning references.
15. Use alerts for monitoring rather than blind execution.
16. Compare every setup with personal structure, session, volatility, and risk rules.
17. Test the exact symbol, timeframe, session, and data feed personally used.
The indicator is designed for structured review.
It should not be treated as an automatic decision-maker.
━━━━━━━━━━━━━━━━━━━━━━
⚙️ SETTINGS REFERENCE
━━━━━━━━━━━━━━━━━━━━━━
⚙️ MACD Core
Calculation Source
Selects the price source used by the MACD calculation.
Fast Length
Controls the fast average.
Default: 12.
Slow Length
Controls the slow average.
Default: 26.
Signal Length
Controls signal-line smoothing.
Default: 9.
MACD Average Type
Selects EMA, SMA, RMA, or WMA for the fast and slow averages.
Signal Average Type
Selects EMA, SMA, RMA, or WMA for the signal line.
━━━━━━━━━━━━━━━━━━━━━━
🎯 Entry Engine
Entry Timing
Early Trigger accepts the confirmed setup event directly.
Momentum Confirmed waits for renewed directional histogram expansion and MACD continuation after the setup is armed.
━━━━━━━━━━━━━━━━━━━━━━
🧠 Momentum Quality Engine
Quality Filter
Selects Off, Loose, Balanced, or Strict.
Strict is the default.
The score combines:
• alignment
• histogram strength
• histogram expansion
• MACD slope
• momentum acceleration
━━━━━━━━━━━━━━━━━━━━━━
📈 Trend Bias Engine
Trend Bias Mode
Selects:
• Off
• Chart EMA
• Higher Timeframe EMA
• Combined EMA
Off is the default.
Trend EMA Length
Controls the chart and higher-timeframe EMA.
Default: 200.
Chart EMA Slope Lookback
Controls the chart-bar lookback used to evaluate EMA direction.
Require EMA Slope Confirmation
Requires a rising EMA for LONG and falling EMA for SHORT.
Higher Timeframe
Selects the confirmed higher-timeframe context.
Default: 60 minutes.
Price-to-EMA ATR Buffer
Requires an optional minimum ATR-normalized distance between price and the trend EMA.
Zero disables the distance requirement.
━━━━━━━━━━━━━━━━━━━━━━
🧱 Anti-Chop Engine
Anti-Chop Filter
Selects Off, Loose, Balanced, or Strict.
Strict is the default.
The regime score combines:
• ADX — 35 points
• price efficiency — 30 points
• EMA separation — 20 points
• volatility expansion — 15 points
━━━━━━━━━━━━━━━━━━━━━━
✅ Entry Qualification Engine
Enable Reversal Setups
Allows MACD crossovers on the opposite side of zero.
Enable Continuation Setups
Allows MACD crossovers on the directional side of zero.
Enable Zero-Line Reclaims
Allows confirmed MACD zero-line crossings with aligned histogram and signal-line conditions.
Enable Momentum Expansions
Allows renewed histogram expansion after contraction while MACD alignment remains valid.
Entry Qualification Filter
Selects Off, Loose, Balanced, or Strict.
Strict is the default.
The score combines:
• candle quality
• MACD separation
• persistence
• price impulse
• trigger context
━━━━━━━━━━━━━━━━━━━━━━
💼 Trade Management Engine
Enable Trade Engine
Enables the one-active-trade-at-a-time visual model.
Risk Model
Selects ATR Based or XAUUSD Fixed Pips.
XAUUSD Fixed Pips is the default.
ATR Length
Controls ATR for the adaptive model.
ATR Stop Multiplier
Controls stop distance in ATR mode.
ATR TP1 Risk/Reward
Controls TP1 distance in ATR mode.
ATR TP2 Risk/Reward
Controls TP2 distance in ATR mode.
ATR TP3 Risk/Reward
Controls TP3 distance in ATR mode.
XAUUSD Pip Size
Controls the price-unit value of one selected pip.
XAUUSD Stop-Loss Pips
Controls fixed Stop distance.
XAUUSD TP1 Pips
Controls fixed TP1 distance.
XAUUSD TP2 Pips
Controls fixed TP2 distance.
XAUUSD TP3 Pips
Controls fixed TP3 distance.
Same-Bar Resolution
Selects Stop First or Targets First.
Show Active TP / SL Zones
Shows Entry, targets, Stop, boxes, and lines on the main chart.
Keep Historical TP3 Zones
Preserves completed TP3 models.
Historical TP3 Trade Limit
Limits completed TP3 models retained on the chart.
Trade Result Labels
Enables SL, Closed TP1, Closed TP2, and TP3 result labels.
SL Label Size
Controls SL result size.
Closed TP1 Label Size
Controls Closed TP1 result size.
Closed TP2 Label Size
Controls Closed TP2 result size.
TP3 Label Size
Controls the separate FULL TARGET label size.
━━━━━━━━━━━━━━━━━━━━━━
🛡️ Signal Filters
Zero-Line Filter
Off allows both sides of zero.
Trend Direction requires LONG above zero and SHORT below zero.
Trend Direction is the default.
Use Absolute Strength Filter
Enables ATR-normalized minimum histogram strength.
Normalization ATR Length
Controls normalization.
Minimum Absolute Strength
Controls the required normalized histogram value.
━━━━━━━━━━━━━━━━━━━━━━
🎨 Visual Settings
Show MACD Line
Shows or hides the MACD line.
Show Signal Line
Shows or hides the signal line.
Show Histogram
Shows or hides histogram columns.
Histogram Visual Length
Changes histogram display scale without changing calculations.
Show MACD Neon Signal Dots
Shows qualified LONG and SHORT dots on the MACD line.
Show Momentum Background
Shows directional momentum background states.
Highlight Blocked Chop Conditions
Shows a neutral background when Anti-Chop blocks entries.
Show LONG / SHORT Labels
Shows or hides main-chart entry labels.
Entry Label Content
Selects Direction Only, Grade, or Score + Grade.
LONG Label Size
Controls LONG label size.
SHORT Label Size
Controls SHORT label size.
━━━━━━━━━━━━━━━━━━━━━━
📟 Mini Dashboard
Show Mini Dashboard
Shows or hides the compact bottom-right main-chart dashboard.
━━━━━━━━━━━━━━━━━━━━━━
🔔 Dynamic Alerts
Enable Detailed Dynamic Alerts
Enables runtime alert() messages.
For these messages, create the TradingView alert using:
Any alert() function call.
Input values are hidden from the status line.
MACD plot values are also prevented from creating status-line or price-scale labels, while diagnostic values remain available in the Data Window.
━━━━━━━━━━━━━━━━━━━━━━
🧠 WHAT MAKES THIS SCRIPT ORIGINAL
━━━━━━━━━━━━━━━━━━━━━━
MACD, moving averages, ATR, ADX, and trend filters are familiar technical-analysis concepts.
These concepts are not unique by themselves.
The originality of MACD Momentum Entry Engine lies in the coordinated process applied to a MACD event:
Configurable MACD event
→ setup-type classification
→ adaptive momentum-strength baselines
→ five-component Momentum Quality Score
→ optional confirmed trend-bias layer
→ four-component Anti-Chop Regime Score
→ five-component Entry Qualification Score
→ final composite score and grade
→ zero-line and normalized-strength validation
→ confirmed-close signal
→ one-active multi-target trade lifecycle
→ TP3-only historical preservation
→ non-TP3 visual cleanup
→ dynamic alerts
→ main-chart diagnostic dashboard
→ XAUUSD mode verification
Distinctive implementation features include:
• four separate setup families
• different logic for Reversal and Continuation crossovers
• zero-line reclaim detection
• renewed expansion detection without requiring a fresh crossover
• adaptive baselines for strength, expansion, slope, and acceleration
• separate bullish and bearish scoring
• a Momentum Quality Score independent from Entry Qualification
• an Anti-Chop Score independent from momentum quality
• confirmed previous higher-timeframe EMA values
• a 70/30 final composite structure
• A+, A, B, and C grades
• visual-only histogram scaling
• equal-third multi-target internal accounting
• same-candle processing assumptions
• XAUUSD symbol verification
• separate result behavior for TP3 and non-TP3 outcomes
• detailed Data Window diagnostics
The script is not a simple combination of unrelated indicators.
Every module supports the same objective: determining whether a confirmed MACD event has enough momentum, market, and entry context to become a permanent visual setup.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ IMPORTANT PRACTICAL NOTES
━━━━━━━━━━━━━━━━━━━━━━
Signal frequency depends on:
• fast, slow, and signal lengths
• selected average types
• Entry Timing
• enabled setup families
• Momentum Quality mode
• Trend Bias mode
• EMA length
• higher timeframe
• EMA slope requirement
• price-to-EMA buffer
• Anti-Chop mode
• Entry Qualification mode
• zero-line filter
• absolute-strength threshold
• symbol
• timeframe
• session
• volatility
• available history
• data provider
• active-trade state
Strict modes reduce accepted signals.
They do not guarantee better results.
Trend Bias Off allows the momentum engine to evaluate both directions without EMA permission.
Higher Timeframe EMA and Combined EMA should use a timeframe meaningfully above the chart timeframe.
XAUUSD Fixed Pips is designed around a selectable pip convention.
The default 0.01 value may not match every broker or synthetic symbol.
Momentum Confirmed produces later and potentially fewer signals than Early Trigger.
Histogram Visual Length does not alter logic.
Changing settings recalculates historical signals and trade models.
A setup that looks different after changing the chart range may be affected by available historical data and adaptive baselines.
━━━━━━━━━━━━━━━━━━━━━━
⚠️ LIMITATIONS AND SHORTCOMINGS
━━━━━━━━━━━━━━━━━━━━━━
This script has important limitations:
It does not guarantee profitable trades.
It does not predict future price movement.
It does not execute orders.
It does not place broker stops or targets.
It does not include spread.
It does not include commission.
It does not include slippage.
It does not include latency.
It does not model partial fills.
It does not model financing or swap.
It uses bar-based OHLC data.
Historical candles do not reveal exact intrabar order.
Stop First and Targets First are assumptions.
The setup score is not a win probability.
A+ is not a guaranteed outcome.
The Anti-Chop Score cannot identify every ranging condition.
Trend filters can delay or block valid reversals.
Trend Bias Off can allow countertrend signals.
ATR normalization does not make settings universal.
Fixed-pip conventions can differ between brokers.
XAUUSD symbol detection cannot verify a broker’s contract specification.
The dashboard is not TradingView Strategy Tester.
Data Window counters are not audited account performance.
The internal R model assumes three equal portions.
The internal model does not represent real position sizing.
One-active-trade logic is a visual-management rule.
Alert delivery depends on TradingView and user configuration.
Changing settings changes historical calculations.
Changing symbol, exchange, session, timeframe, or feed can change signals.
Adaptive baselines depend on available chart history.
Confirmed higher-timeframe values reduce unfinished-HTF changes but introduce delay.
Permanent signals wait for candle close and therefore do not capture the earliest intrabar moment.
For these reasons, the indicator should be used as an educational decision-support tool, not as a standalone automated strategy.
━━━━━━━━━━━━━━━━━━━━━━
👤 WHO THIS SCRIPT MAY BE USEFUL FOR
━━━━━━━━━━━━━━━━━━━━━━
This script may be useful for traders who:
• already understand basic MACD behavior
• want more context than a raw crossover
• study momentum expansion and contraction
• distinguish reversal, continuation, zero-line, and expansion events
• want transparent setup scoring
• want an anti-chop layer
• want optional chart and higher-timeframe trend context
• prefer confirmed-close signals
• want Entry, SL, and three target references
• use XAUUSD and want configurable fixed-pip distances
• want symbol-mismatch warnings
• want a compact dashboard
• want detailed alerts
• want diagnostic Data Window values
• prefer one active visual model at a time
It may be less suitable for users who:
• want guaranteed signals
• want a fully automated trading bot
• want every MACD crossover displayed
• expect a score to equal probability
• expect one setting to work on every market
• require exact tick-level execution
• want Strategy Tester results from an indicator
• want the indicator to replace personal judgment
• expect alerts to execute broker orders automatically
━━━━━━━━━━━━━━━━━━━━━━
🧭 BEST PRACTICE SUGGESTIONS
━━━━━━━━━━━━━━━━━━━━━━
For the default selective profile:
• use standard candlesticks
• begin with MACD 12 / 26 / 9
• keep Entry Timing on Early Trigger
• keep Momentum Quality on Strict
• keep Anti-Chop on Strict
• keep Entry Qualification on Strict
• keep the Zero-Line Filter on Trend Direction
• keep Absolute Strength enabled
• keep all four setup families enabled while learning
• use the dashboard to identify blocked regime conditions
• verify the selected risk model before reviewing trade levels
• use Stop First for conservative historical same-bar handling
• confirm XAUUSD VERIFIED when using Fixed Pips
• use alerts for monitoring rather than blind execution
For additional frequency:
• change Momentum Quality from Strict to Balanced
• change Anti-Chop from Strict to Balanced
• change Entry Qualification from Strict to Balanced
• disable the Zero-Line Filter
• disable Absolute Strength
• keep Trend Bias Off
• use Early Trigger
For additional directional restriction:
• use Chart EMA, Higher Timeframe EMA, or Combined EMA
• enable EMA slope confirmation
• add a Price-to-EMA ATR Buffer
• use a higher timeframe above the chart timeframe
• use Momentum Confirmed instead of Early Trigger
Always:
• wait for the setup candle to close
• review the setup type
• review the score components
• verify market structure independently
• review session and volatility
• verify the stop distance
• use personal position sizing
• test the exact symbol and timeframe
• understand the same-bar assumption
• treat all projected levels as analytical references
━━━━━━━━━━━━━━━━━━━━━━
🔓 PUBLICATION NOTE
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine [trade_w_samet] is published as an educational momentum-analysis and visual trade-model tool.
The purpose of this description is to explain:
• how the configurable MACD core is calculated
• how average types affect the MACD and signal lines
• how setup events are classified
• how Reversal setups work
• how Continuation setups work
• how Zero-Line Reclaim setups work
• how Momentum Expansion setups work
• how Early Trigger and Momentum Confirmed differ
• how the Momentum Quality Score is constructed
• how adaptive momentum baselines work
• how the Anti-Chop Score is constructed
• how the Entry Qualification Score is constructed
• how final composite scores and grades are assigned
• how chart and confirmed higher-timeframe trend filters work
• how zero-line and absolute-strength filters work
• when permanent signals appear
• how the one-active-trade model works
• how Entry and Stop are calculated
• how TP1, TP2, and TP3 are calculated
• how same-candle ambiguity is handled
• how historical TP3 visuals are retained
• how non-TP3 visuals are cleaned
• how result labels behave
• what the dashboard displays
• how XAUUSD protection works
• what static and dynamic alerts contain
• what diagnostic values are available
• what the timing limitations are
• what the model does not simulate
• why familiar MACD concepts are organized into an original workflow
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 LONG/SHORT system.
MAIN CHART SCREENSHOT PLAN
Use one clean standard candlestick chart.
Show the indicator with its default settings.
The screenshot should contain:
• complete symbol and timeframe information
• the indicator name
• visible standard price candles
• one clear LONG or SHORT label
• one active or completed Entry / TP / SL model
• the white Entry line
• green TP1, TP2, and TP3 levels
• the red SL area and solid SL line
• the MACD pane
• the white MACD line
• the red signal line
• the green/red histogram
• one neon MACD signal dot
• the bottom-right main-chart dashboard
• the Protection state
Do not include:
• other indicators
• manual drawings
• unrelated labels
• social-media links
• pricing information
• promotional claims
• account-profit screenshots
• win-rate claims
• non-standard candles
• hidden symbol or timeframe information
• excessive zoom
• decorative graphics unrelated to the script
The screenshot should demonstrate normal default behavior and make the relationship between the MACD event, main-chart signal, trade model, and dashboard easy to understand.
━━━━━━━━━━━━━━━━━━━━━━
🛡️ DISCLAIMER
━━━━━━━━━━━━━━━━━━━━━━
MACD Momentum Entry Engine [trade_w_samet] 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.
Momentum changes.
Volatility changes.
Liquidity changes.
Historical chart behavior does not ensure future performance.
Every user is responsible for their own:
• analysis
• validation
• risk management
• position sizing
• alert configuration
• trading decisions
• broker execution
• legal obligations
• tax obligations
The MACD line, signal line, histogram, momentum states, setup types, quality scores, regime scores, entry scores, composite scores, grades, trend states, LONG and SHORT labels, Entry references, Stop Loss levels, take-profit levels, boxes, result labels, Data Window values, dashboard states, internal counters, and alerts are visual analysis tools only.
The displayed Entry is not a guaranteed fill.
The displayed Stop Loss is not a broker order.
The displayed TP1, TP2, and TP3 levels are not guaranteed objectives.
The Momentum Quality Score is not a win probability.
The Entry Qualification Score is not a probability.
The Market Regime Score is not a guarantee that a market is trending.
The A+, A, B, and C grades are not promises of performance.
The internal trade model does not include spread, commissions, slippage, latency, order-book conditions, contract specifications, or partial fills.
Use this script as a structured MACD momentum-review and decision-support framework, not as a promise of profitability or a substitute for independent judgment.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
Clean indicators & Systems 💻
Free & PRO+ tools, setup guides & books.➡️
🌐 tradewsamet.com
whop.com/joined/tradewsamet
Free & PRO+ tools, setup guides & books.➡️
🌐 tradewsamet.com
whop.com/joined/tradewsamet
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
Clean indicators & Systems 💻
Free & PRO+ tools, setup guides & books.➡️
🌐 tradewsamet.com
whop.com/joined/tradewsamet
Free & PRO+ tools, setup guides & books.➡️
🌐 tradewsamet.com
whop.com/joined/tradewsamet
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。