Real-World Solutions

Building a Custom Dual-MA Strategy with DrawMyEA

Hanz Osborne

· 4 min read
A cartoon trader with exaggerated funny features sits at a cluttered desk facing a glowing computer monitor. On the screen, green and red moving average lines swirl like animated ribbons across a MetaTrader 5 chart. Floating puzzle-shaped nodes snap together above the desk, forming a cheerful robot with silly eyes. Coffee mugs, sticky notes, and bar counters march around the desk, creating a humorous and magical trading scene that visually represents building a custom dual moving average strategy with DrawMyEA.

In our new Real-World Solutions series, we take actual project descriptions from the MQL5 Freelance board and show you how to build them yourself. Instead of spending your budget on a developer for a "standard" strategy, you can use DrawMyEA to visualize the logic and generate the code in a fraction of the time.

Today, we’re looking at Job #248647: A dual-set Moving Average strategy that requires precise entry timing and multi-directional trade management.

Image

The Challenge: The "Two-Set Moving Average" Strategy

A trader on MQL5 recently requested an Expert Advisor with the following logic:

  • Two Sets of Moving Averages: Set 1 (Fast/Slow) for entries and Set 2 (Fast/Slow) for exits.
  • The Entry Rule: Buy when Set 1 Fast crosses above Set 1 Slow, but only if it happened within a specific number of bars.
  • The Exit Rule: Close the Buy when Set 2 Fast crosses below Set 2 Slow.
  • The Twist: Short and Long trades can run simultaneously.

In traditional MQL5 coding, managing two different sets of indicators and the "bars since cross" logic requires careful handle management and counter variables. In DrawMyEA, it’s just a few nodes.

Step 1: Setting up the Indicators

First, we drag and drop our Moving Average nodes. Since the user wants two distinct sets, we create:

  1. Set 1 (Entry): Fast MA and Slow MA.
  2. Set 2 (Exit): Fast MA and Slow MA.

Step 2: Defining the Entry Logic (with the "Number of Previous Candles to Search")

The requirement states: Open a Long trade when Set 1 crosses... as long as the number of bars is not more than a certain number after cross-over.

In DrawMyEA, we use the Cross above node. To satisfy the "bar limit," we simply set Number of Previous Candles to Search input parameter.

  • Logic: Crosses Above (Set 1 Fast, Set 1 Slow)

Step 3: Defining the Exit Logic

The exit logic is independent of the entry set. We simply look for the crossover on Set 2.

  • Long Exit: Crosses Below (Set 2 Fast, Set 2 Slow).

Step 4: Enabling Simultaneous Trades

The client specified that a Short trade could open while a Long trade is still active.

In the Inputs settings, we simply ensure Entry Mode is set to Buy and Sell. This allows the EA to trigger a Sell signal based on Set 1 even if the Set 2 Exit hasn't triggered for the Long position yet.

The Result

What would have cost $30 and a 3-day wait on MQL5 Freelance is now a completed file ready for MetaTrader 5.

Image

Why this matters:

  • Instant Iteration: Want to change the "Number of Previous Candles to Search" from 3 bars to 5? Just change the number in the Inputs. No need to ask a developer for a revision.
  • Visual Clarity: You can see exactly why a trade opened by looking at the node connections.
  • Cost-Effective: You keep your strategy private and your budget in your pocket.

Ready to build your own?

Don't let your strategy ideas sit in a "to-do" list. Head over to DrawMyEA.com and turn your MQL5 job descriptions into working robots today.

See the Build in Action

Want to see exactly how these nodes were connected? Watch the 5-minute build video below to see us take this MQL5 job from a description to a finished EA download and then verify the trades in MetaTrader.

https://youtu.be/IrmNO4uXzN0

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·