mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-24 05:28:05 +00:00
docs: remove C# Implementation Considerations sections, clean up temp scripts, reorganize test files
- Remove 'C# Implementation Considerations' sections from 34 indicator .md files - Delete 29 temp PowerShell scripts (_fix_mojibake.ps1, _hex_scan.ps1, etc.) - Move test files into tests/ subdirectories for consistent project structure - Add trader-focused bullet points to indicator documentation
This commit is contained in:
@@ -215,79 +215,6 @@ var atr14 = new Atr(source, 14);
|
||||
// ATR updates automatically when bars are added to source
|
||||
```
|
||||
|
||||
## C# Implementation Considerations
|
||||
|
||||
### Delegation to RMA
|
||||
|
||||
ATR delegates smoothing to an internal RMA instance:
|
||||
|
||||
```csharp
|
||||
private readonly Rma _rma;
|
||||
```
|
||||
|
||||
This reuses RMA's warmup compensation and state management logic.
|
||||
|
||||
### State Management
|
||||
|
||||
```csharp
|
||||
private TBar _prevBar; // Previous bar for TR calculation
|
||||
private bool _isInitialized; // First bar flag
|
||||
```
|
||||
|
||||
The implementation tracks the previous bar to compute True Range gaps. The `_isInitialized` flag handles the first-bar edge case where no previous close exists.
|
||||
|
||||
### True Range Calculation
|
||||
|
||||
```csharp
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public TValue Update(TBar input, bool isNew = true)
|
||||
{
|
||||
double tr;
|
||||
if (!_isInitialized)
|
||||
{
|
||||
tr = input.High - input.Low; // First bar: H-L only
|
||||
}
|
||||
else
|
||||
{
|
||||
double hl = input.High - input.Low;
|
||||
double hpc = Math.Abs(input.High - _prevBar.Close);
|
||||
double lpc = Math.Abs(input.Low - _prevBar.Close);
|
||||
tr = Math.Max(hl, Math.Max(hpc, lpc));
|
||||
}
|
||||
// ... RMA smoothing ...
|
||||
}
|
||||
```
|
||||
|
||||
### Batch True Range Calculation
|
||||
|
||||
For TBarSeries input, TR is calculated for all bars first, then passed to RMA:
|
||||
|
||||
```csharp
|
||||
private static TSeries CalculateTrueRange(TBarSeries source)
|
||||
{
|
||||
// First bar: H - L
|
||||
v.Add(source[0].High - source[0].Low);
|
||||
|
||||
// Subsequent bars: max of three components
|
||||
for (int i = 1; i < source.Count; i++)
|
||||
{
|
||||
double hl = bar.High - bar.Low;
|
||||
double hpc = Math.Abs(bar.High - prevBar.Close);
|
||||
double lpc = Math.Abs(bar.Low - prevBar.Close);
|
||||
v.Add(Math.Max(hl, Math.Max(hpc, lpc)));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Memory Layout
|
||||
|
||||
| Component | Size | Purpose |
|
||||
| :-------- | ---: | :------ |
|
||||
| `_rma` (Rma) | ~40 bytes | RMA smoothing state |
|
||||
| `_prevBar` (TBar) | 48 bytes | Previous bar for gap calculation |
|
||||
| `_isInitialized` | 1 byte | First bar flag |
|
||||
| **Total per instance** | **~90 bytes** | No period-dependent allocations |
|
||||
|
||||
## References
|
||||
|
||||
- Wilder, J. W. (1978). *New Concepts in Technical Trading Systems*. Trend Research. Chapter: Average True Range.
|
||||
|
||||
Reference in New Issue
Block a user