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

Session color

/------------------------------------------------------------------------------
//
// Indicator SessionColor. Copyright (c) 2023 Tiger Trade Capital AG. All rights reserved.
//
//------------------------------------------------------------------------------
 
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Windows;
using System.Windows.Media;
using TigerTrade.Chart.Base;
using TigerTrade.Chart.Indicators.Common;
using TigerTrade.Chart.Indicators.Enums;
using TigerTrade.Dx;
 
namespace TigerTrade.Chart.Indicators.Custom
{
    [DataContract(Name = "SessionColorIndicator", Namespace = "http://schemas.datacontract.org/2004/07/TigerTrade.Chart.Indicators.Custom")]
    [Indicator("X_SessionColor", "*SessionColor", true, Type = typeof(SessionColorIndicator))]
    internal sealed class SessionColorIndicator : IndicatorBase
    {
        private TimeSpan _startTime;
 
        [DataMember(Name = "StartTime")]
        [Category("Параметры"), DisplayName("Начальное время")]
        public TimeSpan StartTime
        {
            get => _startTime;
            set
            {
                if (value == _startTime)
                {
                    return;
                }
 
                _startTime = value;
 
                OnPropertyChanged();
            }
        }
 
        private TimeSpan _endTime;
 
        [DataMember(Name = "EndTime")]
        [Category("Параметры"), DisplayName("Конечное время")]
        public TimeSpan EndTime
        {
            get => _endTime;
            set
            {
                if (value == _endTime)
                {
                    return;
                }
 
                _endTime = value;
 
                OnPropertyChanged();
            }
        }
 
        private XBrush _backBrush;
 
        private XColor _backColor;
 
        [DataMember(Name = "BackColor")]
        [Category("Стиль"), DisplayName("Цвет фона")]
        public XColor BackColor
        {
            get => _backColor;
            set
            {
                if (value == _backColor)
                {
                    return;
                }
 
                _backColor = value;
 
                _backBrush = new XBrush(_backColor);
 
                OnPropertyChanged();
            }
        }
 
        [Browsable(false)]
        public override bool ShowIndicatorValues => false;
 
        [Browsable(false)]
        public override bool ShowIndicatorLabels => false;
 
        [Browsable(false)]
        public override IndicatorCalculation Calculation => IndicatorCalculation.OnEachTick;
 
        public SessionColorIndicator()
        {
            ShowIndicatorTitle = false;
 
            StartTime = TimeSpan.FromHours(0);
            EndTime = TimeSpan.FromHours(12);
 
            BackColor = Color.FromArgb(127, 30, 144, 255);
        }
 
        protected override void Execute()
        {
        }
 
        public override void Render(DxVisualQueue visual)
        {
            var st = DateTime.MinValue;
            var et = DateTime.MinValue;
            var sp = new Point();
            var ep = new Point();
 
            for (var i = Canvas.Count - 1; i >= -Canvas.AfterBars; i--)
            {
                var index = Canvas.GetIndex(i);
 
                var d = Canvas.ConvertTimeToLocal(Canvas.IndexToDate(index));
 
                if (StartTime < EndTime)
                {
                    var newStartDate = d.Date.Add(StartTime);
                    var newEndDate = d.Date.Add(EndTime);
 
                    if (st == DateTime.MinValue && d >= newStartDate && d < newEndDate)
                    {
                        sp = new Point(Canvas.GetXX(i) - Canvas.ColumnWidth / 2.0, 0);
                        st = d;
 
                        et = DateTime.MinValue;
                        ep = new Point();
                    }
 
                    if (st != DateTime.MinValue && st.Date < d.Date)
                    {
                        ep = new Point(Canvas.GetXX(i + 1) + Canvas.ColumnWidth / 2.0, Canvas.Rect.Bottom);
                        et = d;
                    }
                    else
                    {
                        if (d >= newEndDate)
                        {
                            ep = new Point(Canvas.GetXX(i + 1) + Canvas.ColumnWidth / 2.0, Canvas.Rect.Bottom);
                            et = d;
                        }
                    }
                }
                else
                {
                    var newStartDate = d.Date.Add(StartTime);
                    var newEndDate = d.Date.Add(EndTime);
 
                    if (st == DateTime.MinValue && (d >= newStartDate || d < newEndDate))
                    {
                        sp = new Point(Canvas.GetXX(i) - Canvas.ColumnWidth / 2.0, 0);
                        st = d;
 
                        et = DateTime.MinValue;
                        ep = new Point();
                    }
 
                    if (d >= newEndDate && d < newStartDate)
                    {
                        ep = new Point(Canvas.GetXX(i + 1) + Canvas.ColumnWidth / 2.0, Canvas.Rect.Bottom);
                        et = d;
                    }
                }
 
                if (st == DateTime.MinValue || et == DateTime.MinValue)
                {
                    continue;
                }
 
                visual.FillRectangle(_backBrush, new Rect(sp, ep));
 
                st = DateTime.MinValue;
                et = DateTime.MinValue;
                sp = new Point();
                ep = new Point();
            }
 
            if (st != DateTime.MinValue)
            {
                visual.FillRectangle(_backBrush,
                    new Rect(sp, new Point(Canvas.Rect.Right, Canvas.Rect.Bottom)));
            }
        }
 
        public override void ApplyColors(IChartTheme theme)
        {
            BackColor = theme.GetNextColor();
 
            base.ApplyColors(theme);
        }
 
        public override void CopyTemplate(IndicatorBase indicator, bool style)
        {
            var i = (SessionColorIndicator)indicator;
 
            BackColor = i.BackColor;
            StartTime = i.StartTime;
            EndTime = i.EndTime;
 
            base.CopyTemplate(indicator, style);
        }
    }
}
PreviousTradesNextOpen Interest

Last updated 2 years ago

⌨️