Category Other  Published on 29/06/2023

AW Multi Data

Description

show symbol and time fram, daily net profit percent, daily net profit, and spread ln your chart.

consider that timezone set to utc to show daily proift correctly.

support us for more free indicator and bot by sign up in LiteFinance broker from this link

LiteFinance Signup

update 2022/09/10:

optional Data

update2023/02/22

Add Step Percent

 


using System;
using System.Linq;
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 AWMultiData : Indicator
    {



        TextBlock tb = new TextBlock();


        [Parameter("FontSize", DefaultValue = 12)]
        public int FontSize { get; set; }
        [Parameter("Space to Corner", DefaultValue = 10)]
        public int Margin { get; set; }
        [Parameter("Horizental Alignment", DefaultValue = HorizontalAlignment.Right)]
        public HorizontalAlignment HAlignment { get; set; }
        [Parameter("Vertical Alignment", DefaultValue = VerticalAlignment.Bottom)]
        public VerticalAlignment VAlignment { get; set; }
        [Parameter("Color", DefaultValue = "Red")]
        public Color Color1 { get; set; }
        [Parameter("Opacity", DefaultValue = 0.7, MinValue = 0.1, MaxValue = 1)]
        public double Opacity { get; set; }
        [Parameter("Text Alignment", DefaultValue = TextAlignment.Center)]
        public TextAlignment Alignment { get; set; }


        // optional 
        [Parameter("Symbol", DefaultValue = true, Group = "Optional")]
        public bool symbol { get; set; }
        [Parameter("Tiem Frame", DefaultValue = true, Group = "Optional")]
        public bool tFrame { get; set; }
        [Parameter("Daily Percent", DefaultValue = true, Group = "Optional")]
        public bool Dpercent { get; set; }
        [Parameter("Step Percent", DefaultValue = true, Group = "Optional")]
        public bool Spercent { get; set; }
        [Parameter("Profit", DefaultValue = true, Group = "Optional")]
        public bool profit { get; set; }
        [Parameter("Spread", DefaultValue = true, Group = "Optional")]
        public bool spreadShow { get; set; }



        protected override void Initialize()
        {

            Chart.AddControl(tb);

        }
        public override void Calculate(int index)
        {

            if (IsLastBar)
                DisplaySpreadOnChart();
        }

        public void DisplaySpreadOnChart()
        {
            // Calc Spread    
            var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2);
            string sp = string.Format("{0}", spread);



            //Calc daily Net Profit
            double DailyNet1 = Positions.Sum(p => p.NetProfit);
            double DailyNet2 = History.Where(x => x.ClosingTime.Date == Time.Date).Sum(x => x.NetProfit);
            double DailyNet = Math.Round(DailyNet1 + DailyNet2, 2);



            // get Starting Balance
            var oldTrades = History.Where(x => x.ClosingTime.Date != Time.Date).OrderBy(x => x.ClosingTime).ToArray();
            double StartingBalance;

            if (oldTrades.Length == 0)
            {
                StartingBalance = History.Count == 0 ? Account.Balance : History.OrderBy(x => x.ClosingTime).First().Balance;
            }
            else
            {
                StartingBalance = oldTrades.Last().Balance;
            }


            //calc Daily Percent Profit

            string DailyPercent = Math.Round(DailyNet / StartingBalance * 100, 2).ToString();
            string StepPercent = Math.Round((Account.Equity-Account.Balance)/Account.Balance*100 , 2).ToString();
            //text

            if (true)
            {
                if (symbol) tb.Text = Symbol.Name;
                if (tFrame) tb.Text += ", " + TimeFrame.ShortName;
                if (Dpercent) tb.Text += "\n" + DailyPercent + " %";
                if (Spercent) tb.Text += "\n" + StepPercent + " %";
                if (profit) tb.Text += "\n" + DailyNet + " $";
                if (spreadShow) tb.Text += "\n" + sp;
            }



            tb.FontSize = FontSize;
            tb.ForegroundColor = Color1;
            tb.HorizontalAlignment = HAlignment;
            tb.VerticalAlignment = VAlignment;
            tb.TextAlignment = Alignment;
            tb.Margin = Margin;
            tb.Opacity = Opacity;



        }



    }


}



IR
IRCtrader

Joined on 17.06.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: AW Multi Data.algo
  • Rating: 5
  • Installs: 1932
  • Modified: 22/02/2023 15:41
Comments
Log in to add a comment.
BI
bigvision · 5 months ago

Thx bro!!!

vahid.zahani's avatar
vahid.zahani · 3 years ago

very good