Stochastic Signal

The Stochastic Signal is a moving average of the %K line that generates trading signals.

Role in the strategy

SlotAvailableRole
Entry PointNo—
Entry RuleYesFilters entries by the %K position against the Signal line.
Exit PointNo—
Exit RuleYesTriggers 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

RuleLong signal is 1 whenShort 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

ParameterTypeDefaultRangePurpose
%K Periodnumber51 to 1000Bars of the price range for the raw %K
%D Periodnumber31 to 1000Period of the Signal line
Slowingnumber31 to 1000Additional 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.