# stochosc

Stochastic oscillator

`stochosc` has been partially removed and will no longer accept a `fints` object (`tsobj`) argument. Use a matrix, `timetable`, or `table` instead for financial time series.

Use `fts2timetable` to convert a `fints` object to a `timetable` object.

## Syntax

``percentKnD = stochosc(Data)``
``percentKnD = stochosc(___,Name,Value)``

## Description

example

````percentKnD = stochosc(Data)` calculates the stochastic oscillator.```

example

````percentKnD = stochosc(___,Name,Value)` adds optional name-value pair arguments. ```

## Input Arguments

collapse all

Data with high, low, open, close information, specified as a matrix, table, or timetable. For matrix input, `Data` is an `M`-by-`3` matrix of high, low, and closing prices stored in the corresponding columns, respectively. Timetables and tables with `M` rows must contain variables named `'High'`, `'Low'`, and `'Close'` (case insensitive).

Data Types: `double` | `table` | `timetable`

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: ```percentKnD = stochosc(TMW,'NumPeriodsD',10,'NumPeriodsK',3,'Type','exponential')```

Period difference for PercentK, specified as the comma-separated pair consisting of `'NumPeriodsK'` and a scalar positive integer.

Data Types: `double`

Length of moving average in periods for PercentD, specified as the comma-separated pair consisting of `'NumPeriodsD'` and a scalar positive integer.

Data Types: `double`

Moving average method for PercentD calculation, specified as the comma-separated pair consisting of `'Type'` and a character vector with a value of:

• `'exponential'` – Exponential moving average is a weighted moving average. Exponential moving averages reduce the lag by applying more weight to recent prices. For example, a 10 period exponential moving average weights the most recent price by 18.18%.

• `'triangular'` – Triangular moving average is a double-smoothing of the data. The first simple moving average is calculated and then a second simple moving average is calculated on the first moving average with the same window size.

Data Types: `char`

## Output Arguments

collapse all

PercentK and PercentD, returned with the same number of rows (`M`) and type (matrix, table, or timetable) as the input `Data`.

## Examples

collapse all

Load the file `SimulatedStock.mat`, which provides a timetable (`TMW`) for financial data for TMW stock.

```load SimulatedStock.mat oscillator = stochosc(TMW,'NumPeriodsD',7,'NumPeriodsK',10,'Type','exponential'); plot(oscillator.Time,oscillator.FastPercentK,oscillator.Time,oscillator.FastPercentD) title('Stochastic Oscillator for TMW')``` collapse all

### Stochastic Oscillator

The stochastic oscillator calculates the Fast PercentK (F%K), Fast PercentD (F%D), Slow PercentK (S%K), and Slow PercentD (S%D) from the series of high, low, and closing stock prices.

By default, the stochastic oscillator is based on 10-period difference for PercentK and a 3-period exponential moving average for PercentD.

 Achelis, S. B. Technical Analysis from A to Z. Second Edition. McGraw-Hill, 1995, pp. 268–271.
{"ft_lang_label":"__label__en","ft_lang_prob":0.54202354,"math_prob":0.8569128,"size":498,"snap":"2020-34-2020-40","text_gpt3_token_len":142,"char_repetition_ratio":0.11740891,"word_repetition_ratio":0.0,"special_character_ratio":0.23493975,"punctuation_ratio":0.19354838,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9911236,"pos_list":[0,1,2],"im_url_duplicate_count":[null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-14T21:04:18Z\",\"WARC-Record-ID\":\"<urn:uuid:3ec83ada-8bb1-491f-81a3-2341ad24d3b7>\",\"Content-Length\":\"85272\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4457b90d-b25f-42e8-8a9e-40e78467117c>\",\"WARC-Concurrent-To\":\"<urn:uuid:da8f7ec1-4c91-4322-8381-5a3f6c1c4bff>\",\"WARC-IP-Address\":\"23.66.56.59\",\"WARC-Target-URI\":\"https://jp.mathworks.com/help/finance/stochosc.html\",\"WARC-Payload-Digest\":\"sha1:UIHYWNRLXWOF6IBV2UNNFLWBRXJR5FWW\",\"WARC-Block-Digest\":\"sha1:GC44EIJ7ZFTDE5OWMNHMP4HXV7C5K4ZT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439739370.8_warc_CC-MAIN-20200814190500-20200814220500-00468.warc.gz\"}"}