ABOVE_Series

This commit is contained in:
Miha Kralj
2023-04-03 09:44:57 -07:00
parent d02fa3a5ec
commit 69fae888d5
6 changed files with 36 additions and 15 deletions
+11 -4
View File
@@ -10,7 +10,8 @@ Remarks:
</summary> */
public class OVER_Series : Pair_TSeries_Indicator {
public TSeries Cross = new();
public TSeries Cross { get; set; } = new();
private double _previous = double.NaN;
public OVER_Series(TSeries d1, TSeries d2) : base(d1, d2) {
if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
@@ -23,13 +24,18 @@ public class OVER_Series : Pair_TSeries_Indicator {
}
public override void Add((System.DateTime t, double v) TValue1, (System.DateTime t, double v) TValue2, bool update) {
(System.DateTime t, double v) over = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, TValue1.v > TValue2.v ? 1 : TValue1.v < TValue2.v ? -1 : 0);
double val = TValue1.v > TValue2.v ? 1 : -1;
val = TValue1.v == TValue2.v ? 0 : val;
(System.DateTime t, double v) over = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, TValue1.v > TValue2.v ? 1 : val);
if (update) { this.Cross[^1] = over; }
else { this.Cross.Add(over); }
val = (this._previous < over.v) ? 1 : -1;
(System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t,
((_previous == over.v) || (_previous != 0) || Double.IsNaN(_previous)) ? 0 : (_previous < over.v) ? 1 : -1);
_previous = over.v;
((this._previous == over.v) || Double.IsNaN(this._previous) || (this._previous == 0)) ? 0 : val);
this._previous = over.v;
if (update) { base[^1] = result; }
else { base.Add(result); }
@@ -37,3 +43,4 @@ public class OVER_Series : Pair_TSeries_Indicator {
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Title>QuanTAlib</Title>
<Version>0.1.30</Version>
<Version>0.1.31</Version>
<Product>Library of TA Calculations, Charts and Strategies for Quantower</Product>
<Description>Quantitative Technical Analysis Library in C# for Quantower</Description>
<RepositoryType>git</RepositoryType>
+2 -3
View File
@@ -10,7 +10,7 @@ Alphavantage - Free API to collect 100 recent daily quotes. It requires a (free)
APIkey: unique Alphavantage API key
</summary>
*/
public class Alphavantage_Feed : TBars
{
public enum Interval { Month, Week, Day, Hour, Min30, Min15, Min5, Min1}
@@ -52,5 +52,4 @@ public class Alphavantage_Feed : TBars
}
return (date, o, h, l, c, v);
}
}
*/
}
+1 -2
View File
@@ -11,7 +11,7 @@ Yahoo Finance - Free API feed to collect daily market quotes
Yahoo_Feed ticker = new("MSFT", 20)
</summary>
*/
public class Yahoo_Feed : TBars
{
public Yahoo_Feed(string Symbol = "IBM", int Period = 252) {
@@ -46,4 +46,3 @@ public class Yahoo_Feed : TBars
}
}
}
*/
+16 -1
View File
@@ -6,15 +6,30 @@ using TradingPlatform.BusinessLayer.Chart;
namespace QuanTAlib;
public class QuanTAlib_Indicator : Indicator {
public abstract class QuanTAlib_Indicator : Indicator {
protected TBars bars;
protected IChartWindow mainWindow;
protected Graphics graphics;
protected int firstOnScreenBarIndex, lastOnScreenBarIndex;
protected HistoricalData History;
protected int HistPeriod;
protected override void OnInit() {
base.OnInit();
bars = new();
var dur1 = this.HistoricalData.FromTime;
var dur = this.HistoricalData.Period.Duration.TotalSeconds * (HistPeriod*4) ; //seconds of two periods
this.History = this.Symbol.GetHistory(period: this.HistoricalData.Period, fromTime: HistoricalData.FromTime);
for (int i = this.History.Count-1; i >= 0; i--) {
var rec = this.History[i, SeekOriginHistory.Begin];
bars.Add(rec.TimeLeft, rec[PriceType.Open],
rec[PriceType.High], rec[PriceType.Low],
rec[PriceType.Close], rec[PriceType.Volume]);
}
}
protected override void OnUpdate(UpdateArgs args) {
+5 -4
View File
@@ -14,7 +14,7 @@ public class JMA_chart : QuanTAlib_Indicator {
private int DataSource = 3;
[InputParameter("Smoothing period", 1, 1, 999, 1, 1)]
private int Period = 10;
private int Period = 9;
[InputParameter("Volatility short", 2, 3, 50, 1, 1)]
private int Vshort = 10;
@@ -28,7 +28,7 @@ public class JMA_chart : QuanTAlib_Indicator {
#endregion Parameters
///////
private JMA_Series indicator;
private EMA_Series indicator;
///////
public JMA_chart() :base() {
@@ -36,14 +36,15 @@ public class JMA_chart : QuanTAlib_Indicator {
Description = "Jurik Moving Average description";
AddLineSeries(lineName: "JMA", lineColor: Color.Yellow, lineWidth: 3,lineStyle: LineStyle.Solid);
SeparateWindow = false;
HistPeriod = Period;
}
protected override void OnInit() {
base.OnInit();
indicator = new(source: bars.Select(DataSource), period: Period,
phase: Jphase, vshort: Vshort, vlong: Vlong,
useNaN: false);
// phase: Jphase, vshort: Vshort, vlong: Vlong,
useNaN: true);
}
protected override void OnUpdate(UpdateArgs args) {