Close posititon based on equity
Created at 23 May 2017, 00:06
TI
Close posititon based on equity
23 May 2017, 00:06
I hope that someone can help me with, and or provide me a code example for closing the postion with the biggest negative gross loss when reaching a certain equity percentage.
So when my equity drawdown is 10% I want to close the postion with the biggest loss
I hope someone can help me
Replies
ClickAlgo
10 Jun 2017, 07:53
this block of code
Position _myWorstPosition=Positions[0]; foreach (Position pos in Positions) { if (_myWorstPosition.NetProfit>pos.NetProfit) { _myWorstPosition = pos; } }
can be replaced using LINQ to a single line
var position = Positions.OrderByDescending(i => i.NetProfit).FirstOrDefault();
@ClickAlgo
Mikro
09 Jun 2017, 18:12
cheers Mirko
@Mikro