Skip to content

LevelsAttribute

class cAlgo.API

DesktopCLICloud

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

Definition

public sealed class LevelsAttribute : Attribute

Namespace: cAlgo.API · Group: Attributes

Remarks

Represents level lines. It is commonly used in Oscillators, for instance to add a zero line. C# and Python indicators declare their levels the same way, with the Levels entry of config.json.

Examples

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    // This sample indicator sets levels on its outputs with the Levels entry of config.json
    public partial class LevelsSample : Indicator
    {
        private RelativeStrengthIndex _rsi;

        protected override void Initialize()
        {
            _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 14);
        }

        public override void Calculate(int index)
        {
            Result[index] = _rsi.Result[index];
        }
    }
}
class LevelsSample():
    def initialize(self):
        self.rsi = api.Indicators.RelativeStrengthIndex(api.Bars.ClosePrices, 14)

    def calculate(self, index):
        api.Result[index] = self.rsi.Result[index]
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": false,
  "LineOutputs": [
    {
      "Name": "Result",
      "DisplayName": "Main"
    }
  ],
  "Levels": [
    30,
    70
  ]
}

Constructors

Name Description
LevelsAttributeDesktopCLICloud Initializes a new LevelsAttribute instance

Properties

Name Description
LevelsDesktopCLIClouddouble[] The array of price values that are ploted as level lines