> For the complete documentation index, see [llms.txt](https://support.tiger.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.tiger.com/razrabotka-dlya-tiger.trade-windows/primery-indikatorov/high-low.md).

# High Low

```
//------------------------------------------------------------------------------
//
// Индикатор HighLow. Copyright (c) 2023 Tiger Trade Capital AG. All rights reserved.
//
//------------------------------------------------------------------------------
 
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using TigerTrade.Chart.Base;
using TigerTrade.Chart.Base.Enums;
using TigerTrade.Chart.Indicators.Common;
using TigerTrade.Chart.Indicators.Drawings;
using TigerTrade.Chart.Indicators.Enums;
using TigerTrade.Core.Utils.Time;
using TigerTrade.Dx.Enums;
 
namespace TigerTrade.Chart.Indicators.Custom
{
    [DataContract(Name = "HighLowIndicator", Namespace = "http://schemas.datacontract.org/2004/07/TigerTrade.Chart.Indicators.Custom")]
    [Indicator("Z_HighLow", "*HighLow", true, Type = typeof(HighLowIndicator))]
    internal sealed class HighLowIndicator : IndicatorBase
    {
        private IndicatorPeriodType _period;
 
        [DataMember(Name = "Period")]
        [Category("Параметры"), DisplayName("Период")]
        public IndicatorPeriodType Period
        {
            get => _period;
            set
            {
                if (value == _period)
                {
                    return;
                }
 
                _period = value;
 
                OnPropertyChanged();
            }
        }
 
        private ChartLine _highLowSeries;
 
        [DataMember(Name = "HighLow")]
        [Category("Графики"), DisplayName("High/Low")]
        public ChartLine HighLowSeries
        {
            get => _highLowSeries ?? (_highLowSeries = new ChartLine());
            private set
            {
                if (Equals(value, _highLowSeries))
                {
                    return;
                }
 
                _highLowSeries = value;
 
                OnPropertyChanged();
            }
        }
 
        private ChartLine _medianSeries;
 
        [DataMember(Name = "Median")]
        [Category("Графики"), DisplayName("Median")]
        public ChartLine MedianSeries
        {
            get => _medianSeries ?? (_medianSeries = new ChartLine());
            private set
            {
                if (Equals(value, _medianSeries))
                {
                    return;
                }
 
                _medianSeries = value;
 
                OnPropertyChanged();
            }
        }
 
        private ChartLine _prevMedianSeries;
 
        [DataMember(Name = "PrevMedian")]
        [Category("Графики"), DisplayName("PrevMedian")]
        public ChartLine PrevMedianSeries
        {
            get => _prevMedianSeries ?? (_prevMedianSeries = new ChartLine
            {
                Style = XDashStyle.Dash
            });
            private set
            {
                if (Equals(value, _prevMedianSeries))
                {
                    return;
                }
 
                _prevMedianSeries = value;
 
                OnPropertyChanged();
            }
        }
 
        [Browsable(false)]
        public override IndicatorCalculation DefaultCalculation => IndicatorCalculation.OnBarClose;
 
        public HighLowIndicator()
        {
            Period = IndicatorPeriodType.Day;
        }
 
        protected override void Execute()
        {
            var date = Helper.Date;
            var high = Helper.High;
            var low = Helper.Low;
 
            var highData = new double[date.Length];
            var lowData = new double[date.Length];
            var medianData = new double[date.Length];
            var prevMedianData = new double[date.Length];
 
            var splits = new bool[date.Length];
 
            var lastSequence = -1;
 
            var highValue = 0.0;
            var lowValue = 0.0;
 
            var prevMedian = double.NaN;
 
            var timeOffset = TimeHelper.GetSessionOffset(DataProvider.Symbol.Exchange);
 
            for (var i = 0; i < date.Length; i++)
            {
                var sequence = 1;
 
                switch (Period)
                {
                    case IndicatorPeriodType.Day:
 
                        sequence = DataProvider.Period.GetSequence(ChartPeriodType.Day, 1, date[i], timeOffset);
 
                        break;
 
                    case IndicatorPeriodType.Week:
 
                        sequence = DataProvider.Period.GetSequence(ChartPeriodType.Week, 1, date[i], timeOffset);
 
                        break;
 
                    case IndicatorPeriodType.Month:
 
                        sequence = DataProvider.Period.GetSequence(ChartPeriodType.Month, 1, date[i], timeOffset);
 
                        break;
                }
 
                if (sequence != lastSequence)
                {
                    lastSequence = sequence;
 
                    highValue = high[i];
                    lowValue = low[i];
 
                    if (i > 0 && medianData.Length > i)
                    {
                        prevMedian = medianData[i - 1];
                    }
 
                    splits[i] = true;
                }
 
                highValue = Math.Max(highValue, high[i]);
                lowValue = Math.Min(lowValue, low[i]);
 
                highData[i] = highValue;
                lowData[i] = lowValue;
 
                medianData[i] = (highValue + lowValue) / 2.0;
                prevMedianData[i] = prevMedian;
            }
 
            Series.Add(new IndicatorSeriesData(prevMedianData, PrevMedianSeries)
            {
                Style =
                {
                    DisableMinMax = true,
                    StraightLine = true
                },
 
            }, new IndicatorSeriesData(highData, HighLowSeries)
            {
                Style =
                {
                    DisableMinMax = true,
                    StraightLine = true
                }
            }, new IndicatorSeriesData(lowData, HighLowSeries)
            {
                Style =
                {
                    DisableMinMax = true,
                    StraightLine = true
                }
            }, new IndicatorSeriesData(medianData, MedianSeries)
            {
                Style =
                {
                    DisableMinMax = true,
                    StraightLine = true
                }
            });
 
            foreach (var series in Series)
            {
                series.UserData["S"] = splits;
                series.UserData["SE"] = true;
            }
        }
 
        public override void ApplyColors(IChartTheme theme)
        {
            HighLowSeries.Color = theme.GetNextColor();
            MedianSeries.Color = theme.GetNextColor();
            PrevMedianSeries.Color = theme.GetNextColor();
 
            base.ApplyColors(theme);
        }
 
        public override void CopyTemplate(IndicatorBase indicator, bool style)
        {
            var i = (HighLowIndicator)indicator;
 
            Period = i.Period;
 
            HighLowSeries.CopyTheme(i.HighLowSeries);
            MedianSeries.CopyTheme(i.MedianSeries);
            PrevMedianSeries.CopyTheme(i.PrevMedianSeries);
 
            base.CopyTemplate(indicator, style);
        }
 
        public override string ToString()
        {
            return $"{Name} ({Period})";
        }
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.tiger.com/razrabotka-dlya-tiger.trade-windows/primery-indikatorov/high-low.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
