mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-20 19:48:05 +00:00
normalization of methods
This commit is contained in:
+15
-15
@@ -6,22 +6,22 @@ Oscillators fluctuate above and below a centerline or within bounded ranges. Use
|
||||
|
||||
| Indicator | Full Name | Description |
|
||||
| :--- | :--- | :--- |
|
||||
| [AC](ac/Ac.md) | Acceleration Oscillator | Second derivative of AO. Measures acceleration of market driving force. |
|
||||
| AC | Acceleration Oscillator | Second derivative of AO. Measures acceleration of market driving force. |
|
||||
| [AO](ao/Ao.md) | Awesome Oscillator | 5-period SMA minus 34-period SMA of bar midpoint. Bill Williams creation. |
|
||||
| [APO](apo/Apo.md) | Absolute Price Oscillator | Raw currency difference between fast and slow EMAs. Unbounded. |
|
||||
| [BBB](bbb/Bbb.md) | Bollinger %B | Position within Bollinger Bands. 0=lower band, 1=upper band. |
|
||||
| [BBS](bbs/Bbs.md) | Bollinger Band Squeeze | BB width < KC width indicates consolidation. Breakout imminent. |
|
||||
| [CFO](cfo/Cfo.md) | Chande Forecast Oscillator | Percentage difference between price and linear regression forecast. |
|
||||
| [DPO](dpo/Dpo.md) | Detrended Price Oscillator | Removes trend via displaced SMA. Reveals cycles. |
|
||||
| [FISHER](fisher/Fisher.md) | Fisher Transform | Converts prices to Gaussian distribution. Sharp reversals. |
|
||||
| [INERTIA](inertia/Inertia.md) | Inertia | Trend strength from distance to linear regression line. |
|
||||
| [KDJ](kdj/Kdj.md) | KDJ Indicator | Enhanced Stochastic. J = 3K - 2D provides leading signal. |
|
||||
| [PGO](pgo/Pgo.md) | Pretty Good Oscillator | Distance from SMA normalized by ATR. Units: ATR multiples. |
|
||||
| [SMI](smi/Smi.md) | Stochastic Momentum Index | Distance from range midpoint. More sensitive than classic Stochastic. |
|
||||
| [STOCH](stoch/Stoch.md) | Stochastic Oscillator | Close position within N-period high-low range. Classic overbought/oversold. |
|
||||
| [STOCHF](stochf/Stochf.md) | Stochastic Fast | Unsmoothed Stochastic. Faster but noisier. |
|
||||
| [STOCHRSI](stochrsi/Stochrsi.md) | Stochastic RSI | Stochastic applied to RSI. More sensitive than either alone. |
|
||||
| [TRIX](trix/Trix.md) | Triple Exponential Average | ROC of triple EMA. Filters noise through three smoothings. |
|
||||
| BBB | Bollinger %B | Position within Bollinger Bands. 0=lower band, 1=upper band. |
|
||||
| BBS | Bollinger Band Squeeze | BB width < KC width indicates consolidation. Breakout imminent. |
|
||||
| CFO | Chande Forecast Oscillator | Percentage difference between price and linear regression forecast. |
|
||||
| DPO | Detrended Price Oscillator | Removes trend via displaced SMA. Reveals cycles. |
|
||||
| FISHER | Fisher Transform | Converts prices to Gaussian distribution. Sharp reversals. |
|
||||
| INERTIA | Inertia | Trend strength from distance to linear regression line. |
|
||||
| KDJ | KDJ Indicator | Enhanced Stochastic. J = 3K - 2D provides leading signal. |
|
||||
| PGO | Pretty Good Oscillator | Distance from SMA normalized by ATR. Units: ATR multiples. |
|
||||
| SMI | Stochastic Momentum Index | Distance from range midpoint. More sensitive than classic Stochastic. |
|
||||
| STOCH | Stochastic Oscillator | Close position within N-period high-low range. Classic overbought/oversold. |
|
||||
| STOCHF | Stochastic Fast | Unsmoothed Stochastic. Faster but noisier. |
|
||||
| STOCHRSI | Stochastic RSI | Stochastic applied to RSI. More sensitive than either alone. |
|
||||
| TRIX | Triple Exponential Average | ROC of triple EMA. Filters noise through three smoothings. |
|
||||
| [TTM_WAVE](ttm_wave/TtmWave.md) | TTM Wave | Fibonacci-period MACD composite (Waves A/B/C). John Carter. |
|
||||
| [ULTOSC](ultosc/Ultosc.md) | Ultimate Oscillator | Multi-timeframe oscillator. Combines 7, 14, 28 period buying pressure. |
|
||||
| [WILLR](willr/Willr.md) | Williams %R | Inverse Stochastic. -100 to 0 range. Overbought/oversold. |
|
||||
| WILLR | Williams %R | Inverse Stochastic. -100 to 0 range. Overbought/oversold. |
|
||||
|
||||
@@ -179,7 +179,7 @@ public sealed class Ao : ITValuePublisher
|
||||
int len = source.Count;
|
||||
var v = new double[len];
|
||||
|
||||
Calculate(source.High.Values, source.Low.Values, v, _fastPeriod, _slowPeriod);
|
||||
Batch(source.High.Values, source.Low.Values, v, _fastPeriod, _slowPeriod);
|
||||
|
||||
// Bulk copy timestamps using CollectionsMarshal
|
||||
var tList = new List<long>(len);
|
||||
@@ -212,7 +212,7 @@ public sealed class Ao : ITValuePublisher
|
||||
/// <param name="slowPeriod">Slow SMA period (default 34)</param>
|
||||
/// <param name="destination">Output AO values</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> high, ReadOnlySpan<double> low, Span<double> destination, int fastPeriod = 5, int slowPeriod = 34)
|
||||
public static void Batch(ReadOnlySpan<double> high, ReadOnlySpan<double> low, Span<double> destination, int fastPeriod = 5, int slowPeriod = 34)
|
||||
{
|
||||
if (high.Length != low.Length || high.Length != destination.Length)
|
||||
{
|
||||
@@ -267,7 +267,7 @@ public sealed class Ao : ITValuePublisher
|
||||
int len = source.Count;
|
||||
var v = new double[len];
|
||||
|
||||
Calculate(source.High.Values, source.Low.Values, v, fastPeriod, slowPeriod);
|
||||
Batch(source.High.Values, source.Low.Values, v, fastPeriod, slowPeriod);
|
||||
|
||||
// Bulk copy timestamps using CollectionsMarshal
|
||||
var tList = new List<long>(len);
|
||||
@@ -283,4 +283,11 @@ public sealed class Ao : ITValuePublisher
|
||||
|
||||
return new TSeries(tList, vList);
|
||||
}
|
||||
|
||||
public static (TSeries Results, Ao Indicator) Calculate(TBarSeries source, int fastPeriod = 5, int slowPeriod = 34)
|
||||
{
|
||||
var indicator = new Ao(fastPeriod, slowPeriod);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public sealed class ApoValidationTests : IDisposable
|
||||
|
||||
// 3. Span Mode
|
||||
double[] spanOutput = new double[input.Length];
|
||||
Apo.Calculate(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
Apo.Batch(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
ValidationHelper.VerifyData(spanOutput, output, outRange, lookback: slowPeriod - 1);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public sealed class ApoValidationTests : IDisposable
|
||||
|
||||
// 3. Span Mode
|
||||
double[] spanOutput = new double[input.Length];
|
||||
Apo.Calculate(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
Apo.Batch(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
ValidationHelper.VerifyData(spanOutput, output, lookback: 1);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public sealed class ApoValidationTests : IDisposable
|
||||
// 3. Span Mode
|
||||
double[] input = _testData.Data.Values.ToArray();
|
||||
double[] spanOutput = new double[input.Length];
|
||||
Apo.Calculate(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
Apo.Batch(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
ValidationHelper.VerifyData(spanOutput, output, lookback: 0, tolerance: ValidationHelper.OoplesTolerance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public sealed class Apo : ITValuePublisher, IDisposable
|
||||
/// <param name="fastPeriod">Fast EMA period (default 12)</param>
|
||||
/// <param name="slowPeriod">Slow EMA period (default 26)</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int fastPeriod = 12, int slowPeriod = 26)
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int fastPeriod = 12, int slowPeriod = 26)
|
||||
{
|
||||
if (source.Length != output.Length)
|
||||
{
|
||||
@@ -198,6 +198,13 @@ public sealed class Apo : ITValuePublisher, IDisposable
|
||||
SimdExtensions.Subtract(fastEma, slowEma, output);
|
||||
}
|
||||
|
||||
public static (TSeries Results, Apo Indicator) Calculate(TSeries source, int fastPeriod = 12, int slowPeriod = 26)
|
||||
{
|
||||
var indicator = new Apo(fastPeriod, slowPeriod);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes resources and unsubscribes from the source publisher.
|
||||
/// </summary>
|
||||
@@ -215,4 +222,4 @@ public sealed class Apo : ITValuePublisher, IDisposable
|
||||
_source = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,7 @@ public sealed class UltoscValidationTests : IDisposable
|
||||
double[] spanOutput = new double[hData.Length];
|
||||
|
||||
// Calculate using span method
|
||||
Ultosc.Calculate(hData, lData, cData, spanOutput, p1, p2, p3);
|
||||
Ultosc.Batch(hData, lData, cData, spanOutput, p1, p2, p3);
|
||||
|
||||
// Calculate using TBarSeries batch
|
||||
var ultosc = new Ultosc(p1, p2, p3);
|
||||
|
||||
@@ -46,6 +46,7 @@ public sealed class Ultosc : AbstractBase
|
||||
private int _p_index;
|
||||
private readonly TBarSeries? _source;
|
||||
private readonly TBarPublishedHandler? _handler;
|
||||
private bool _disposed;
|
||||
|
||||
// Weights: 4:2:1
|
||||
private const double Weight1 = 4.0;
|
||||
@@ -118,9 +119,13 @@ public sealed class Ultosc : AbstractBase
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && _source != null && _handler != null)
|
||||
if (!_disposed)
|
||||
{
|
||||
_source.Pub -= _handler;
|
||||
if (disposing && _source != null && _handler != null)
|
||||
{
|
||||
_source.Pub -= _handler;
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
@@ -241,7 +246,7 @@ public sealed class Ultosc : AbstractBase
|
||||
var vSpan = CollectionsMarshal.AsSpan(v);
|
||||
|
||||
// Calculate using span method
|
||||
Calculate(source.High.Values, source.Low.Values, source.Close.Values,
|
||||
Batch(source.High.Values, source.Low.Values, source.Close.Values,
|
||||
vSpan, _period1, _period2, _period3);
|
||||
source.Times.CopyTo(tSpan);
|
||||
|
||||
@@ -290,7 +295,7 @@ public sealed class Ultosc : AbstractBase
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(
|
||||
public static void Batch(
|
||||
ReadOnlySpan<double> high,
|
||||
ReadOnlySpan<double> low,
|
||||
ReadOnlySpan<double> close,
|
||||
@@ -412,6 +417,14 @@ public sealed class Ultosc : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Ultosc Indicator) Calculate(TBarSeries source, int period1 = 7, int period2 = 14, int period3 = 28)
|
||||
{
|
||||
var indicator = new Ultosc(period1, period2, period3);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
_bp1.Clear();
|
||||
|
||||
Reference in New Issue
Block a user