Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Indicators/.samples.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,9 @@
{
"name": "BarsTickEventArgs Sample"
},
{
"name": "Bollinger Bands Cloud Sample"
},
{
"name": "Bollinger Bands MTF Cloud Sample"
},
Expand DownExpand Up@@ -272,6 +275,9 @@
{
"name": "Line Style Sample"
},
{
"name": "MA Cloud Sample"
},
{
"name": "Market Data Sample"
},
Expand Down
Original file line numberDiff line numberDiff line change
@@ -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}") = "Bollinger Bands Cloud Sample", "Bollinger Bands Cloud Sample\Bollinger Bands Cloud Sample.csproj", "{d13ce943-9302-455b-9ec2-5e6a99b87f23}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{d13ce943-9302-455b-9ec2-5e6a99b87f23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{d13ce943-9302-455b-9ec2-5e6a99b87f23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{d13ce943-9302-455b-9ec2-5e6a99b87f23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{d13ce943-9302-455b-9ec2-5e6a99b87f23}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Algo API example.
//
// The code is provided as a sample only and does not guarantee any particular outcome or profit of any kind. Use it at your own risk.
//
// This sample indicator draws a cloud between the top and bottom bands of Bollinger Bands.
//
// For a detailed tutorial on creating this indicator, see this video: https://www.youtube.com/watch?v=AWqo0k0Rrag
//
// -------------------------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
[Cloud("Top", "Bottom", Opacity = 0.2)]

public class BollingerBandsCloud : Indicator
{

[Output("Main", LineColor = "Yellow", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Main{get; set}

[Output("Top", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Top{get; set}

[Output("Bottom", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Bottom{get; set}

private BollingerBands _bollingerBands;

protected override void Initialize()
{
_bollingerBands = Indicators.BollingerBands(Bars.ClosePrices, 20, 2, MovingAverageType.Simple);
}

public override void Calculate(int index)
{
Main[index] = _bollingerBands.Main[index];
Top[index] = _bollingerBands.Top[index];
Bottom[index] = _bollingerBands.Bottom[index];
}
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="cTrader.Automate" Version="*" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions Indicators/MA Cloud Sample/MA Cloud Sample.sln
Original file line numberDiff line numberDiff line change
@@ -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}") = "MA Cloud Sample", "MA Cloud Sample\MA Cloud Sample.csproj", "{121fedb8-4ad2-4fd0-80dd-97ee82602d8d}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{121fedb8-4ad2-4fd0-80dd-97ee82602d8d}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{121fedb8-4ad2-4fd0-80dd-97ee82602d8d}.Debug|Any CPU.Build.0 = Debug|Any CPU
{121fedb8-4ad2-4fd0-80dd-97ee82602d8d}.Release|Any CPU.ActiveCfg = Release|Any CPU
{121fedb8-4ad2-4fd0-80dd-97ee82602d8d}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
46 changes: 46 additions & 0 deletions Indicators/MA Cloud Sample/MA Cloud Sample/MA Cloud Sample.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Algo API example.
//
// The code is provided as a sample only and does not guarantee any particular outcome or profit of any kind. Use it at your own risk.
//
// This sample indicator draws a green cloud for uptrends and a red cloud for downtrends on a Moving Average (MA) Crossover.
//
// For a detailed tutorial on creating this indicator, see this video: https://www.youtube.com/watch?v=AWqo0k0Rrag
//
// -------------------------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
[Cloud("Fast", "Slow", Opacity = 0.2)]
public class MACloud : Indicator
{
[Output("Fast", LineColor = "Green", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Fast{get; set}

[Output("Slow", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Slow{get; set}

SimpleMovingAverage _fastMA;
SimpleMovingAverage _slowMA;

protected override void Initialize()
{
_fastMA = Indicators.SimpleMovingAverage(Bars.ClosePrices, 7);
_slowMA = Indicators.SimpleMovingAverage(Bars.ClosePrices, 13);
}

public override void Calculate(int index)
{
Fast[index] = _fastMA.Result[index];
Slow[index] = _slowMA.Result[index];
}
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="cTrader.Automate" Version="*" />
</ItemGroup>
</Project>