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

Bid Ask

//------------------------------------------------------------------------------
//
// Indicator BidAsk. Copyright (c) 2023 Tiger Trade Capital AG. All rights reserved.
//
//------------------------------------------------------------------------------
 
using System;
using System.Collections.Generic;
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 = "BidAskIndicator", Namespace = "http://schemas.datacontract.org/2004/07/TigerTrade.Chart.Indicators.Custom")]
    [Indicator("X_BidAsk", "*BidAsk", false, Type = typeof(BidAskIndicator))]
    internal sealed class BidAskIndicator : IndicatorBase
    {
        private XBrush _bidBrush;
 
        private XPen _bidPen;
 
        private XColor _bidColor;
 
        [DataMember(Name = "BidColor")]
        [Category("Стиль"), DisplayName("Цвет Bid")]
        public XColor BidColor
        {
            get => _bidColor;
            set
            {
                if (value == _bidColor)
                {
                    return;
                }
 
                _bidColor = value;
 
                _bidBrush = new XBrush(_bidColor);
                _bidPen = new XPen(_bidBrush, 1);
             
                OnPropertyChanged();
            }
        }
 
        private XBrush _askBrush;
 
        private XPen _askPen;
 
        private XColor _askColor;
 
        [DataMember(Name = "AskColor")]
        [Category("Стиль"), DisplayName("Цвет Ask")]
        public XColor AskColor
        {
            get => _askColor;
            set
            {
                if (value == _askColor)
                {
                    return;
                }
 
                _askColor = value;
 
                _askBrush = new XBrush(_askColor);
                _askPen = new XPen(_askBrush, 1);
             
                OnPropertyChanged();
            }
        }
 
        [Browsable(false)]
        public override IndicatorCalculation Calculation => IndicatorCalculation.OnEachTick;
 
        public override bool IntegerValues => true;
 
        public BidAskIndicator()
        {
            BidColor = Color.FromArgb(255, 178, 34, 34);
            AskColor = Color.FromArgb(255, 30, 144, 255);
        }
 
        protected override void Execute()
        {
        }
 
        public override void Render(DxVisualQueue visual)
        {
            var zeroPoint = GetY(0.0);
 
            var width = Math.Max(Canvas.ColumnWidth - 1, 1);
 
            for (var i = 0; i < Canvas.Count; i++)
            {
                var index = Canvas.GetIndex(i);
 
                var cluster = DataProvider.GetCluster(index);
 
                if (cluster == null)
                {
                    continue;
                }
 
                // Bid
 
                var x = Canvas.GetX(index);
                var y = GetY(-cluster.Bid);
                var h = (int)zeroPoint - (int)y;
 
                if (h < 0.0)
                {
                    y += h;
                    h = -h;
                }
 
                if (h < 1)
                {
                    y = (int)zeroPoint;
                    h = 1;
                }
 
                h = Math.Max(1, h);
 
                if (width > 1.0)
                {
                    visual.FillRectangle(_bidBrush, new Rect(x - width / 2.0, y, width, h));
                }
                else
                {
                    visual.DrawLine(_bidPen, x, y, x, y + h);
                }
 
                // Ask
 
                y = GetY(cluster.Ask);
                h = (int)zeroPoint - (int)y;
 
                if (h < 0.0)
                {
                    y += h;
                    h = -h;
                }
 
                if (h < 1)
                {
                    y = (int)zeroPoint - 1;
                    h = 1;
                }
 
                h = Math.Max(1, h);
 
                if (width > 1.0)
                {
                    visual.FillRectangle(_askBrush, new Rect(x - width / 2.0, y, width, h));
                }
                else
                {
                    visual.DrawLine(_askPen, x, y, x, y + h);
                }
            }
        }
 
        public override bool GetMinMax(out double min, out double max)
        {
            var bid = 0.0;
            var ask = 0.0;
 
            for (var i = 0; i < Canvas.Count; i++)
            {
                var index = Canvas.GetIndex(i);
 
                var cluster = DataProvider.GetCluster(index);
 
                if (cluster == null)
                {
                    continue;
                }
 
                bid = Math.Max(bid, (double)cluster.Bid);
                ask = Math.Max(ask, (double)cluster.Ask);
            }
 
            max = ask;
            min = -bid;
 
            return true;
        }
 
        public override List<IndicatorValueInfo> GetValues(int cursorPos)
        {
            var info = new List<IndicatorValueInfo>();
 
            var cluster = DataProvider.GetCluster(cursorPos);
 
            if (cluster == null)
            {
                return info;
            }
 
            info.Clear();
 
            var sBid = Canvas.FormatValue((double)cluster.Bid);
 
            info.Add(new IndicatorValueInfo(sBid, BidColor));
 
            var sAsk = Canvas.FormatValue((double)cluster.Ask);
 
            info.Add(new IndicatorValueInfo(sAsk, AskColor));
 
            return info;
        }
 
        public override void GetLabels(ref List<IndicatorLabelInfo> labels)
        {
            if (DataProvider.Count <= Canvas.Start)
            {
                return;
            }
 
            var cluster = DataProvider.GetCluster(DataProvider.Count - 1 - Canvas.Start);
 
            if (cluster == null)
            {
                return;
            }
 
            labels.Add(new IndicatorLabelInfo((double)cluster.Bid, BidColor));
            labels.Add(new IndicatorLabelInfo((double)cluster.Ask, AskColor));
        }
 
        public override bool CheckAlert(double value, int distance, ref int lastIndex, ref double lastValue)
        {
            if (DataProvider.Count == lastIndex && value == lastValue)
            {
                return false;
            }
 
            var cluster = DataProvider.GetCluster(DataProvider.Count - 1);
 
            if (cluster == null)
            {
                return false;
            }
 
            var result = false;
 
            if (value > 0 && (double)cluster.Ask >= value - distance)
            {
                result = true;
            }
            else if (value < 0 && (double)cluster.Bid <= value + distance)
            {
                result = true;
            }
 
            if (result == false)
            {
                return false;
            }
 
            lastIndex = DataProvider.Count;
            lastValue = value;
 
            return true;
        }
 
        public override void ApplyColors(IChartTheme theme)
        {
            BidColor = theme.PaletteColor7;
            AskColor = theme.PaletteColor6;
 
            base.ApplyColors(theme);
        }
 
        public override void CopyTemplate(IndicatorBase indicator, bool style)
        {
            var i = (BidAskIndicator)indicator;
 
            BidColor = i.BidColor;
            AskColor = i.AskColor;
 
            base.CopyTemplate(indicator, style);
        }
    }
}
PreviousCluster StatisticNextExternal Chart

Last updated 2 years ago

⌨️