Initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30011.22
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Difference", "Difference\Difference.csproj", "{3ebc950e-1111-4055-9211-b51d7d4ac02e}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3ebc950e-1111-4055-9211-b51d7d4ac02e}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3ebc950e-1111-4055-9211-b51d7d4ac02e}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3ebc950e-1111-4055-9211-b51d7d4ac02e}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3ebc950e-1111-4055-9211-b51d7d4ac02e}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using cAlgo.API;
|
||||
using cAlgo.API.Internals;
|
||||
|
||||
namespace cAlgo.Indicators
|
||||
{
|
||||
// Calculates the difference or absolute distance between two data sources
|
||||
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
|
||||
public class DifferenceIndicator : Indicator
|
||||
{
|
||||
[Parameter("Source 1")]
|
||||
public DataSeries Source1 { get; set; }
|
||||
|
||||
[Parameter("Source 2")]
|
||||
public DataSeries Source2 { get; set; }
|
||||
|
||||
[Parameter("Use Absolute Distance", DefaultValue = false)]
|
||||
public bool UseAbsoluteDistance { get; set; }
|
||||
|
||||
[Output("Result", LineColor = "MainColor", PlotType = PlotType.Line, Thickness = 1)]
|
||||
public IndicatorDataSeries Result { get; set; }
|
||||
|
||||
// Core calculation logic
|
||||
public override void Calculate(int index)
|
||||
{
|
||||
double diff = Source1[index] - Source2[index];
|
||||
|
||||
// Result is either raw difference or absolute distance
|
||||
Result[index] = UseAbsoluteDistance ? Math.Abs(diff) : diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="cTrader.Automate" Version="*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user