Discussing the article: "How to Test and Customize Built-in MQL5 Programs: Envelopes with Alligator Strategy"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: How to Test and Customize Built-in MQL5 Programs: Envelopes with Alligator Strategy.
Envelopes define percentage boundaries around a moving average, but a boundary touch alone does not identify whether the market is trending or ranging. We build Envelope_Alligator_Strategy.mq5, a custom indicator that reads the built-in Envelopes and Alligator buffers. Ordered Alligator lines classify directional states; interwoven lines identify a neutral state. This context changes how envelope crossings are interpreted and produces testable, non-trading chart signals.
The iEnvelopes() function returns a handle whose buffer 0 is the upper line and buffer 1 is the lower line. Each boundary is displaced from the moving average by a percentage. A widening or narrowing distance may reflect changes in the level of the moving average, but a fixed-percentage envelope is not a direct volatility estimator. More importantly, reaching a boundary does not automatically imply reversal.
In a range, movement beyond a boundary can be temporary and the price may return toward the center. During a directional move, however, the price can remain near one boundary or repeatedly cross it without producing a reversal. This difference is the main weakness of interpreting Envelopes alone: the same lower-band event can represent a range extreme, a healthy bullish pullback, or accelerating bearish pressure. We therefore need a second component that describes the market state before an envelope crossing becomes a signal candidate.
The standard Alligator is defined as three smoothed moving-average components: Jaws, Teeth, and Lips. The common configuration uses periods 13, 8, and 5 with forward visual shifts 8, 5, and 3, calculated with the Smoothed Moving Average method on PRICE_MEDIAN, which is (high + low) / 2. In this implementation, we reproduce those components with three unshifted iMA() source series and apply the configured shifts only to the visible plots, not to the source indices used by the signal logic. Their order gives us a compact state filter. Lips above Teeth above Jaws indicates an upward raw order; Jaws above Teeth above Lips indicates a downward raw order; any other arrangement is neutral. The filter keeps these cases distinct from directional orders that have not yet persisted for InpTrendMinBars. A persistent order confirms only the indicator state used by this method; it does not prove that the market is trending or predict the next move.
Author: Clemence Benjamin