Real-World Solutions

Building a Multi-EMA Retest Bot: From MQL5 Job to Working EA

Hanz Osborne

· 4 min read
A whimsical cartoon trader with exaggerated funny features sits at a glowing computer monitor, surrounded by colorful EMA lines labeled 15, 30, 60, and 90 curling back like playful ribbons. On the desk, tiny trade action buttons march in sequence with lot sizes 0.01, 0.02, 0.03, and 0.04, while a cheerful robot made of puzzle‑shaped nodes hovers above juggling stop‑loss and take‑profit icons. Animated candlesticks dance across the background chart, visually representing a multi‑layered EMA retest strategy built in DrawMyEA for MetaTrader 5.

Whenever I browse the MQL5 Jobs board, I’m always looking for specific logic patterns that can be streamlined. Today’s pick (#249213) is a classic example: a multi-layered EMA retest strategy. It looks complex on paper, but as we’ve seen before, breaking these jobs down into modular code is easier than you might think.

This specific strategy uses three different Exponential Moving Averages (EMAs) to scale into positions as the price retraces. Let’s dive into how we can build this.

Image

The Logic: 3 Layers of Entry

The client for this job wants to enter trades as the price pulls back to specific Exponential Moving Averages (EMAs). Instead of one big entry, they want to "scale in" with larger lots the deeper the price retraces:

  • 15 EMA @ 0.01 Lot
  • 30 EMA @ 0.02 Lot
  • 60 EMA @ 0.03 Lot

The Goal: If the trend is strong, you catch it early. If it pulls back deep, you get a better average price with higher volume.

Visualizing the Build in DrawMyEA

In a traditional coding environment, you’d be writing dozens of lines to manage four separate positions and tracking magic numbers. In DrawMyEA, it’s just a matter of connecting the right nodes.

1. Setting the "Foundation" Nodes

First, we drop four Moving Average nodes onto the canvas. We’ll set them all to "Exponential" and assign our periods: 15, 30, and 60.

2. The Cross Signal

We use a Candle node connected to three Cross nodes to identify when the price has officially crossed above an EMA. This tells the EA that a specific trend level is now active and "in play."

3. The Retest Trigger

The "Trigger" is the pull-back. Once the signal is established, we look for the price to return and "test" that EMA level again. In DrawMyEA, we use a Retest node to detect when the current price touches the EMA value. This ensures we aren't just chasing the initial breakout but entering at the most efficient price point.

  1. long and short condition: Connect the output of Cross Node to the input conditions to signal that price has already crossed above the EMA line.
  2. value: Attach the EMA output to the node’s value endpoint, specifying which EMA line the price is retesting against.

4. Scaling the Lots

Instead of complex math, you simply link each trigger to a Trade Node with its specific lot size (0.01, 0.02, etc.).

5. Managing the Risk (1:2 Ratio)

The job specifies a 10-pip Stop Loss. While the client didn't specify a Take Profit, a professional 1:2 Risk/Reward ratio is a solid choice.

We configure the Stoploss and Takeprofit directly inside each correspnding action node.

  • Stoploss from entry; distance in points: 100
  • Takeprofit based on Risk Reward; ratio: 2

Setting it this way means that even as you scale in with different lot sizes, each specific position is governed by its own precise risk parameters the moment it hits the market.

The Result

Image

To ensure the bot operates cleanly, we keep the "Max Number of Simultaneous Trades" at the default level of 1. This prevents the EA from opening multiple entries on the same EMA if the price "flickers" on the line, keeping your risk exactly where you want it.

Why Build This Yourself?

Why did we choose this specific job? Because it highlights the power of Logic Layering.

  • Speed: While a hired dev might take 3 days, you can drag these nodes together in 10 minutes.
  • Flexibility: Don't like the 60 EMA? Just click the node and change it to 100. No recompiling, no searching through lines of code.
  • Visual Clarity: You can see exactly why a trade was triggered because your logic map is right in front of you.

Conclusion

Turning a professional MQL5 job into a working MT5 bot doesn't require a computer science degree; it just requires the right tools. With DrawMyEA, you are the architect. You take the idea, draw the logic, and export the bot.

Ready to build your own version of the EMA Retest bot? Head to DrawMyEA.com and start dragging!

Note: Automated trading carries significant risk. Always test your visual EAs in the MT5 Strategy Tester before going live.

See the Build in Action

Disclaimer: MetaTrader®, MT4, and MT5 are trademarks of MetaQuotes Software Corp.
DrawMyEA is an independent service and is not affiliated with, endorsed by, or sponsored by MetaQuotes.
Copyright © 2026 DrawMyEA. All rights reserved.
Made by Web3Templates·