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 EMA", "Sample EMA\Sample EMA.csproj", "{F76AABC5-E32A-4B1F-9FBF-EAA686B5F769}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F76AABC5-E32A-4B1F-9FBF-EAA686B5F769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F76AABC5-E32A-4B1F-9FBF-EAA686B5F769}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F76AABC5-E32A-4B1F-9FBF-EAA686B5F769}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F76AABC5-E32A-4B1F-9FBF-EAA686B5F769}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {244A7EFF-8CB3-4A89-A5CB-E9224A234C17}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,43 @@
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// 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 cAlgo.API;
|
||||
|
||||
namespace cAlgo
|
||||
{
|
||||
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
|
||||
public class SampleEMA : Indicator
|
||||
{
|
||||
[Parameter("Source")]
|
||||
public DataSeries Source { get; set; }
|
||||
|
||||
[Parameter("Periods", DefaultValue = 14)]
|
||||
public int Periods { get; set; }
|
||||
|
||||
[Output("Main", LineColor = "Turquoise")]
|
||||
public IndicatorDataSeries Result { get; set; }
|
||||
|
||||
private double exp;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
exp = 2.0 / (Periods + 1);
|
||||
}
|
||||
|
||||
public override void Calculate(int index)
|
||||
{
|
||||
var previousValue = Result[index - 1];
|
||||
|
||||
if (double.IsNaN(previousValue))
|
||||
Result[index] = Source[index];
|
||||
else
|
||||
Result[index] = Source[index] * exp + previousValue * (1 - exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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