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 DeMarker", "Sample DeMarker\Sample DeMarker.csproj", "{5D4E7D9A-43FC-4F05-901D-546347D93E4E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5D4E7D9A-43FC-4F05-901D-546347D93E4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5D4E7D9A-43FC-4F05-901D-546347D93E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5D4E7D9A-43FC-4F05-901D-546347D93E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5D4E7D9A-43FC-4F05-901D-546347D93E4E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {36F1F62C-8815-4939-B2A2-1FAF0FA9B2FF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -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 SampleDeMarker : Indicator
|
||||
{
|
||||
[Parameter(DefaultValue = 14)]
|
||||
public int Periods { get; set; }
|
||||
|
||||
[Output("DMark", LineColor = "Turquoise")]
|
||||
public IndicatorDataSeries DMark { get; set; }
|
||||
|
||||
private IndicatorDataSeries deMin;
|
||||
private IndicatorDataSeries deMax;
|
||||
private MovingAverage deMinMA;
|
||||
private MovingAverage deMaxMA;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
deMin = CreateDataSeries();
|
||||
deMax = CreateDataSeries();
|
||||
deMinMA = Indicators.MovingAverage(deMin, Periods, MovingAverageType.Simple);
|
||||
deMaxMA = Indicators.MovingAverage(deMax, Periods, MovingAverageType.Simple);
|
||||
}
|
||||
|
||||
public override void Calculate(int index)
|
||||
{
|
||||
deMin[index] = Math.Max(Bars.LowPrices[index - 1] - Bars.LowPrices[index], 0);
|
||||
deMax[index] = Math.Max(Bars.HighPrices[index] - Bars.HighPrices[index - 1], 0);
|
||||
|
||||
var min = deMinMA.Result[index];
|
||||
var max = deMaxMA.Result[index];
|
||||
|
||||
DMark[index] = max / (min + max);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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