# R-Squared

#### Description <a href="#description_100" id="description_100"></a>

This indicator belongs to the linear regression series. R-Squared is the correlation coefficient that specifies the quality of the linear regression line.

It is the calculation that gives R-Squared its name – the value is the square of the correlation coefficient, which in mathematics is prefixed with the Greek letter Rho (P).

See [*Linear Regression*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#linearregression), [*LinRegSlope*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#linregslope), [*LinRegIntercept*](https://agenatrader.github.io/AgenaIndicator-documentation/indicators_oscillators/#linregintercept).

#### Interpretation <a href="#interpretation_49" id="interpretation_49"></a>

The value of the oscillator fluctuates between 0 and 1. By default, the upper boundary line is located at 0.75, and the lower border is at 0.2. If the prices are in a sideways movement, the data is scattered around the regression line. R-Squared will have a value of 0 in the aforementioned situation. In a strong trend phase, the prices will remain within a tight range for an extended period of time; if these are located close to the regression line then the R-Squared indicator will have a value of 1. Stanley Kroll and Tuchar Chande used the correlation coefficient as a trend filter in their book “*The new technical trader*”.

#### Further information <a href="#further-information_37" id="further-information_37"></a>

<http://www.blastchart.com/Community/IndicatorGuide/Indicators/LinearRegressionRSquared.aspx>

#### Usage <a href="#usage_96" id="usage_96"></a>

```csharp
RSquared(int period)
RSquared(IDataSeries inSeries, int period)
RSquared(int period)[int barsAgo]
RSquared(IDataSeries inSeries, int period)[int barsAgo]
```

#### Return value <a href="#return-value_94" id="return-value_94"></a>

**double**

When using this method with an index (e.g. **RSquared**(8)\[**int** barsAgo] ), the value of the indicator will be issued for the referenced bar.

#### Parameters <a href="#parameters_87" id="parameters_87"></a>

inSeries Input data series for the indicator

period Number of bars included in the calculations

#### Visualization <a href="#visualization_91" id="visualization_91"></a>

![R-Squared](https://agenatrader.github.io/AgenaIndicator-documentation/media/RSquared.jpg)

#### Example <a href="#example_91" id="example_91"></a>

```csharp
//Output for the value of R-Squared
Print("The current value of R-Squared is: " + RSquared(8)[0]);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://indicators.agenatrader.com/standard-indicators/r-squared.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
