diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d7babda3..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/.github/workflows/main_automation.yml b/.github/workflows/main_automation.yml index 26d3e2b0..22374fbe 100644 --- a/.github/workflows/main_automation.yml +++ b/.github/workflows/main_automation.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index e986e214..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Quantower/Indicators/ATR_chart.cs b/Quantower/Indicators/ATR_chart.cs index ce467455..e069ae18 100644 --- a/Quantower/Indicators/ATR_chart.cs +++ b/Quantower/Indicators/ATR_chart.cs @@ -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) diff --git a/Quantower/Indicators/BIAS_chart.cs b/Quantower/Indicators/BIAS_chart.cs index 7dde6123..33405a72 100644 --- a/Quantower/Indicators/BIAS_chart.cs +++ b/Quantower/Indicators/BIAS_chart.cs @@ -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) diff --git a/Quantower/Indicators/DEMA_chart.cs b/Quantower/Indicators/DEMA_chart.cs index 76c63628..10e1aa43 100644 --- a/Quantower/Indicators/DEMA_chart.cs +++ b/Quantower/Indicators/DEMA_chart.cs @@ -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); } diff --git a/Quantower/Indicators/EMA_chart.cs b/Quantower/Indicators/EMA_chart.cs index 27055ade..3a6eb9ce 100644 --- a/Quantower/Indicators/EMA_chart.cs +++ b/Quantower/Indicators/EMA_chart.cs @@ -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) diff --git a/Quantower/Indicators/ENTP_chart.cs b/Quantower/Indicators/ENTP_chart.cs index 5e1974eb..b5a66f7d 100644 --- a/Quantower/Indicators/ENTP_chart.cs +++ b/Quantower/Indicators/ENTP_chart.cs @@ -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) diff --git a/Quantower/Indicators/HEMA_chart.cs b/Quantower/Indicators/HEMA_chart.cs index 273648fc..121aa17f 100644 --- a/Quantower/Indicators/HEMA_chart.cs +++ b/Quantower/Indicators/HEMA_chart.cs @@ -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); } diff --git a/Quantower/Indicators/HMA_chart.cs b/Quantower/Indicators/HMA_chart.cs index 2c1f5f96..26630247 100644 --- a/Quantower/Indicators/HMA_chart.cs +++ b/Quantower/Indicators/HMA_chart.cs @@ -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."); } diff --git a/Quantower/Indicators/JMA_chart.cs b/Quantower/Indicators/JMA_chart.cs index 9f9c016d..70c3b445 100644 --- a/Quantower/Indicators/JMA_chart.cs +++ b/Quantower/Indicators/JMA_chart.cs @@ -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) diff --git a/Quantower/Indicators/KAMA_chart.cs b/Quantower/Indicators/KAMA_chart.cs index 3e497191..109ba100 100644 --- a/Quantower/Indicators/KAMA_chart.cs +++ b/Quantower/Indicators/KAMA_chart.cs @@ -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}"); } } diff --git a/Quantower/Indicators/KURT_chart.cs b/Quantower/Indicators/KURT_chart.cs index 81cad58d..09cdc5e3 100644 --- a/Quantower/Indicators/KURT_chart.cs +++ b/Quantower/Indicators/KURT_chart.cs @@ -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); } diff --git a/Quantower/Indicators/MAD_chart.cs b/Quantower/Indicators/MAD_chart.cs index dc675d2b..819189b2 100644 --- a/Quantower/Indicators/MAD_chart.cs +++ b/Quantower/Indicators/MAD_chart.cs @@ -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); } diff --git a/Quantower/Indicators/MAPE_chart.cs b/Quantower/Indicators/MAPE_chart.cs index 57e47fcb..9b772f33 100644 --- a/Quantower/Indicators/MAPE_chart.cs +++ b/Quantower/Indicators/MAPE_chart.cs @@ -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); diff --git a/Quantower/Indicators/MAX_chart.cs b/Quantower/Indicators/MAX_chart.cs index a0d2d851..8f318006 100644 --- a/Quantower/Indicators/MAX_chart.cs +++ b/Quantower/Indicators/MAX_chart.cs @@ -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); diff --git a/Quantower/Indicators/MED_chart.cs b/Quantower/Indicators/MED_chart.cs index 98fa6428..e8952bbb 100644 --- a/Quantower/Indicators/MED_chart.cs +++ b/Quantower/Indicators/MED_chart.cs @@ -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); diff --git a/Quantower/Indicators/MIN_chart.cs b/Quantower/Indicators/MIN_chart.cs index c35a5700..20da1dc3 100644 --- a/Quantower/Indicators/MIN_chart.cs +++ b/Quantower/Indicators/MIN_chart.cs @@ -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); diff --git a/Quantower/Indicators/MSE_chart.cs b/Quantower/Indicators/MSE_chart.cs index dce7d818..ef3dfe53 100644 --- a/Quantower/Indicators/MSE_chart.cs +++ b/Quantower/Indicators/MSE_chart.cs @@ -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); diff --git a/Quantower/Indicators/PSDEV_chart.cs b/Quantower/Indicators/PSDEV_chart.cs index d10f65b3..91b45426 100644 --- a/Quantower/Indicators/PSDEV_chart.cs +++ b/Quantower/Indicators/PSDEV_chart.cs @@ -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); diff --git a/Quantower/Indicators/PVAR_chart.cs b/Quantower/Indicators/PVAR_chart.cs index 2fa31678..f2be74e7 100644 --- a/Quantower/Indicators/PVAR_chart.cs +++ b/Quantower/Indicators/PVAR_chart.cs @@ -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); diff --git a/Quantower/Indicators/RMA_chart.cs b/Quantower/Indicators/RMA_chart.cs index 53357414..153f78f0 100644 --- a/Quantower/Indicators/RMA_chart.cs +++ b/Quantower/Indicators/RMA_chart.cs @@ -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); diff --git a/Quantower/Indicators/SDEV_chart.cs b/Quantower/Indicators/SDEV_chart.cs index 6a8709a0..d920c6fa 100644 --- a/Quantower/Indicators/SDEV_chart.cs +++ b/Quantower/Indicators/SDEV_chart.cs @@ -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); diff --git a/Quantower/Indicators/SMAPE_chart.cs b/Quantower/Indicators/SMAPE_chart.cs index b0005e89..92084b5b 100644 --- a/Quantower/Indicators/SMAPE_chart.cs +++ b/Quantower/Indicators/SMAPE_chart.cs @@ -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); diff --git a/Quantower/Indicators/SMA_chart.cs b/Quantower/Indicators/SMA_chart.cs index 3b1933e9..3439c0ee 100644 --- a/Quantower/Indicators/SMA_chart.cs +++ b/Quantower/Indicators/SMA_chart.cs @@ -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); diff --git a/Quantower/Indicators/TEMA_chart.cs b/Quantower/Indicators/TEMA_chart.cs index 72904f66..ef944cbc 100644 --- a/Quantower/Indicators/TEMA_chart.cs +++ b/Quantower/Indicators/TEMA_chart.cs @@ -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); diff --git a/Quantower/Indicators/VAR_chart.cs b/Quantower/Indicators/VAR_chart.cs index cbb05692..8e316e73 100644 --- a/Quantower/Indicators/VAR_chart.cs +++ b/Quantower/Indicators/VAR_chart.cs @@ -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); diff --git a/Quantower/Indicators/WMAPE_chart.cs b/Quantower/Indicators/WMAPE_chart.cs index f8a66212..f75dbecd 100644 --- a/Quantower/Indicators/WMAPE_chart.cs +++ b/Quantower/Indicators/WMAPE_chart.cs @@ -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) { diff --git a/Quantower/Indicators/WMA_chart.cs b/Quantower/Indicators/WMA_chart.cs index fc9ab073..20019b22 100644 --- a/Quantower/Indicators/WMA_chart.cs +++ b/Quantower/Indicators/WMA_chart.cs @@ -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); diff --git a/Quantower/Indicators/ZLEMA_chart.cs b/Quantower/Indicators/ZLEMA_chart.cs index 16ee75ee..2c33c693 100644 --- a/Quantower/Indicators/ZLEMA_chart.cs +++ b/Quantower/Indicators/ZLEMA_chart.cs @@ -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) { diff --git a/Quantower/Quantower.csproj b/Quantower/Quantower.csproj index 44a503ad..853a4d15 100644 --- a/Quantower/Quantower.csproj +++ b/Quantower/Quantower.csproj @@ -9,11 +9,12 @@ Quantower_QTAlib QuanTAlib embedded + preview AnyCPU disable False - + True 3 @@ -31,7 +32,9 @@ - + + QuanTAlib\%(RecursiveDir)%(Filename)%(Extension) + diff --git a/Source/Indicators/KAMA_Series.cs b/Source/Indicators/KAMA_Series.cs index ed7ebc7b..c9360ae5 100644 --- a/Source/Indicators/KAMA_Series.cs +++ b/Source/Indicators/KAMA_Series.cs @@ -26,28 +26,38 @@ Remark: public class KAMA_Series : Single_TSeries_Indicator { private static double _scFast, _scSlow; + private readonly System.Collections.Generic.List _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); } } \ No newline at end of file