Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31729.503
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample Standard Deviation", "Sample Standard Deviation\Sample Standard Deviation.csproj", "{9A613E47-9DBB-415C-9AF9-DC10C3B588CC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9A613E47-9DBB-415C-9AF9-DC10C3B588CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9A613E47-9DBB-415C-9AF9-DC10C3B588CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9A613E47-9DBB-415C-9AF9-DC10C3B588CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9A613E47-9DBB-415C-9AF9-DC10C3B588CC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A1B1BB6D-BE3B-4D5A-9FD9-83E6085D984A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// This code is a cTrader Automate API example.
|
||||
//
|
||||
// All changes to this file might be lost on the next application update.
|
||||
// If you are going to modify this file please make a copy using the "Duplicate" command.
|
||||
//
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using cAlgo.API;
|
||||
using cAlgo.API.Indicators;
|
||||
|
||||
namespace cAlgo
|
||||
{
|
||||
[Indicator(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
|
||||
public class SampleStandardDeviation : Indicator
|
||||
{
|
||||
[Parameter("Source")]
|
||||
public DataSeries Source { get; set; }
|
||||
|
||||
[Parameter(DefaultValue = 14, MinValue = 2)]
|
||||
public int Periods { get; set; }
|
||||
|
||||
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
|
||||
public MovingAverageType MAType { get; set; }
|
||||
|
||||
[Output("Result", LineColor = "Orange")]
|
||||
public IndicatorDataSeries Result { get; set; }
|
||||
|
||||
private MovingAverage movingAverage;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
movingAverage = Indicators.MovingAverage(Source, Periods, MAType);
|
||||
}
|
||||
|
||||
public override void Calculate(int index)
|
||||
{
|
||||
var average = movingAverage.Result[index];
|
||||
var sum = 0.0;
|
||||
|
||||
for (var period = 0; period < Periods; period++)
|
||||
sum += Math.Pow(Source[index - period] - average, 2.0);
|
||||
|
||||
Result[index] = Math.Sqrt(sum / Periods);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="cTrader.Automate" Version="1.*-*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user