macos dev update

This commit is contained in:
Miha
2024-10-26 23:54:55 -07:00
parent e4f718a365
commit c21b96152c
28 changed files with 458 additions and 345 deletions
+1 -3
View File
@@ -51,9 +51,7 @@
<PackageReference Include="Microsoft.DotNet.Interactive.Formatting" Version="1.0.0-beta.21459.1" /> <PackageReference Include="Microsoft.DotNet.Interactive.Formatting" Version="1.0.0-beta.21459.1" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="'$(IsLocalBuild)' == 'true'"> <PropertyGroup Condition="'$(IsLocalBuild)' == 'true' AND $([MSBuild]::IsOSPlatform('Windows'))">
<!-- Set the correct path to Quantower here -->
<QuantowerRoot>D:\Quantower</QuantowerRoot> <QuantowerRoot>D:\Quantower</QuantowerRoot>
<QuantowerPath>$([System.IO.Directory]::GetDirectories("$(QuantowerRoot)\TradingPlatform", "v1*")[0])</QuantowerPath> <QuantowerPath>$([System.IO.Directory]::GetDirectories("$(QuantowerRoot)\TradingPlatform", "v1*")[0])</QuantowerPath>
</PropertyGroup> </PropertyGroup>
+7 -1
View File
@@ -51,6 +51,12 @@ public class EventingTests
("Tema", new Tema(p), new Tema(input, p)), ("Tema", new Tema(p), new Tema(input, p)),
("Kama", new Kama(2, 30, 6), new Kama(input, 2, 30, 6)), ("Kama", new Kama(2, 30, 6), new Kama(input, 2, 30, 6)),
("Zlema", new Zlema(p), new Zlema(input, p)), ("Zlema", new Zlema(p), new Zlema(input, p)),
// oscillators
("Rsi", new Rsi(p), new Rsi(input, p)),
("Rsx", new Rsx(p), new Rsx(input, p)),
("Cmo", new Cmo(p), new Cmo(input, p)),
// volatility
("Rv", new Rv(p), new Rv(input, p)),
// error classes // error classes
("Mae", new Mae(p), new Mae(input, p)), ("Mae", new Mae(p), new Mae(input, p)),
("Mapd", new Mapd(p), new Mapd(input, p)), ("Mapd", new Mapd(p), new Mapd(input, p)),
@@ -67,7 +73,7 @@ public class EventingTests
("Rse", new Rse(p), new Rse(input, p)), ("Rse", new Rse(p), new Rse(input, p)),
("Smape", new Smape(p), new Smape(input, p)), ("Smape", new Smape(p), new Smape(input, p)),
("Rsquared", new Rsquared(p), new Rsquared(input, p)), ("Rsquared", new Rsquared(p), new Rsquared(input, p)),
("Huberloss", new Huberloss(p), new Huberloss(input, p)) ("Huber", new Huber(p), new Huber(input, p))
}; };
// Generate 200 random values and feed them to both direct and event-based indicators // Generate 200 random values and feed them to both direct and event-based indicators
+1 -1
View File
@@ -20,7 +20,7 @@ public class UpdateTests
[Fact] [Fact]
public void Huberloss_Update() public void Huberloss_Update()
{ {
var indicator = new Huberloss(period: 14); var indicator = new Huber(period: 14);
double initialValue = indicator.Calc(new TValue(DateTime.Now, ReferenceValue, IsNew: true)); double initialValue = indicator.Calc(new TValue(DateTime.Now, ReferenceValue, IsNew: true));
for (int i = 0; i < RandomUpdates; i++) for (int i = 0; i < RandomUpdates; i++)
+2 -2
View File
@@ -45,7 +45,7 @@ public class VolatilityUpdateTests
[Fact] [Fact]
public void Historical_Update() public void Historical_Update()
{ {
var indicator = new Historical(period: 14); var indicator = new Hv(period: 14);
double initialValue = indicator.Calc(new TBar(DateTime.Now, ReferenceValue, ReferenceValue, ReferenceValue, ReferenceValue, 1000, IsNew: true)); double initialValue = indicator.Calc(new TBar(DateTime.Now, ReferenceValue, ReferenceValue, ReferenceValue, ReferenceValue, 1000, IsNew: true));
for (int i = 0; i < RandomUpdates; i++) for (int i = 0; i < RandomUpdates; i++)
@@ -60,7 +60,7 @@ public class VolatilityUpdateTests
[Fact] [Fact]
public void Realized_Update() public void Realized_Update()
{ {
var indicator = new Realized(period: 14); var indicator = new Rv(period: 14);
double initialValue = indicator.Calc(new TBar(DateTime.Now, ReferenceValue, ReferenceValue, ReferenceValue, ReferenceValue, 1000, IsNew: true)); double initialValue = indicator.Calc(new TBar(DateTime.Now, ReferenceValue, ReferenceValue, ReferenceValue, ReferenceValue, 1000, IsNew: true));
for (int i = 0; i < RandomUpdates; i++) for (int i = 0; i < RandomUpdates; i++)
+3
View File
@@ -1,5 +1,8 @@
* [Home](/) * [Home](/)
[JMA](indicators/averages/jma/calc.md)
* Introduction * Introduction
* [Overview]() * [Overview]()
* [Features]() * [Features]()
+48
View File
@@ -0,0 +1,48 @@
# JMA Calculation
### Initial Parameters:
$\beta = factor \cdot \frac{period - 1}{factor \cdot (period - 1) + 2}$
$len1 = \frac{\ln(\sqrt{period - 1})}{\ln(2)} + 2$
$pow1 = \max(len1 - 2, 0.5)$
$phase \in [0.5, 2.5]$ (clamped to $(phase \cdot 0.01) + 1.5$)
### Volatility Calculations:
$del1_t = price_t - upperBand_{t-1}$
$del2_t = price_t - lowerBand_{t-1}$
$volty_t = \max(|del1_t|, |del2_t|)$
$vSum_t = \frac{\sum_{i=t-buffer+1}^t volty_i}{buffer}$
$avgVolty_t = \text{mean}(vSum_{t-64:t})$
$rVolty_t = \text{clamp}(\frac{volty_t}{avgVolty_t}, 1, len1^{1/pow1})$
### Band Calculations:
$pow2_t = rVolty_t^{pow1}$
$K_v = \beta^{\sqrt{pow2_t}}$
$upperBand_t = price_t - K_v \cdot del1_t$
$\alpha_t = \beta^{pow2_t}$
$ma1_t = price_t + \alpha_t(ma1_{t-1} - price_t)$
$det0_t = price_t + \beta(det0_{t-1} - price_t + ma1_t) - ma1_t$
$ma2_t = ma1_t + phase \cdot det0_t$
$det1_t = (ma2_t - jma_{t-1})(1-\alpha_t)^2 + \alpha_t^2 \cdot det1_{t-1}$
$jma_t = jma_{t-1} + det1_t$
+152 -152
View File
@@ -4,17 +4,17 @@
✔️= Validation tests passed<br> ✔️= Validation tests passed<br>
❌= Issue ❌= Issue
|**MOMENTUM INDICATORS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**MOMENTUM INDICATORS**|**Class Name**|Skender.Stock|TALib.NETCore|
|--|:--:|:--:|:--:| |--|:--:|:--:|:--:|
|*DMI - Directional Movement Index|`?`|GetDmi|| |DMI - Directional Movement Index|`?`|GetDmi||
|*DMX - Jurik Directional Movement Index|`?`||| |DMX - Jurik Directional Movement Index|`?`|||
|*MOM - Momentum|`?`||| |MOM - Momentum|`?`|||
|*VEL - Jurik Signal Velocity|`?`||| |VEL - Jurik Signal Velocity|`?`|||
|ADX - Average Directional Movement Index|`?`|GetAdx|Adx| |ADX - Average Directional Movement Index|`?`|GetAdx|Adx|
|ADXR - Average Directional Movement Index|`?`|Rating|Adxr| |ADXR - Average Directional Movement Index|`?`|Rating|Adxr|
|APO - Absolute Price Oscillator|`?`|Apo|| |APO - Absolute Price Oscillator|`?`|Apo||
|DPO - Detrended Price Oscillator|`?`|GetDpo|| |DPO - Detrended Price Oscillator|`?`|GetDpo||
|MACD - Movign Average Convergence/Divergence|`?`||| |MACD - Moving Average Convergence/Divergence|`?`|||
|PO - Price Oscillator|`?`||| |PO - Price Oscillator|`?`|||
|PPO - Percentage Price Oscillator|`?`||| |PPO - Percentage Price Oscillator|`?`|||
|PMO - Price Momentum Oscillator|`?`|GetPmo|| |PMO - Price Momentum Oscillator|`?`|GetPmo||
@@ -23,161 +23,161 @@
|TRIX - 1-day ROC of TEMA|`?`|GetTrix|| |TRIX - 1-day ROC of TEMA|`?`|GetTrix||
|VORTEX - Vortex Indicator|`?`||| |VORTEX - Vortex Indicator|`?`|||
<br> <br>
|**VOLATILITY INDICATORS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**VOLATILITY INDICATORS**|**Class Name**|Skender.Stock|TALib.NETCore|
|ADR - Average Daily Range|||| |ADR - Average Daily Range|`?`|||
|ANDREW - Andrew's Pitchfork|||| |ANDREW - Andrew's Pitchfork|`?`|||
|ATR - Average True Range|`Atr`|GetAtr|Atr| |ATR - Average True Range|`Atr`|GetAtr|Atr|
|ATRP - Average True Range Percent|||| |ATRP - Average True Range Percent|`?`|||
|ATRSTOP - ATR Trailing Stop ||GetAtrStop|| |ATRSTOP - ATR Trailing Stop|`?`|GetAtrStop||
|BBANDS - Bollinger Bands®||BollingerBands|| |BBANDS - Bollinger Bands®|`?`|BollingerBands||
|CHAND - Chandelier Exit||GetChandelier|| |CHAND - Chandelier Exit|`?`|GetChandelier||
|CVI - Chaikins Volatility|||| |CVI - Chaikins Volatility|`?`|||
|DON - Donchian Channels||GetDonchian|| |DON - Donchian Channels|`?`|GetDonchian||
|FCB - Fractal Chaos Bands||GetFcb|| |FCB - Fractal Chaos Bands|`?`|GetFcb||
|HV - Historical Volatility|||| |HV - Historical Volatility|`Hv`|||
|ICH - Ichimoku Cloud||GetIchimoku|| |ICH - Ichimoku Cloud|`?`|GetIchimoku||
|KEL - Keltner Channels||GetKeltner|| |KEL - Keltner Channels|`?`|GetKeltner||
|NATR - Normalized Average True Range||GetAtr|| |NATR - Normalized Average True Range|`?`|GetAtr||
|CHN - Price Channel Indicator|||| |CHN - Price Channel Indicator|`?`|||
|SAR - Parabolic Stop and Reverse||GetParabolicSar|| |SAR - Parabolic Stop and Reverse|`?`|GetParabolicSar||
|STARC - Starc Bands||GetStarcBands|| |STARC - Starc Bands|`?`|GetStarcBands||
|TR - True Range|||| |TR - True Range|`?`|||
|UI - Ulcer Index||GetUlcerIndex|| |UI - Ulcer Index|`?`|GetUlcerIndex||
|VSTOP - Volatility Stop||GetVolatilityStop|| |VSTOP - Volatility Stop|`?`|GetVolatilityStop||
<br> <br>
|**OSCILLATORS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**OSCILLATORS**|**Class Name**|Skender.Stock|TALib.NETCore|
|RSI - Relative Strength Index|`Rsi`|GetRsi|| |RSI - Relative Strength Index|`Rsi`|GetRsi||
|RSX - Jurik Trend Strength Index|`Rsx`||| |RSX - Jurik Trend Strength Index|`Rsx`|||
|AC - Acceleration Oscillator||||| |AC - Acceleration Oscillator|`?`|||
|AO - Awesome Oscillator||GetAwesome||| |AO - Awesome Oscillator|`?`|GetAwesome||
|AROON - Aroon oscillator||GetAroon|Aroon|| |AROON - Aroon oscillator|`?`|GetAroon|Aroon|
|BOP - Balance of Power||GetBop|Bop|| |BOP - Balance of Power|`?`|GetBop|Bop|
|CCI - Commodity Channel Index||GetCci|Cci|| |CCI - Commodity Channel Index|`?`|GetCci|Cci|
|CFO - Chande Forcast Oscillator||||| |CFO - Chande Forcast Oscillator|`?`|||
|CMO - Chande Momentum Oscillator||GetCmo|Cmo|| |CMO - Chande Momentum Oscillator|`Cmo`|GetCmo|Cmo|
|CHOP - Choppiness Index||GetChop||| |CHOP - Choppiness Index|`?`|GetChop||
|COG - Ehler's Center of Gravity||||| |COG - Ehler's Center of Gravity|`?`|||
|COPPOCK - Coppock Curve||||| |COPPOCK - Coppock Curve|`?`|||
|CRSI - Connor RSI||GetConnorsRsi||| |CRSI - Connor RSI|`?`|GetConnorsRsi||
|CTI - Ehler's Correlation Trend Indicator||||| |CTI - Ehler's Correlation Trend Indicator|`?`|||
|DOSC - Derivative Oscillator||||| |DOSC - Derivative Oscillator|`?`|||
|EFI - Elder Ray's Force Index||GetElderRay||| |EFI - Elder Ray's Force Index|`?`|GetElderRay||
|FISHER - Fisher Transform||||| |FISHER - Fisher Transform|`?`|||
|FOSC - Forecast Oscillator|||||| |FOSC - Forecast Oscillator|`?`|||
|GATOR - Williams Alliator Oscillator||GetGator||| |GATOR - Williams Alliator Oscillator|`?`|GetGator||
|KDJ - KDJ Indicator (trend reversal)||||| |KDJ - KDJ Indicator (trend reversal)|`?`|||
|KRI - Kairi Relative Index||||| |KRI - Kairi Relative Index|`?`|||
|RVGI - Relative Vigor Index||||| |RVGI - Relative Vigor Index|`?`|||
|SMI - Stochastic Momentum Index||GetSmi||| |SMI - Stochastic Momentum Index|`?`|GetSmi||
|SRSI - Stochastic RSI||GetStochRsi||| |SRSI - Stochastic RSI|`?`|GetStochRsi||
|STC - Schaff Trend Cycle||GetStc||| |STC - Schaff Trend Cycle|`?`|GetStc||
|STOCH - Stochastic Oscillator||`GetStoch||| |STOCH - Stochastic Oscillator|`?`|GetStoch||
|TSI - True Strength Index||GetTsi||| |TSI - True Strength Index|`?`|GetTsi||
|UO - Ultimate Oscillator||GetUltimate||| |UO - Ultimate Oscillator|`?`|GetUltimate||
|WILLR - Larry Williams' %R||GetWilliamsR||| |WILLR - Larry Williams' %R|`?`|GetWilliamsR||
<br> <br>
|**VOLUME INDICATORS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**VOLUME INDICATORS**|**Class Name**|Skender.Stock|TALib.NETCore|
|ADL - Chaikin Accumulation Distribution Line||GetAdl|Ad|| |ADL - Chaikin Accumulation Distribution Line|`?`|GetAdl|Ad|
|ADOSC - Chaikin Accumulation Distribution Oscillator||GetChaikinOsc|AdOsc|| |ADOSC - Chaikin Accumulation Distribution Oscillator|`?`|GetChaikinOsc|AdOsc|
|AOBV - Archer On-Balance Volume||||| |AOBV - Archer On-Balance Volume|`?`|||
|CMF - Chaikin Money Flow||GetCmf||| |CMF - Chaikin Money Flow|`?`|GetCmf||
|EOM - Ease of Movement||||| |EOM - Ease of Movement|`?`|||
|KVO - Klinger Volume Oscillator||GetKvo|||| |KVO - Klinger Volume Oscillator|`?`|GetKvo||
|MFI - Money Flow Index||GetMfi||| |MFI - Money Flow Index|`?`|GetMfi||
|NVI - Negative Volume Index||||| |NVI - Negative Volume Index|`?`|||
|OBV - On-Balance Volume||GetObv||| |OBV - On-Balance Volume|`?`|GetObv||
|PVI - Positive Volume Index||||| |PVI - Positive Volume Index|`?`|||
|PVOL - Price-Volume||||| |PVOL - Price-Volume|`?`|||
|PVO - Percentage Volume Oscillator||GetPvo||| |PVO - Percentage Volume Oscillator|`?`|GetPvo||
|PVR - Price Volume Rank||||| |PVR - Price Volume Rank|`?`|||
|PVT - Price Volume Trend||||| |PVT - Price Volume Trend|`?`|||
|TVI - Trade Volume Index||||| |TVI - Trade Volume Index|`?`|||
|VP - Volume Profile||||| |VP - Volume Profile|`?`|||
|VWAP - Volume Weighted Average Price||GetVwap||| |VWAP - Volume Weighted Average Price|`?`|GetVwap||
|VWMA - Volume Weighted Moving Average||GetVwma|||| |VWMA - Volume Weighted Moving Average|`?`|GetVwma||
<br> <br>
|**NUMERICAL ANALYSIS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**NUMERICAL ANALYSIS**|**Class Name**|Skender.Stock|TALib.NETCore|
|BETA - Beta coefficient||||| |BETA - Beta coefficient|`?`|||
|CORR - Correlation Coefficient||||| |CORR - Correlation Coefficient|`?`|||
|CURVATURE - Rate of Change in Direction or Slope|`Curvature`|||| |CURVATURE - Rate of Change in Direction or Slope|`Curvature`|||
|ENTROPY - Measure of Uncertainty or Disorder|`Entropy`|||| |ENTROPY - Measure of Uncertainty or Disorder|`Entropy`|||
|KURTOSIS - Measure of Tails/Peakedness|`Kurtosis`|||| |KURTOSIS - Measure of Tails/Peakedness|`Kurtosis`|||
|HUBER - Huber Loss|`Huberloss`|||| |HUBER - Huber Loss|`Huber`|||
|HURST - Hurst Exponent||GetHurst||| |HURST - Hurst Exponent|`?`|GetHurst||
|MAX - Maximum with exponential decay|`Max`|||| |MAX - Maximum with exponential decay|`Max`|||
|MEDIAN - Middle value|`Median`|||| |MEDIAN - Middle value|`Median`|||
|MIN - Minimum with exponential decay|`Min`|||| |MIN - Minimum with exponential decay|`Min`|||
|MODE - Most Frequent Value|`Mode`|||| |MODE - Most Frequent Value|`Mode`|||
|PERCENTILE - Rank Order|`Percentile`|||| |PERCENTILE - Rank Order|`Percentile`|||
|RSQUARED - Coefficient of Determination R-Squared||||| |RSQUARED - Coefficient of Determination R-Squared|`?`|||
|SKEW - Skewness, asymmetry of distribution|`Skew`|||| |SKEW - Skewness, asymmetry of distribution|`Skew`|||
|SLOPE - Rate of Change, Linear Regression|`Slope`|||| |SLOPE - Rate of Change, Linear Regression|`Slope`|||
|STDDEV - Standard Deviation, Measure of Spread|`Stddev`|||| |STDDEV - Standard Deviation, Measure of Spread|`Stddev`|||
|THEIL - Theil's U Statistics||||| |THEIL - Theil's U Statistics|`?`|||
|TSF - Time Series Forecast|||`✔️`|`✔️`| |TSF - Time Series Forecast|`?`|✔️|✔️|
|VARIANCE - Average of Squared Deviations|`Variance`|||| |VARIANCE - Average of Squared Deviations|`Variance`|||
|ZSCORE - Standardized Score|`Zscore`|||| |ZSCORE - Standardized Score|`Zscore`|||
<br> <br>
|**ERRORS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**ERRORS**|**Class Name**|Skender.Stock|TALib.NETCore|
|MAE - Mean Absolute Error|`Mae`|||| |MAE - Mean Absolute Error|`Mae`|||
|MAPD - Mean Absolute Percentage Deviation|`Mapd`|||| |MAPD - Mean Absolute Percentage Deviation|`Mapd`|||
|MAPE - Mean Absolute Percentage Error|`Mape`|||| |MAPE - Mean Absolute Percentage Error|`Mape`|||
|MASE - Mean Absolute Scaled Error|`Mase`|||| |MASE - Mean Absolute Scaled Error|`Mase`|||
|MDA - Mean Directional Accuracy||||| |MDA - Mean Directional Accuracy|`Mda`|||
|ME - Mean Error|`Me`|||| |ME - Mean Error|`Me`|||
|MPE - Pean Percentage Error|`Mpe`|||| |MPE - Mean Percentage Error|`Mpe`|||
|MSE - Mean Squared Error|`Mse`|||| |MSE - Mean Squared Error|`Mse`|||
|MSLE - Mean Squared Logarithmic Error|`Msle`|||| |MSLE - Mean Squared Logarithmic Error|`Msle`|||
|RAE - Relative Absolute Error|`Rae`|||| |RAE - Relative Absolute Error|`Rae`|||
|RMSE - Root Mean Squared Error|`Rmse`|||| |RMSE - Root Mean Squared Error|`Rmse`|||
|RSE - Relateive Squared Error|`Rse`|||| |RSE - Relative Squared Error|`Rse`|||
|RMSLE - Root Mean Squared Logarithmic Error|`Rmsle`|||| |RMSLE - Root Mean Squared Logarithmic Error|`Rmsle`|||
|SMAPE - Symmetric Mean Absolute Percentage Error|`Smape`|||| |SMAPE - Symmetric Mean Absolute Percentage Error|`Smape`|||
<br> <br>
|**AVERAGES & TRENDS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**AVERAGES & TRENDS**|**Class Name**|Skender.Stock|TALib.NETCore|
|AFIRMA - Autoregressive Finite Impulse Response Moving Average|`Afirma`|||| |AFIRMA - Autoregressive Finite Impulse Response Moving Average|`Afirma`|||
|ALMA - Arnaud Legoux Moving Average|`Alma`|`✔️`|| |ALMA - Arnaud Legoux Moving Average|`Alma`|✔️||
|DEMA - Double EMA Average|`Dema`|`✔️`|`✔️`| |DEMA - Double EMA Average|`Dema`|✔️|✔️|
|DSMA - Deviation Scaled Moving Average|`Dsma`|||| |DSMA - Deviation Scaled Moving Average|`Dsma`|||
|DWMA - Double WMA Average|`Dwma`|||| |DWMA - Double WMA Average|`Dwma`|||
|EMA - Exponential Moving Average|`Ema`|``|``| |EMA - Exponential Moving Average|`Ema`|⭐|⭐|
|EPMA - Endpoint Moving Average|`Epma`|`✔️`||| |EPMA - Endpoint Moving Average|`Epma`|✔️||
|FRAMA - Fractal Adaptive Moving Average|`Frama`|||| |FRAMA - Fractal Adaptive Moving Average|`Frama`|||
|FWMA - Fibonacci Weighted Moving Average|`Fwma`|||| |FWMA - Fibonacci Weighted Moving Average|`Fwma`|||
|HILO - Gann High-Low Activator||||| |HILO - Gann High-Low Activator|`?`|||
|HTIT - Hilbert Transform Instantaneous Trendline|`Htit`|`✔️`|`✔️`|| |HTIT - Hilbert Transform Instantaneous Trendline|`Htit`|✔️|✔️|
|GMA - Gaussian-Weighted Moving Average|`Gma`|||| |GMA - Gaussian-Weighted Moving Average|`Gma`|||
|HMA - Hull Moving Average|`Hma`|`✔️`||`✔️`| |HMA - Hull Moving Average|`Hma`|✔️|✔️|
|HWMA - Holt-Winter Moving Average|`Hwma`|||| |HWMA - Holt-Winter Moving Average|`Hwma`|||
|JMA - Jurik Moving Average|`Jma`|||| |JMA - Jurik Moving Average|`Jma`|||
|JORDAN - Jordan Moving Average||||| |JORDAN - Jordan Moving Average|`?`|||
|KAMA - Kaufman's Adaptive Moving Average|`Kama`|`✔️`|`✔️`|`✔️`| |KAMA - Kaufman's Adaptive Moving Average|`Kama`|✔️|✔️|
|LTMA - Laguerre Transform Moving Average|`Ltma`|||| |LTMA - Laguerre Transform Moving Average|`Ltma`|||
|MAAF - Median-Average Adaptive Filter|`Maaf`|||| |MAAF - Median-Average Adaptive Filter|`Maaf`|||
|MAMA - MESA Adaptive Moving Average|`Mama`|`✔️`|`✔️`|| |MAMA - MESA Adaptive Moving Average|`Mama`|✔️|✔️|
|MGDI - McGinley Dynamic Indicator|`Mgdi`|`✔️`||| |MGDI - McGinley Dynamic Indicator|`Mgdi`|✔️||
|MLMA - Minimal Lag Moving Average||||| |MLMA - Minimal Lag Moving Average|`?`|||
|MMA - Modified Moving Average|`Mma`|||| |MMA - Modified Moving Average|`Mma`|||
|PPMA - Pivot Point Moving Average||||| |PPMA - Pivot Point Moving Average|`?`|||
|PWMA - Pascal's Weighted Moving Average|`Pwma`|||| |PWMA - Pascal's Weighted Moving Average|`Pwma`|||
|QEMA - Quad Exponential Moving Average|`Qema`|||| |QEMA - Quad Exponential Moving Average|`Qema`|||
|RMA - WildeR's Moving Average|`Rma`|||| |RMA - WildeR's Moving Average|`Rma`|||
|SINEMA - Sine Weighted Moving Average|`Sinema`|||| |SINEMA - Sine Weighted Moving Average|`Sinema`|||
|SMA - Simple Moving Average|`Sma`||| |SMA - Simple Moving Average|`Sma`|||
|SMMA - Smoothed Moving Average|`Smma`|`✔️`|| |SMMA - Smoothed Moving Average|`Smma`|✔️||
|SSF - Ehler's Super Smoother Filter|||| |SSF - Ehler's Super Smoother Filter|`?`|||
|SUPERTREND - Supertrend||`✔️`|| |SUPERTREND - Supertrend|`?`|✔️||
|T3 - Tillson T3 Moving Average|`T3`|`✔️`|`✔️`| |T3 - Tillson T3 Moving Average|`T3`|✔️|✔️|
|TEMA - Triple EMA Average|`Tema`|`✔️`|`✔️`| |TEMA - Triple EMA Average|`Tema`|✔️|✔️|
|TRIMA - Triangular Moving Average|`Trima`|`✔️`|| |TRIMA - Triangular Moving Average|`Trima`|✔️||
|VIDYA - Variable Index Dynamic Average|`Vidya`||| |VIDYA - Variable Index Dynamic Average|`Vidya`|||
|WMA - Weighted Moving Average|`Wma`|`✔️`|| |WMA - Weighted Moving Average|`Wma`|✔️||
|ZLEMA - Zero Lag EMA Average|`Zlema`||| |ZLEMA - Zero Lag EMA Average|`Zlema`|||
<br> <br>
|**BASIC TRANSFORMS**|**QuanTALib**|Skender.Stock|TALib.NETCore| |**BASIC TRANSFORMS**|**Class Name**|Skender.Stock|TALib.NETCore|
|OC2 - Midpoint price|`.OC2`|CandlePart.OC2|MidPoint| |OC2 - Midpoint price|`.OC2`|CandlePart.OC2|MidPoint|
|HL2 - Median Price|`.HL2`|CandlePart.HL2|MedPrice| |HL2 - Median Price|`.HL2`|CandlePart.HL2|MedPrice|
|HLC3 - Typical Price|`.HLC3`|CandlePart.HLC3|TypPrice| |HLC3 - Typical Price|`.HLC3`|CandlePart.HLC3|TypPrice|
|OHL3 - Mean Price|`.OHL3`|CandlePart.OHL3| |OHL3 - Mean Price|`.OHL3`|CandlePart.OHL3||
|OHLC4 - Average Price|`.OHLC4`|CandlePart.OHLC4|AvgPrice| |OHLC4 - Average Price|`.OHLC4`|CandlePart.OHLC4|AvgPrice|
|HLCC4 - Weighted Price|`.HLCC4`||WclPrice| |HLCC4 - Weighted Price|`.HLCC4`||WclPrice|
+33
View File
@@ -0,0 +1,33 @@
✔️ AFIRMA - Adaptive FIR Moving Average
✔️ ALMA - Arnaud Legoux Moving Average
✔️ DEMA - Double Exponential Moving Average
✔️ DSMA - Dynamic Simple Moving Average
✔️ DWMA - Dynamic Weighted Moving Average
✔️ EMA - Exponential Moving Average
✔️ EPMA - Endpoint Moving Average
✔️ FRAMA - Fractal Adaptive Moving Average
✔️ FWMA - Forward Weighted Moving Average
✔️ GMA - Gaussian Moving Average
✔️ HMA - Hull Moving Average
✔️ HTIT - Hilbert Transform Instantaneous Trendline
✔️ HWMA - Hann Weighted Moving Average
✔️ JMA - Jurik Moving Average
✔️ KAMA - Kaufman Adaptive Moving Average
✔️ LTMA - Linear Time Moving Average
✔️ MAAF - Moving Average Adaptive Filter
✔️ MAMA - MESA Adaptive Moving Average
✔️ MGDI - McGinley Dynamic Indicator
✔️ MMA - Modified Moving Average
✔️ PWMA - Parabolic Weighted Moving Average
✔️ QEMA - Quick Exponential Moving Average
✔️ REMA - Regularized Exponential Moving Average
✔️ RMA - Running Moving Average
✔️ SINEMA - Sine-weighted Moving Average
✔️ SMA - Simple Moving Average
✔️ SMMA - Smoothed Moving Average
✔️ T3 - Triple Exponential Moving Average (T3)
✔️ TEMA - Triple Exponential Moving Average
✔️ TRIMA - Triangular Moving Average
✔️ VIDYA - Variable Index Dynamic Average
✔️ WMA - Weighted Moving Average
✔️ ZLEMA - Zero-Lag Exponential Moving Average
@@ -1,12 +1,12 @@
namespace QuanTAlib; namespace QuanTAlib;
public class Huberloss : AbstractBase public class Huber : AbstractBase
{ {
private readonly CircularBuffer _actualBuffer; private readonly CircularBuffer _actualBuffer;
private readonly CircularBuffer _predictedBuffer; private readonly CircularBuffer _predictedBuffer;
private readonly double _delta; private readonly double _delta;
public Huberloss(int period, double delta = 1.0) public Huber(int period, double delta = 1.0)
{ {
if (period < 1) if (period < 1)
{ {
@@ -24,7 +24,7 @@ public class Huberloss : AbstractBase
Init(); Init();
} }
public Huberloss(object source, int period, double delta = 1.0) : this(period, delta) public Huber(object source, int period, double delta = 1.0) : this(period, delta)
{ {
var pubEvent = source.GetType().GetEvent("Pub"); var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new ValueSignal(Sub)); pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
+16
View File
@@ -0,0 +1,16 @@
✔️ HUBER - Huber Loss
✔️ MAE - Mean Absolute Error
✔️ MAPD - Mean Absolute Percentage Deviation
✔️ MAPE - Mean Absolute Percentage Error
✔️ MASE - Mean Absolute Scaled Error
✔️ MDA - Mean Directional Accuracy
✔️ ME - Mean Error
✔️ MPE - Mean Percentage Error
✔️ MSE - Mean Squared Error
✔️ MSLE - Mean Squared Logarithmic Error
✔️ RAE - Relative Absolute Error
✔️ RMSE - Root Mean Squared Error
✔️ RMSLE - Root Mean Squared Logarithmic Error
✔️ RSE - Relative Squared Error
✔️ RSQUARED - R-Squared (Coefficient of Determination)
✔️ SMAPE - Symmetric Mean Absolute Percentage Error
+16
View File
@@ -0,0 +1,16 @@
ADX - Average Directional Movement Index
ADXR - Average Directional Movement Index
APO - Absolute Price Oscillator
DMI - Directional Movement Index
DMX - Jurik Directional Movement Index
DPO - Detrended Price Oscillator
MACD - Moving Average Convergence/Divergence
MOM - Momentum
PMO - Price Momentum Oscillator
PO - Price Oscillator
PPO - Percentage Price Oscillator
PRS - Price Relative Strength
ROC - Rate of Change
TRIX - 1-day ROC of TEMA
VEL - Jurik Signal Velocity
VORTEX - Vortex Indicator
+11 -2
View File
@@ -20,6 +20,17 @@ public class Cmo : AbstractBase
Name = $"CMO({period})"; Name = $"CMO({period})";
} }
/// <summary>
/// Initializes a new instance of the CMO class with a data source.
/// </summary>
/// <param name="source">The source object that publishes data.</param>
/// <param name="period">The number of data points to consider.</param>
public Cmo(object source, int period) : this(period)
{
var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
}
protected override void ManageState(bool isNew) protected override void ManageState(bool isNew)
{ {
if (isNew) if (isNew)
@@ -54,7 +65,6 @@ public class Cmo : AbstractBase
{ {
_sumH.Add(0, Input.IsNew); _sumH.Add(0, Input.IsNew);
_sumL.Add(-diff, Input.IsNew); _sumL.Add(-diff, Input.IsNew);
} }
// Calculate sums for the specified period only // Calculate sums for the specified period only
@@ -67,4 +77,3 @@ public class Cmo : AbstractBase
0.0; 0.0;
} }
} }
@@ -22,6 +22,17 @@ public class Rsi : AbstractBase
Name = $"RSI({period})"; Name = $"RSI({period})";
} }
/// <summary>
/// Initializes a new instance of the RSI class with a data source.
/// </summary>
/// <param name="source">The source object that publishes data.</param>
/// <param name="period">The number of data points to consider.</param>
public Rsi(object source, int period) : this(period)
{
var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
}
protected override void ManageState(bool isNew) protected override void ManageState(bool isNew)
{ {
if (isNew) if (isNew)
@@ -53,10 +64,7 @@ public class Rsi : AbstractBase
_avgLoss.Calc(loss, IsNew: Input.IsNew); _avgLoss.Calc(loss, IsNew: Input.IsNew);
double rsi = (_avgLoss.Value > 0) ? 100 - (100 / (1 + (_avgGain.Value / _avgLoss.Value))) : 100; double rsi = (_avgLoss.Value > 0) ? 100 - (100 / (1 + (_avgGain.Value / _avgLoss.Value))) : 100;
return rsi; return rsi;
} }
} }
@@ -24,6 +24,19 @@ public class Rsx : AbstractBase
Name = $"RSX({period})"; Name = $"RSX({period})";
} }
/// <summary>
/// Initializes a new instance of the RSX class with a data source.
/// </summary>
/// <param name="source">The source object that publishes data.</param>
/// <param name="period">The number of data points to consider.</param>
/// <param name="phase">The phase parameter.</param>
/// <param name="factor">The factor parameter.</param>
public Rsx(object source, int period, int phase = 0, double factor = 0.55) : this(period, phase, factor)
{
var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
}
protected override void ManageState(bool isNew) protected override void ManageState(bool isNew)
{ {
if (isNew) if (isNew)
@@ -58,7 +71,5 @@ public class Rsx : AbstractBase
double rsx = _rsx.Calc(rsi, Input.IsNew); double rsx = _rsx.Calc(rsi, Input.IsNew);
return rsx; return rsx;
} }
} }
+29
View File
@@ -0,0 +1,29 @@
AC - Acceleration Oscillator
AO - Awesome Oscillator
AROON - Aroon oscillator
BOP - Balance of Power
CCI - Commodity Channel Index
CFO - Chande Forcast Oscillator
✔️ CMO - Chande Momentum Oscillator
CHOP - Choppiness Index
COG - Ehler's Center of Gravity
COPPOCK - Coppock Curve
CRSI - Connor RSI
CTI - Ehler's Correlation Trend Indicator
DOSC - Derivative Oscillator
EFI - Elder Ray's Force Index
FISHER - Fisher Transform
FOSC - Forecast Oscillator
GATOR - Williams Alliator Oscillator
KDJ - KDJ Indicator (trend reversal)
KRI - Kairi Relative Index
✔️ RSI - Relative Strength Index
✔️ RSX - Jurik Trend Strength Index
RVGI - Relative Vigor Index
SMI - Stochastic Momentum Index
SRSI - Stochastic RSI
STC - Schaff Trend Cycle
STOCH - Stochastic Oscillator
TSI - True Strength Index
UO - Ultimate Oscillator
WILLR - Larry Williams' %R
+20
View File
@@ -0,0 +1,20 @@
BETA - Beta coefficient
CORR - Correlation Coefficient
✔️ CURVATURE - Rate of Change in Direction or Slope
✔️ ENTROPY - Measure of Uncertainty or Disorder
HUBER - Huber Loss
HURST - Hurst Exponent
✔️ KURTOSIS - Measure of Tails/Peakedness
✔️ MAX - Maximum with exponential decay
✔️ MEDIAN - Middle value
✔️ MIN - Minimum with exponential decay
✔️ MODE - Most Frequent Value
✔️ PERCENTILE - Rank Order
RSQUARED - Coefficient of Determination R-Squared
✔️ SKEW - Skewness, asymmetry of distribution
✔️ SLOPE - Rate of Change, Linear Regression
✔️ STDDEV - Standard Deviation, Measure of Spread
THEIL - Theil's U Statistics
TSF - Time Series Forecast
✔️ VARIANCE - Average of Squared Deviations
✔️ ZSCORE - Standardized Score
@@ -9,7 +9,7 @@ namespace QuanTAlib;
/// both annualized and non-annualized volatility measures. The calculation uses a sample /// both annualized and non-annualized volatility measures. The calculation uses a sample
/// standard deviation formula and assumes 252 trading days in a year for annualization. /// standard deviation formula and assumes 252 trading days in a year for annualization.
/// </remarks> /// </remarks>
public class Historical : AbstractBase public class Hv : AbstractBase
{ {
private readonly int Period; private readonly int Period;
private readonly bool IsAnnualized; private readonly bool IsAnnualized;
@@ -25,7 +25,7 @@ public class Historical : AbstractBase
/// <exception cref="ArgumentOutOfRangeException"> /// <exception cref="ArgumentOutOfRangeException">
/// Thrown when period is less than 2. /// Thrown when period is less than 2.
/// </exception> /// </exception>
public Historical(int period, bool isAnnualized = true) public Hv(int period, bool isAnnualized = true)
{ {
if (period < 2) if (period < 2)
{ {
@@ -46,7 +46,7 @@ public class Historical : AbstractBase
/// <param name="source">The source object to subscribe to for value updates.</param> /// <param name="source">The source object to subscribe to for value updates.</param>
/// <param name="period">The period over which to calculate historical volatility.</param> /// <param name="period">The period over which to calculate historical volatility.</param>
/// <param name="isAnnualized">Whether to annualize the volatility (default is true).</param> /// <param name="isAnnualized">Whether to annualize the volatility (default is true).</param>
public Historical(object source, int period, bool isAnnualized = true) : this(period, isAnnualized) public Hv(object source, int period, bool isAnnualized = true) : this(period, isAnnualized)
{ {
var pubEvent = source.GetType().GetEvent("Pub"); var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new ValueSignal(Sub)); pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
@@ -9,7 +9,7 @@ namespace QuanTAlib;
/// both annualized and non-annualized volatility measures. The calculation uses a rolling /// both annualized and non-annualized volatility measures. The calculation uses a rolling
/// sum of squared returns for efficiency and assumes 252 trading days in a year for annualization. /// sum of squared returns for efficiency and assumes 252 trading days in a year for annualization.
/// </remarks> /// </remarks>
public class Realized : AbstractBase public class Rv : AbstractBase
{ {
private readonly int Period; private readonly int Period;
private readonly bool IsAnnualized; private readonly bool IsAnnualized;
@@ -25,7 +25,7 @@ public class Realized : AbstractBase
/// <exception cref="ArgumentOutOfRangeException"> /// <exception cref="ArgumentOutOfRangeException">
/// Thrown when period is less than 2. /// Thrown when period is less than 2.
/// </exception> /// </exception>
public Realized(int period, bool isAnnualized = true) public Rv(int period, bool isAnnualized = true)
{ {
if (period < 2) if (period < 2)
{ {
@@ -39,6 +39,18 @@ public class Realized : AbstractBase
Init(); Init();
} }
/// <summary>
/// Initializes a new instance of the Realized class with a data source.
/// </summary>
/// <param name="source">The source object that publishes data.</param>
/// <param name="period">The period over which to calculate realized volatility.</param>
/// <param name="isAnnualized">Whether to annualize the volatility (default is true).</param>
public Rv(object source, int period, bool isAnnualized = true) : this(period, isAnnualized)
{
var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new ValueSignal(Sub));
}
/// <summary> /// <summary>
/// Initializes the Realized instance by clearing buffers and resetting calculation variables. /// Initializes the Realized instance by clearing buffers and resetting calculation variables.
/// </summary> /// </summary>
@@ -113,4 +125,4 @@ public class Realized : AbstractBase
IsHot = _index >= WarmupPeriod; IsHot = _index >= WarmupPeriod;
return volatility; return volatility;
} }
} }
+34
View File
@@ -0,0 +1,34 @@
ADR - Average Daily Range
AP - Andrew's Pitchfork
✔️ ATR - Average True Range
ATRP - Average True Range Percent
ATRS - ATR Trailing Stop
BB - Bollinger Bands®
CCV - Close-to-Close Volatility
CE - Chandelier Exit
CV - Conditional Volatility (ARCH/GARCH)
CVI - Chaikin's Volatility
DC - Donchian Channels
FCB - Fractal Chaos Bands
GKV - Garman-Klass Volatility
HLV - High-Low Volatility
✔️ HV - Historical Volatility
ICH - Ichimoku Cloud
✔️ JVOLTY - Jurik Volatility
KC - Keltner Channels
NATR - Normalized Average True Range
PCH - Price Channel Indicator
PSAR - Parabolic Stop and Reverse
PV - Parkinson Volatility
RSV - Rogers-Satchell Volatility
✔️ RV - Realized Volatility
RVI - Relative Volatility Index
STARC - Starc Bands
SV - Stochastic Volatility
TR - True Range
UI - Ulcer Index
VC - Volatility Cone
VOV - Volatility of Volatility
VR - Volatility Ratio
VS - Volatility Stop
YZV - Yang-Zhang Volatility
+18
View File
@@ -0,0 +1,18 @@
ADL - Chaikin Accumulation Distribution Line
ADOSC - Chaikin Accumulation Distribution Oscillator
AOBV - Archer On-Balance Volume
CMF - Chaikin Money Flow
EOM - Ease of Movement
KVO - Klinger Volume Oscillator
MFI - Money Flow Index
NVI - Negative Volume Index
OBV - On-Balance Volume
PVI - Positive Volume Index
PVOL - Price-Volume
PVO - Percentage Volume Oscillator
PVR - Price Volume Rank
PVT - Price Volume Trend
TVI - Trade Volume Index
VP - Volume Profile
VWAP - Volume Weighted Average Price
VWMA - Volume Weighted Moving Average
+5 -5
View File
@@ -4,7 +4,7 @@
#!csharp #!csharp
#r "..\lib\obj\Debug\QuanTAlib.dll" #r "../lib/obj/Debug/QuanTAlib.dll"
using QuanTAlib; using QuanTAlib;
QuanTAlib.Formatters.Initialize(); QuanTAlib.Formatters.Initialize();
@@ -40,14 +40,14 @@ Formatter.Register(typeof(ScottPlot.Plot), (p, w) =>
TSeries ma1 = Spike; TSeries ma1 = Spike;
TSeries out1 = new(); TSeries out1 = new();
Ema calc1 = new(10); Jma calc1 = new(period: 7, phase: 0, factor: 0.30, buffer: 2);
foreach (var value in ma1) { out1.Add(calc1.Calc(value)); } foreach (var value in ma1) { out1.Add(calc1.Calc(value)); }
double[] gma1 = ma1.v.ToArray()[52..]; double[] gma1 = ma1.v.ToArray()[52..];
double[] gsig1 = out1.v.ToArray()[52..]; double[] gsig1 = out1.v.ToArray()[52..];
TSeries ma2 = Impulse; TSeries ma2 = Impulse;
TSeries out2 = new(); TSeries out2 = new();
Ema calc2 = new(10); Jma calc2 = new(period: 7, phase: 0, factor: 0.20, buffer: 2);
foreach (var value in ma2) { out2.Add(calc2.Calc(value)); } foreach (var value in ma2) { out2.Add(calc2.Calc(value)); }
double[] gma2 = ma2.v.ToArray()[52..]; double[] gma2 = ma2.v.ToArray()[52..];
double[] gsig2 = out2.v.ToArray()[52..]; double[] gsig2 = out2.v.ToArray()[52..];
@@ -57,12 +57,12 @@ double[] gsig2 = out2.v.ToArray()[52..];
Plot plt1 = new(); Plot plt1 = new();
var p1a = plt1.Add.Signal(gma1); p1a.Color = ScottPlot.Colors.Red; p1a.LineWidth = 2; var p1a = plt1.Add.Signal(gma1); p1a.Color = ScottPlot.Colors.Red; p1a.LineWidth = 2;
var p1b = plt1.Add.Signal(gsig1); p1b.Color = ScottPlot.Colors.Blue; p1b.LineWidth = 3; var p1b = plt1.Add.Signal(gsig1); p1b.Color = ScottPlot.Colors.Blue; p1b.LineWidth = 3;
plt1.Title("Spike - EMA(10)"); plt1.Title("Spike - JMA(10)");
Plot plt2 = new(); Plot plt2 = new();
var p2a = plt2.Add.Signal(gma2); p2a.Color = ScottPlot.Colors.Red; p2a.LineWidth = 2; var p2a = plt2.Add.Signal(gma2); p2a.Color = ScottPlot.Colors.Red; p2a.LineWidth = 2;
var p2b = plt2.Add.Signal(gsig2); p2b.Color = ScottPlot.Colors.Blue; p2b.LineWidth = 3; var p2b = plt2.Add.Signal(gsig2); p2b.Color = ScottPlot.Colors.Blue; p2b.LineWidth = 3;
plt2.Title("Impulse - EMA(10)"); plt2.Title("Impulse - JMA(10)");
plt1.Display(); plt1.Display();
plt2.Display(); plt2.Display();
+4 -156
View File
@@ -41,7 +41,7 @@ plt.Display();
#!csharp #!csharp
#r "..\lib\obj\Debug\QuanTAlib.dll" #r "../lib/obj/Debug/QuanTAlib.dll"
using QuanTAlib; using QuanTAlib;
QuanTAlib.Formatters.Initialize(); QuanTAlib.Formatters.Initialize();
@@ -82,163 +82,11 @@ TSeries MarketJMA = new() { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
#!csharp #!csharp
public class Jmaxx : AbstractBase TSeries ma = Spike;
{ TSeries re = SpikeJMA;
private readonly double _period;
private readonly double _phase;
private readonly CircularBuffer _vsumBuff;
private readonly CircularBuffer _avoltyBuff;
private double _len1;
private double _pow1;
private readonly double _beta;
private double _upperBand, _lowerBand, _p_upperBand, _p_lowerBand;
private double _prevMa1, _prevDet0, _prevDet1, _prevJma, _p_prevMa1, _p_prevDet0, _p_prevDet1, _p_prevJma;
private double _vSum, _p_vSum;
public double UpperBand { get; set; }
public double LowerBand { get; set; }
public double Volty { get; set; }
/// <summary>
/// Initializes a new instance of the Jma class with the specified parameters.
/// </summary>
/// <param name="period">The period over which to calculate the Jvolty.</param>
/// <param name="phase">The phase parameter for the JMA-style calculation.</param>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown when period is less than 1.
/// </exception>
public Jmaxx(int period, int phase = 0)
{
if (period < 1)
{
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 1.");
}
_period = period;
_phase = Math.Clamp((phase * 0.01) + 1.5, 0.5, 2.5);
_vsumBuff = new CircularBuffer(10);
_avoltyBuff = new CircularBuffer(65);
_beta = 0.45 * (_period - 1) / (0.45 * (_period - 1) + 2);
WarmupPeriod = (int)_period * 2;
Name = $"JMA({period})";
}
/// <summary>
/// Initializes the Jma instance by setting up the initial state.
/// </summary>
public override void Init()
{
base.Init();
_upperBand = _lowerBand = 0.0;
_p_upperBand = _p_lowerBand = 0.0;
_len1 = Math.Max((Math.Log(Math.Sqrt(_period - 1)) / Math.Log(2.0)) + 2.0, 0);
_pow1 = Math.Max(_len1 - 2.0, 0.5);
_avoltyBuff.Clear();
_vsumBuff.Clear();
}
/// <summary>
/// Manages the state of the Jma instance based on whether a new value is being processed.
/// </summary>
/// <param name="isNew">Indicates whether the current input is a new value.</param>
protected override void ManageState(bool isNew)
{
if (isNew)
{
_index++;
_p_upperBand = _upperBand;
_p_lowerBand = _lowerBand;
_p_vSum = _vSum;
_p_prevMa1 = _prevMa1;
_p_prevDet0 = _prevDet0;
_p_prevDet1 = _prevDet1;
_p_prevJma = _prevJma;
}
else
{
_upperBand = _p_upperBand;
_lowerBand = _p_lowerBand;
_vSum = _p_vSum;
_prevMa1 = _p_prevMa1;
_prevDet0 = _p_prevDet0;
_prevDet1 = _p_prevDet1;
_prevJma = _p_prevJma;
}
}
/// <summary>
/// Performs the Jma calculation for the current value.
/// </summary>
/// <returns>
/// The calculated Jma value for the current input.
/// </returns>
protected override double Calculation()
{
ManageState(Input.IsNew);
double price = Input.Value;
if (_index == 1)
{
_upperBand = _lowerBand = price;
}
double del1 = price - _upperBand;
double del2 = price - _lowerBand;
double volty = Math.Max(Math.Abs(del1), Math.Abs(del2));
_vsumBuff.Add(volty, Input.IsNew);
_vSum += (_vsumBuff[^1] - _vsumBuff[0]) / 10;
_avoltyBuff.Add(_vSum, Input.IsNew);
double avgvolty = _avoltyBuff.Average();
double rvolty = (avgvolty > 0) ? volty / avgvolty : 1;
rvolty = Math.Min(Math.Max(rvolty, 1.0), Math.Pow(_len1, 1.0 / _pow1));
double pow2 = Math.Pow(rvolty, _pow1);
double Kv = Math.Pow(_beta, Math.Sqrt(pow2));
_upperBand = (del1 >= 0) ? price : price - (Kv * del1);
_lowerBand = (del2 <= 0) ? price : price - (Kv * del2);
double alpha = Math.Pow(_beta, pow2);
double ma1 = (1 - alpha) * Input.Value + alpha * _prevMa1;
_prevMa1 = ma1;
double det0 = (price - ma1) * (1 - _beta) + _beta * _prevDet0;
_prevDet0 = det0;
double ma2 = ma1 + _phase * det0;
double det1 = ((ma2 - _prevJma) * (1 - alpha) * (1 - alpha) ) + (alpha * alpha * _prevDet1);
_prevDet1 = det1;
double jma = _prevJma + det1;
_prevJma = jma;
UpperBand = _upperBand;
LowerBand = _lowerBand;
Volty = volty;
IsHot = _index >= WarmupPeriod;
return jma;
}
}
#!csharp
TSeries ma = Complex;
TSeries re = ComplexJMA;
TSeries out1 = new(); TSeries out1 = new();
Jmaxx calc = new(10); Jma calc = new(period: 10, phase: 0, factor: 0.45);
foreach (var value in ma) { out1.Add(calc.Calc(value)); } foreach (var value in ma) { out1.Add(calc.Calc(value)); }
+1 -1
View File
@@ -26,7 +26,7 @@ public class ZlemaIndicator : Indicator, IWatchlistIndicator
public bool ShowColdValues { get; set; } = true; public bool ShowColdValues { get; set; } = true;
private Zlema? ma; private Zlema? ma;
private Huberloss? err; private Huber? err;
protected LineSeries? Series; protected LineSeries? Series;
protected string? SourceName; protected string? SourceName;
public int MinHistoryDepths => Periods; public int MinHistoryDepths => Periods;
+4 -2
View File
@@ -26,8 +26,10 @@
</None> </None>
</ItemGroup> </ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild" Condition="'$(IsLocalBuild)' == 'true'"> <Target Name="CopyCustomContent" AfterTargets="AfterBuild"
<Copy SourceFiles="$(OutputPath)\Averages.dll" DestinationFolder="$(QuantowerRoot)\Settings\Scripts\Indicators\QuanTAlib\Averages" /> Condition="'$(IsLocalBuild)' == 'true' AND $([MSBuild]::IsOSPlatform('Windows'))">
<Copy SourceFiles="$(OutputPath)\Averages.dll"
DestinationFolder="$(QuantowerRoot)\Settings\Scripts\Indicators\QuanTAlib\Averages" />
</Target> </Target>
</Project> </Project>
+2 -1
View File
@@ -25,7 +25,8 @@
</None> </None>
</ItemGroup> </ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild" Condition="'$(IsLocalBuild)' == 'true'"> <Target Name="CopyCustomContent" AfterTargets="AfterBuild"
Condition="'$(IsLocalBuild)' == 'true' AND $([MSBuild]::IsOSPlatform('Windows'))">
<Copy SourceFiles="$(OutputPath)\Statistics.dll" DestinationFolder="$(QuantowerRoot)\Settings\Scripts\Indicators\QuanTAlib\Statistics" /> <Copy SourceFiles="$(OutputPath)\Statistics.dll" DestinationFolder="$(QuantowerRoot)\Settings\Scripts\Indicators\QuanTAlib\Statistics" />
</Target> </Target>
+2 -2
View File
@@ -11,7 +11,7 @@ public class HistoricalIndicator : Indicator, IWatchlistIndicator
[InputParameter("Annualized", sortIndex: 2)] [InputParameter("Annualized", sortIndex: 2)]
public bool IsAnnualized { get; set; } = true; public bool IsAnnualized { get; set; } = true;
private Historical? historical; private Hv? historical;
protected LineSeries? HvSeries; protected LineSeries? HvSeries;
public int MinHistoryDepths => Periods; public int MinHistoryDepths => Periods;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths; int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
@@ -28,7 +28,7 @@ public class HistoricalIndicator : Indicator, IWatchlistIndicator
protected override void OnInit() protected override void OnInit()
{ {
historical = new Historical(Periods, IsAnnualized); historical = new(Periods, IsAnnualized);
base.OnInit(); base.OnInit();
} }
+2 -2
View File
@@ -11,7 +11,7 @@ public class RealizedIndicator : Indicator, IWatchlistIndicator
[InputParameter("Annualized", sortIndex: 2)] [InputParameter("Annualized", sortIndex: 2)]
public bool IsAnnualized { get; set; } = true; public bool IsAnnualized { get; set; } = true;
private Realized? realized; private Rv? realized;
protected LineSeries? RvSeries; protected LineSeries? RvSeries;
public int MinHistoryDepths => Periods; public int MinHistoryDepths => Periods;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths; int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
@@ -28,7 +28,7 @@ public class RealizedIndicator : Indicator, IWatchlistIndicator
protected override void OnInit() protected override void OnInit()
{ {
realized = new Realized(Periods, IsAnnualized); realized = new(Periods, IsAnnualized);
base.OnInit(); base.OnInit();
} }
+2 -1
View File
@@ -26,7 +26,8 @@
</None> </None>
</ItemGroup> </ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild" Condition="'$(IsLocalBuild)' == 'true'"> <Target Name="CopyCustomContent" AfterTargets="AfterBuild"
Condition="'$(IsLocalBuild)' == 'true' AND $([MSBuild]::IsOSPlatform('Windows'))">
<Copy SourceFiles="$(OutputPath)\Volatility.dll" DestinationFolder="$(QuantowerRoot)\Settings\Scripts\Indicators\QuanTAlib\Volatility" /> <Copy SourceFiles="$(OutputPath)\Volatility.dll" DestinationFolder="$(QuantowerRoot)\Settings\Scripts\Indicators\QuanTAlib\Volatility" />
</Target> </Target>