Tiger.com Windows Wiki
English
English
  • 👋Welcome!
  • ⭐How to start?
    • Recommended system requirements
    • Register and setup
    • Licenses and login
  • ⚙️Settings
    • Workspace
    • Trading modes
    • Connections
      • Crypto exchanges
        • TigerX
        • Binance via Tiger.com Broker
        • Bybit via Tiger.com Broker
        • Binance
        • Bitfinex
        • BitMEX
        • Bybit
        • OKX
        • Gate.io
        • MEXC
      • Trading terminals
        • DataFeed
        • MetaTrader 5
        • OEC Trader (GAIN Capital)
        • Rithmic
        • QUIK
        • SmartCOM
        • Trader WorkStation (Interactive Brokers)
        • Transaq Connector
    • Basic setup
      • Selecting a symbol
      • Selecting a timeframe
      • Linking windows
      • Setting up exit strategies
      • Setting offsets
    • Terminal
      • Order volumes preset
      • Configuration
        • How to create public configuration
      • General settings
      • Email notifications
      • Telegram alerts
      • Hotkeys Manager
      • Sound alerts
      • Symbols manager
  • 🖥️Windows
    • Chart
      • Chart trading
      • Toolbar setup
      • Chart theme
      • Chart settings
      • Scaling and moving the chart
      • Cluster chart
      • Cluster presets
      • Graphical objects in Chart window
        • Text
        • Ruler
        • Volume profile
        • Trend angle
        • Elliott Correction Wave
        • Elliott Impulse Wave
        • Fibonacci Fan
        • Fibonacci Extensions
        • Fibonacci Retracement
        • Fibonacci Time Zones
        • Linear Regression
      • Main indicators in Chart window
        • Bar Search
        • Bar Timer
        • Bid Ask
        • Big Trades
        • BW MFI
        • Cluster Search
        • Cluster Statistic
        • Cumulative Delta
        • Delta
        • Depth Of Market
        • Dynamic Levels
        • Elders Force Index
        • External Chart
        • Gradient
        • Heatmap
        • High Low
        • Histogram
        • Ichimoku
        • Margin Zones
        • Maximum Levels
        • Open Interest
        • Price
        • Session Color
        • Trades Flow
        • Volume
        • Volume Profile
        • VWAP
        • Weis Wave Volume
        • ZigZag
    • DOM
      • Selecting a trading account
      • Ruler
      • Multiplier
      • DOM settings
        • Main
        • Cluster
        • Trading
      • Stop Loss
      • Take Profit
      • Trigger orders
    • Watchlist
      • How to filter watchlist
    • SmartTape
    • Statistics
    • Volume search
    • All prices
    • Options board
  • 📋Tables
    • Orders
    • Executions
    • Positions
    • XPositions
    • Accounts
    • Limits
    • Player
    • Signals
    • Log
  • 🔍Video Tutorials
    • Terminal Basics
    • Charts and technical analysis
    • Charts, Trade Tape and Player
    • Trading in Tiger.com Windows
  • 💡Platform Updates
    • Version 7.0 Beta
    • Version 6.9
    • Version 6.8
    • Version 6.7
    • Version 6.6
    • Version 6.5
    • Version 6.4
    • Version 6.3
    • Version 6.2
    • Version 6.1
    • Version 6.0.2
    • Version 6.0.1
    • Version 6.0.0
    • Version 5.0.7
    • Version 4.5.15
  • ⌨️Development for Tiger.com Windows
    • Indicator examples
      • DepthOfMarket
      • Trades Flow
      • Volume Profiles
      • Cluster Search
      • Bar Search
      • VWAP
      • Bar Timer
      • Volume
      • Trades
      • Session color
      • Open Interest
      • Dynamic Levels
      • Delta
      • Cumulative Delta
      • Cluster Statistic
      • Bid Ask
      • External Chart
      • High Low
      • Histogram
    • Source examples
      • Moving Average
      • Stock
    • Examples of graphical objects
      • Fibonacci Extensions
      • Fibonacci Retracement
      • Vertical Line
      • Horizontal Line
      • Volume Profile
      • Rectangle
  • ❓Frequently Asked Questions
    • Questions about licenses
    • Questions about indicators
    • Questions about connections
    • Questions about trading
    • Error "Connection lost" when launching the terminal
    • Why do I need to set commission in the terminal?
    • How does automatic account selection work?
    • How do I optimize the terminal to improve performance?
    • How to use the Crypto license to trade on Binance
    • Which order types are available in Tiger.com?
    • How to set up chart auto-refresh for QUIK connection?
    • How do I enable Take Profit orders on Binance?
    • How does autoselection of data type work?
    • Troubles installing the terminal
    • What are the system requirements for the terminal?
    • How to provide Tiger.com Windows app logs for investigation?
    • Fixing Network Issues: How to Adjust DNS Settings
  • 📬Technical support
  • 💭Suggest an improvement
Powered by GitBook
On this page
  1. Development for Tiger.com Windows
  2. Indicator examples

High Low

//------------------------------------------------------------------------------
//
// Indicator 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})";
        }
    }
}
PreviousExternal ChartNextHistogram

Last updated 2 years ago

⌨️