MyMiniFXBook v1.0

by Phu Nguyen in category Other at 31/01/2019
Description

MyMiniFxBook v1.0

- Spread;

- Total gain;

- Today gain;

- Balance;

- Equity;

- Profit;

- Maximum lot size (depends on your Risk percent and pips lost)

 

Download
119 downloads
How to install
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 cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.ChinaStandardTime, AccessRights = AccessRights.FullAccess)]
    public class MiniFXBook : Indicator
    {
        [Parameter("Stop loss Risk Percentage", DefaultValue = 5)]
        public int stopLossRiskPercent { get; set; }

        [Parameter("Stop loss in Pips", DefaultValue = 25)]
        public int stopLossInPips { get; set; }


        protected override void Initialize()
        {
            // No needs
        }

        public override void Calculate(int index)
        {
            double spread = 0;
            double costPerPip = 0;
            double positionSizeForRisk = 0;
            double gain = 0;
            double gainToday = 0;
            double totalGain = 0;
            double totalGainToday = 0;

            spread = Math.Round(Symbol.Spread / Symbol.PipSize, 5);

            foreach (var position in History)
            {
                gain += position.NetProfit;
                if (position.ClosingTime.DayOfYear == Time.DayOfYear)
                {
                    gainToday += position.NetProfit;
                }
            }

            totalGain = Math.Round((gain / (Account.Balance - gain)) * 100, 3);
            if (gainToday != 0)
            {
                totalGainToday = Math.Round((gainToday / (Account.Balance - gainToday)) * 100, 3);
            }

            costPerPip = (double)((int)(Symbol.PipValue * 10000000)) / 100;
            positionSizeForRisk = (Account.Balance * stopLossRiskPercent / 100) / (stopLossInPips * costPerPip);

            ChartObjects.DrawText("Account Summary", "Account Summary:", StaticPosition.TopLeft, Colors.MediumSpringGreen);
            string text = string.Format("\nSpread: {0,0} \nTotal gain: {1,0}% \nToday gain: {2,0}% \nBalance: {3,0} USD \nEquity: {4,0} USD \nProfit: {5,0} USD \nMaximum lot size: {6,0}", spread * 10, Math.Round(totalGain, 2), Math.Round(totalGainToday, 2), Account.Balance, Account.Equity, Math.Round(gain, 2), Math.Round(positionSizeForRisk, 2));
            ChartObjects.DrawText("Account Text", "\t" + text, StaticPosition.TopLeft, Colors.White);
        }
    }
}
Comments
5