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.

Syntax

public sealed class LevelsAttribute : Attribute

Members

NameTypeSummary
Levels PropertyThe array of price values that are ploted as level lines
LevelsAttribute MethodInitializes a new LevelsAttribute instance

Example 1

namespace cAlgo.Indicators
{
    [Levels(0, 50, 100)]
    [Indicator()]
    public class NewIndicator : Indicator
    //...

Example 2

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];
        }
    }
}
Reference