MA + Envelope Breakouts

MA + Envelope Breakouts
Download ALL MT5 experts (1569)
YouTube Video Thumbnail



Similar MetaTrader Tools

MA + Envelope Breakouts

Info

The MA + Envelope Breakouts is a Expert Advisor for MetaTrader 5 that here is a brief, technical narration of the core logic driving your expert advisor. The architecture relies on an equity-based portfolio management model rather than traditional pip-based static targets.

Usage

This tool is typically used for breakout trading when price moves beyond key support/resistance levels.

Platform

This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use MA + Envelope Breakouts

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

Here is a brief, technical narration of the core logic driving your Expert Advisor.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.

Description & Settings

Related: exp trend envelopes - another powerful expert for MetaTrader 5 traders.



Here is a brief, technical narration of the core logic driving your Expert Advisor. The architecture relies on an equity-based portfolio management model rather than traditional pip-based static targets.

Also recommended: exp color qe m a envelopes digit system - similar expert with strong performance on MetaTrader 5.


1. Entry Logic (Conditionals)

The EA evaluates trading conditions on a per-bar basis, comparing the previous completed candle ( Close[1] ) and the current developing candle ( Open[0] ) against indicator buffers.

Cycle 1 (Moving Average):
Acts as a basic trend-following module.

Buy:
Triggers if Close[1] and Open[0] are both strictly
above
the MA line.

Sell:
Triggers if Close[1] and Open[0] are both strictly
below
the MA line.

Cycles 2 & 3 (Envelopes):
Acts as a breakout or momentum module.

Buy:
Triggers if Close[1] and Open[0] are both
above
the Upper Envelope band.

Sell:
Triggers if Close[1] and Open[0] are both
below
the Lower Envelope band.

(Note: Cycle 3 is a direct clone of Cycle 2 logic, simply running on an independent magic number and deviation parameter).

2. Take Profit (TP) and Stop Loss (SL) Logic

Instead of sending hardcoded SL/TP price levels to the broker, this EA manages risk internally by monitoring
floating equity
.

When a cycle initiates its first trade (e.g., Buycount == 0 ), the EA snapshots the current Account Equity and calculates two monetary thresholds:

Target Price (TP):
Initial Equity + (Initial Equity * target_percent / 100)

Risk Price (SL):
Initial Equity - (Initial Equity * risk_percent / 100)

Execution:
On every tick, custom functions ( MyAccountProfit_Buy / MyAccountProfit_Sell ) aggregate the floating profit, swap, and commission for all active positions tied to a specific Cycle's Magic Number. If Initial Equity + Floating Profit hits either the Target (TP) or Risk (SL) threshold, the EA triggers a routine to close all positions for that cycle and resets the cycle state.

Codebase Anomaly Note: In your original Cycle 1 Buy logic, the target/risk math divides by 1000 instead of 100, which calculates a 0.1% target instead of 1%. Cycles 2, 3, and Cycle 1 Sells divide by 100.

3. Execution & State Management

Bar Lock:
To prevent opening hundreds of trades on a single candle, the EA stores the Open[0] price into open_price . A new trade is only authorized if the current open price differs from the stored variable (ensuring one entry per bar).

Alternation / Grid:
Variables like c1_Buycycle and c1_sellcycle are used to toggle the availability of the opposing signal. For instance, successfully executing a Buy disables further independent Buys but primes the Sell cycle, suggesting a loosely structured hedging or reversal grid.

You may also like: exp color pe m a envelopes digit system - excellent alternative for expert users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version   "1.02"
#include <Trade\Trade.mqh>
input int risk_percent = 99;
input int target_percent = 1;
input bool cycle1 = true;
input bool cycle2 = false;
input bool cycle3 = false;
input double LotSize = 0.01;

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.