On this page
What Schaff Trend Cycle shows
Schaff Trend Cycle is a 0–100 oscillator developed by Doug Schaff. This implementation applies two stochastic normalization stages to the MACD main line, smoothing each with a fixed factor of 0.5. It is not RSI, price ATR or a volume indicator. STC and MACD use the same price history, so agreement between them is not independent confirmation.
ForexBestRobots edition 1.05 is a marked derivative of EarnForex 1.04. We use a documented common EMA seed, deterministic recalculation, input guards, closed-candle events and separate object namespaces. Both platform ZIPs retain the original source, author notices, Apache 2.0 and a patch explaining the changes.
From MACD to two stochastic stages
The input is Close. MACD M is EMA(Close,MAShort) minus EMA(Close,MALong); defaults are 23 and 50. This is the MACD main line, not the histogram after subtracting a signal line. For a series X, stochastic normalization over Cycle bars is K=100×(X−lowest)/(highest−lowest). The first smoothed stage uses M; the second uses the first stage. Each smoothing step is previous+0.5×(K−previous).
Both EMAs start from the first available Close and use alpha=2/(period+1). The first stochastic starts after Cycle observations. The second starts after Cycle+1 first-stage observations, retaining the upstream first-pass delay. Each first valid stage value is seeded directly. At default settings the first 70 candles are hidden; that warm-up does not make different history windows identical.
A zero or almost zero range carries the previous stage value, initially zero. The MACD-range tolerance is 1e−12 times the current price; the second-stage tolerance is 1e−10 oscillator units. These numerical guards and the common seed can make this edition differ from other STC implementations. Flat values at 0 or 100 do not predict an immediate reversal.
M_t = EMA_f(Close)_t - EMA_l(Close)_t K_C(X)_t = 100 * (X_t - LLV_C(X)_t) / (HHV_C(X)_t - LLV_C(X)_t) S_t = S_(t-1) + 0.5 * (K_C(M)_t - S_(t-1)) STC_t = STC_(t-1) + 0.5 * (K_C(S)_t - STC_(t-1))
Real EUR/USD examples
These are our reconstructions of archived real Yahoo Finance EUR/USD H1 candles, with earlier history from January 2025. Times are UTC. They are not MetaTrader screenshots, tick replay or a profit backtest. CSV files contain prices, intermediate calculations, threshold events and confirmation times.
In the first figure, A is the 10 June 2025 01:00 source candle: STC falls from 98.985 to 66.236, below 75; it is known at 02:00. B at 11:00 rises from 13.247 to 56.623, above 25; it is known at 12:00. The letters identify source candles, while program arrows are placed at the confirmation opening.
The second figure shows alternating events: 4 June 07:00 upward, 5 June 03:00 downward, and 5 June 12:00 upward. Each is confirmed at the next hourly opening. A threshold event alone does not define an entry, stop-loss or exit. The third figure changes only Cycle to 5, 10 and 20; a different curve is not evidence of better trading performance.



