
PART 4 XAU Breakout Scalper MT5: Official Optimization Blueprint

Phase 4: The Profit Maximizer - Tuning the Trailing Stop
Goal: Test if an intelligent, multi-stage trailing stop can increase average profit.
You have now built a complete, robust, and filtered trading strategy. The next question we ask is, "Can we make our winning trades even more profitable?"
A fixed Take Profit gets you out of a trade at a predefined level, which is safe and consistent. However, what if a trade wants to run for 200, 300, or even 500 pips? A fixed TP would leave all that extra profit on the table.
This is where the XAU Breakout Scalper's advanced trailing stop comes in. It's a "Profit Maximizer." It is designed to first protect your capital by moving to break-even, and then to aggressively trail behind a winning trade, capturing as much of a large move as possible. In this phase, we will test if this dynamic exit management is superior to the static exit we found earlier.
Step 1: Lock In Your Proven S1 Strategy Settings
As always, we begin by locking in our winning formula from all the previous phases.
Go to the "Inputs" tab in your Strategy Tester.
- All the parameters for your core Entry, Exit, and Filters should be set to the winning values you have discovered and decided upon.
- Verify that every single one of their checkboxes is UN-TICKED. This is absolutely critical. We want to test the effect of the trailing stop on our already optimized strategy, not change the strategy itself.
Step 2: Optimize the S1 Trailing Stop Parameters
Now, we will enable the trailing stop and allow the optimizer to find its most effective configuration.
- 1. Enable the Trailing Stop:
- Find the UseTrailingStopStrategy1 parameter and set its value to true. Do not tick its checkbox. We want the trailing stop to be active for every test in this run.
- 2. Configure the Optimization:
- Tick the checkboxes for the three parameters that control the trailing stop's behavior. We want to find the perfect harmony between when it activates and how tightly it follows the price.
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
BreakEvenStartPoints_S1 | YES ✔ | 20 | 10 | 100 | "How much profit should a trade show before you protect it by moving the Stop Loss to break-even? Should you do it quickly or wait for more confirmation?" |
ATRStartPoints_S1 | YES ✔ | 30 | 20 | 150 | "After break-even is secure, how much more profit is needed before you activate the advanced ATR trailing? Should it start trailing early or late?" |
ATRTrailingMultiplier_S1 | YES ✔ | 1.0 | 0.5 | 3.5 | "How tightly should you trail the price? Should the Stop Loss be very close to catch a small reversal (low multiplier), or far away to survive a pullback (high multiplier)?" |
Action: Run the Trailing Stop Test & Make Your Decision
- Confirm Your Goal: Ensure the Optimization criterion is set to "Complex Criterion".
- Begin the Test: Click the green "Start" button. The optimizer will now test various combinations of trailing stop behaviors against your fully-tuned strategy.
- Analyze the Final Result: When the test is complete, look at the top-performing pass in the "Optimization Results" tab.
- Make the Final Decision:
- This is the most important comparison. Compare the "Complex Criterion" score of this new top result with your final, best score from the end of Phase 3 (the filter testing phase).
- Did the score IMPROVE? If the score is higher, it means that dynamically managing your exits with a trailing stop is superior to your previous static exit. It's successfully maximizing profit. Right-click the winning row and select "Set Input Parameters". Your strategy is now even more powerful.
- Did the score DECREASE or stay the same? Sometimes, for certain strategies, a simple, fixed exit is more reliable. If the score did not improve, it means the trailing stop logic is not a good fit for this specific configuration. In this case, the more robust choice is to stick with what has been proven. Go back to the "Inputs" tab and set UseTrailingStopStrategy1 back to false.
You have now tested and made a data-driven decision on the optimal exit management for your strategy, ready for the final touches.
Phase 5: The Final Polish - Time & Trade Management
Goal: Control when and how often the S1 strategy trades.
Congratulations, you have arrived at the final stage of tuning. At this point, you have a complete, highly-refined strategy where every internal component—from entry to exit, filters to profit maximization—has been scientifically tested and proven.
This last phase is about applying two powerful "master controls" that sit on top of the entire strategy. We will ask two final questions:
- "When?": Does our strategy perform better during specific, high-volume market hours, or is it profitable 24 hours a day?
- "How Many?": Is it better to let the strategy take every single signal it gets, or should we limit its exposure by only allowing a certain number of trades at once?
Optimizing these two factors can be the key to reducing drawdown and increasing consistency by forcing the EA to operate only during its most favorable conditions.
Step 1: Lock In Your Complete S1 Strategy
This is our final pre-flight check. We must ensure that the master settings we are about to test are being applied to the fully-tuned strategy we have painstakingly built through all the previous phases.
Go to the "Inputs" tab in your Strategy Tester.
- Every single parameter you have optimized and decided to keep from Phase 1 through Phase 4 should be set to its winning value.
- Crucially, verify that ALL of their checkboxes are UN-TICKED. We are no longer changing the strategy's internal logic. We are only testing the master rules that govern its operation.
Step 2: Optimize the Global Trading Session (Time Filter)
The personality of the Gold market changes dramatically throughout the 24-hour cycle. It is often quiet during the Asian session and highly volatile during the London/New York overlap. This test will discover the most profitable "trading window" for your specific strategy.
- 1. Configure the Optimization:
- Tick the checkboxes for the start and finish hours of the global trading session.
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
StartHour | YES ✔ | 0 | 1 | 12 | "What is the best possible hour to START looking for trades each day?" (Tests from midnight to noon). |
FinishHour | YES ✔ | 13 | 1 | 23 | "What is the best possible hour to STOP looking for new trades each day?" (Tests from 1 PM to the end of the day). |
- 2. Run and Analyze:
- Click "Start". The genetic algorithm will now test thousands of different time windows (e.g., 2 AM to 10 PM, 9 AM to 4 PM, etc.) to find the most profitable one.
- When finished, look at the top result. Compare its "Complex Criterion" score to your best score from the end of Phase 4. If applying a time filter has improved the overall result, it is a significant edge.
- Right-click on the top-performing row and select "Set Input Parameters".
Step 3: Optimize the Global Trade Concurrency (Quantity Filter)
The final question is about risk concentration. Is it better to allow the EA to take every valid signal, potentially opening multiple trades at once? Or is it safer and more profitable to limit it to just one or two high-conviction positions at a time?
- 1. Configure the Optimization:
- Lock in your new time settings: Go back to the "Inputs" tab and UN-TICK the checkboxes for StartHour and FinishHour.
- Tick the checkbox only for MaxActiveOrders.
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
MaxActiveOrders | YES ✔ | 1 | 1 | 20 | "Am I more profitable and safer if I limit you to taking only 1, 2, 3, or 4 trades at the same time?" |
- 2. Run the Final Test:
- Click "Start". This will be a very fast optimization.
- When it's complete, the results will clearly show which number of maximum orders produced the best result.
Action: Lock In Your Master S1 Settings File
- Right-click on the winning row from the MaxActiveOrders test and select "Set Input Parameters".
- Go to the "Inputs" tab one last time.
- Click the "Save" button at the bottom.
- Save this file with a clear, descriptive name, for example: S1_SuperTrend_M15_Optimized_2023.set.
You have now officially completed the entire 5-phase optimization for Strategy 1. This .set file contains your master configuration, where every single active parameter has been scientifically tested and validated. It is now ready for the most important step of all: validation on unseen data.
Part 3: Core Optimization for Strategy 2 (ZigZag Engine)
Title: Tuning the Second Engine: A Guide to Optimizing Strategy 2
Congratulations on fully optimizing Strategy 1. You now have a complete, data-driven trading system saved in your master .set file.
Now, we turn our attention to the second, independent trading engine within your XAU Breakout Scalper MT5: Strategy 2 (S2). This strategy operates on a completely different logic based on the classic ZigZag indicator, designed to identify and trade breakouts from significant market swing points.
Because S1 and S2 are separate systems, you must tune Strategy 2 with the same professional care you applied to Strategy 1. It is entirely possible that for certain market conditions or timeframes, S2 may perform even better than S1, or vice-versa. Optimizing both gives you maximum flexibility and allows you to deploy the best possible engine for the job.
Our goal in this part is not to repeat every single screenshot, but to equip you with the knowledge to confidently apply the 5-phase methodology you have already mastered to the unique parameters of Strategy 2.
Title: Applying the 5-Phase Methodology to the ZigZag Strategy
The powerful 5-phase optimization process you learned is a universal blueprint. The principles of starting simple, isolating variables, and building layer-by-layer are the keys to success, regardless of the underlying indicators.
We will now walk you through how to adapt each phase for the specific inputs that control Strategy 2.
Sub-Title: A Note on Re-using the Process for S2 Parameters
Before you begin, you must prepare your "Clean Slate" just as you did before, but this time, you will be enabling S2 and disabling S1.
Your Initial Setup for ALL S2 Optimization:
- Go to the "Inputs" tab in the Strategy Tester.
- CRITICAL: Set EnableStrategy1 to false.
- CRITICAL: Set EnableStrategy2 to true.
- Load your saved S1 master .set file. This is a good practice to ensure all global settings (like Time and Trade Management) start from a proven baseline, though you will re-optimize them for S2 later.
You are now ready to begin the 5-phase process again, from scratch, for Strategy 2.
Action: Repeat Phases 1-5 Using Only Strategy 2 Settings
Here is your guide to the key variables to optimize in each phase for Strategy 2.
Phase 1: The Baseline (S2 Entry Signal)
- Goal: Find the core "engine" of the ZigZag breakout signal.
- Disable all S2 filters and the S2 trailing stop. Use a wide, fixed SL and TP.
- Optimize these S2 parameters:
- ZigZagTimeframe
- ZigZagDepth
- ZigZagDeviation
- ZigZagBackstep
- PaddingPoints (This is a global setting, but it's part of the S2 entry logic here)
Phase 2: The Exit Strategy (S2 SL & TP)
- Goal: Find the best exit logic for the S2 signal.
- Lock in your winning S2 entry settings from the previous step.
- Optimize these S2 parameters:
- FallbackSLPoints_S2
- UseFixedTP_S2
- FixedTakeProfit_S2
- ZigZagRiskReward
Phase 3: The Refinement (S2 Filters)
- Goal: Test which filters add value to the S2 strategy.
- Test one by one:
- Test the S2_EnableMAFilter (optimizing S2_NumMAs, S2_MA1_Period, etc.).
- Test the EnableAdxFilter_S2 (optimizing AdxLevel_S2).
- Test the EnableVwapFilter_S2 (a simple On/Off backtest).
Phase 4: The Profit Maximizer (S2 Trailing Stop)
- Goal: See if the S2 trailing stop improves results.
- Lock in your winning S2 strategy from the previous steps.
- Enable UseTrailingStopStrategy2 and optimize its related parameters:
- BreakEvenStartPoints_S2
- ATRStartPoints_S2
- ATRTrailingPeriod_S2
- ATRTrailingMultiplier_S2
Phase 5: The Final Polish (Global Settings for S2)
- Goal: Find the best operating hours and trade limits for your tuned S2 strategy.
- Lock in your complete S2 strategy.
- Re-optimize the global parameters:
- StartHour and FinishHour
- MaxActiveOrders
Final Action for Part 3:
Once you have completed this full process, go to the "Inputs" tab and click "Save". Save this new file with a clear name, for example: S2_ZigZag_H1_Optimized_2023.set.
You now possess two distinct, professionally tuned master settings files—one for each of the EA's powerful trading engines. You are fully prepared to select the best tool for the current market or to proceed with advanced risk testing.
Part 4: Advanced Tuning - Risk & Money Management
Title: Introduction to Advanced Risk Overlays
Congratulations. You have successfully completed the core optimization process for one or both of the EA's trading engines. You now have master .set files that contain highly-tuned, statistically-proven strategies.
Now, we move from strategy tuning to risk tuning. This part of the guide will show you how to use the advanced risk and money management features built into the XAU Breakout Scalper MT5. These are powerful "overlays" that sit on top of your tuned strategy to control how it calculates trade sizes and manages overall account risk.
Think of it this way: until now, you have perfected the race car and the driver. Now, you will define the rules of the race itself: how much fuel to put in the car for each lap, and what safety conditions will cause the race to be stopped entirely.
We will cover two main topics:
- Money Management Models: How should the EA calculate the lot size for each trade?
- Portfolio Risk Engines: What master "circuit breakers" can we apply to the entire account to protect capital?
Title: Testing Money Management Models
Goal: To find the best risk calculation method for your tuned strategy.
Up until now, you have likely been optimizing using a FIXED_VOLUME (a fixed lot size) to keep the test results simple and consistent. Now, we will test the EA's dynamic lot sizing features to see if they can improve performance by adapting the trade size to your account's equity or market volatility.
Important: For this entire section, you will use one of your saved master .set files (e.g., S1_SuperTrend_M15_Optimized_2023.set). You will not be changing the strategy itself, only the money management method.
Step 1: Testing FIXED_RISK_PERCENT vs. FIXED_RISK_MONEY
This test answers the question: "Is it better to risk a consistent percentage of my account, or a fixed dollar amount per trade?"
- 1. Load Your Master Settings:
- In the Strategy Tester's "Inputs" tab, click "Load" and select your saved .set file.
- 2. Run Test A - Fixed Risk Percentage:
- Set MoneyManagementMethod to FIXED_RISK_PERCENT.
- Set RiskPercentage to a value you are comfortable with, for example, 0.5 (meaning 0.5% of your account balance per trade).
- Run a single backtest (Optimization "Disabled"). Note the final Profit, Drawdown %, and Complex Criterion score.
- 3. Run Test B - Fixed Risk Money:
- Now, set MoneyManagementMethod to FIXED_RISK_MONEY.
- Set FixedMoney to a dollar amount that is roughly equivalent to your percentage risk on your starting deposit (e.g., if you started with $10,000 and risked 0.5%, your FixedMoney would be $50).
- Run another single backtest. Note the results.
- 4. Compare and Decide:
- Compare the two backtest results. One method will likely produce a smoother equity curve and better overall score. Choose the MoneyManagementMethod that works best for your risk tolerance and performance goals. For most traders, FIXED_RISK_PERCENT is superior as it naturally compounds results during winning streaks and reduces risk during drawdowns.
Step 2: Testing the AutoScaleVolume Volatility Engine
This is an advanced feature that adjusts your calculated lot size based on market volatility. It asks, "Should we trade a smaller size when the market is volatile and a larger size when it is quiet?"
- 1. Enable the Feature:
- Using your preferred money management method from Step 1, now set AutoScaleVolume to true.
- 2. Optimize the Volatility Clamps:
- This feature is best tuned by optimizing its "clamp" settings. Tick the boxes for the following:
Variable | Tick Box? | Start | Step | Stop | Friendly Rationale: What We're Asking the EA |
AutoScaleVolClampMin | YES ✔ | 0.5 | 0.1 | 1.0 | "What is the minimum factor you should apply? Should you never scale down below 100% of the normal lot size (1.0)?" |
AutoScaleVolClampMax | YES ✔ | 1.0 | 0.2 | 2.0 | "What is the maximum factor you should apply? Should you cap the scaling at 150% (1.5) or more?" |
- 3. Run, Analyze, and Decide:
- Run this optimization. Compare the best result with your score from the end of Step 1.
- If the score improved, AutoScaleVolume is helping your strategy adapt to changing volatility. "Set Input Parameters" to lock in the winning clamp settings.
- If not, your strategy may perform better with a simpler, more direct lot calculation. Set AutoScaleVolume back to false.
Step 3: Testing Prop Firm Drawdown Mode
This is a specialized mode built specifically for traders using prop firm accounts, which have strict maximum drawdown rules. Only test this if you are a prop firm trader. This mode changes the base for the FIXED_RISK_PERCENT calculation from "Account Balance" to your "Remaining Drawdown Allowance."
- 1. Enable Prop Firm Mode:
- Set MoneyManagementMethod to FIXED_RISK_PERCENT.
- Set EnablePropFirmDrawdown to true.
- Enter your specific prop firm account rules:
- PropFirmMaxDrawdownAmount: Your total allowed drawdown (e.g., 10000).
- PropFirmRiskPercentage: The percentage of the remaining drawdown you wish to risk (e.g., 1.0).
- 2. Run a Final Backtest:
- Run one last single backtest. The equity curve should look different. It will be much more conservative, as the risk is dynamically reduced as your account approaches its maximum drawdown limit. This is not about maximizing profit, but about ensuring survival and adherence to prop firm rules.