Skip to content

LevelsAttribute

Summary

Levels Attribute. Applies metadata to enable the plot of level lines.

Remarks

Represents level lines. It is commonly used in Oscillators, for instance to add a zero line. Must be added before the indicator class declaration.

Signature

1
public sealed class LevelsAttribute : Attribute

Namespace

cAlgo.API

Properties

Name Description
Levels { get; set; } The array of price values that are ploted as level lines

Examples

1
2
3
4
5
6
 namespace cAlgo.Indicators
 {
     [Levels(0, 50, 100)]
     [Indicator()]
     public class NewIndicator : Indicator
     //...
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 using cAlgo.API;
 using cAlgo.API.Indicators;
 namespace cAlgo
 {
     // This sample indicator shows how to use the LevelsAttribute to set levels on your indicator outputs
     [Levels(30, 70)]
     [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class LevelsSample : Indicator
     {
         private RelativeStrengthIndex _rsi;
         [Parameter(DefaultValue = 0.0)]
         public double Parameter { get; set; }
         [Output("Main")]
         public IndicatorDataSeries Result { get; set; }
         protected override void Initialize()
         {
             _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 20);
         }
         public override void Calculate(int index)
         {
             Result[index] = _rsi.Result[index];
         }
     }
 }

Last update: December 8, 2022

Comments