mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 19:18:05 +00:00
CCI
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class CCI_chart : Indicator
|
||||
{
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
|
||||
private readonly int Period = 10;
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
private TBars bars;
|
||||
|
||||
///////
|
||||
private CCI_Series indicator;
|
||||
///////
|
||||
|
||||
public CCI_chart()
|
||||
{
|
||||
this.SeparateWindow = true;
|
||||
this.Name = "CCI - Commodity Channel Index";
|
||||
this.Description = "CCI description";
|
||||
this.AddLineSeries("CCI", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.ShortName = "CCI (" + this.Period + ")";
|
||||
this.bars = new();
|
||||
this.indicator = new(source: bars, period: this.Period, useNaN: false);
|
||||
}␍
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
bool update = (args.Reason != UpdateReason.NewBar && args.Reason != UpdateReason.HistoricalBar);
|
||||
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;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,12 @@ public class ZLMA_chart : Indicator
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
|
||||
private int Period = 10;
|
||||
private readonly int Period = 10;
|
||||
|
||||
[InputParameter("Data source", 1, 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;
|
||||
private readonly int DataSource = 3;
|
||||
|
||||
[InputParameter("MA algorithm", 2, variants: new object[]
|
||||
{ "SMA", 0,
|
||||
@@ -27,7 +27,7 @@ public class ZLMA_chart : Indicator
|
||||
"JMA", 7,
|
||||
"SMMA", 8
|
||||
})]
|
||||
private int matype = 2;
|
||||
private readonly int matype = 2;
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ZLMA_chart : Indicator
|
||||
this.GetPrice(PriceType.Close),
|
||||
this.GetPrice(PriceType.Volume), update);
|
||||
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
double result = this.indicator[this.indicator.Count-1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<AlgoType>Indicator</AlgoType>
|
||||
@@ -14,7 +14,6 @@
|
||||
<Nullable>disable</Nullable>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<Optimize>True</Optimize>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
@@ -22,7 +21,6 @@
|
||||
<PlatformTarget>anycpu</PlatformTarget>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
@@ -30,20 +28,17 @@
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<PlatformTarget>anycpu</PlatformTarget>
|
||||
</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">
|
||||
<Copy SourceFiles=".\bin\$(Configuration)\net48\Quantower_QTAlib.dll" DestinationFolder="\Quantower\Settings\Scripts\Indicators\QuanTAlib" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="TradingPlatform.BusinessLayer">
|
||||
<HintPath>.\dll\TradingPlatform.BusinessLayer.dll</HintPath>
|
||||
<HintPath>C:\Quantower\TradingPlatform\v1.124.6\bin\TradingPlatform.BusinessLayer.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user