# Difference (Bar or Single Line)

This study calculates the difference between two charts. Refer to the Multiple Chart Studies instructions for the steps to use this type of study. These two charts must be open at all times and be within the same Chartbook for this study to work properly.

The displayed graph can be either a Bar or Single Line. If you use the Bar version, the actual graph type is set through the Graph Draw Type setting on the Subgraphs tab of the Study Settings window for the study.

For every bar/column in this study, it references the corresponding bar/column in the chart being referenced (through the Chart 2 Number Input). This is the nearest matching Date-Time value in the chart being referenced compared to the Date-Time of the corresponding bar in the chart this study is on. So if there is no exact Date-Time match, then the nearest bar will be used instead.

The Single Line version of this study calculates the difference between the selected Input Data of the chart this study is applied to and the same Input Data element in the chart specified with the Chart 2 Number Input. For example, if the Input Data Input is set to Last, then it is the difference between the Last value of a bar in the chart that this study is applied to and the Last value of the corresponding bar in the specified chart.

The Bar version of the Difference study calculates the difference between the Open, High, Low, and Close values independently, for each bar in the chart the study is applied to and the corresponding bar in the chart being referenced which is specified by the Chart 2 Number Input. The difference between the Open to Open is calculated, High to High is calculated, Low to Low is calculated, and the Close to Close is calculated, all independently.

The High and Low can change within a bar. The High will not always get higher and the Low will not always get lower. They are based upon the High and Low values between the two charts used in the calculation, respectively.

If the Open or the Close differences exceed the High or Low differences, then the High and/or Low are adjusted so that the Open or Close differences do not exceed them. For the greatest accuracy you may be interested in the High Accuracy Spread study configuration.

When either chart used in the calculation is updated, then the last column of the study and any new columns of the study in the chart are updated.

#### Inputs

• Chart 2 Number and Graph: Defines the Chart Number and Graph to be used as the second set of data to be subtracted from the main graph on which this study has been applied.

In addition to the Main Price Graph, graphs that have been added to a chart using the Add Additional Symbol study are made available in the graph selection box.

In this case, first select the chart from the first list. The chart will be the very same chart that the Difference (Bar) study has been added to. Next select the Add Additional Symbol study from the second list. The Add Additional Symbol study will have a name which contains the symbol it is displaying.
• Chart 1 Multiplier: Defines the multiplier value to be applied to the primary graph that is used for the difference calculation. By default this value is set to 1.
• Chart 2 Multiplier: Defines the multiplier value to be applied to the secondary graph that is use for the difference calculation. By default this value is set to 1.
• Chart 1 Addition: Defines an additive value to be applied to the primary graph prior to the subtraction. This allows the values to be move up or down by the amount entered into this input. By default this value is set to 0.
• Zero Output When Non Exact Date-Time Match: When this is set to Yes then if there is no matching data at the same date and time in both primary and secondary graphs, then there is no data displayed in the Difference study at that Date an Time. Otherwise, if this is set to No then the Difference study will use the nearest match for the data in the necessary graph an use that in the calculation.
• Use Latest Source Data for Last Bar: When the Zero Output When Non Exact Date-Time Match input is set to No and this input is set to Yes then the latest bar that is available in Chart 2 is used for the comparison with the last bar in Chart 1.
• Zero Output When One Source Graph Has Zero Values: When this input is set to Yes and one of the source charts has a value of zero for its data point, then this study will not display any information for that bar. Note that this is different from missing data. In order to not display data when there is no data present for a particular time, use the Zero Output When Non Exact Date-Time Match input.