Discussing the article: "Swing Extremes and Pullbacks (Part 5): Filtering Weak Swings Using Candle Imbalance"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Swing Extremes and Pullbacks (Part 5): Filtering Weak Swings Using Candle Imbalance.
This article implements an MQL5 Expert Advisor that scores each impulse leg behind a swing extreme with a 0–100 Candle Imbalance Score. The score combines four bounded components—body dominance, directional consistency, leg efficiency, and Fair Value Gap coverage—to filter weak swings before any pullback setup is armed. You will see enforced swing alternation, a state machine for first-clean-retest-only entries, and a three-mode trailing stop, enabling consistent setup selection and exit management.
The Expert Advisor operates entirely on closed bars for its structural logic and on every tick for exit management. On each new bar, it runs a pivot-based swing detector with separate left and right lookbacks, and it enforces strict alternation: a swing high must follow a swing low and vice versa. When two same-type swings appear in a row, the more extreme of the two replaces its predecessor in place. This alternation rule matters more here than in earlier parts, because it guarantees that every confirmed swing has a well-defined impulse leg—the run of candles from the previous opposite swing to the new extreme. That leg is the object the imbalance engine grades.
The moment a swing is confirmed, its leg is scored. Body dominance averages the body-to-range ratio of every candle in the leg, rewarding full-bodied displacement candles and punishing wicks and dojis. Directional consistency counts the fraction of leg candles that closed in the leg's direction. Leg efficiency divides the net close-to-close travel of the leg by the gross close-to-close travel, a Kaufman-style ratio that punishes overlapping, back-and-forth price action even when it eventually reaches a new extreme. FVG coverage sums the size of every Fair Value Gap inside the leg and normalizes it by the leg's height, since genuine imbalance leaves gaps that choppy legs never produce. The four components are combined by adjustable weights into a 0–100 score, and a single input decides the pass mark. A swing that passes is drawn as a solid colored leg with its score printed at the extreme; a swing that fails is drawn gray and dotted, labeled with its score, and is never allowed to arm a pullback setup.
Swing Confirmation and Leg Imbalance Grading
Author: Hlomohang John Borotho