Perry Kaufman's Adaptive Moving Average (KAMA) changes its own speed depending on market conditions. It measures the Efficiency Ratio (ER): the net price change over N bars divided by the sum of all bar-to-bar changes over the same N bars. ER is close to 1 when price moves in a straight line and close to 0 when it moves sideways with a lot of noise. The ER then sets the smoothing constant between a fast and a slow EMA. In a clean trend KAMA follows price closely, and in a choppy range it almost stops moving.
A single KAMA depends heavily on the ER period N. This indicator draws several KAMA lines at once. The first one uses a short ER period and each following one uses a longer period (by default 5, 8, 11 ... 26). Because every line measures "trendiness" over a different window, the ribbon shows how a trend develops across several horizons: lines fan out and line up when the move is persistent, and bunch together or cross when the market is ranging or turning.
Everything is calculated from the standard KAMA formula:
ER = |P[i] - P[i-N]| / Sum(|P[k] - P[k-1]|, N bars) SC = (ER * (2/(Fast+1) - 2/(Slow+1)) + 2/(Slow+1))^2 KAMA = KAMA[prev] + SC * (P[i] - KAMA[prev])
The indicator draws only in the main chart window. The values of all lines are available in the Data Window and through iCustom() (buffers 0–7, from the fastest to the slowest line).
| Input | Default | Purpose |
|---|---|---|
| InpRibbonCount | 8 | Number of KAMA lines in the ribbon (1–8). Unused plots are hidden. |
| InpFirstER | 5 | Efficiency Ratio period of the first (fastest) line. |
| InpERStep | 3 | Increment of the ER period for every next line. With the defaults the periods are 5, 8, 11, 14, 17, 20, 23, 26. |
| InpFastPeriod | 2 | Period of the fast EMA: the upper limit of adaptation, used when ER = 1. |
| InpSlowPeriod | 30 | Period of the slow EMA: the lower limit of adaptation, used when ER = 0. Must be greater than InpFastPeriod. |
| InpPrice | PRICE_CLOSE | Applied price used for the calculation. |
| InpShowStatus | true | Show or hide the on-chart status label. |
| InpCorner | CORNER_LEFT_UPPER | Chart corner in which the status label is placed. |
| InpStatusColor | clrWhite | Color of the status label text. |
Invalid parameters (for example a count outside 1–8 or a slow period not greater than the fast period) stop the initialization and a message is printed to the Experts tab.

Fig. 1. KAMA Ribbon (8 lines) on a price chart; black & white image according to the Code Base image guidelines.
Hull Moving Average with Slope Color Change
Hull Moving Average that changes color with its slope: one color while the line rises, another while it falls, a neutral one when it is flat, with optional arrows at the turns.
Gold Trend Breakout Lite — educational XAUUSD trend-following EA
Open-source gold EA built on XAUUSD's multi-day trend persistence: H1 Donchian breakout in the direction of the D1 EMA slope, 3×ATR hard stop, break-even at +1R. Fixed lot, one position, no grid, no martingale.
ATR Trailing Stop Line (Chandelier Exit)
ATR Trailing Stop Line (Chandelier Exit): a volatility-based trailing stop that hangs below the highest high in an up-trend and rises above the lowest low in a down-trend, with trend-flip arrows, an on-chart status label and optional alerts.
Breakeven and R-Trail Manager — break-even at +1R and R-multiple trailing for any trade
Utility EA that moves the stop to break-even plus a small lock once a trade reaches +X R, then trails it N R behind price. Manual trades or any EA by magic number. Never opens trades and never widens a stop.