﻿ StochRSI Indicator
 StochRSI Indicator Send Feedback

Glossary Item Box

## Topic Overview

#### Purpose

This topic provides a conceptual overview of the IGChartView™ control’s StochRSI Indicator and demonstrates how to add it to the chart view using a code example.

#### In this topic

This topic contains the following sections:

## Introduction

#### StochRSI indicator summary

The StochRSI indicator is financial indicator that measures when a security is overbought or oversold within a specified period with and having values ranging from 0 to 1. Calculate the StochRSI indicator by applying the Stochastic Oscillator formula to Relative Strength Index Indicator (RSI) data.

#### Data requirements

While the IGChartView control allows easy binding to your own data model, make sure to supply the appropriate amounts and types of data required by the series. If the data does not meet the minimum requirements, based on the type of series that you are using, the IGChartView will appear to be blank.

Required – the data model must contain a numeric field, close, for rendering data.

## Adding a StochRSI Indicator to the IGChartView – Code Example

#### Description

The code below uses the IGOHLCSeriesDataSourceHelper to supply randomly generated data to a financial price series by first adding to the IGChartView instance, then next adding the financial indicator to the IGChartView instance as a series, and then finally adding the IGChartView as a subview of the current UIView.

#### Prerequisites

This code example requires the inclusion of the IGChartView framework, detail about how to add this framework can be found in the Adding the Chart Framework File topic.

#### Code

In C#:

```List<NSObject> open = new List<NSObject>();
for (int i = 0; i < 25; i++) {
}
List<NSObject> high = new List<NSObject>();
for (int i = 0; i < 25; i++) {
}
List<NSObject> low = new List<NSObject>();
for (int i = 0; i < 25; i++) {
}
List<NSObject> close = new List<NSObject>();
for (int i = 0; i < 25; i++) {
}
List<NSObject> volume = new List<NSObject>();
for (int i = 0; i < 25; i++) {
}
IGOHLCSeriesDataSourceHelper source = new IGOHLCSeriesDataSourceHelper();
source.OpenValues = open.ToArray();
source.HighValues = high.ToArray();
source.LowValues = low.ToArray();
source.CloseValues = close.ToArray();
source.VolumeValues = volume.ToArray();
IGChartView infraChart = new IGChartView(this.View.Frame);
IGCategoryXAxis xAxis = new IGCategoryXAxis("xAxis");
IGNumericYAxis yAxis = new IGNumericYAxis("yAxis");
IGFinancialPriceSeries financialPriceSeries = new IGFinancialPriceSeries("financialPriceSeries");
financialPriceSeries.XAxis = xAxis;
financialPriceSeries.YAxis = yAxis;
financialPriceSeries.DataSource = source;
financialPriceSeries.DisplayType = IGPriceDisplayType.IGPriceDisplayTypeCandlestick;
IGStochRSIIndicator financialIndicator = new IGStochRSIIndicator("financialIndicator");
financialIndicator.XAxis = xAxis;
financialIndicator.YAxis = yAxis;
financialIndicator.DataSource = source;
financialIndicator.Thickness = 3.0f;
```

In Objective-C:

```    NSMutableArray *open = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++) {
[open addObject:[[NSNumber alloc] initWithDouble:(arc4random() % 100)]];
}

NSMutableArray *high = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++) {
[high addObject:[[NSNumber alloc] initWithDouble:(arc4random() % 100 + 30)]];
}

NSMutableArray *low = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++) {
[low addObject:[[NSNumber alloc] initWithDouble:(arc4random() % 100)]];
}

NSMutableArray *close = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++) {
[close addObject:[[NSNumber alloc] initWithDouble:(arc4random() % 100 + 10)]];
}

NSMutableArray *volume = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++)
{
[volume addObject:[[NSNumber alloc] initWithDouble:(arc4random() % 1000000 + 100000)]];
}

IGOHLCSeriesDataSourceHelper *source = [[IGOHLCSeriesDataSourceHelper alloc] init];
source.openValues = open;
source.highValues = high;
source.lowValues = low;
source.closeValues = close;
source.volumeValues = volume;

IGChartView *infraChart = [[IGChartView alloc] initWithFrame:self.view.frame];

IGCategoryXAxis *xAxis = [[IGCategoryXAxis alloc] initWithKey:@"xAxis"];
IGNumericYAxis *yAxis = [[IGNumericYAxis alloc] initWithKey:@"yAxis"];

IGFinancialPriceSeries *financialPriceSeries = [[IGFinancialPriceSeries alloc] initWithKey:@"financialPriceSeries"];
financialPriceSeries.xAxis = xAxis;
financialPriceSeries.yAxis = yAxis;
financialPriceSeries.dataSource = source;
financialPriceSeries.displayType = IGPriceDisplayTypeCandlestick;
IGStochRSIIndicator *financialIndicator = [[IGStochRSIIndicator alloc] initWithKey:@"financialIndicator"];
financialIndicator.xAxis = xAxis;
financialIndicator.yAxis = yAxis;
financialIndicator.dataSource = source;
financialIndicator.thickness = 3.0f;

```

## Related Content

#### Topics

The following topics provide additional information related to this topic.

Topic

Purpose

This collection of topics explains each of the individual charts supported by the IGChartView control.