Stochastic Signal
The Stochastic Signal is a moving average of the %K line that generates trading signals.
Role in the strategy
| Slot | Available | Role |
|---|---|---|
| Entry Point | No | — |
| Entry Rule | Yes | Filters entries by the %K position against the Signal line. |
| Exit Point | No | — |
| Exit Rule | Yes | Triggers exits by the %K position against the Signal line. |
The Stochastic Signal produces conditions, not order prices. As an entry rule it is ANDed with the entry point and the other entry rules; as an exit rule it is ORed with the other exit rules.
Logic rules
| Rule | Long signal is 1 when | Short signal is 1 when |
|---|---|---|
| Stochastic line crosses the Signal line upward | %K crossed above the Signal line | %K crossed below the Signal line |
| Stochastic line crosses the Signal line downward | %K crossed below the Signal line | %K crossed above the Signal line |
| Stochastic line is higher than the Signal line | %K is above the Signal line | %K is below the Signal line |
| Stochastic line is lower than the Signal line | %K is below the Signal line | %K is above the Signal line |
The comparison uses the previous bar's values for both lines.
Parameters
| Parameter | Type | Default | Range | Purpose |
|---|---|---|---|---|
| %K Period | number | 5 | 1 to 1000 | Bars of the price range for the raw %K |
| %D Period | number | 3 | 1 to 1000 | Period of the Signal line |
| Slowing | number | 3 | 1 to 1000 | Additional smoothing of the %K line |
Calculation
tech.Stochastic in engine/indicator-engine/tech.ts computes the %K line (close position within its range, smoothed over the Slowing period); tech.StochasticSignal computes the Signal line as a moving average of the %K over the %D Period. The %K line and the dotted Signal line are drawn in a separate chart pane.
Backtesting
- The rule is evaluated on the previous (closed) bar with the standard dead zone (
SIGMA = 0.000001). - The indicator contributes only long/short signal arrays — it never changes the entry or exit order price.
- An entry happens only when the entry point allows the direction and every entry rule passes; an exit happens when the exit point is reached and any exit rule passes.