Chart timeframe and confirmation time
This edition calculates on the chart timeframe. It has no higher-timeframe input or built-in MTF mapping. An H1 example does not imply that these readings also describe H4. Changing the chart timeframe changes the source candles and restarts the calculation.
A closed-candle event compares the last two closed chart candles. It is observable when the next available candle opens; after a weekend or missing quotes, that can be later than the nominal candle close. Program timestamps follow the broker clock. The current candle’s plotted STC can change before it closes.
Settings and default values
Both platforms expose the same 11 inputs. Require 1≤MAShort<MALong≤10000 and Cycle between 2 and 1000. Each instance on the same chart needs a unique ObjectPrefix of 1–32 ASCII letters, digits, underscores or hyphens. Large periods and long histories need more calculation time.
| Input | Default | Practical meaning |
|---|---|---|
MAShort | 23 | Fast Close EMA period; must be positive and smaller than MALong. |
MALong | 50 | Slow Close EMA period; maximum 10000. |
Cycle | 10 | Window of each stochastic stage; 2–1000 bars. |
ShowArrows | false | Draw confirmed-event arrows; independent of messages. |
UpColor | clrBlue | Color of upward-event arrows. |
DownColor | clrRed | Color of downward-event arrows. |
ShowAlerts | false | Show a platform popup for a new confirmed event. |
SoundAlerts | false | Play alert.wav for a new confirmed event. |
EmailAlerts | false | Send email; configure the terminal first. |
PushAlerts | false | Send a push notification; configure MetaQuotes ID first. |
ObjectPrefix | "FBR_STC" | Unique per chart; 1–32 ASCII letters, digits, underscores or hyphens. |
Threshold events, arrows and notifications
An upward event requires current STC>25 and previous STC≤25. A downward event requires current STC<75 and previous STC≥75. Equality on the current candle is not an event; equality on the previous candle is allowed. The two thresholds are fixed, not input settings.
ShowArrows and all four delivery switches are off by default. Arrows and messages are independent. Historical arrows, when enabled, appear at the next available opening after a closed source candle; no arrow is created from the still-forming source candle. Marker price uses already known source extremes and the confirmation open.
Initial attachment and explicit history resets are silent. Later calculations process the most recent closed event once per new opening; historical catch-up does not send a queue of old messages. A failed delivery is not retried on every tick. Email and push require terminal configuration and an online desktop terminal. The program displays calculations and does not place or manage trades.
Install and compile the source
- Extract the ZIP for desktop MT4 or MT5.
- In MetaTrader select File → Open Data Folder, then MQL4 or MQL5.
- Copy the ZIP’s Indicators folder there. Keep upstream separately as the original reference.
- Open Schaff_Trend_Cycle_ForexBestRobots.mq4 or .mq5 in the matching MetaEditor, press F7 and inspect errors and warnings.
- Refresh Navigator → Indicators and attach the compiled program to a demo chart with sufficient history.
- Use a unique ObjectPrefix. Start with notifications off, compare closed-candle events and only then configure the delivery channels you need.
These are source packages, with no ready EX4/EX5. Desktop custom indicators cannot be installed directly in the MetaTrader mobile app. A CSV is explanatory data, not an installable indicator.
Download STC free
Download the ZIP for your platform directly from our site. It contains the marked source, unchanged EarnForex original, Apache 2.0, change notes, a patch, checksums and installation instructions in all 12 site languages. No DLL, external include or trading account registration is required to download the files.
Compile the source with F7 in the matching desktop MetaEditor, inspect errors and warnings, then test on a demo chart. Numerical and modeled-API checks outside MetaTrader do not verify native compilation, chart rendering, broker history handling or actual notification delivery.
Free source ZIP · ForexBestRobots edition 1.05 · Compile in MetaEditor
Changing values and practical limits
STC transforms historical prices; it does not provide a win probability. Threshold events can alternate in a range or occur during a pullback inside a continuing trend. MACD and STC agreement does not add an independent data source. These examples establish no trading performance.
The current value moves while its candle forms. Closed-candle confirmation removes that open candle from event detection, but corrected prices, older history, the EMA seed and different feeds can still change historical results. Reload after history corrections that the platform does not flag for recalculation.
The round-off tolerances, warm-up, seed and arrow timing are explicit choices of this edition. Compare their definitions before treating another STC curve as an error. Use distinct prefixes for multiple copies; cleanup is limited to objects owned by that instance.
Frequently asked questions
Is STC the same as RSI or the MACD histogram?
No. It uses two smoothed stochastic stages of the MACD main line. It does not use RSI or a MACD signal-line histogram.
Can I change the 25/75 levels or factor 0.5?
Not in these inputs. MAShort, MALong and Cycle are adjustable; the two thresholds and smoothing factor are fixed.
When is a signal confirmed?
After its source candle closes, at the next available chart opening. The arrow marks that confirmation opening.
Does this edition support MTF?
No. It uses the current chart timeframe. Changing the timeframe restarts the calculation.
Why are there no messages or arrows?
All switches are off by default. Enable arrows separately; for email or push, also configure the corresponding terminal service.
Why is the beginning blank or STC stuck near 100?
The first 70 candles are hidden at defaults. Later, a persistent value near an extreme can occur during a trend and is not an automatic reversal signal.
Are the downloads compiled and verified in MetaTrader?
No. They contain MQ4/MQ5 source for desktop MetaEditor. Source-level numerical tests do not verify native compilation or runtime.
Sources and review scope
This review follows the pinned EarnForex revision and our marked changes. Doug Schaff’s authorship and the TradeStation adaptation credit are retained. Real-data figures are our calculations. Inclusion does not imply endorsement by Doug Schaff or EarnForex.