Refer to last closed position
Created at 18 Feb 2018, 14:37
DR
Refer to last closed position
18 Feb 2018, 14:37
Hi All,
I want to close all open positions if one position hits it's stop loss, the code below seems logical but I fear it is outdated... What would the current approach be?
var lastPosition = Trade.Result.Last(1); if (lastPosition.NetProfit < 0) { foreach (Position position in symbolSearch) { ClosePosition(position); } }
PanagiotisCharalampous
20 Feb 2018, 11:53
Hi Drummond360,
You might consider something like the below
However note that the code above does not guarantee that the position has been closed by a stop loss. It could be a manual close as well.
Best Regards,
Panagiotis
@PanagiotisCharalampous