Skip to content

CloudAttribute

Summary

Represents the cloud between the indicator lines.

Signature

1
public class CloudAttribute : Attribute

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 using cAlgo.API;
 using cAlgo.API.Indicators;
 using System;
 namespace cAlgo
 {
     // This indicator shows how to use cloud attribute
     [Cloud("Top", "Bottom", Opacity = 0.2)]
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class BollingerBandsMTFCloudSample : Indicator
     {
         private BollingerBands _bollingerBands;
         private Bars _baseBars;
         [Parameter("Base TimeFrame", DefaultValue = "Daily")]
         public TimeFrame BaseTimeFrame { get; set; }
         [Parameter("Source", DefaultValue = PriceType.Close)]
         public PriceType DataSeriesType { get; set; }
         [Parameter("Periods", DefaultValue = 14, MinValue = 0)]
         public int Periods { get; set; }
         [Parameter("Standard Deviation", DefaultValue = 2, MinValue = 0)]
         public double StandardDeviation { get; set; }
         [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
         public MovingAverageType MaType { get; set; }
         [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; }
         protected override void Initialize()
         {
             _baseBars = MarketData.GetBars(BaseTimeFrame);
             _bollingerBands = Indicators.BollingerBands(_baseBars.GetPrices(DataSeriesType), Periods, StandardDeviation, MaType);
         }
         public override void Calculate(int index)
         {
             var baseIndex = _baseBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
             Main[index] = _bollingerBands.Main[baseIndex];
             Top[index] = _bollingerBands.Top[baseIndex];
             Bottom[index] = _bollingerBands.Bottom[baseIndex];
         }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 import clr
 clr.AddReference("cAlgo.API")
 from cAlgo.API import *
 # Attribute, parameters, and outputs are defined the same way as in C# example
 class Test():
     def initialize(self):
         self.baseBars = api.MarketData.GetBars(api.BaseTimeFrame)
         self.bollingerBands = api.Indicators.BollingerBands(self.baseBars.GetPrices(api.DataSeriesType), api.Periods, api.StandardDeviation, api.MaType)
     def calculate(self, index):
         baseIndex = self.baseBars.OpenTimes.GetIndexByTime(api.Bars.OpenTimes[index])
         api.Main[index] = self.bollingerBands.Main[baseIndex]
         api.Top[index] = self.bollingerBands.Top[baseIndex]
         api.Bottom[index] = self.bollingerBands.Bottom[baseIndex]

Properties

FirstLineName

Summary

The name of the first indicator line.

Signature

1
public string FirstLineName {get;}

Return Value

string

SecondLineName

Summary

The name of the second indicator line.

Signature

1
public string SecondLineName {get;}

Return Value

string

Opacity

Summary

The cloud opacity. Value can be set from 0 (transparent) to 1 (opaque). Values higher than 1 will be set to 1, values below 0 will be set to 0. Opacity is multiplied by the alpha channel of the active color (first or second color). Default opacity value is 0.2.

Signature

1
public double Opacity {get; set;}

Return Value

double

FirstColor

Summary

Cloud color when the first line is above the second one. If not specified, the color of the first line is used.

Signature

1
public string FirstColor {get; set;}

Return Value

string

SecondColor

Summary

Cloud color when the second line is above the first one. If not specified, color of the second line is used.

Signature

1
public string SecondColor {get; set;}

Return Value

string