Stochastic Oscillator (Fast, Slow and Full)

Overview

Stochastic oscillator is a momentum indicator used in technical analysis. Introduced by George Lane in the 1950s, it serves for comparing the closing price of a commodity to its price range over a given time span.

There are three subtypes of Stochastic Oscillator - Fast Stochastic, Slow Stochastic and Full Stochastic. AnyChart Stock allows adding only the Full Stochastic Indicator; however, you can use it to create the Fast and Slow subtypes as well.

The mathematical description of the indicator is available at: Mathematical Description of Technical Indicators

to top

Adding Indicator

To add any indicator to the chart, you need to use Data Provider with the fields required by the indicator. When such Data Provider is ready - you can add indicator to the chart.

Preparing Data Provider

Stochastic Oscillator indicator needs Data Provider with High, Low and Close fields.

Sample XML of Data Provider, which can be used to create Stochastic Oscillator indicator:

XML/JSON Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <stock xmlns="http://anychart.com/products/stock/schemas/1.9.0/schema.xsd">
03   <data>
04     <data_providers>
05       <general_data_providers>
06         <data_provider data_set="dataSet1" id="dpMsft">
07           <fields>
08             <field type="High" column="2" approximation_type="High" />
09             <field type="Low" column="3" approximation_type="Low" />
10             <field type="Close" column="4" approximation_type="Close" />
11           </fields>
12         </data_provider>
13       </general_data_providers>
14     </data_providers>
15   </data>
16 </stock>
01{
02  data: {
03    dataProviders: {
04      generalDataProviders: [
05        {
06          dataSet: "dataSet1",
07          id: "dpMsft",
08          fields: [
09            {
10              type: "High",
11              column: 2,
12              approximationType: "High"
13            },
14            {
15              type: "Low",
16              column: 3,
17              approximationType: "Low"
18            },
19            {
20              type: "Close",
21              column: 4,
22              approximationType: "Close"
23            }
24          ]
25        }
26      ]
27    }
28  }
29}

to top

Indicator Declaration

As soon as Data Provider is ready you can add an indicator to a chart.

Stochastic Oscillator is usually shown on the chart below the chart with data (stock data). So we should declare it in another chart.

XML for Stochastic Oscillator declaration, note that there are two charts defined - one is used to show the stock data, and another one contains technical indicator:

XML/JSON Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <stock xmlns="http://anychart.com/products/stock/schemas/1.9.0/schema.xsd">
03   <settings>
04     <charts>
05       <chart>
06         <series_list>
07           <series type="Line" data_provider="dpMsft" />
08         </series_list>
09       </chart>
10       <chart>
11         <technical_indicators>
12           <technical_indicator type="StochasticOscillator" data_provider="dpMsft" />
13         </technical_indicators>
14       </chart>
15     </charts>
16   </settings>
17 </stock>
01{
02  settings: {
03    charts: [
04      {
05        seriesList: [
06          {
07            type: "Line",
08            dataProvider: "dpMsft"
09          }
10        ]
11      },
12      {
13        technicalIndicators: [
14          {
15            type: "StochasticOscillator",
16            dataProvider: "dpMsft"
17          }
18        ]
19      }
20    ]
21  }
22}

Another important thing is the fact that Stochastic Oscillator is measured on a 0 - 100 scale, so to show it properly we need to configure value axis scale in the chart with indicator, like that, for example:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="StochasticOscillator" data_provider="dpMsft" />
05   <value_axes>
06     <primary>
07       <scale minimum_mode="CustomValue" minimum="0" maximum_mode="CustomValue" maximum="100" interval_mode="CustomValue" interval="20" />
08     </primary>
09   </value_axes>
10 </chart>
01{
03    {
04      type: "StochasticOscillator",
05      dataProvider: "dpMsft"
06    }
07  ],
08  valueAxes: {
09    primary: {
10      scale: {
11        minimumMode: "CustomValue",
12        minimum: 0,
13        maximumMode: "CustomValue",
14        maximum: 100,
15        intervalMode: "CustomValue",
16        interval: 20
17      }
18    }
19  }
20}

Of course you can use other steps or margins, if you'd like to, as described in Y-Axes Settings article.

After all things mentioned above are done, you can create a chart with Stochastic Oscillator indicator, see basic Live Sample with it below:

Live Sample:  Technical Indicators - Adding Stochastic Oscillator Indicator

to top

Types and Parameters

As it has already been said in the overview, AnyChart Stock uses the Full Stochastic Oscillator indicator to draw the Full, Slow and Fast Oscillators. Use the power of the Full or limit it to the Slow or Fast - everything is under control.

The indicator parameters can be set in the <stochastic_oscillator_indicator> node. There are only four parameters, which are defined using the attributes listed below:

The sections below describe how to display any of the indicator subtypes along with the live samples for each of them.

Fast Stochastic

