Two envelopes, measured two ways, say something neither one manages alone. The contraction expansion trend indicator sets a spread-based envelope against a range-based one. When the first sits inside the second the market is coiling. It boxes that stretch and marks the bar the coil breaks.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 6: Coil upper, Coil lower, Expansion upper, Expansion lower, Coil resolves up, Coil resolves down |
| Alerts | popup, push notification, email, sound |
| Inputs | 45 |
What appears on the chart
Four envelope lines and two marks.
`Coil upper` and `Coil lower` trace medium purple.
`Expansion upper` and `Expansion lower` trace gold.
`Coil resolves up` prints chartreuse using arrow 233.
`Coil resolves down` prints orange red using arrow 234.
`InpShowBoxes` draws a rectangle over each coil.
- Coil upper: line, medium purple, width 1
- Coil lower: line, medium purple, width 1
- Expansion upper: line, gold, width 2
- Expansion lower: line, gold, width 2
- Coil resolves up: arrow, chartreuse, width 2, arrow code 233
- Coil resolves down: arrow, orange red, width 2, arrow code 234

Inside the calculation
Two half-widths
`InpRegimePeriod` `20` feeds both. `InpBbMult` `2.0` scales a spread figure. `InpKcMult` `1.5` scales a range figure. Two half-widths, one window.
One against the other
The ratio between those halves is the first test. `InpContractCR` `1.00` or under calls a coil. `InpExpandCR` `1.05` or over calls a break out of one.
The second test
Range against its own baseline. `InpAtrAvgPeriod` `50` sets that baseline, and either `InpContractRER` `0.90` or `InpExpandRER` `1.00` has to agree with the first test.
Using it on a chart
Purple inside gold means the market is coiling.
Purple outside gold means it has broken out.
A box marks a coil that has finished.
Marks land on the bar a coil broke.
`InpMinCoilBars` `5` is the shortest run boxed.
`InpMinBarsApart` `6` holds same-side marks apart.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
A coil breaking either way is what speaks. `EnableAlerts` is the master switch with `EnablePopup` on already. The push notification, the email route and the file named by `SoundFile` each begin switched off.
Every Contraction Expansion Trend Indicator input
Core settings: Regime engine
| Setting | What it does | Default |
|---|---|---|
InpRegimePeriod |
Regime period (basis SMA, std dev and ATR). Bars behind both envelopes, `20`. | 20 |
InpBbMult |
Bollinger multiplier (statistical half width). Multiplier on the deviation half-width, `2.0`. | 2.0 |
InpKcMult |
Keltner multiplier (drawn envelope half width). Multiplier on the range half-width, `1.5`. | 1.5 |
InpAtrAvgPeriod |
ATR baseline period (longer volatility average). Window behind the range baseline, `50`. | 50 |
InpMaxHalfAtr |
Hard cap on the envelope half width (x ATR). Hard cap on the drawn half-width, `4.0`. | 4.0 |
InpExpandCR |
Expansion entry: BB/KC ratio at or above. Ratio at or over which it calls a break, `1.05`. | 1.05 |
InpExpandRER |
Expansion entry: ATR / baseline at or above. | 1.00 |
InpContractCR |
Contraction entry: BB/KC ratio at or below. Ratio at or under which it calls a coil, `1.00`. | 1.00 |
InpContractRER |
Contraction entry: ATR / baseline at or below. | 0.90 |
Core settings: Input NAME changed, so the default signal set is byte-identi
| Setting | What it does | Default |
|---|---|---|
InpRequireExtremeClose |
Require an extreme close outside the envelope. | off |
InpMinBarsApart |
Minimum bars between signals on the same side. Bars held between same-side marks, `6`. | 6 |
InpTagGapPx |
Tag gap from the arrow (pixels). | 38 |
InpTagBars |
Draw text tags over the last N bars. | 300 |
InpMaxTags |
Hard cap on BUY / SELL captions drawn at once. | 30 |
Core settings: Text fencing
| Setting | What it does | Default |
|---|---|---|
InpPriceScalePx |
Right margin owned by the price scale, in pixels. | 62 |
InpOneClickWpx |
Width of the one-click trade panel zone, top-left. | 260 |
InpOneClickHpx |
Height of the one-click trade panel zone, top-left. | 100 |
Core settings: Coil boxes
| Setting | What it does | Default |
|---|---|---|
InpFillBoxes |
Fill the boxes (outline only when off). | off |
InpMinCoilBars |
Minimum bars for a run to be boxed. Shortest run that earns a box, `5`. | 5 |
InpBoxLookback |
Box the last N bars only. | 600 |
Core settings: Readout panel
| Setting | What it does | Default |
|---|---|---|
InpX |
Panel X offset (px). | 14 |
InpY |
Panel Y offset (px) – clears one-click panel. | 120 |
Display settings
| Setting | What it does | Default |
|---|---|---|
InpShowArrows |
Show contraction-resolves arrows. | on |
InpArrowPad |
Arrow distance from the bar (points). Points between a mark and its bar, `34`. | 34 |
InpShowTags |
Show BUY / SELL text next to the arrows. | on |
InpCapFontSize |
BUY / SELL caption font size. | 8 |
InpBuyColor |
BUY tag colour. | chartreuse |
InpSellColor |
SELL tag colour. | orange red |
InpAvoidPanel |
Keep arrows and captions clear of the info panel. | on |
InpLabelEdgePadPx |
Padding kept clear at the chart edges, in pixels. | 10 |
InpShowBoxes |
Box each completed contraction run. | on |
InpBoxColor |
Coil box colour. | medium purple |
InpShowPanel |
Show the regime panel. | on |
InpCorner |
Panel corner (0=UL 1=UR 2=LL 3=LR). | 0 |
InpFontSize |
Panel font size. | 9 |
InpFont |
Panel font. | Consolas |
InpPanelBg |
Panel background. | RGB 22,14,30 |
InpBorderColor |
Panel border. | medium purple |
InpTextColor |
Panel text. | gainsboro |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
Master alert switch. | on |
EnablePopup |
Popup alert. | on |
EnablePushNotify |
Push notification to the mobile terminal. | off |
EnableEmail |
Email alert. | off |
EnableSound |
Play a sound file. | off |
SoundFile |
Sound file name. | alert.wav |

