`TBar` is a lightweight, immutable struct representing a single OHLCV (Open, High, Low, Close, Volume) bar. It is designed for high-performance financial data processing with minimal memory overhead.
## Key Features
- **Memory Efficient**: Pure data type occupying exactly 48 bytes (1 `long` + 5 `double`s).
- **Immutable**: Thread-safe by design.
- **Zero-Copy Conversions**: Efficiently converts to `TValue` for individual price components (Open, High, Low, Close, Volume).
- **Computed Properties**: Provides on-demand calculation of common price averages (HL2, HLC3, etc.) without storage overhead.
- **SIMD Compatible**: Layout is optimized for potential vectorization in collection types.
## Structure Definition
```csharp
publicreadonlystructTBar:IEquatable<TBar>
{
publicreadonlylongTime;// Unix ticks
publicreadonlydoubleOpen;
publicreadonlydoubleHigh;
publicreadonlydoubleLow;
publicreadonlydoubleClose;
publicreadonlydoubleVolume;
}
```
## Properties
| Property | Type | Description |
|----------|------|-------------|
| `Time` | `long` | Timestamp in ticks. |
| `Open` | `double` | Opening price. |
| `High` | `double` | Highest price. |
| `Low` | `double` | Lowest price. |
| `Close` | `double` | Closing price. |
| `Volume` | `double` | Traded volume. |
| `AsDateTime` | `DateTime` | `Time` converted to UTC DateTime. |
### Computed Averages
These properties are calculated on the fly:
-`HL2`: (High + Low) / 2
-`OC2`: (Open + Close) / 2
-`OHL3`: (Open + High + Low) / 3
-`HLC3`: (High + Low + Close) / 3
-`OHLC4`: (Open + High + Low + Close) / 4
-`HLCC4`: (High + Low + Close + Close) / 4
### TValue Accessors
Efficiently access components as `TValue` (Time-Value pair):