AW Multi Data free

by khoshroomahdi in category Other at 15/07/2021
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.

 

 

 

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
´╗┐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 string 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; }


        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
            double StartingBalance = History.Where(x => x.ClosingTime.Date != Time.Date).OrderBy(x => x.ClosingTime).Last().Balance;


            //calc Daily Percent Profit

            string DailyPercent = Math.Round(DailyNet / StartingBalance * 100, 2).ToString();


            //text property
            tb.Text = Symbol.Name + ", " + TimeFrame.ShortName + "\n" + DailyPercent + " %" + "\n" + DailyNet + " $" + "\n" + sp;
            tb.FontSize = FontSize;
            tb.ForegroundColor = Color1.TrimEnd();
            tb.HorizontalAlignment = HAlignment;
            tb.VerticalAlignment = VAlignment;
            tb.TextAlignment = Alignment;
            tb.Margin = Margin;
            tb.Opacity = Opacity;



        }



    }


}

Comments
0