Markets and timeframes
Coils need a chart where quiet stretches actually last. EURUSD H1 is the reference chart, where a boxed coil typically covers half a session. On M5 the regime flips constantly. On H4 a coil can run for most of a week.
The trade-offs
A coil breaking says nothing about how far price runs.
Both lines move only after the market does.
Boxes and captions add up to many chart objects.
Two tests agreeing is still two late measurements.
Copy the compiled Contraction Expansion Trend Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Background reading on the method behind the Contraction Expansion Trend Indicator: Bollinger BandWidth at StockCharts ChartSchool, Squeeze at Investopedia.
Download the Contraction Expansion Trend Indicator for MT4 and MT5
The zip holds the compiled Contraction Expansion Trend Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
What does the ratio between InpBbMult and InpKcMult measure?
How the deviation of closes compares against the size of recent bars. When the statistical half-width slips inside the range half-width, closes have bunched relative to how far bars are travelling, which is the coil condition.
Why does InpContractRER 0.90 add a second test?
Because the ratio alone can drop for the wrong reason. Requiring range to sit under ninety percent of its fifty-bar baseline confirms that the market really is quiet rather than merely producing tightly grouped closes.
What does InpMaxHalfAtr 4.0 prevent?
The drawn envelope from exploding after a shock. It caps the half-width at four ranges, so one enormous bar cannot stretch the lines so far that the chart becomes unreadable for the next fifty bars.
When does a Coil resolves up arrow print?
On the bar a boxed coil stretch ends upward. The rectangle marks where the market was quiet; the arrow marks where it stopped being quiet, which are two different pieces of information.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Contraction Expansion Trend Indicator as one input. Always backtest before trading live.
External references
- Learn more about the underlying method in Success trap on Wikipedia.
- For wider market background, see Guidelines For Applying Elliott Wave Theory at StockCharts ChartSchool.
