The smoothing is the strategy
The stochastic oscillator reports where the close sits inside a recent high-to-low range, on a 0–100 scale, as two lines:
- %K — the raw position, then smoothed
- %D — a moving average of %K
A crossover strategy trades %K crossing %D. Which means the signal you are trading is produced almost entirely by the smoothing values, not by the lookback length — and that is the opposite of where most people spend their tuning effort.
Why the lookback is the least important of the three
| Parameter | What changing it does |
|---|---|
| %K length (lookback) | changes where the extremes are, not how often the lines cross |
| %K smoothing | changes the crossover count directly |
| %D smoothing | changes the crossover count directly |
Two lines that are both lightly smoothed cross constantly, because they are nearly the same series. As you increase either smoothing value the lines separate and cross less.
So if you widened the lookback from 14 to 21 and your results barely moved, that is expected — you adjusted the parameter that does not control your trade count. The diagnostic is simple: change each of the three by a meaningful amount in turn and note the trade count each time. The one that moves it is the one that matters, and on a stochastic crossover it will be a smoothing value.
The pinning problem
Like RSI, the stochastic is bounded, so in a strong trend it reaches an extreme and stays there. But the crossover version has a worse version of this problem: while both lines sit near 80, they continue to cross each other repeatedly on noise.
So a strong uptrend produces a stream of crossover signals, all inside the same trend, none of them marking a turn. A strategy that shorts each bearish cross is short a trending market repeatedly.
The fix is the same as for RSI — a trend gate, and then a check that it is doing something: the confluence count test.
Building it
| Field | Value | Note |
|---|---|---|
| %K length | 14 | affects the extremes, not the cross frequency |
| %K smoothing | 3 | this is your trade-count dial |
| %D smoothing | 3 | so is this |
| Entry | %K crosses above %D below 20 | the level condition filters the trend crosses |
| Exit | %K crosses below %D, or an ATR stop |
Restricting the cross to below 20 (or above 80 for shorts) is what stops the strategy taking every mid-trend cross. It is a cheap and effective filter, and it is worth confirming it removes trades rather than assuming it.
What to verify in the export
The two smoothing values must appear as separate movable inputs. If the export declares three inputs but the emitted condition contains hard-coded numbers, the controls are inert and you will spend an afternoon tuning nothing — which is exactly the defect the input test catches: reading the Strategy Tester.
Tactix AI — Studio vs Guide
Tactix AI is AlfaTactix’s product assistant brand (open Tactix AI).
- Tactix Studio turns a one-sentence strategy description into a draft across Timeframe, Signals, Filters, and Risk in the visual Strategy Builder. You review and edit every field before Code Generator writes MQL5 or Pine Script.
- Tactix Guide explains the step you are on — what to fill, what a control means, or how to phrase a rule — without dumping untested source code.
That is form-first automation: the LLM never replaces Code Generator, and you keep plan limits and real-time validation.

