Profit Pips Today free

by yomm0401 in category Other at 27/07/2020
Description
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 System.Text;


namespace cAlgo
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None, TimeZone = TimeZones.NorthAsiaStandardTime)]
    public class ProfitPipsToday : Indicator
    {
        [Parameter("Profit", DefaultValue = true)]
        public bool _profit { get; set; }

        [Parameter("pips", DefaultValue = true)]
        public bool _pips { get; set; }

        [Parameter("Currency Symbol", DefaultValue = "$")]
        public string Csymbol { get; set; }

        //you can find currency Symbol here ==> https://justforex.com/education/currencies

        [Parameter("Color", DefaultValue = "Black")]
        public string tColor { get; set; }

        //you can find color name here ==> https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.colors?view=netcore-3.1

        [Parameter("VerticalAlignment", DefaultValue = VerticalAlignment.Top)]
        public VerticalAlignment VerticalAlignment { get; set; }

        [Parameter("HorizontalAlignment", DefaultValue = HorizontalAlignment.Right)]
        public HorizontalAlignment HorizontalAlignment { get; set; }

        [Parameter("Visible", DefaultValue = true)]
        public bool _visible { get; set; }

        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {
            if (_visible)
            {
                var h = History.ToList();
                var p = Positions.ToList();

                double NPT = h.Where(t => t.ClosingTime.DayOfYear == Time.DayOfYear).Sum(t => t.NetProfit);
                double PIT = h.Where(t => t.ClosingTime.DayOfYear == Time.DayOfYear).Sum(t => t.Pips);



                StringBuilder sb = new StringBuilder();
                if (_profit)
                {
                    if (NPT != 0)
                    {
                        sb.AppendFormat(Csymbol + "{0:N}", NPT);
                        sb.AppendLine();
                    }
                }
                if (_pips)
                {
                    if (PIT != 0)
                    {
                        sb.AppendFormat("{0:N}pips", PIT);
                    }
                }
                Chart.DrawStaticText("Today", sb.ToString(), VerticalAlignment, HorizontalAlignment, tColor);
            }
        }

    }
}
Comments