Update RSI_Series to check for period != 0 before calculating RSI

This commit is contained in:
Miha Kralj
2023-04-27 22:30:13 -07:00
parent 3b71ac70c8
commit e1680e9d04
145 changed files with 4826 additions and 4207 deletions
+6 -6
View File
@@ -7,7 +7,7 @@ namespace QuanTAlib;
public class MovingAverage_chart : Indicator {
#region Parameters
[InputParameter("MA1: Type:", 0, variants: new object[]
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FMA", 7, "DEMA", 8, "TEMA", 9,
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
"ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
private int MA1type = 15;
@@ -20,7 +20,7 @@ public class MovingAverage_chart : Indicator {
private int MA1DataSource = 3;
[InputParameter("MA2: Type:", 3, variants: new object[]
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FMA", 7, "DEMA", 8, "TEMA", 9,
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
"ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
private int MA2type = 16;
@@ -97,8 +97,8 @@ public class MovingAverage_chart : Indicator {
this.Name += $"DWMA";
break;
case 7:
MA1 = new FMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period);
this.Name += $"FMA";
MA1 = new FWMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period);
this.Name += $"FWMA";
break;
case 8:
MA1 = new DEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
@@ -171,8 +171,8 @@ public class MovingAverage_chart : Indicator {
this.Name += $"DWMA";
break;
case 7:
MA2 = new FMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period);
this.Name += $"FMA";
MA2 = new FWMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period);
this.Name += $"FWMA";
break;
case 8:
MA2 = new DEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
+7 -11
View File
@@ -7,7 +7,7 @@ namespace QuanTAlib;
public class MovingAverageSlope_chart : Indicator {
#region Parameters
[InputParameter("MA1: Type:", 0, variants: new object[]
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FMA", 7, "DEMA", 8, "TEMA", 9,
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
"ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
private int MA1type = 16;
@@ -20,7 +20,7 @@ public class MovingAverageSlope_chart : Indicator {
private int MA1DataSource = 3;
[InputParameter("MA2: Type:", 3, variants: new object[]
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FMA", 7, "DEMA", 8, "TEMA", 9,
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
"ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
private int MA2type = 6;
@@ -101,8 +101,8 @@ public class MovingAverageSlope_chart : Indicator {
this.Name += $"DWMA";
break;
case 7:
MA1 = new FMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period);
this.Name += $"FMA";
MA1 = new FWMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period);
this.Name += $"FWMA";
break;
case 8:
MA1 = new DEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
@@ -175,8 +175,8 @@ public class MovingAverageSlope_chart : Indicator {
this.Name += $"DWMA";
break;
case 7:
MA2 = new FMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period);
this.Name += $"FMA";
MA2 = new FWMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period);
this.Name += $"FWMA";
break;
case 8:
MA2 = new DEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
@@ -227,11 +227,7 @@ public class MovingAverageSlope_chart : Indicator {
protected override void OnUpdate(UpdateArgs args) {
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High),
this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.bars.Add(this.Time(),this.Open(), this.High(), this.Low(), this.Close(), this.Volume(), update);
this.SetValue(this.MA1[^1].v, lineIndex: 0);
this.SetValue(this.MA2[^1].v, lineIndex: 1);
+1 -3
View File
@@ -64,9 +64,7 @@ public class JMA_chart : Indicator {
rec[PriceType.Close], rec[PriceType.Volume]);
}
indicator = new(source: bars.Select(DataSource), period: Period,
phase: Jphase, vshort: Vshort, vlong: Vlong,
useNaN: true);
indicator = new(source: bars.Select(DataSource), period: Period, phase: Jphase, vshort: Vshort, vlong: Vlong, useNaN: true);
}
protected override void OnUpdate(UpdateArgs args) {
+2
View File
@@ -17,6 +17,8 @@
<InformationalVersion>0.2.1-dev.2+Branch.dev.Sha.cb5fe2dc86a78fe9358da810d17952c82299ed3d</InformationalVersion>
<Version>0.2.1-dev.2</Version>
<SuppressNETSdkWarningProperty>NETSDK1057</SuppressNETSdkWarningProperty>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<NoWarn>NETSDK1057</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>True</Optimize>