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:
Miha Kralj
2026-03-12 12:34:16 -07:00
parent 8937b0c0fa
commit 060649192f
1149 changed files with 1780 additions and 3316 deletions
-73
View File
@@ -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.
-44
View File
@@ -219,50 +219,6 @@ var bbw = new Bbw(source, period: 20, multiplier: 2.0);
// BBW updates automatically when prices are added to source
```
## C# Implementation Considerations
### Delegation to SMA and StdDev
BBW composes two internal indicators:
```csharp
private readonly Sma _sma;
private readonly Stddev _stddev;
private readonly double _mult;
```
This reuses existing SMA and StdDev implementations with their warmup and state management.
### Core Calculation
```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TValue Update(TValue input, bool isNew = true)
{
_sma.Update(input, isNew);
_stddev.Update(input, isNew);
double smaValue = _sma.Last.Value;
double stdValue = _stddev.Last.Value;
// Guard against division by zero
double bbw = smaValue > 0 ? (2.0 * _mult * stdValue) / smaValue : 0.0;
return new TValue(input.Time, bbw);
}
```
### Memory Layout
| Component | Size | Purpose |
| :-------- | ---: | :------ |
| `_sma` (Sma) | ~48 + N×8 bytes | SMA with circular buffer |
| `_stddev` (Stddev) | ~48 + N×8 bytes | StdDev with circular buffer |
| `_mult` | 8 bytes | Multiplier constant |
| **Total per instance** | **~104 + 2N×8 bytes** | Period-dependent |
For default N=20: approximately 424 bytes per instance.
## References
- Bollinger, J. (2001). *Bollinger on Bollinger Bands*. McGraw-Hill. (Original Bollinger Band methodology)