Close positions by Position.Id
Created at 08 Jan 2020, 21:18
Close positions by Position.Id
08 Jan 2020, 21:18
Good night,
How can i close positions by Position.Id ? Positions ID its a string (PID00000000).
My code below
Thank you
[Parameter("POS.ID #1", Group = "Close Pos.ID", DefaultValue = "")]
public string PosID1 { get; set; }
[Parameter("POS.ID #2", Group = "Close Pos.ID", DefaultValue = "")]
public string PosID2 { get; set; }
netBalancePosID = 0.0;
foreach (var position in Positions)
{
if (position.Id == PosID1 && position.Id == PosID2)
{
netBalancePosID += position.NetProfit;
}
_netBalancePosID = Math.Round(netBalancePosID, 2);
_PermissionToCloseByPosID = (_netBalancePosID >= EquityProfitClosePosID) ? true : false;
}
Replies
DelFonseca
20 Jan 2020, 22:54
RE:
PanagiotisCharalampous said:
Hi DelTrader,
See below
if (Positions.Count(x => x.Id == PosID1) > 0) { Positions.First(x => x.Id == PosID1).Close(); }
Best Regards,
Panagiotis
Thank you so much Sir.
@DelFonseca
PanagiotisCharalampous
09 Jan 2020, 08:37
Hi DelTrader,
See below
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous