Total profit corresponding to the label.
07 Mar 2016, 19:26
Hello
can you tell me if it is possible to make a total profit related to the label.?
this would not mix decision-profits with several robots (or positions) that operate on the same account.
in my example the profit taking is on "Account.Equity - Account.Balance".
I would like to improve the method.
thanks in advance.
[Parameter("TotalProfit", DefaultValue = 10)]
public double TotalProfit { get; set; }
protected override void OnTick()
{
var netProfit = 0.0;
foreach (var openedPosition in Positions)
{
netProfit += openedPosition.NetProfit + openedPosition.Commissions;
}
ChartObjects.DrawText("a", netProfit.ToString(), StaticPosition.BottomRight, new Colors?(Colors.Lime));
{
if (Account.Equity - Account.Balance > TotalProfit) {
foreach (var openedPosition in Positions)
{
ClosePosition(openedPosition);
foreach (var pendingOrder in PendingOrders)
{
CancelPendingOrder(pendingOrder);
}
}
}
}
}
}
}
thanks in advance.
Replies
tradermatrix
07 Mar 2016, 21:27
RE:
lucian said:
profit = 0;
foreach (var posi in Positions)
{
if (posi.Label.StartsWith(label))
{
profit += posi.NetProfit;
}
}
thank you
I will try to adapt your code
cordially
@tradermatrix

... Deleted by UFO ...