StochK

Modified on 2008/05/03 15:43 by Administrator — Categorized as: Standard Indicators

Syntax

public static StochK Series(Bars source, int period)
public StochK(Bars source, int period, string description)

Parameter Description

source The Bars object
period Indicator period

Description

StochK returns the Stochastic Oscillator %K. The Stochastic Oscillator measures how much price tends to close in the upper or lower areas of its trading range. The indicator can range from 0 to 100. Values near 0 indicate that most of the recent price action closed near the days lows, and readings near 100 indicate that prices are closing near the upper range.

The Stochastic is a momentum indicator. The closing price tends to close near the high in an uptrend and near the low in a downtrend. If the closing price then slips away form the high or the low, then momentum is slowing. Stochastics are most effective in broad trading ranges or slow moving trends.

Interpretation

The classic way to interpret the Stochastic is to wait for %K to reach an extreme level. A level above 70 typically indicates an overbought condition, while below 30 indicates an oversold level. While these penetrations of extreme levels indicate a warning, the actual buy/sell signals occur when %K crosses %D, StochD.


Calculation

n = Number of periods, normally 5
HHn = Highest High over n periods
LLn = Lowest Low over n periods
C = PriceClose today
%K = Stochastic K = 100 * ( C - LLn ) / ( HHn - LLn )

Example

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { //A system based on Fast Stochastic Extreme Levels DataSeries stK = StochK.Series( Bars, 14 ); ChartPane StochPane = CreatePane( 30, true, true ); PlotSeries( StochPane, stK, Color.Purple, LineStyle.Solid, 2 );

for(int bar = 14; bar < Bars.Count; bar++) { if( CrossUnder( bar, stK, 20 ) ) BuyAtMarket( bar+1 ); if ( ( ActivePositions.Count > 0 ) && CrossOver( bar, stK, 20 ) ) { // Let's work directly with the list of active positions, introduced in WL5 for( int p = ActivePositions.Count - 1; p > -1 ; p-- ) SellAtMarket( bar+1, ActivePositions[p] ); } } } } }