How to calculate the all profits in pips when stopping the strategy
07 Aug 2021, 16:14
How to calculate the the total profit of all positions in pips when stopping the strategy?
How to calculate the all profits in pips when stopping the strategy
07 Aug 2021, 16:14
How to calculate the the total profit of all positions in pips when stopping the strategy?
amusleh
09 Aug 2021, 15:28
Hi,
Try this:
using System; using System.Linq; using cAlgo.API; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Test : Robot { [Parameter(DefaultValue = "Test")] public string Label { get; set; } protected override void OnStop() { var openPoisitionPipsSum = Positions.FindAll(Label).Sum(position => position.Pips); var historicalTradesPipsSum = History.Where(trade => trade.Label.Equals(Label, StringComparison.OrdinalIgnoreCase)).Sum(trade => trade.Pips); Print("Open Positions Pips: {0} | Historical Trades Pips: {1}", openPoisitionPipsSum, historicalTradesPipsSum); } } }
@amusleh