Somebody recently asked over support channel for Fast Stochastic formulas.
Stochastics come with %K and %D lines and two flavors: "fast" and "slow". %D line is derived by smoothing %K line by 3-bar simple moving average. Then "slow" favor is obtained by yet another moving average applied on top of either fast %K or fast %D.
AmiBroker has built-in StochK()
and StochD()
functions that can return both "fast" and "slow" stochastics. The following table shows how this works
Stochastic | AFL code | Alternative AFL code |
---|---|---|
Fast %K (period) | StochK( period, 1 ) |
|
Fast %D (period) | StochK( period, 3 ) |
StochD( period, 3, 1 ) |
Slow %K (period) | StochK( period, 3 ) |
StochD( period, 3, 1 ) |
Slow %D (period) | StochD( period, 3, 3 ) |
As you can see Fast %D is the same as Slow %K. And Slow %D is actually double smoothed Fast %K.
Also for those who want "analytical" formula here it comes:
// FAST STOCHASTICS
function FastK( Kperiod )
{
mh = HHV( H, Kperiod );
ml = LLV( L, Kperiod );
return 100 * ( C - ml ) / ( mh - ml );
}
function FastD( Kperiod, Dperiod )
{
return MA( FastK( Kperiod ), Dperiod );
}
// fast stochastic %K -- both are the same
Plot( StochK( 14, 1 ), "StochK( 14, 1 )", colorRed );
Plot( FastK( 14 ), "FastK( 14 )", colorGreen );
// fast stochastic %d -- all three are the same
Plot( StochK( 14, 3 ), "StochK( 14, 3 )", colorBlue );
Plot( StochD( 14, 3, 1 ), "StochD( 14, 3, 1 )", colorYellow );
Plot( FastD( 14, 3 ), "FastD( 14, 3 )", colorGreen );