How do i close multiple orders order by profit descending or time ascending ...
Created at 26 Jun 2022, 11:57
How do i close multiple orders order by profit descending or time ascending ...
26 Jun 2022, 11:57
How do i close orders by profit descending or time descending etc..
Replies
MongolTrader
29 Jun 2022, 09:18
RE:
firemyst said:
//Quick example on how to sort positions by NetProfit (not gross profit) //Change things around if you want to sort by time or something else. foreach (Position p in Positions.FindAll(YourLabel, s.Name).OrderBy(x => x.NetProfit)) { ClosePositionAsync(p, (TradeResult r) => { if (r.IsSuccessful) { Print("Closed position \"{0} {1}\".", p.Id, p.Label); } else if (!r.IsSuccessful) { Print("WARNING! Could not close position \"{0} {1}\"!", p.Id, p.Label); Print("Error message: {0}", r.Error.Value); } }); }
Thank you very much. It delete from low profit to high. Can you provide code delete from high profit to low.
@MongolTrader
firemyst
27 Jun 2022, 07:14
@firemyst