
PART 3 XAU Breakout Scalper MT5: Official Optimization Blueprint

Phase 1: The Baseline - Finding a Raw Entry Signal
Goal: Isolate and tune the core SuperTrend entry signal.
Our mission in this phase is to answer one critical question: "Does the S1 SuperTrend signal, on its own, have a natural, profitable edge in the Gold market?" We must prove this before adding any other variables. To do this, we will strip the EA down to its bare essentials and test only the parameters that create the entry signal.
Step 1: Prepare the "Clean Slate" Configuration for S1
This is our "lab preparation" step. Go to the "Inputs" tab in the Strategy Tester. We are going to manually set up a very simple, non-interfering environment.
- 1. Isolate the Strategy:
- EnableStrategy1: Ensure this is set to true.
- EnableStrategy2: You must set this to false.
- 2. Disable ALL Strategy 1 Filters:
- UseHigherTimeframe: Set to false.
- EnableAdxFilter_S1: Set to false.
- EnableVwapFilter_S1: Set to false.
- S1_EnableMAFilter: Set to false.
- 3. Set a Basic, Non-Interfering Exit Strategy: We need exits that are so wide they won't influence the test. We want to judge the entry, not a clever exit.
- UseTrailingStopStrategy1: Set to false.
- TakeProfit_Mode_S1: Set this to the simplest mode, FIXED_TP.
- FixedTakeProfit_S1: Set a very large value, like 2000 (200 pips).
- UseSuperTrendForSL_S1: Set to false.
- FallbackSLPoints_S1: Set a reasonable but fixed value, like 500 (50 pips).
Your "Inputs" tab should now look very clean, with almost all of S1's advanced features disabled.
Step 2: Optimize the Core S1 Entry & Signal Parameters
Now, we tell the optimizer what to test. Tick the checkboxes only for the parameters that define the S1 entry signal's behavior.
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
SuperTrendTimeframe | YES ✔ | M5 | 1 | H1 | "On which chart timeframe does your SuperTrend signal work best for Gold?" |
ATRPeriod | YES ✔ | 10 | 2 | 24 | "How many past candles should you look at to measure volatility? Should you be fast and responsive, or slow and smooth?" |
ATRMultiplier | YES ✔ | 1.5 | 0.5 | 4.0 | "How sensitive should you be? Should you place the signal line very close to the price, or give it lots of breathing room?" |
SwingLookback | YES ✔ | 3 | 1 | 10 | "After you get a signal, how many bars should you check to find the best breakout high or low for our entry point?" |
PaddingPoints | YES ✔ | 5 | 5 | 50 | "How much extra 'padding' should you add beyond that breakout point to confirm the price is really moving?" |
Action: Run the Baseline Test & Establish Your Foundation
- Confirm Your Goal: Double-check that your Optimization criterion in the main "Settings" tab is set to "Complex Criterion".
- Begin the Test: Click the green "Start" button. The optimizer will now run thousands of tests, searching for the best combination of the five parameters you selected.
- Find the Winner: Once the process is complete, go to the "Optimization Results" tab. The single best result—your winner—will be the first line at the top of the list.
- Set Your Foundation: Right-click on that top row and select "Set Input Parameters" from the menu that appears.
Congratulations. You have successfully completed the most important phase. The values now loaded in your "Inputs" tab represent the strongest possible core signal the EA could find. This is your proven foundation, and every subsequent phase will be dedicated to building upon it. Note down your "Complex Criterion" score, as our goal in the next phases will be to improve it.
Phase 2: The Exit Strategy - Optimizing Stop Loss & Take Profit
Goal: Pair the proven entry with the most profitable exit logic.
In Phase 1, we found a promising entry signal—our "engine". However, an entry signal alone does not make a profitable strategy. How we exit a trade is just as, if not more, important.
In this phase, our mission is to find the most effective combination of Stop Loss (SL) and Take Profit (TP) settings that work in harmony with the unique entry logic we just discovered. We will test different styles of exits (like a dynamic SL vs. a fixed one) and different values to discover what transforms our raw signal into a consistently profitable system.
Step 1: Lock In Your S1 Baseline Settings
Before we test our exits, we must ensure the proven entry signal we found in Phase 1 is used as the non-negotiable foundation for this test. We don't want the optimizer changing our core engine while we're trying to test the brakes.
Go to the "Inputs" tab in your Strategy Tester.
- The values for SuperTrendTimeframe, ATRPeriod, ATRMultiplier, SwingLookback, and PaddingPoints should already be set to the winning combination from your baseline test.
- This is a critical action: You must now UN-TICK the checkboxes next to all five of these variables. This "locks them in," telling the optimizer to use these exact values for every test it runs in this phase.
Step 2: Optimize the S1 Stop Loss & Take Profit Parameters
Now, we tell the optimizer to experiment with every tool in the EA's arsenal for managing exits. This is a comprehensive test of all SL and TP logic. Tick the checkboxes for the following parameters.
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
UseSuperTrendForSL_S1 | YES ✔ | false | 1 | true | "Is it better to use a dynamic Stop Loss that follows your own SuperTrend line, or is a more static approach better?" |
FallbackAtrMultiplier_S1 | YES ✔ | 1.0 | 0.5 | 3.0 | "If we use a static SL, should it be based on a multiple of the market's current volatility (ATR)?" |
FallbackSLPoints_S1 | YES ✔ | 150 | 50 | 600 | "Or, is a simple, fixed-point Stop Loss more reliable?" (This tests from 15 to 60 pips). |
TakeProfit_Mode_S1 | YES ✔ | FIXED_TP | 1 | ATR_MULTIPLE | "What is the best STYLE for taking profit? A fixed target? A target based on our risk (R:R)? Or one based on volatility (ATR)?" |
FixedTakeProfit_S1 | YES ✔ | 200 | 100 | 1500 | "If a fixed TP is best, what is the optimal distance?" (Tests from 20 to 150 pips). |
RiskRewardRatio_S1 | YES ✔ | 1.0 | 0.5 | 4.0 | "If a Risk:Reward TP is best, what is the ideal ratio?" |
AtrMultipleTp_S1 | YES ✔ | 1.5 | 0.5 | 5.0 | "If an ATR-based TP is best, what is the perfect volatility multiple to use?" |
Action: Run the Exit Test & Refine Your Core Strategy
- Confirm Your Goal: Ensure the Optimization criterion is still "Complex Criterion".
- Begin the Test: Click the green "Start" button. The optimizer will now test thousands of combinations of exit strategies against your proven entry signal.
- Find and Analyze the Winner: When the test is complete, go to the "Optimization Results" tab. Look at the top-performing pass. This single row contains a wealth of information.
- Check the value for TakeProfit_Mode_S1. Did the optimizer decide RISK_REWARD was best? Or FIXED_TP? This tells you which style of profit-taking is most effective.
- Check the value for UseSuperTrendForSL_S1. This tells you if a dynamic or static Stop Loss is superior.
- The other values on that line will show you the corresponding optimal settings for the modes that were chosen (e.g., the best RiskRewardRatio_S1 value).
- Refine Your Strategy: Right-click on that top row and select "Set Input Parameters".
You have now successfully paired your entry engine with a statistically proven exit system. Your strategy is no longer just a raw signal; it's a complete trading methodology. Compare the new "Complex Criterion" score to the one from Phase 1. It should be significantly better. You are now ready to add the final layers of refinement.
Phase 3: The Refinement - Testing Confirmation Filters
Goal: Scientifically test which filters improve the S1 strategy.
At this point, you have a powerful core strategy with a proven entry and a statistically optimized exit. It's a complete system. Now, we ask a new question: "Can we make it even better by being more selective?"
The purpose of a filter is to act as a final "gatekeeper." It examines a valid trade signal and gives it a final "Go" or "No-Go" based on broader market conditions. A good filter will successfully stop you from taking trades that would have otherwise lost, thereby increasing your profit factor and reducing drawdown. A bad filter will needlessly block winning trades.
Our method here is crucial: we will test one filter at a time and compare the result directly to our score from the end of Phase 2. This is the only way to know for sure if a filter is helping or hurting.
Step 1: Lock In Your S1 Entry & Exit Settings
This is our pre-test ritual. We must ensure that the proven strategy we've built so far is the foundation for our filter tests.
Go to the "Inputs" tab in your Strategy Tester.
- Every parameter you optimized in Phase 1 (Entry) and Phase 2 (Exit) should now be set to its winning value.
- Verify that every single one of their checkboxes is UN-TICKED. This is critical. It locks in your complete core strategy, ensuring we are only measuring the effect of the one filter we are about to test.
Step 2: Test Filter 1 - The Higher Timeframe (HTF) Filter
This is one of the most powerful concepts in trading: using a higher timeframe to confirm the primary trend direction. This filter asks, "Does the bigger picture agree with this short-term trading signal?"
- 1. Enable the Filter:
- Find the UseHigherTimeframe parameter and set its value to true.
- Since this filter's logic is built-in (it automatically looks at the next standard timeframe), there are no other parameters to optimize for this specific test.
- 2. Run a Simple Comparison Test:
- Because we are just testing one setting (On vs. Off), we do not need to run a full optimization.
- Go to the "Settings" tab and change the Optimization mode to "Disabled".
- Click the "Start" button to run a single backtest with the HTF filter enabled.
- 3. Analyze and Decide:
- When the test is finished, look at the "Backtest" tab. Note the "Complex Criterion" score.
- Compare this new score to your final score from the end of Phase 2.
- Did the score IMPROVE? If the score is higher, it means confirming the trend on a higher timeframe is beneficial. The filter is a valuable addition. Keep UseHigherTimeframe set to true for all future tests.
- Did the score DECREASE or stay the same? If the score went down, it means the filter was too restrictive for this particular strategy and blocked too many good trades. It is not helpful. Go back to the "Inputs" tab and set UseHigherTimeframe back to false.
You have now made your first scientific decision about a filter.
Step 3: Test Filter 2 - The Moving Average (MA) Filter
Now, let's test if a classic moving average can serve as an effective dynamic trend filter.
- 1. Reflect Your Previous Decision:
- First, ensure the UseHigherTimeframe setting reflects your decision from the previous step.
- Go back to the "Settings" tab and change the Optimization mode back to "Fast genetic based algorithm".
- 2. Enable the MA Filter:
- Find S1_EnableMAFilter and set its value to true. Do not tick its checkbox. We want it to be ON for this entire test run.
- 3. Optimize the MA Filter's Key Parameters:
- Tick the checkboxes for the most important MA settings to find the best combination.
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
S1_NumMAs | YES ✔ | 1 | 1 | 3 | "Is it better to use a simple 1-MA crossover, a 2-MA ribbon, or a full 3-MA confirmation?" |
S1_MA1_Period | YES ✔ | 50 | 25 | 200 | "What is the best period for our slowest, primary trend MA?" |
S1_MA2_Period | YES ✔ | 20 | 10 | 100 | "What is the best period for our medium-term MA?" |
- 4. Run, Analyze, and Decide:
- Click "Start" to run the optimization.
- When finished, look at the top result in the "Optimization Results" tab.
- Compare its "Complex Criterion" score to your best score from the end of the previous step.
- If the score IMPROVED: This MA configuration adds value. Right-click the winning row and select "Set Input Parameters". This locks in your new, better strategy.
- If the score did NOT improve: The MA filter, even at its best, did not help. Go back and set S1_EnableMAFilter to false and proceed to the next filter test.
You are now systematically building a more intelligent trading logic, only keeping the components that have statistically proven their worth.
Step 4: Test Filter 3 - The ADX Momentum Filter
Now we test a different concept: trend momentum. The ADX (Average Directional Index) filter doesn't care about trend direction, only its strength. This filter asks, "Is there enough conviction or 'fuel' behind this move to be worth trading, or is the market lazy and consolidating?" Trading only when momentum is high can be a powerful way to avoid choppy, directionless periods.
- 1. Reflect Your Previous Decisions:
- Go to the "Inputs" tab. First, ensure your settings for the HTF Filter and MA Filter reflect the decisions you made in the previous steps (whether you decided to keep them enabled with their winning parameters or disabled).
- Ensure all checkboxes from previous tests are UN-TICKED.
- 2. Enable the ADX Filter:
- Find the EnableAdxFilter_S1 parameter and set its value to true. Do not tick its checkbox.
- 3. Optimize the ADX Filter's Key Parameter:
- The most important setting for ADX is its threshold level. Tick the checkbox for AdxLevel_S1.
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
AdxLevel_S1 | YES ✔ | 20 | 1 | 30 | "What is the minimum 'strength score' a trend needs before you will participate? A score of 20 is a developing trend, while 25-30 indicates a strong, established one." |
- 4. Run, Analyze, and Decide:
- Click "Start" to run this optimization.
- When finished, compare the top "Complex Criterion" score with your best score from the end of the previous step.
- If the score IMPROVED: The ADX filter is successfully helping you avoid weak trades. It's a valuable addition. Right-click the winning row and select "Set Input Parameters".
- If the score did NOT improve: The momentum requirement was not beneficial for this strategy. Go back and set EnableAdxFilter_S1 to false.
Step 5: Test Filter 4 - The VWAP Session Filter
This final filter is unique. The VWAP (Volume-Weighted Average Price) acts as a dynamic level of "fair value" for the current trading day. Professional traders often use it as a session bias filter. This filter asks, "Are we trading on the 'strong' side of the day's fair value (buys above VWAP, sells below), or are we fighting the intraday institutional flow?"
- 1. Enable the Filter:
- Ensure all previous settings are locked in based on your prior decisions.
- Find EnableVwapFilter_S1 and set its value to true.
- 2. Run a Simple Comparison Test:
- Like the HTF filter, the VWAP filter is a simple "On vs. Off" test based on its calculated value. It doesn't have a primary parameter to optimize.
- Go to the "Settings" tab and change the Optimization mode to "Disabled".
- Click the "Start" button to run a single backtest with the VWAP filter enabled.
- 3. Analyze and Decide:
- When the test is finished, look at the "Backtest" tab and note the "Complex Criterion" score.
- Compare this new score to your best score from the end of the previous step.
- Did the score IMPROVE? If yes, using the daily VWAP as a bias filter is effective. Keep EnableVwapFilter_S1 set to true.
- Did the score DECREASE or stay the same? If no, the filter is not a good fit for this strategy's logic. Go back and set EnableVwapFilter_S1 to false.
Action: Make Your Final Decision on S1 Filters
You have now completed the entire refinement phase. Take a moment to review the "Inputs" tab of your Expert Advisor.
You have systematically and scientifically tested four different types of confirmation filters:
- A Trend Confirmation Filter (HTF)
- A Dynamic Level Filter (Moving Average)
- A Momentum Filter (ADX)
- An Intraday Session Filter (VWAP)
Your final configuration for this phase should only have the filters enabled that have conclusively proven to improve the performance of your core strategy. You haven't just guessed; you have the data to back up every decision. This highly-refined strategy is now ready for the profit maximization phase.