Fast Stochastic is the default indicator in AnyChart Stock StochasticOscillator, so you don't need to change anything in order to draw it. Having the %K smoothing period set to 1 means that no smoothing whatsoever is used.

To tune up the indicator in this case, you can change %K, %D and MA Type. Here is a sample XML for adding and configuring the Fast Stochastic indicator:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="StochasticOscillator" data_provider="dpMsft">
04       <stochastic_oscillator_indicator k_period="14" d_period="3" ma_type="EMA">
05         <k_series>
06           <name><![CDATA[Fast Stochastic: %K(14)]]></name>
07         </k_series>
08         <d_series>
09           <name><![CDATA[%D(3)]]></name>
10         </d_series>
12     </technical_indicator>
14 </chart>
01{
03    {
04      type: "StochasticOscillator",
05      dataProvider: "dpMsft",
07        kPeriod: 14,
08        dPeriod: 3,
09        maType: "EMA",
10        kSeries: {
11          name: "Fast Stochastic: %K(14)"
12        },
13        dSeries: {
14          name: "%D(3)"
15        }
16      }
17    }
18  ]
19}

Here is a live sample for the Fast Stochastic indicator:

Live Sample:  Technical Indicators - Fast Stochastic

to top

Slow Stochastic

To display the Slow Stochastic, set k_smoothing_period to 3. All the other parameters can be altered. Here is a sample XML for adding and configuring the Slow Stochastic indicator:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="StochasticOscillator" data_provider="dpMsft">
05         <k_series>
06           <name><![CDATA[Slow Stochastic: %K(14)]]></name>
07         </k_series>
08         <d_series>
09           <name><![CDATA[%D(3)]]></name>
10         </d_series>
12     </technical_indicator>
14 </chart>
01{
03    {
04      type: "StochasticOscillator",
05      dataProvider: "dpMsft",
07        kPeriod: 14,
08        dPeriod: 3,
09        maType: "EMA",
10        kSmoothingPeriod: 3,
11        kSeries: {
12          name: "Slow Stochastic: %K(14)"
13        },
14        dSeries: {
15          name: "%D(3)"
16        }
17      }
18    }
19  ]
20}

Here is a live sample for the Slow Stochastic indicator:

Live Sample:  Technical Indicators - Slow Stochastic

to top

Full Stochastic

The Full Stochastic Oscillator differs from the Fast and the Slow by allowing you to select the %K smoothing period as you wish.

The live sample for the Full Stochastic with the %K smoothing period set to 10 is shown below; the Fast and Slow Stochastic are also added to the chart, so anyone can see the difference:

Live Sample:  Technical Indicators - Full Stochastic

to top

Visualization

To visualize and tune visualization of technical indicators AnyChart Stock Component uses the same methods as for the data series.

By default Stochastic Oscillator is shown as series of Line types, but you can use almost any of available series types to show it on the chart.

Stochastic Oscillator indicator settings are contained in <stochastic_oscillator_indicator> node, also in this node you can put <k_series>, <d_series> subnodes - these nodes define how exactly indicator is displayed on the chart. These nodes are identical to <series> node used to describe data series, so you can do with indicator anything you can do with series.

Sample XML for changing indicator visualization:

XML/JSON Syntax
Plain code
01 <chart>
03     <technical_indicator type="StochasticOscillator" data_provider="dpMsft">
05         <k_series color="#98335E" type="Line">
06           <name><![CDATA[Slow Stochastic: %K(15)]]></name>
07           <line_series thickness="2" />
08         </k_series>
09         <d_series color="#339833" type="Line">
10           <name><![CDATA[%D(5)]]></name>
11           <line_series thickness="2" />
12         </d_series>
14     </technical_indicator>
16 </chart>
01{
03    {
04      type: "StochasticOscillator",
05      dataProvider: "dpMsft",
07        kPeriod: 15,
08        dPeriod: 5,
09        kSeries: {
10          color: "#98335E",
11          type: "Line",
12          name: "Slow Stochastic: %K(15)",
13          lineSeries: {
14            thickness: 2
15          }
16        },
17        dSeries: {
18          color: "#339833",
19          type: "Line",
20          name: "%D(5)",
21          lineSeries: {
22            thickness: 2
23          }
24        }
25      }
26    }
27  ]
28}

Live sample below shows how the look of indicator can be altered:

Live Sample:  Technical Indicators - Stochastic Visualization Settings

to top

Overbought/Oversold Visualization

Stochastic Oscillator can be used to determine if there is too much or too little volume associated with a security. A stock is considered "overbought" if the Stochastic Oscillator indicator reaches 80 and above, and if it is 20 and below it is suggested that a stock is "oversold".

To chart Overbought and Oversold signals in AnyChart Stock you can use Line or Range axis markers with labels, which are described in

Live sample below shows Stochastic Oscillator with labeled range axis markers used to highlight Overbought and Oversold signals:

Live Sample:  Technical Indicators - Stochastic with Overbought and Oversold Signals

to top