mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 03:58:04 +00:00
Update RSI_Series to check for period != 0 before calculating RSI
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user