mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-24 05:28:05 +00:00
ABOVE_Series
This commit is contained in:
@@ -10,7 +10,8 @@ Remarks:
|
|||||||
</summary> */
|
</summary> */
|
||||||
|
|
||||||
public class OVER_Series : Pair_TSeries_Indicator {
|
public class OVER_Series : Pair_TSeries_Indicator {
|
||||||
public TSeries Cross = new();
|
public TSeries Cross { get; set; } = new();
|
||||||
|
|
||||||
private double _previous = double.NaN;
|
private double _previous = double.NaN;
|
||||||
public OVER_Series(TSeries d1, TSeries d2) : base(d1, d2) {
|
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); } }
|
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) {
|
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; }
|
if (update) { this.Cross[^1] = over; }
|
||||||
else { this.Cross.Add(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,
|
(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);
|
((this._previous == over.v) || Double.IsNaN(this._previous) || (this._previous == 0)) ? 0 : val);
|
||||||
_previous = over.v;
|
|
||||||
|
this._previous = over.v;
|
||||||
|
|
||||||
if (update) { base[^1] = result; }
|
if (update) { base[^1] = result; }
|
||||||
else { base.Add(result); }
|
else { base.Add(result); }
|
||||||
@@ -37,3 +43,4 @@ public class OVER_Series : Pair_TSeries_Indicator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Title>QuanTAlib</Title>
|
<Title>QuanTAlib</Title>
|
||||||
<Version>0.1.30</Version>
|
<Version>0.1.31</Version>
|
||||||
<Product>Library of TA Calculations, Charts and Strategies for Quantower</Product>
|
<Product>Library of TA Calculations, Charts and Strategies for Quantower</Product>
|
||||||
<Description>Quantitative Technical Analysis Library in C# for Quantower</Description>
|
<Description>Quantitative Technical Analysis Library in C# for Quantower</Description>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Alphavantage - Free API to collect 100 recent daily quotes. It requires a (free)
|
|||||||
APIkey: unique Alphavantage API key
|
APIkey: unique Alphavantage API key
|
||||||
|
|
||||||
</summary>
|
</summary>
|
||||||
|
*/
|
||||||
public class Alphavantage_Feed : TBars
|
public class Alphavantage_Feed : TBars
|
||||||
{
|
{
|
||||||
public enum Interval { Month, Week, Day, Hour, Min30, Min15, Min5, Min1}
|
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);
|
return (date, o, h, l, c, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@@ -11,7 +11,7 @@ Yahoo Finance - Free API feed to collect daily market quotes
|
|||||||
Yahoo_Feed ticker = new("MSFT", 20)
|
Yahoo_Feed ticker = new("MSFT", 20)
|
||||||
|
|
||||||
</summary>
|
</summary>
|
||||||
|
*/
|
||||||
public class Yahoo_Feed : TBars
|
public class Yahoo_Feed : TBars
|
||||||
{
|
{
|
||||||
public Yahoo_Feed(string Symbol = "IBM", int Period = 252) {
|
public Yahoo_Feed(string Symbol = "IBM", int Period = 252) {
|
||||||
@@ -46,4 +46,3 @@ public class Yahoo_Feed : TBars
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@@ -6,15 +6,30 @@ using TradingPlatform.BusinessLayer.Chart;
|
|||||||
|
|
||||||
namespace QuanTAlib;
|
namespace QuanTAlib;
|
||||||
|
|
||||||
public class QuanTAlib_Indicator : Indicator {
|
public abstract class QuanTAlib_Indicator : Indicator {
|
||||||
protected TBars bars;
|
protected TBars bars;
|
||||||
protected IChartWindow mainWindow;
|
protected IChartWindow mainWindow;
|
||||||
protected Graphics graphics;
|
protected Graphics graphics;
|
||||||
protected int firstOnScreenBarIndex, lastOnScreenBarIndex;
|
protected int firstOnScreenBarIndex, lastOnScreenBarIndex;
|
||||||
|
protected HistoricalData History;
|
||||||
|
protected int HistPeriod;
|
||||||
|
|
||||||
protected override void OnInit() {
|
protected override void OnInit() {
|
||||||
base.OnInit();
|
base.OnInit();
|
||||||
bars = new();
|
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) {
|
protected override void OnUpdate(UpdateArgs args) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class JMA_chart : QuanTAlib_Indicator {
|
|||||||
private int DataSource = 3;
|
private int DataSource = 3;
|
||||||
|
|
||||||
[InputParameter("Smoothing period", 1, 1, 999, 1, 1)]
|
[InputParameter("Smoothing period", 1, 1, 999, 1, 1)]
|
||||||
private int Period = 10;
|
private int Period = 9;
|
||||||
|
|
||||||
[InputParameter("Volatility short", 2, 3, 50, 1, 1)]
|
[InputParameter("Volatility short", 2, 3, 50, 1, 1)]
|
||||||
private int Vshort = 10;
|
private int Vshort = 10;
|
||||||
@@ -28,7 +28,7 @@ public class JMA_chart : QuanTAlib_Indicator {
|
|||||||
#endregion Parameters
|
#endregion Parameters
|
||||||
|
|
||||||
///////
|
///////
|
||||||
private JMA_Series indicator;
|
private EMA_Series indicator;
|
||||||
///////
|
///////
|
||||||
|
|
||||||
public JMA_chart() :base() {
|
public JMA_chart() :base() {
|
||||||
@@ -36,14 +36,15 @@ public class JMA_chart : QuanTAlib_Indicator {
|
|||||||
Description = "Jurik Moving Average description";
|
Description = "Jurik Moving Average description";
|
||||||
AddLineSeries(lineName: "JMA", lineColor: Color.Yellow, lineWidth: 3,lineStyle: LineStyle.Solid);
|
AddLineSeries(lineName: "JMA", lineColor: Color.Yellow, lineWidth: 3,lineStyle: LineStyle.Solid);
|
||||||
SeparateWindow = false;
|
SeparateWindow = false;
|
||||||
|
HistPeriod = Period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void OnInit() {
|
protected override void OnInit() {
|
||||||
base.OnInit();
|
base.OnInit();
|
||||||
indicator = new(source: bars.Select(DataSource), period: Period,
|
indicator = new(source: bars.Select(DataSource), period: Period,
|
||||||
phase: Jphase, vshort: Vshort, vlong: Vlong,
|
// phase: Jphase, vshort: Vshort, vlong: Vlong,
|
||||||
useNaN: false);
|
useNaN: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnUpdate(UpdateArgs args) {
|
protected override void OnUpdate(UpdateArgs args) {
|
||||||
|
|||||||
Reference in New Issue
Block a user