EA BoS and FVG
- 专家
- 版本: 3.60
- 激活: 5
Trade Market Structure and Fair Value Gaps Automatically
Take your trading strategy to the next level with this MetaTrader 5 Expert Advisor based on Break of Structure (BoS) and Fair Value Gap (FVG).
This EA was developed and refined over several months with extensive backtesting and adjustments to improve the way market structure, impulsive movements, FVG zones, retracements, and confirmations are handled.
The system is designed to avoid entering simply because an FVG exists. Instead, it waits for the market to show a Break of Structure, identifies the relevant impulsive leg and FVG, waits for a retracement, and then looks for a rejection/confirmation before entering the trade.
The strategy in one line:
Structure → BoS → Impulsive Leg → FVG → Retracement → Rejection → Entry
Backtested Results
The EA has been extensively tested and optimized during its development.
In one of the backtests performed during development, an initial balance of €1,000 grew to approximately €6,600 over a period of 4 months.
These results demonstrate the potential of the strategy under the specific historical market conditions and settings used in the test.
Important: Past backtest performance does not guarantee future results. Trading involves risk, and live-market results can differ significantly from historical testing.
How Does the EA Work?The EA combines several confirmations instead of relying on a single indicator.
1. Break of Structure
The system analyzes swing highs and swing lows to identify a valid Break of Structure (BoS).
This helps determine the direction of the market and the structural movement that the EA is interested in trading.
2. Impulsive Leg Detection
After detecting a BoS, the EA identifies the relevant impulsive movement that produced the breakout.
This is important because the FVG search is restricted to the actual impulse leg rather than simply scanning random candles on the chart.
3. Fair Value Gap Detection
The EA searches for a valid Fair Value Gap (FVG) inside the relevant impulsive leg.
A minimum FVG size can be configured to help filter out small gaps and market noise.
4. Retracement
The EA does not immediately enter when an FVG is detected.
Instead, the FVG becomes a candidate trading zone.
The market must subsequently retrace into the zone.
5. Rejection Confirmation
Once price returns to the FVG, the EA waits for a confirmation candle.
The candle must interact with the zone and close in the expected direction, providing the rejection required for the trade entry.
This additional confirmation is designed to avoid entering simply because price has touched an FVG.
Risk ManagementThe EA includes several built-in risk and trade-management mechanisms.
Automatic Stop Loss
The EA can calculate the Stop Loss using the relevant structural pullback swing after the breakout.
It can also use the broken swing depending on the configured settings.
Automatic Take Profit
You can choose between:
-
Fixed Risk/Reward
-
Structural Take Profit
When using fixed RR, the desired Risk/Reward ratio can be configured.
Broker Stop-Distance Validation
Before sending an order, the EA checks the broker's minimum stop distance to help prevent invalid Stop Loss or Take Profit levels.
Automatic Lot Normalization
The EA automatically adjusts the requested lot size according to the broker's:
-
Minimum volume
-
Maximum volume
-
Volume step
This helps ensure that the requested position size is compatible with the trading account.
Trade ProtectionThe EA also contains additional controls designed to prevent unwanted trades.
Opposite Position Protection
The system prevents opening a new position in the opposite direction when an existing position is already open.
At the same time, same-direction positions can be allowed, making the system compatible with controlled pyramiding.
Structure Invalidation
The EA monitors whether the original market structure remains valid.
If price reclaims the origin of the impulse leg, the structure can be considered invalidated.
You can optionally configure the EA to automatically close positions when this structural invalidation occurs.
Main Input ParametersGeneral Settings
LotSize
Default: 0.1
Defines the requested trading volume.
MagicNumber
Default: 123456
Unique identifier used by the EA to recognize its own trades.
Slippage
Default: 10
Maximum allowed slippage for trade execution.
Swing & Break of Structure
SwingBars
Default: 2
Controls how many candles are used to identify swing highs and swing lows.
Higher values generally produce stronger but less frequent swing points.
UseATRFilter
Default: false
Enables or disables an ATR-based filter for Break of Structure detection.
ATRPeriod
Default: 14
ATR calculation period when the ATR filter is enabled.
ATRMultiplier
Default: 0.5
Multiplier used by the ATR filter.
Fair Value Gap Settings
FVGLookbackBars
Default: 20
Number of bars the EA searches when looking for an FVG.
LegOriginLookback
Default: 150
Maximum lookback used to identify the origin of the relevant impulsive leg.
MinFVGSizePoints
Default: 50
Minimum FVG size required for the zone to be considered valid.
This helps filter out very small gaps and market noise.
Visual Settings
DrawZonesOnChart
Default: true
Displays detected FVG zones on the chart.
DrawSwingPoints
Default: false
Displays detected swing highs and swing lows on the chart.
This can be useful when calibrating the SwingBars parameter.
Entry Confirmation
MaxBarsWaitRetrace
Default: 15
Maximum number of candles the EA will wait for price to return to the FVG zone after the zone has been detected.
Risk Management
CloseOnStructureInvalidation
Default: false
Allows the EA to close an open position when the original trading structure becomes invalid.
UseFixedRR
Default: true
Enables fixed Risk/Reward Take Profit calculation.
RR_Ratio
Default: 1.0
Defines the desired Risk/Reward ratio when fixed RR is enabled.
UseStructuralTP
Default: false
Allows Take Profit to be based on market structure instead of a fixed RR calculation.
UsePullbackSwingSL
Default: true
Uses the relevant post-breakout pullback swing when calculating the Stop Loss.
Session Filter
UseSessionFilter
Default: false
Enables a trading-session filter.
StartHour
Default: 0
Defines the beginning of the permitted trading session.
EndHour
Default: 24
Defines the end of the permitted trading session.
Why Use This EA?This Expert Advisor is designed for traders who want to automate a structured price-action approach without relying on a simple indicator crossover or a single technical signal.
The system combines:
✓ Market Structure
✓ Break of Structure
✓ Impulsive Leg Analysis
✓ Fair Value Gaps
✓ Minimum FVG Size Filtering
✓ Retracement Confirmation
✓ Rejection Candle Confirmation
✓ Structural Stop Loss
✓ Fixed or Structural Take Profit
✓ Risk/Reward Management
✓ Broker Stop-Distance Validation
✓ Automatic Lot Normalization
✓ Session Filtering
✓ Structure Invalidation
✓ Opposite-Position Protection
✓ Optional Chart Visualization
One of the key characteristics of this EA is that an FVG by itself is not enough to trigger a trade.
The system follows a sequence of conditions before entering:
1. Market structure is identified
↓
2. Break of Structure occurs
↓
3. Relevant impulsive leg is identified
↓
4. Valid FVG is detected
↓
5. Price retraces into the FVG
↓
6. Rejection/confirmation occurs
↓
7. Trade is executed
↓
8. SL and TP are automatically calculated
This approach is designed to make the entry logic more selective and structured.
Built for MetaTrader 5The EA is programmed specifically for MetaTrader 5 and is designed to automate the execution of the BoS + FVG strategy without requiring manual trade entry.
You can adjust the main strategy parameters directly from the EA settings to adapt the system to different market conditions, instruments, and trading preferences.
Automate the Strategy. Remove Emotional Execution.
Instead of manually watching every Break of Structure, searching for FVGs, waiting for retracements, and monitoring confirmation candles, let the EA continuously monitor the market according to its programmed rules.
BoS + FVG Expert Advisor — structured price action, automated execution.
Backtest results are historical results and should not be interpreted as a guarantee of future profitability. Always test the EA on your broker, symbol, timeframe, and trading conditions before using it with real funds.
