# Technical Studies Reference

- Technical Studies Reference
- Common Study Inputs (Opens a new page)
- Using Studies (Opens a new page)

### Bar Difference

This study calculates and displays the difference between the **Input Data 1** Input and **Input Data 2** Input for each bar in the chart. By default, each of these **Input Data** Inputs refers to the same bar. Also by default, the study calculates the difference between the High and Low of a bar, indicating its range.

The study also supports referencing **Input Data 2** from a prior bar through the **Input Data 2 Offset** Input.

Let \(X^{(1)}\) and \(X^{(2)}\) be random variables denoting **Input Data 1** and **Input Data 2**, respectively, and let \(X_t^{(1)}\) and \(X_t^{(2)}\) be their respective values at Index \(t\). Let the Input **Offset** be denoted as \(k\). Then we denote the **Bar Difference** at Index \(t\) for the given Inputs as \(BarDiff_t(X_t^{(1)}, X_t^{(2)}, k)\), and we compute it for \(t \geq 0\) as follows.

If the Input **Calculate Difference in Price Ticks** is set to Yes, then we divide by the Tick Size \(s\). The Tick Size is set through **Chart >> Chart Settings >> Main Settings**, and it appears as a third argument in the **Bar Difference** function. We calculate it as follows.

#### Inputs

- Input Data 1
- Input Data 2
**Input Data 2 Offset**: This Input specifies bar offset for**Input Data 2**. If this is set to 1, then this means**Input Data 2**refers to the prior bar. For example: If**Input Data 1**is set to High and**Input Data 2**is set to Low and**Input Data 2 Offset**is set to 1, then for each bar in the chart, this study will graph the difference between the calculated bar's High and the Low of the prior bar.**Calculate Difference in Price Ticks**: This Input determines whether or not the**Bar Difference**is expressed in ticks.

#### Spreadsheet

The spreadsheet below contains the formulas for this study in Spreadsheet format. Save this Spreadsheet to the Data Files Folder.

Open it through **File >> Open Spreadsheet**.

*Last modified Wednesday, 20th June, 2018.