Schaff Trend Cycle
A plain MACD is normally read against its own zero line, and that is exactly what makes it late at trend changes - it has nothing to compare itself to except its own history, so a genuine reversal has to travel all the way back through zero before it registers. Schaff Trend Cycle fixes this by running a stochastic %K-style rescale on the MACD spread itself: not "is the MACD above zero" but "how high is the MACD currently sitting inside its own recent range". That rescaled value is then smoothed and put through a second stochastic rescale on top of the first one's own output. The double pass is what gives STC its bounded 0-100 reading and its earlier turns - the cost is that it is a fully derived oscillator with no price unit of its own, two steps removed from the MACD, so it should be read as a timing tool for a trend call made elsewhere rather than as a trend indicator by itself. Both stochastic passes are smoothed with the same simple recursive factor (0.5 by default) that Schaff's original description uses, rather than a fixed-length moving average - each new reading nudges the smoothed value halfway toward it rather than averaging a fixed window of past readings. Notes and limitations - Needs roughly SlowEmaPeriod + 2 x CyclePeriod bars of history before the first value appears; earlier bars are intentionally left empty. - When either stochastic pass's recent range is completely flat (its high and low over CyclePeriod bars are equal), that pass holds its previous smoothed value rather than dividing by zero - a legitimate edge case in a genuinely flat market, not a bug. - This is a bounded, derived oscillator, not a price-based level - it does not itself suggest an entry price or a stop distance. - The forming, still-open bar's reading can still change tick to tick as its own underlying MACD develops through the bar - that is normal intrabar update for any live oscillator, not repainting of a closed bar.
Indicator · MT4 · v1.0 · Free
About Schaff Trend Cycle
Schaff Trend Cycle is an indicator for MetaTrader 4 based on Moving Average. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Fast ema period, Slow ema period and Cycle period. MQL source code included.
Files in the download: SchaffTrendCycle.ex4, SchaffTrendCycle.mq4, SchaffTrendCycle.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fast ema period | 23 | Fast EMA period for the underlying MACD |
| Slow ema period | 50 | Slow EMA period for the underlying MACD |
| Cycle period | 10 | Lookback for both stochastic rescale passes |
| Factor | 0.5 | Recursive smoothing factor for each stochastic pass |
| Alerts | true | Alert once per closed bar on a 25/75 threshold cross |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: MACD · Stochastic · Trend · Alerts · Moving Average · MT4 Indicator · MQL4 Source Code