Description
MyMiniFxBook v1.0
- Spread;
- Total gain;
- Today gain;
- Balance;
- Equity;
- Profit;
- Maximum lot size (depends on your Risk percent and pips lost)
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);
}
}
}
![ntphu619's avatar](/uploads/user-21875/avatar/557a883b7b559f45227490a9c982236be4ca9ea2.png)
ntphu619
Joined on 31.01.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: MiniFXBook.algo
- Rating: 5
- Installs: 1796
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.