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
-73
View File
@@ -1,73 +0,0 @@
name: Build
on:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install .NET 7.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
7.0.x
5.0.x
include-prerelease: true
- name: Install JDK11 for Sonar Scanner
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Install JetBrains
run: dotnet tool install JetBrains.dotCover.GlobalTool --global
- name: Install Sonar Scanner
run: dotnet tool install dotnet-sonarscanner --global
- name: Install dotnet-coverage
run: dotnet tool install dotnet-coverage --global
- name: Install CodeCov
run: dotnet tool install --global Codecov.Tool
- name: Sonar start
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
#run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="./coverage.xml"
run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib"
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.dotcover.reportsPaths=./coveragereport.html
- name: Build Core DLL
run: dotnet build ./Source/QuanTAlib.csproj --verbosity normal --configuration Release --nologo
- name: Build Quantower DLL
run: dotnet build ./Quantower/Quantower.csproj --verbosity normal --configuration Release --nologo
- name: dotnet Test
run: dotnet test ./Tests/Tests.csproj --verbosity normal --configuration Release --nologo
- name: DotCover Test XML
run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=DetailedXML --dcoutput=./coveragereport.xml
- name: DotCover Test HTML
run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=HTML --dcoutput=./coveragereport.html
# - name: dotnet-coverage
# run: dotnet-coverage collect 'dotnet test' -f xml -o './coverage.xml'
- name: Sonar reporter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: CodeCov run
run: codecov -f ./coveragereport.xml -v -t ${{ secrets.CODECOV_TOKEN }}
- name: Codacy coverage reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coveragereport.xml
+1 -68
View File
@@ -114,7 +114,7 @@ jobs:
run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
--api-key ${{ secrets.GITHUB_TOKEN }}
--source https://nuget.pkg.github.com/mihakralj/index.json
--skip-duplicate
# --skip-duplicate
- name: Push package to nuget.org
run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
@@ -123,74 +123,7 @@ jobs:
--skip-duplicate
# build:
# runs-on: windows-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Install .NET 7.0
# uses: actions/setup-dotnet@v1
# with:
# dotnet-version: |
# 7.0.x
# 5.0.x
# include-prerelease: true
# - name: Install JDK11 for Sonar Scanner
# uses: actions/setup-java@v1
# with:
# java-version: 1.11
# - name: Install JetBrains
# run: dotnet tool install JetBrains.dotCover.GlobalTool --global
# - name: Install Sonar Scanner
# run: dotnet tool install dotnet-sonarscanner --global
# - name: Install dotnet-coverage
# run: dotnet tool install dotnet-coverage --global
# - name: Install CodeCov
# run: dotnet tool install --global Codecov.Tool
# - name: Sonar start
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# #run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="./coverage.xml"
# run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib"
# /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
# /d:sonar.host.url="https://sonarcloud.io"
# /d:sonar.cs.dotcover.reportsPaths=./coveragereport.html
# - name: Build Core DLL
# run: dotnet build ./Source/QuanTAlib.csproj --verbosity normal --configuration Release --nologo
# - name: Build Quantower DLL
# run: dotnet build ./Quantower/Quantower.csproj --verbosity normal --configuration Release --nologo
# - name: dotnet Test
# run: dotnet test ./Tests/Tests.csproj --verbosity normal --configuration Release --nologo
# - name: DotCover Test XML
# run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=DetailedXML --dcoutput=./coveragereport.xml
# - name: DotCover Test HTML
# run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=HTML --dcoutput=./coveragereport.html
# # - name: dotnet-coverage
# # run: dotnet-coverage collect 'dotnet test' -f xml -o './coverage.xml'
# - name: Sonar reporter
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
# - name: CodeCov run
# run: codecov -f ./coveragereport.xml -v -t ${{ secrets.CODECOV_TOKEN }}
# - name: Codacy coverage reporter
# uses: codacy/codacy-coverage-reporter-action@v1
# with:
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# coverage-reports: ./coveragereport.xml
# - name: Zip DLLs
# uses: thedoctor0/zip-release@master
-54
View File
@@ -1,54 +0,0 @@
name: Publish
on:
workflow_dispatch:
jobs:
publish:
runs-on: windows-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install .NET 7.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
7.0.x
5.0.x
include-prerelease: true
- name: Build Core DLL
run: dotnet build ./Source/QuanTAlib.csproj --verbosity normal --configuration Release --nologo
- name: Build Quantower DLL
run: dotnet build ./Quantower/Quantower.csproj --verbosity normal --configuration Release --nologo
- name: Zip DLLs
uses: thedoctor0/zip-release@master
with:
type: 'zip'
directory: \Quantower\Settings\Scripts\Indicators\QuanTAlib
filename: QL_Quantower.zip
- name: Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Pre-release Build"
files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.zip
- name: Push package to nuget.org
run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
--api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate
- name: Push package to github
run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
--api-key ${{ secrets.GITHUB_TOKEN }}
--source https://nuget.pkg.github.com/mihakralj/index.json
--skip-duplicate
+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">
+26 -16
View File
@@ -26,28 +26,38 @@ Remark:
public class KAMA_Series : Single_TSeries_Indicator
{
private static double _scFast, _scSlow;
private readonly System.Collections.Generic.List<double> _buffer = new();
private double _lastkama = double.NaN;
private double _lastlastkama;
public KAMA_Series(TSeries source, int period, int fast = 2, int slow= 30, bool useNaN = false) : base(source, period, useNaN) {
_scFast = 2.0 / (fast+1);
_scSlow = 2.0 / (slow+1);
if (base._data.Count > 0) { base.Add(base._data); }
}
public override void Add((System.DateTime t, double v) TValue, bool update) {
//if (update) { } else { }
double _change = Math.Abs( TValue.v - _data[(this.Count>_p)?this.Count-_p : 0].v);
double _sumpv = 0;
double _kama = TValue.v;
for (int i = (this.Count-_p+1>0)?this.Count-_p+1:0; i <= this.Count; i++) {
_sumpv += Math.Abs(_data[(i>0)?i:0].v- _data[(i>1)?i-1:0].v);
}
if (_sumpv != 0) {
double _er = _change/_sumpv;
double _sc = (_er * (_scFast - _scSlow)) + _scSlow;
double _prevKama = (this.Count > 0) ? this[this.Count-1].v : TValue.v;
if (double.IsNaN(_prevKama)) { _prevKama = TValue.v; }
_kama = (_prevKama + (_sc * _sc * (TValue.v - _prevKama)));
}
if (update) {
_buffer[_buffer.Count - 1] = TValue.v;
this._lastkama = this._lastlastkama;
}
else {
_buffer.Add(TValue.v);
}
if (_buffer.Count>_p+1) { _buffer.RemoveAt(0); }
double _kama = TValue.v;
double _change = Math.Abs( _buffer[_buffer.Count-1] - _buffer[(_buffer.Count>_p+1)?1:0]);
double _sumpv = 0;
for (int i = 1; i < _buffer.Count; i++) {
_sumpv += Math.Abs(_buffer[(_buffer.Count>0)?i:0]- _buffer[i-1]);
}
double _er = (_sumpv==0)?0:_change/_sumpv;
double _sc = (_er * (_scFast - _scSlow)) + _scSlow;
if (_buffer.Count==1) { _lastkama = _buffer[0]; }
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _kama);
base.Add(result, update);
_kama = (_lastkama + (_sc * _sc * (TValue.v - _lastkama)));
_lastlastkama = _lastkama;
_lastkama = _kama;
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _kama);
base.Add(result, update);
}
}