Initial commit

This commit is contained in:
Michael Schimmel
2026-01-28 09:10:52 +01:00
commit a1d2e96f8a
513 changed files with 19503 additions and 0 deletions
@@ -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}") = "BarCloseAlert", "BarCloseAlert\BarCloseAlert.csproj", "{5de69e58-aff2-4b56-be9b-3de3b4fc7e82}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5de69e58-aff2-4b56-be9b-3de3b4fc7e82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5de69e58-aff2-4b56-be9b-3de3b4fc7e82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5de69e58-aff2-4b56-be9b-3de3b4fc7e82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5de69e58-aff2-4b56-be9b-3de3b4fc7e82}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,72 @@
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class BarCloseAlert : Indicator
{
private HullMovingAverage _hma;
[Parameter("Bar Close Sound File", Group = "Sounds", DefaultValue = "C:\\Windows\\Media\\Alarm07.wav")]
public string BarCloseSoundFileName { get; set; }
[Parameter("HMA Sound File", Group = "Sounds", DefaultValue = "C:\\Windows\\Media\\Alarm08.wav")]
public string HmaSoundFileName { get; set; }
[Parameter("HMA Period", Group = "HMA Settings", DefaultValue = 200)]
public int HmaPeriod { get; set; }
protected override void Initialize()
{
_hma = Indicators.HullMovingAverage(Bars.ClosePrices, HmaPeriod);
Bars.BarClosed += OnBarsClosed;
}
private void OnBarsClosed(BarClosedEventArgs obj)
{
// 1. Play Bar Close Sound
if (!string.IsNullOrEmpty(BarCloseSoundFileName))
{
Notifications.PlaySound(BarCloseSoundFileName);
}
// 2. Check HMA High/Low
// We need enough bars for Last(0), Last(1), Last(2)
if (Bars.Count < 3 || string.IsNullOrEmpty(HmaSoundFileName))
{
return;
}
// Adjusted Indexing per user requirement:
// Last(0) is treated as the bar that just closed.
double hmaJustClosed = _hma.Result.Last(0);
double hmaPrev = _hma.Result.Last(1);
double hmaPrePrev = _hma.Result.Last(2);
// Check for High Point (Peak): Rising then Falling
// Shape: / \
bool isHigh = (hmaPrePrev < hmaPrev) && (hmaPrev > hmaJustClosed);
// Check for Low Point (Valley): Falling then Rising
// Shape: \ /
bool isLow = (hmaPrePrev > hmaPrev) && (hmaPrev < hmaJustClosed);
if (isHigh || isLow)
{
Notifications.PlaySound(HmaSoundFileName);
}
}
public override void Calculate(int index)
{
}
protected override void OnDestroy()
{
Bars.BarClosed -= OnBarsClosed;
}
}
}
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="cTrader.Automate" Version="*" />
</ItemGroup>
</Project>