Information Pad free

by winsonet in category Trend at 19/01/2021
Description

New version release:

1.1  Can change the panel position by ctrl + mouse

You can display the trading and account information in this panel:

1. Set to display the period data (base on months) for total trades and success rate

2. Set to display the account information (e.g balance, equity, net profit..)

3. Set to display margin information (e.g leverage, used margin, free margin, margin level...)

4. Can hide and show the panel

 

Parameters:

1. Set the panel position with vertical and horizontal

2. Default to Show:  whether default to show or hide

3. Show Trading Info: whether to show the trading info panel

4. Show Account Info: whether to show the account info panel

5. Show Margin Info: whether to show the margin info panel

6. Data of Months: how many recent months of data do you want to show (e.g 3 for recent 3 months data, 0 will show all of the history data)

 

 

 

 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
////////////////////////////////////////////////////////////////////////////////////////////////////////
//Author  : Winson
//Website : https://www.coderblog.in
//Version : 1.1
//Description : Display the trading information in a panel
////////////////////////////////////////////////////////////////////////////////////////////////////////

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class InformationPad : Indicator
    {
        [Parameter("Vertical Position", Group = "Panel alignment", DefaultValue = VerticalAlignment.Top)]
        public VerticalAlignment PanelVerticalAlignment { get; set; }

        [Parameter("Horizontal Position", Group = "Panel alignment", DefaultValue = HorizontalAlignment.Left)]
        public HorizontalAlignment PanelHorizontalAlignment { get; set; }

        [Parameter("Default to Show", DefaultValue = false, Group = "Display Info")]
        public bool DefaultShow { get; set; }

        [Parameter("Data of Months(0 for all period)", DefaultValue = 1, Group = "Data Period")]
        public int Months { get; set; }

        [Parameter("Show Trading Info", DefaultValue = true, Group = "Display Info")]
        public bool ShowTradingInfo { get; set; }

        [Parameter("Show Account Info", DefaultValue = true, Group = "Display Info")]
        public bool ShowAccountInfo { get; set; }

        [Parameter("Show Margin Info", DefaultValue = true, Group = "Display Info")]
        public bool ShowMarginInfo { get; set; }

        [Parameter("Pree Ctrl+Mouse can change the panel position", DefaultValue = "", Group = "Tip")]
        public string Description { get; set; }

        Border contentBorder;
        ToggleButton hideBtn;

        #region Trading Info
        TextBlock lbSpreadValue;
        TextBlock lbTotalTradesValue;
        TextBlock lbWinTradeValue;
        TextBlock lbLossTradeValue;
        TextBlock lbSuccessRateValue;
        TextBlock lbLossRateValue;
        #endregion

        #region Account Info
        TextBlock lbBalanceValue;
        TextBlock lbEquityValue;
        TextBlock lbNetProfitValue;
        TextBlock lbUnrealizedNetProfitValue;
        TextBlock lbUnrealizedGrossProfitValue;
        #endregion

        #region Margin Info
        TextBlock lbFreeMarginValue;
        TextBlock lbUsedMarginValue;
        TextBlock lbMarginLevelValue;
        #endregion

        Border InformationPanel;
        ChartRectangle SelectRectangle;

        protected override void Initialize()
        {
            int fontSize = 12;
            int labelWidth = 85;

            Color titleColor = Color.FromHex("#F15923");

            StackPanel mainPanel = new StackPanel();
            #region Header
            var headerBorder = new Border 
            {
                BorderThickness = "0 0 0 1",
                Style = Styles.CreateCommonBorderStyle()
            };
            var headerGrid = new Grid(1, 2);
            headerGrid.Columns[1].SetWidthInPixels(60);

            var title = new TextBlock 
            {
                Text = "Info Pad (by Winson, coderblog.in)",
                Margin = "10 7",
                FontSize = 12,
                Style = Styles.CreateHeaderStyle()
            };
            headerGrid.AddChild(title, 0, 0);

            //Margin(double left, double top, double right, double bottom)
            hideBtn = new ToggleButton 
            {
                Text = "Hide",
                Width = 55,
                Height = 20,
                FontSize = 8,
                Margin = new Thickness(0, 5, 5, 5)
            };
            hideBtn.Click += HideBtn_Click;
            headerGrid.AddChild(hideBtn, 0, 1);

            headerBorder.Child = headerGrid;

            mainPanel.AddChild(headerBorder);
            #endregion

            #region Content
            contentBorder = new Border 
            {
                BorderThickness = "0 0 0 1",
                //Height = 250,
                Style = Styles.CreateCommonBorderStyle()
            };
            //var contentGrid = new Grid(1, 2);
            StackPanel contentPanel = new StackPanel();
            contentPanel.Orientation = Orientation.Vertical;

            #region Display Period
            var periodBoarder = new Border 
            {
                BorderThickness = "0 0 0 1",
                VerticalAlignment = VerticalAlignment.Stretch,
                Style = Styles.CreateCommonBorderStyle()
            };
            //var contentGrid = new Grid(1, 2);
            StackPanel periodPanel = new StackPanel();
            periodPanel.Orientation = Orientation.Vertical;

            #region Period Title Row
            StackPanel periodTitleRow = new StackPanel();
            periodTitleRow.Margin = new Thickness(10, 5, 5, 5);
            periodTitleRow.Orientation = Orientation.Horizontal;
            var lbPeriodTitle = new TextBlock 
            {
                Text = "⌦ Data Source Period (ver 1.1)",
                FontSize = (fontSize + 1),
                ForegroundColor = titleColor,
                Style = Styles.CreateHeaderStyle()
            };
            //Chart.DrawIcon("test", ChartIconType.Circle)
            periodTitleRow.AddChild(lbPeriodTitle);
            periodPanel.AddChild(periodTitleRow);
            #endregion

            #region Period Row

            #region Calculate Period by setting months
            DateTime period = Months > 0 ? DateTime.Now.AddMonths(-Months) : DateTime.Now;
            #endregion

            StackPanel periodRow = new StackPanel();
            periodRow.Margin = new Thickness(10, 5, 5, 5);
            periodRow.Orientation = Orientation.Horizontal;
            var lbPeriod = new TextBlock 
            {
                Text = "From " + period.ToString("yyyy-MM-dd") + " to now",
                //Width = labelWidth,
                FontSize = fontSize,
                FontWeight = FontWeight.Bold,
                Style = Styles.CreateHeaderStyle()
            };
            periodRow.AddChild(lbPeriod);

            periodPanel.AddChild(periodRow);
            #endregion

            periodBoarder.Child = periodPanel;
            contentPanel.AddChild(periodBoarder);
            #endregion

            if (ShowTradingInfo)
            {
                #region Trading Info
                var tradingInfoBoarder = new Border 
                {
                    BorderThickness = "0 0 0 1",
                    VerticalAlignment = VerticalAlignment.Stretch,
                    Style = Styles.CreateCommonBorderStyle()
                };
                //var contentGrid = new Grid(1, 2);
                StackPanel tradingInfoPanel = new StackPanel();
                tradingInfoPanel.Orientation = Orientation.Vertical;

                #region Trading Info Title Row
                StackPanel tradingInfoTitleRow = new StackPanel();
                tradingInfoTitleRow.Margin = new Thickness(10, 5, 5, 5);
                tradingInfoTitleRow.Orientation = Orientation.Horizontal;
                var lbTradingInfoTitle = new TextBlock 
                {
                    Text = "⌦ Trading Info",
                    FontSize = (fontSize + 1),
                    ForegroundColor = titleColor,
                    Style = Styles.CreateHeaderStyle()
                };
                tradingInfoTitleRow.AddChild(lbTradingInfoTitle);

                tradingInfoPanel.AddChild(tradingInfoTitleRow);
                #endregion

                #region Spread Row
                StackPanel spreadRow = new StackPanel();
                spreadRow.Margin = new Thickness(10, 5, 5, 5);
                spreadRow.Orientation = Orientation.Horizontal;
                var lbSpread = new TextBlock 
                {
                    Text = "Spread:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                spreadRow.AddChild(lbSpread);

                lbSpreadValue = new TextBlock 
                {
                    Text = "0",
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                spreadRow.AddChild(lbSpreadValue);
                tradingInfoPanel.AddChild(spreadRow);
                #endregion

                #region Total Trades Row
                StackPanel totalTradesRow = new StackPanel();
                totalTradesRow.Margin = new Thickness(10, 0, 5, 5);
                totalTradesRow.Orientation = Orientation.Horizontal;
                var lbTotalTrades = new TextBlock 
                {
                    Text = "Total Trades:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                totalTradesRow.AddChild(lbTotalTrades);

                lbTotalTradesValue = new TextBlock 
                {
                    Text = "0",
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                totalTradesRow.AddChild(lbTotalTradesValue);
                tradingInfoPanel.AddChild(totalTradesRow);
                #endregion

                #region Trades Win/Loss Row
                StackPanel tradeStatusRow = new StackPanel();
                tradeStatusRow.Margin = new Thickness(10, 0, 5, 5);
                tradeStatusRow.Orientation = Orientation.Horizontal;
                #region Win Trades
                var lbWinTrade = new TextBlock 
                {
                    Text = "Win:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                tradeStatusRow.AddChild(lbWinTrade);

                lbWinTradeValue = new TextBlock 
                {
                    Text = "0",
                    FontSize = fontSize,
                    Width = 50,
                    Style = Styles.CreateHeaderStyle()
                };
                tradeStatusRow.AddChild(lbWinTradeValue);
                #endregion

                #region Loss Trades
                var lbLossTrade = new TextBlock 
                {
                    Text = "Loss:",
                    Width = 70,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Margin = new Thickness(10, 0, 0, 0),
                    Style = Styles.CreateHeaderStyle()
                };
                tradeStatusRow.AddChild(lbLossTrade);

                lbLossTradeValue = new TextBlock 
                {
                    Text = "0",
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                tradeStatusRow.AddChild(lbLossTradeValue);
                #endregion


                tradingInfoPanel.AddChild(tradeStatusRow);
                #endregion

                #region Success/Loss Rate Row
                StackPanel rateRow = new StackPanel();
                rateRow.Margin = new Thickness(10, 0, 5, 5);
                rateRow.Orientation = Orientation.Horizontal;

                #region Success Rate
                var lbSuccessRate = new TextBlock 
                {
                    Text = "Success Rate:",
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Width = labelWidth,
                    Style = Styles.CreateHeaderStyle()
                };
                rateRow.AddChild(lbSuccessRate);

                lbSuccessRateValue = new TextBlock 
                {
                    Text = "50.55 %",
                    Width = 50,
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                rateRow.AddChild(lbSuccessRateValue);
                #endregion

                #region Loss Rate
                var lbLossRate = new TextBlock 
                {
                    Text = "Loss Rate:",
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Width = 70,
                    Margin = new Thickness(10, 0, 0, 0),
                    Style = Styles.CreateHeaderStyle()
                };
                rateRow.AddChild(lbLossRate);

                lbLossRateValue = new TextBlock 
                {
                    Text = "30.58 %",
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                rateRow.AddChild(lbLossRateValue);
                #endregion

                tradingInfoPanel.AddChild(rateRow);
                #endregion

                tradingInfoBoarder.Child = tradingInfoPanel;
                contentPanel.AddChild(tradingInfoBoarder);
                #endregion
            }

            if (ShowAccountInfo)
            {
                #region Account Info
                var accountInfoBoarder = new Border 
                {
                    BorderThickness = "0 0 0 1",
                    //Height = 100,
                    VerticalAlignment = VerticalAlignment.Stretch,
                    Style = Styles.CreateCommonBorderStyle()
                };
                StackPanel accountInfoPanel = new StackPanel();
                accountInfoPanel.Orientation = Orientation.Vertical;

                #region Account Info Title Row
                StackPanel accountInfoTitleRow = new StackPanel();
                accountInfoTitleRow.Margin = new Thickness(10, 5, 5, 5);
                accountInfoTitleRow.Orientation = Orientation.Horizontal;
                var lbAccountInfoTitle = new TextBlock 
                {
                    Text = "⌦ Account Info",
                    FontSize = (fontSize + 1),
                    ForegroundColor = titleColor,
                    Style = Styles.CreateHeaderStyle()
                };
                accountInfoTitleRow.AddChild(lbAccountInfoTitle);

                accountInfoPanel.AddChild(accountInfoTitleRow);
                #endregion

                #region Balance Row
                StackPanel balanceRow = new StackPanel();
                balanceRow.Margin = new Thickness(10, 5, 5, 5);
                balanceRow.Orientation = Orientation.Horizontal;
                var lbBalance = new TextBlock 
                {
                    Text = "Balance:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                balanceRow.AddChild(lbBalance);

                lbBalanceValue = new TextBlock 
                {
                    Text = Account.Balance.ToString() + " " + Account.Currency,
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                balanceRow.AddChild(lbBalanceValue);
                accountInfoPanel.AddChild(balanceRow);
                #endregion

                #region Equity Row
                StackPanel equityRow = new StackPanel();
                equityRow.Margin = new Thickness(10, 0, 5, 5);
                equityRow.Orientation = Orientation.Horizontal;
                var lbEquity = new TextBlock 
                {
                    Text = "Equity:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                equityRow.AddChild(lbEquity);

                lbEquityValue = new TextBlock 
                {
                    Text = Account.Equity.ToString() + " " + Account.Currency,
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                equityRow.AddChild(lbEquityValue);
                accountInfoPanel.AddChild(equityRow);
                #endregion

                #region Net Profit Row
                StackPanel netProfitRow = new StackPanel();
                netProfitRow.Margin = new Thickness(10, 0, 5, 5);
                netProfitRow.Orientation = Orientation.Horizontal;
                var lbNetProfit = new TextBlock 
                {
                    Text = "Net Profit:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                netProfitRow.AddChild(lbNetProfit);

                lbNetProfitValue = new TextBlock 
                {
                    Text = "0 " + Account.Currency,
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                netProfitRow.AddChild(lbNetProfitValue);
                accountInfoPanel.AddChild(netProfitRow);
                #endregion

                #region Unrealized NetProfit Row
                StackPanel unrealizedNetProfitRow = new StackPanel();
                unrealizedNetProfitRow.Margin = new Thickness(10, 0, 5, 5);
                unrealizedNetProfitRow.Orientation = Orientation.Horizontal;
                var lbunrealizedNetProfit = new TextBlock 
                {
                    Text = "Unrealized Net Profit:",
                    Width = 140,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                unrealizedNetProfitRow.AddChild(lbunrealizedNetProfit);

                lbUnrealizedNetProfitValue = new TextBlock 
                {
                    Text = Account.UnrealizedNetProfit.ToString() + " " + Account.Currency,
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                unrealizedNetProfitRow.AddChild(lbUnrealizedNetProfitValue);
                accountInfoPanel.AddChild(unrealizedNetProfitRow);
                #endregion

                #region Unrealized Gross Profit Row
                StackPanel unrealizedGrossProfitRow = new StackPanel();
                unrealizedGrossProfitRow.Margin = new Thickness(10, 0, 5, 5);
                unrealizedGrossProfitRow.Orientation = Orientation.Horizontal;
                var lbUnrealizedGrossProfit = new TextBlock 
                {
                    Text = "Unrealized Gross Profit:",
                    Width = 140,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                unrealizedGrossProfitRow.AddChild(lbUnrealizedGrossProfit);

                lbUnrealizedGrossProfitValue = new TextBlock 
                {
                    Text = Account.UnrealizedGrossProfit.ToString() + " " + Account.Currency,
                    FontSize = fontSize,
                    Style = Styles.CreateHeaderStyle()
                };
                unrealizedGrossProfitRow.AddChild(lbUnrealizedGrossProfitValue);
                accountInfoPanel.AddChild(unrealizedGrossProfitRow);
                #endregion


                accountInfoBoarder.Child = accountInfoPanel;
                contentPanel.AddChild(accountInfoBoarder);
                #endregion
            }

            if (ShowMarginInfo)
            {
                #region Margin Info
                var marginInfoBoarder = new Border 
                {
                    BorderThickness = "0 0 0 1",
                    //Height = 100,
                    VerticalAlignment = VerticalAlignment.Stretch,
                    Style = Styles.CreateCommonBorderStyle()
                };
                StackPanel marginInfoPanel = new StackPanel();
                marginInfoPanel.Orientation = Orientation.Vertical;

                #region Margin Info Title Row
                StackPanel marginInfoTitleRow = new StackPanel();
                marginInfoTitleRow.Margin = new Thickness(10, 5, 5, 5);
                marginInfoTitleRow.Orientation = Orientation.Horizontal;
                var lbMarginInfoTitle = new TextBlock 
                {
                    Text = "⌦ Margin Info",
                    FontSize = (fontSize + 1),
                    ForegroundColor = titleColor,
                    Style = Styles.CreateHeaderStyle()
                };
                marginInfoTitleRow.AddChild(lbMarginInfoTitle);
                marginInfoPanel.AddChild(marginInfoTitleRow);
                #endregion


                #region Leverage
                StackPanel leverageRow = new StackPanel();
                leverageRow.Margin = new Thickness(10, 5, 5, 5);
                leverageRow.Orientation = Orientation.Horizontal;

                var lbMargin = new TextBlock 
                {
                    Text = "Leverage:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                leverageRow.AddChild(lbMargin);

                var lbMarginValue = new TextBlock 
                {
                    Text = Account.PreciseLeverage.ToString(),
                    FontSize = fontSize,
                    Width = 50,
                    TextWrapping = TextWrapping.WrapWithOverflow,
                    Style = Styles.CreateHeaderStyle()
                };
                leverageRow.AddChild(lbMarginValue);

                marginInfoPanel.AddChild(leverageRow);
                #endregion

                #region Margin Usage Row
                StackPanel marginUsageRow = new StackPanel();
                marginUsageRow.Margin = new Thickness(10, 0, 5, 5);
                marginUsageRow.Orientation = Orientation.Horizontal;

                #region Used Margin
                var lbUsedMargin = new TextBlock 
                {
                    Text = "Used Margin:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                marginUsageRow.AddChild(lbUsedMargin);

                lbUsedMarginValue = new TextBlock 
                {
                    Text = Account.Margin.ToString(),
                    FontSize = fontSize,
                    Width = 50,
                    TextWrapping = TextWrapping.WrapWithOverflow,
                    Style = Styles.CreateHeaderStyle()
                };
                marginUsageRow.AddChild(lbUsedMarginValue);
                #endregion

                #region Free Margin
                var lbFreeMargin = new TextBlock 
                {
                    Text = "Free Margin:",
                    Width = 80,
                    Margin = new Thickness(10, 0, 0, 0),
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                marginUsageRow.AddChild(lbFreeMargin);

                lbFreeMarginValue = new TextBlock 
                {
                    Text = Account.FreeMargin.ToString(),
                    FontSize = fontSize,
                    TextWrapping = TextWrapping.WrapWithOverflow,
                    Style = Styles.CreateHeaderStyle()
                };
                marginUsageRow.AddChild(lbFreeMarginValue);
                #endregion

                marginInfoPanel.AddChild(marginUsageRow);
                #endregion


                #region Margin Row
                StackPanel marginRow = new StackPanel();
                marginRow.Margin = new Thickness(10, 0, 5, 5);
                marginRow.Orientation = Orientation.Horizontal;

                #region Margin Stop Level
                var lbMarginStopLevel = new TextBlock 
                {
                    Text = "Stop Level:",
                    Width = labelWidth,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Style = Styles.CreateHeaderStyle()
                };
                marginRow.AddChild(lbMarginStopLevel);

                var lbMarginStopLevelValue = new TextBlock 
                {
                    Text = Account.StopOutLevel.ToString() + " %",
                    FontSize = fontSize,
                    Width = 50,
                    TextWrapping = TextWrapping.WrapWithOverflow,
                    Style = Styles.CreateHeaderStyle()
                };
                marginRow.AddChild(lbMarginStopLevelValue);
                #endregion

                #region Margin Level
                var lbMarginLevel = new TextBlock 
                {
                    Text = "Margin Level:",
                    Width = 80,
                    FontSize = fontSize,
                    FontWeight = FontWeight.Bold,
                    Margin = new Thickness(10, 0, 0, 0),
                    Style = Styles.CreateHeaderStyle()
                };
                marginRow.AddChild(lbMarginLevel);

                lbMarginLevelValue = new TextBlock 
                {
                    Text = Account.MarginLevel.HasValue ? Math.Round(Account.MarginLevel.Value, 2).ToString() + " %" : "0 %",
                    FontSize = fontSize,
                    TextWrapping = TextWrapping.WrapWithOverflow,
                    Style = Styles.CreateHeaderStyle()
                };
                marginRow.AddChild(lbMarginLevelValue);
                #endregion

                marginInfoPanel.AddChild(marginRow);
                #endregion


                marginInfoBoarder.Child = marginInfoPanel;
                contentPanel.AddChild(marginInfoBoarder);
                #endregion
            }


            contentBorder.Child = contentPanel;
            mainPanel.AddChild(contentBorder);
            #endregion


            InformationPanel = new Border 
            {
                VerticalAlignment = PanelVerticalAlignment,
                HorizontalAlignment = PanelHorizontalAlignment,
                Style = Styles.CreatePanelBackgroundStyle(),
                Margin = "20 40 20 20",
                Width = 300,
                Child = mainPanel
            };


            Chart.AddControl(InformationPanel);

            if (DefaultShow)
            {
                hideBtn.IsChecked = false;
                contentBorder.IsVisible = true;
                hideBtn.Text = "Hide";
            }
            else
            {
                hideBtn.IsChecked = true;
                contentBorder.IsVisible = false;
                hideBtn.Text = "Show";
            }

            Chart.MouseDown += Chart_MouseDown;
        }


        private void Chart_MouseDown(ChartMouseEventArgs obj)
        {
            if (obj.CtrlKey)
            {

                Chart.IsScrollingEnabled = false;
                var left = Chart.Width - obj.MouseX > 160 ? obj.MouseX : obj.MouseX - 160;
                var right = Chart.Height - obj.MouseY > 100 ? obj.MouseY : obj.MouseY - 100;
                InformationPanel.Margin = new Thickness(left, right, 0, 0);
            }
        }

        private ChartRectangle _createDragRectangle(DateTime time)
        {
            var rect = Chart.DrawRectangle("DragRectangle", time, Chart.TopY, time, Chart.BottomY, Color.Transparent);
            rect.IsFilled = true;
            return rect;
        }

        private void HideBtn_Click(ToggleButtonEventArgs obj)
        {
            if (obj.ToggleButton.IsChecked)
            {
                contentBorder.IsVisible = false;
                hideBtn.Text = "Show";
            }
            else
            {
                contentBorder.IsVisible = true;
                hideBtn.Text = "Hide";
            }
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...
            CalculateInfo();
        }

        private void CalculateInfo()
        {
            lbSpreadValue.Text = Math.Round(Symbol.Spread / Symbol.PipSize, 2).ToString();


            var totalTrades = 0;
            double successTrades = 0;
            double netProfit = 0;
            DateTime period = Months > 0 ? DateTime.Now.AddMonths(-Months) : DateTime.Now;

            foreach (var trade in History)
            {
                var isvalid = true;
                if (Months > 0)
                {
                    if (trade.ClosingTime < period)
                    {
                        isvalid = false;
                    }
                }

                if (isvalid)
                {
                    if (trade.NetProfit > 0)
                    {
                        successTrades++;
                    }
                    netProfit += trade.NetProfit;
                    totalTrades++;
                }
            }

            double successRate = Math.Round(successTrades / totalTrades * 100, 2);
            double lossTrades = totalTrades - successTrades;
            double lossRate = Math.Round(lossTrades / totalTrades * 100, 2);

            lbTotalTradesValue.Text = totalTrades.ToString();
            lbWinTradeValue.Text = successTrades.ToString();
            lbLossTradeValue.Text = lossTrades.ToString();
            lbSuccessRateValue.Text = successRate.ToString() + " %";
            lbLossRateValue.Text = lossRate.ToString() + " %";

            lbBalanceValue.Text = Account.Balance.ToString() + " " + Account.Currency;
            lbEquityValue.Text = Account.Equity.ToString() + " " + Account.Currency;
            lbNetProfitValue.Text = netProfit.ToString() + " " + Account.Currency;
            lbUnrealizedNetProfitValue.Text = Math.Round(Account.UnrealizedNetProfit, 2).ToString() + " " + Account.Currency;
            lbUnrealizedGrossProfitValue.Text = Math.Round(Account.UnrealizedGrossProfit, 2).ToString() + " " + Account.Currency;

            lbFreeMarginValue.Text = Account.FreeMargin.ToString();
            lbUsedMarginValue.Text = Account.Margin.ToString();
            lbMarginLevelValue.Text = Account.MarginLevel.HasValue ? Math.Round(Account.MarginLevel.Value, 2).ToString() + " %" : "0 %";
        }
    }

    public static class Styles
    {
        public static Style CreatePanelBackgroundStyle()
        {
            var style = new Style();
            style.Set(ControlProperty.CornerRadius, 3);
            style.Set(ControlProperty.BackgroundColor, GetColorWithOpacity(Color.FromHex("#292929"), 0.85m), ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, GetColorWithOpacity(Color.FromHex("#FFFFFF"), 0.85m), ControlState.LightTheme);
            style.Set(ControlProperty.BorderColor, Color.FromHex("#3C3C3C"), ControlState.DarkTheme);
            style.Set(ControlProperty.BorderColor, Color.FromHex("#C3C3C3"), ControlState.LightTheme);
            style.Set(ControlProperty.BorderThickness, new Thickness(1));

            return style;
        }

        public static Style CreateCommonBorderStyle()
        {
            var style = new Style();
            style.Set(ControlProperty.BorderColor, GetColorWithOpacity(Color.FromHex("#FFFFFF"), 0.12m), ControlState.DarkTheme);
            style.Set(ControlProperty.BorderColor, GetColorWithOpacity(Color.FromHex("#000000"), 0.12m), ControlState.LightTheme);
            return style;
        }

        public static Style CreateHeaderStyle()
        {
            var style = new Style();
            style.Set(ControlProperty.ForegroundColor, GetColorWithOpacity("#FFFFFF", 0.70m), ControlState.DarkTheme);
            style.Set(ControlProperty.ForegroundColor, GetColorWithOpacity("#000000", 0.65m), ControlState.LightTheme);
            return style;
        }

        public static Style CreateInputStyle()
        {
            var style = new Style(DefaultStyles.TextBoxStyle);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#1A1A1A"), ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#111111"), ControlState.DarkTheme | ControlState.Hover);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#E7EBED"), ControlState.LightTheme);
            style.Set(ControlProperty.BackgroundColor, Color.FromHex("#D6DADC"), ControlState.LightTheme | ControlState.Hover);
            style.Set(ControlProperty.CornerRadius, 3);
            return style;
        }

        public static Style CreateBuyButtonStyle()
        {
            return CreateButtonStyle(Color.FromHex("#009345"), Color.FromHex("#10A651"));
        }

        public static Style CreateSellButtonStyle()
        {
            return CreateButtonStyle(Color.FromHex("#F05824"), Color.FromHex("#FF6C36"));
        }

        public static Style CreateCloseButtonStyle()
        {
            return CreateButtonStyle(Color.FromHex("#F05824"), Color.FromHex("#FF6C36"));
        }

        public static Style CreateButtonStyle(Color color, Color hoverColor)
        {
            var style = new Style(DefaultStyles.ButtonStyle);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.LightTheme);
            style.Set(ControlProperty.BackgroundColor, hoverColor, ControlState.DarkTheme | ControlState.Hover);
            style.Set(ControlProperty.BackgroundColor, hoverColor, ControlState.LightTheme | ControlState.Hover);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.DarkTheme);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.LightTheme);
            return style;
        }


        public static Style CreateToggleButtonStyle(Color color, Color checkedColor)
        {
            var style = new Style(DefaultStyles.ToggleButtonStyle);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.DarkTheme);
            style.Set(ControlProperty.BackgroundColor, color, ControlState.LightTheme);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.DarkTheme | ControlState.Checked);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.LightTheme | ControlState.Checked);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.DarkTheme | ControlState.Hover);
            style.Set(ControlProperty.BackgroundColor, checkedColor, ControlState.LightTheme | ControlState.Hover);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.DarkTheme);
            style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.LightTheme);
            return style;
        }

        private static Color GetColorWithOpacity(Color baseColor, decimal opacity)
        {
            var alpha = (int)Math.Round(byte.MaxValue * opacity, MidpointRounding.AwayFromZero);
            return Color.FromArgb(alpha, baseColor);
        }
    }
}
Comments

ClickAlgo - January 19, 2021 @ 20:41

Good work Winson.

winsonet - January 20, 2021 @ 02:31

Thank you!, ClickAlgo :)

5