Idea by: Vladimir Khlystov.
MQL5 Code by: barabashkakvn.
If you’re looking to enhance your trading strategy, the Virtual Trailing Stop is a game-changer for MetaTrader 5 users. This nifty feature allows you to set up stop loss and take profit levels that remain invisible to your broker—meaning your trading plans are kept strictly between you and your PC.
But that’s not all; this approach also helps you dodge the pitfalls associated with brokers that have wide spreads and specific stop order levels. With the Virtual Trailing Stop, you can ignore those levels entirely, giving you more control over your trades.
Let’s dive into how the trailing works, as it’s essential for maximizing your profits while minimizing potential losses.
How Trailing Stops Work
The Virtual Trailing Stop relies on three main parameters:
- Trailing Length
- Minimum Profit to Activate
- Tailing Step
Here’s a quick breakdown of each:
Trailing Length: This defines the distance behind the current price at which your stop loss will follow.
Minimum Profit: This is the profit level you need to hit before the virtual stop loss starts kicking in.
Tailing Step: This interval dictates how often the virtual stop loss will adjust to follow the price.
Let’s say you set your parameters to 5, 2, and 3, respectively. Here’s how it works:
Once your position hits a profit of 7 points, your virtual stop loss will move up to your entry price plus the minimum profit of 2 points. Then, as the price climbs another 3 points in your favor, the stop loss will adjust up by 5 points. This process continues, trailing the price by 3 points. If the market takes a dip and hits your stop level, your position will be closed automatically.
The trailing stop will be displayed as dashed lines on your chart, making it easy to visualize where your stops are set.
For a better understanding of how the EA operates, I recommend installing it in the tester. You can watch it in action in visualization mode, which makes it easier to grasp its mechanics:

Related Posts
- Harnessing MQL5 Wizard for Trading Signals: 3 Black Crows & 3 White Soldiers with MFI
- Mastering Trading Signals with MQL5 Wizard: Bullish and Bearish Engulfing Strategies
- Creating a Stochastic-Based EA for Hammer and Hanging Man Patterns in MetaTrader 5
- Creating an Expert Advisor for Dark Cloud Cover and Piercing Line Patterns with CCI Confirmation
- Creating Powerful Trade Signals with MQL5 Wizard: Bullish and Bearish Engulfing Patterns + RSI