Reworked KAMA & Charts

This commit is contained in:
Miha Kralj
2022-04-23 20:10:58 -07:00
parent 2a73615161
commit 438449f5c0
32 changed files with 127 additions and 287 deletions
+4 -4
View File
@@ -11,7 +11,7 @@ public class ATR_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private ATR_Series indicator;
@@ -27,9 +27,9 @@ public class ATR_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"ATR (" + this.Period + ")";
this.indicator = new(source: bars, period: this.Period, useNaN: false);
this.ShortName = "ATR (" + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars, period: this.Period, useNaN: false);
}
protected override void OnUpdate(UpdateArgs args)
+4 -5
View File
@@ -16,7 +16,7 @@ public class BIAS_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private BIAS_Series indicator;
@@ -32,10 +32,9 @@ public class BIAS_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"BIAS (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
this.ShortName = "BIAS (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period);
}
protected override void OnUpdate(UpdateArgs args)
+3 -2
View File
@@ -16,7 +16,7 @@ public class DEMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars ;
///////
private DEMA_Series indicator;
@@ -34,7 +34,8 @@ public class DEMA_chart : Indicator
{
this.ShortName =
"DEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
+4 -5
View File
@@ -16,7 +16,7 @@ public class EMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private EMA_Series indicator;
@@ -32,10 +32,9 @@ public class EMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"EMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
this.ShortName = "EMA (" + 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)
+4 -5
View File
@@ -16,7 +16,7 @@ public class ENTP_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private ENTP_Series indicator;
@@ -32,10 +32,9 @@ public class ENTP_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"ENTP (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
this.ShortName = "ENTP (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: true);
}
protected override void OnUpdate(UpdateArgs args)
+3 -2
View File
@@ -16,7 +16,7 @@ public class HEMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private HEMA_Series indicator;
@@ -34,7 +34,8 @@ public class HEMA_chart : Indicator
{
this.ShortName =
"HEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
+3 -2
View File
@@ -17,7 +17,7 @@ public class HMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private HMA_Series indicator;
@@ -35,7 +35,8 @@ public class HMA_chart : Indicator
{
this.ShortName =
"HMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
Debug.WriteLine("Send to debug output.");
}
+3 -2
View File
@@ -16,7 +16,7 @@ public class JMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars ;
///////
private JMA_Series indicator;
@@ -34,7 +34,8 @@ public class JMA_chart : Indicator
{
this.ShortName =
"JMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected override void OnUpdate(UpdateArgs args)
+11 -7
View File
@@ -9,15 +9,19 @@ public class KAMA_chart : Indicator
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Fastest EMA", 1, 1, 999, 1, 1)]
private int Fast = 2;
[InputParameter("Slowest EMA", 2, 1, 999, 1, 1)]
private int Slow = 30;
[InputParameter("Data source", 1, variants: new object[]
[InputParameter("Data source", 3, 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 readonly TBars bars = new();
private TBars bars;
///////
private KAMA_Series indicator;
@@ -33,10 +37,9 @@ public class KAMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"KAMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
Debug.WriteLine($"KAMA on-init. indicator.Count: {indicator.Count}");
this.ShortName = "KAMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ":" + this.Fast + ":" + this.Slow + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, fast: this.Fast, slow: this.Slow, useNaN: false);
}
protected override void OnUpdate(UpdateArgs args)
@@ -46,7 +49,8 @@ public class KAMA_chart : Indicator
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;
double result = this.indicator;
this.SetValue(result);
Debug.WriteLine($"{this.indicator[0].v}");
}
}
+3 -2
View File
@@ -16,7 +16,7 @@ public class KURT_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private KURT_Series indicator;
@@ -34,7 +34,8 @@ public class KURT_chart : Indicator
{
this.ShortName =
"KURT (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+3 -2
View File
@@ -16,7 +16,7 @@ public class MAD_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private MAD_Series indicator;
@@ -34,7 +34,8 @@ public class MAD_chart : Indicator
{
this.ShortName =
"MAD (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+3 -2
View File
@@ -16,7 +16,7 @@ public class MAPE_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////dotnet
private MAPE_Series indicator;
@@ -32,7 +32,8 @@ public class MAPE_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"MAPE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
+3 -2
View File
@@ -16,7 +16,7 @@ public class MAX_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private MAX_Series indicator;
@@ -32,7 +32,8 @@ public class MAX_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"MAX (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
+3 -2
View File
@@ -16,7 +16,7 @@ public class MED_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private MED_Series indicator;
@@ -32,7 +32,8 @@ public class MED_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"MED (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
+3 -2
View File
@@ -16,7 +16,7 @@ public class MIN_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private MIN_Series indicator;
@@ -32,7 +32,8 @@ public class MIN_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"MIN (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
+3 -2
View File
@@ -16,7 +16,7 @@ public class MSE_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private MSE_Series indicator;
@@ -32,7 +32,8 @@ public class MSE_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"MSE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
+3 -2
View File
@@ -16,7 +16,7 @@ public class PSDEV_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////dotnet
private PSDEV_Series indicator;
@@ -32,7 +32,8 @@ public class PSDEV_chart : Indicator
protected override void OnInit()
{
this.ShortName =
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);
+3 -2
View File
@@ -16,7 +16,7 @@ public class PVAR_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////dotnet
private PVAR_Series indicator;
@@ -32,7 +32,8 @@ public class PVAR_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"PVAR (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
+3 -2
View File
@@ -16,7 +16,7 @@ public class RMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private RMA_Series indicator;
@@ -32,7 +32,8 @@ public class RMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"RMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
+3 -2
View File
@@ -16,7 +16,7 @@ public class SDEV_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////dotnet
private SDEV_Series indicator;
@@ -32,7 +32,8 @@ public class SDEV_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"SDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
+3 -2
View File
@@ -16,7 +16,7 @@ public class SMAPE_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////dotnet
private SMAPE_Series indicator;
@@ -32,7 +32,8 @@ public class SMAPE_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"SMAPE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
+3 -2
View File
@@ -16,7 +16,7 @@ public class SMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private SMA_Series indicator;
@@ -32,7 +32,8 @@ public class SMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"SMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
+3 -2
View File
@@ -16,7 +16,7 @@ public class TEMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private TEMA_Series indicator;
@@ -32,7 +32,8 @@ public class TEMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"TEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
+3 -2
View File
@@ -16,7 +16,7 @@ public class VAR_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////dotnet
private VAR_Series indicator;
@@ -32,7 +32,8 @@ public class VAR_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"VAR (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
+4 -3
View File
@@ -25,7 +25,7 @@ public class WMAPE_chart : Indicator
#endregion Parameters
private readonly QuanTAlib.TBars bars = new();
private TBars bars;
///////dotnet
private QuanTAlib.WMAPE_Series indicator;
@@ -41,8 +41,9 @@ public class WMAPE_chart : Indicator
protected override void OnInit()
{
this.ShortName = "WMAPE (" + QuanTAlib.TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: this.bars.Select(this.DataSource), period: this.Period, useNaN: true);
this.bars = new();
this.ShortName = "WMAPE (" + QuanTAlib.TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: this.bars.Select(this.DataSource), period: this.Period, useNaN: true);
}
protected override void OnUpdate(UpdateArgs args)
{
+3 -2
View File
@@ -16,7 +16,7 @@ public class WMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private WMA_Series indicator;
@@ -32,7 +32,8 @@ public class WMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
this.bars = new();
this.ShortName =
"WMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
+4 -5
View File
@@ -16,7 +16,7 @@ public class ZLEMA_chart : Indicator
#endregion Parameters
private readonly TBars bars = new();
private TBars bars;
///////
private ZLEMA_Series indicator;
@@ -32,10 +32,9 @@ public class ZLEMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"ZLEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
this.bars = new();
this.ShortName = "ZLEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
}
protected override void OnUpdate(UpdateArgs args)
{
+5 -2
View File
@@ -9,11 +9,12 @@
<AssemblyName>Quantower_QTAlib</AssemblyName>
<RootNamespace>QuanTAlib</RootNamespace>
<DebugType>embedded</DebugType>
<LangVersion>preview</LangVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<Nullable>disable</Nullable>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>True</Optimize>
<WarningLevel>3</WarningLevel>
@@ -31,7 +32,9 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Source\**\*.cs" Exclude="..\Source\obj\**" />
<Compile Include="..\Source\**\*.cs" Exclude="..\Source\obj\**" >
<Link>QuanTAlib\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild">