 # Bar Overlap

Bar Info

Debugging

Derivatives

Matrix Handling

Price Rounding

Regression Lines

Statistics

User Tracking

Example Strategies

## Bar Overlap

Description:

Calculate the overlap of bar of most recent bar to the prior bar.

Syntax:

`OverlapBase1();OverlapBase0();OverlapFull();`

Notes:

There are different ways to calculate the overlap of two objects. You must determine which method is right for your specific task.

Which object is the overlap relative to?

```				```
/// <summary>
/// Calculates the overlap with bar 1 as base bar.
/// </summary>
private void OverlapBase1()
{
if (High <= Low || Low >= High)						// no overlap
{
Value = 0;
}
else if (High < High)
{
if (Low < Low)										// inside bar
Value = (High - Low) / (High - Low);
else if (Low == Low)                                  // inside bar even lows
Value = (High - Low) / (High - Low);
else if (Low < Low)									// low bar with overlap
Value = (High - Low) / (High - Low);
}
else if (High == High)
{
if (Low < Low)                                        // inside bar even highs
Value = (High - Low) / (High - Low);
else if (Low == Low)                                  // equal bars
Value = 1;
else if (Low < Low)									// low bar with even highs
Value = 1;
}
else if (High > High)
{
if (Low > Low)										// high bar with some overlap
Value = (High - Low) / (High - Low);
else if (Low == Low)									// high bar with even lows
Value = 1;
else if (Low < Low)                                   // outside bar
Value = 1;
}
}

/// <summary>
/// Calculates the overlap with bar 0 as base bar.
/// </summary>
private void OverlapBase0()
{
if (High <= Low || Low >= High)                     // no overlap
{
Value = 0;
}
else if (High < High)
{
if (Low < Low)                                        // inside bar
Value = 1;
else if (Low == Low)                                  // inside bar even lows
Value = 1;
else if (Low < Low)                                   // low bar with overlap
Value = (High - Low) / (High - Low);
}
else if (High == High)
{
if (Low < Low)                                        // inside bar even highs
Value = 1;
else if (Low == Low)                                  // equal bars
Value = 1;
else if (Low < Low)                                   // low bar with even highs
Value = (High - Low) / (High - Low);
}
else if (High > High)
{
if (Low > Low)                                        // high bar with some overlap
Value = (High - Low) / (High - Low);
else if (Low == Low)                                  // high bar with even lows
Value = (High - Low) / (High - Low);
else if (Low < Low)                                   // outside bar
Value = (High - Low) / (High - Low);
}
}

/// <summary>
/// Calculates the overlap with the highest point to the lowest point as the base.
/// </summary>
private void OverlapFull()
{
if (High <= Low || Low >= High)                     // no overlap
{
Value = 0;
}
else if (High < High)
{
if (Low < Low)                                        // inside bar
Value = (High - Low) / (High - Low);
else if (Low == Low)                                  // inside bar even lows
Value = (High - Low) / (High - Low);
else if (Low < Low)                                   // low bar with overlap
Value = (High - Low) / (High - Low);
}
else if (High == High)
{
if (Low < Low)                                        // inside bar even highs
Value = (High - Low) / (High - Low);
else if (Low == Low)                                  // equal bars
Value = 1;
else if (Low < Low)                                   // low bar with even highs
Value = (High - Low) / (High - Low);
}
else if (High > High)
{
if (Low > Low)                                        // high bar with some overlap
Value = (High - Low) / (High - Low);
else if (Low == Low)                                  // high bar with even lows
Value = (High - Low) / (High - Low);
else if (Low < Low)                                   // outside bar
Value = (High - Low) / (High - Low);
}
}
```
```