sdev, psdev, alphavantage

This commit is contained in:
Miha Kralj
2022-11-06 17:20:57 -08:00
parent 32615af18b
commit 28025fbdd3
28 changed files with 1860 additions and 2545 deletions
+52
View File
@@ -0,0 +1,52 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class JMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private TBars bars ;
///////
private JMA_Series indicator;
///////
public JMA_chart()
{
this.SeparateWindow = false;
this.Name = "JMA - Jurik Moving Average";
this.Description = "Jurik Moving Average description";
this.AddLineSeries("JMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"JMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
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);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
@@ -2,7 +2,7 @@ using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class SSDEV_chart : Indicator
public class PSDEV_chart : Indicator
{
#region Parameters
@@ -19,22 +19,22 @@ public class SSDEV_chart : Indicator
private TBars bars;
///////dotnet
private SSDEV_Series indicator;
private PSDEV_Series indicator;
///////
public SSDEV_chart()
public PSDEV_chart()
{
this.SeparateWindow = true;
this.Name = "SSDEV - Sample Standard Deviation (Unbiased)";
this.Description = "SSDEV description";
this.AddLineSeries("SSDEV", Color.RoyalBlue, 3, LineStyle.Solid);
this.Name = "PSDEV - Population Standard Deviation (Biased)";
this.Description = "PSDEV description";
this.AddLineSeries("PSDEV", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.bars = new();
this.bars = new();
this.ShortName =
"SSDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
"PSDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+53
View File
@@ -0,0 +1,53 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class PSDEV_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private TBars bars;
///////dotnet
private PSDEV_Series indicator;
///////
public PSDEV_chart()
{
this.SeparateWindow = true;
this.Name = "PSDEV - Population Standard Deviation (Biased)";
this.Description = "PSDEV description";
this.AddLineSeries("PSDEV", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"PSDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
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);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
@@ -0,0 +1,53 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class PSDEV_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private TBars bars;
///////dotnet
private PSDEV_Series indicator;
///////
public PSDEV_chart()
{
this.SeparateWindow = true;
this.Name = "PSDEV - Population Standard Deviation (Biased)";
this.Description = "PSDEV description";
this.AddLineSeries("PSDEV", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"PSDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
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);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+2 -2
View File
@@ -25,14 +25,14 @@ public class SDEV_chart : Indicator
public SDEV_chart()
{
this.SeparateWindow = true;
this.Name = "SDEV - Population Standard Deviation (Biased)";
this.Name = "SDEV - Sample Standard Deviation (Unbiased)";
this.Description = "SDEV description";
this.AddLineSeries("SDEV", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.bars = new();
this.bars = new();
this.ShortName =
"SDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
+6 -5
View File
@@ -30,12 +30,12 @@ public class ZLMA_chart : Indicator
private readonly int matype = 2;
#endregion Parameters
private TBars bars;
///////
///////
private TSeries indicator;
///////
///////
public ZLMA_chart()
{
this.SeparateWindow = false;
@@ -72,7 +72,8 @@ public class ZLMA_chart : Indicator
4 => new TEMA_Series(source: zerolag, period: this.Period, useNaN: false),
5 => new HMA_Series(source: zerolag, period: this.Period, useNaN: false),
6 => new KAMA_Series(source: zerolag, period: this.Period, useNaN: false),
7 => new SMMA_Series(source: zerolag, period: this.Period, useNaN: false),
7 => new JMA_Series(source: zerolag, period: this.Period, useNaN: false),
8 => new SMMA_Series(source: zerolag, period: this.Period, useNaN: false),
_ => new EMA_Series(source: zerolag, period: this.Period, useNaN: false)
};
}