Constant Lines Areas - makes vertical constant lines and color each area created by the lines

public class ConstantLineArea : Indicator
    {
        #region Variables

         private double line0Value = 68.88;
private double line1Value = 67.77;
private double line2Value = 66.66;
private double line3Value = 65.55;

       #endregion

        protected override void Initialize()
        {
            Add(new Plot(Color.DimGray, PlotStyle.Line, "Line0"));
Add(new Plot(Color.DimGray, PlotStyle.Line, "Line1"));
            Add(new Plot(Color.DimGray, PlotStyle.Line, "Line2"));
            Add(new Plot(Color.DimGray, PlotStyle.Line, "Line3"));

ChartOnly = true;
            AutoScale = false;
CalculateOnBarClose = true;
DisplayInDataBox = false;
            Overlay = true;
        }

       protected override void OnBarUpdate()
        {
Line0.Set(line0Value);
Line1.Set(line1Value);
Line2.Set(line2Value);
Line3.Set(line3Value);
         


DrawRegion("tag1RegionAbove", CurrentBar, 0, Line0, 100000, Color.Empty, Color.PaleGreen, 6);
DrawRegion("tag1RegionAbove2", CurrentBar, 0, Line0, Line1, Color.Empty, Color.PaleGreen, 5);
DrawRegion("tag1RegionBelow", CurrentBar, 0, Line3, 0, Color.Empty, Color.Salmon, 6);
DrawRegion("tag1RegionBelow2", CurrentBar, 0, Line3, Line2, Color.Empty, Color.Salmon, 5);
DrawRegion("tag1RegionMiddle", CurrentBar, 0, Line2, Line1, Color.Empty, Color.Gray, 4);


        }

        #region Properties
        [Browsable(false)]
        [XmlIgnore()]
        public DataSeries Line0
        {
            get { return Values[0]; }
        }

        [Browsable(false)]
        [XmlIgnore()]
        public DataSeries Line1
        {
            get { return Values[1]; }
        }

        [Browsable(false)]
        [XmlIgnore()]
        public DataSeries Line2
        {
            get { return Values[2]; }
        }

        [Browsable(false)]
        [XmlIgnore()]
        public DataSeries Line3
        {
            get { return Values[3]; }
        }


        [Description("Line 0 value")]
        [GridCategory("Parameters")]
        public double Line0Value
        {
            get { return line0Value; }
            set { line0Value = value; }
        }

[Description("Line 1 value")]
        [GridCategory("Parameters")]
        public double Line1Value
        {
            get { return line1Value; }
            set { line1Value = value; }
        }

[Description("Line 2 value")]
        [GridCategory("Parameters")]
        public double Line2Value
        {
            get { return line2Value; }
            set { line2Value = value; }
        }

[Description("Line 3 value")]
        [GridCategory("Parameters")]
        public double Line3Value
        {
            get { return line3Value; }
            set { line3Value = value; }
        }
     
     
        #endregion

    }

Comments

Popular posts from this blog

ATR in Tick - shows ATR in the number of ticks

Chart Sizing - adjusts the vertical scale of the chart by the number of ticks