EntryTime
EntryTime
05 Apr 2023, 01:13
Hello to all,
I have a problem with this code, I would like to get the EntryTime only of the first opened position of a group of positions.
EXAMPLE:
My goal is to close a group of positions if the first position has been open for more than one day.
foreach (var trade in PositionLabelID.Where(x => x.EntryTime == x.EntryTime))
{
Print("Entry time: " + trade.EntryTime);
}
Thx for your TIME guys.
Marco.
Replies
PanagiotisCharalampous
05 Apr 2023, 10:07
Hi Goulk
Try the following
var trade = PositionLabelID.OrderBy(x => x.EntryTime).First()
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisCharalampous
Goulk
05 Apr 2023, 10:27
RE:
PanagiotisCharalampous said:
Hi Goulk
Try the following
var trade = PositionLabelID.OrderBy(x => x.EntryTime).First()
Need help? Join us on Telegram
Need premium support? Trade with us
Thanks, this works perfectly. :)
@Goulk
firemyst
05 Apr 2023, 04:04
The API isn't that great for what you want to do if you have a position and change the volume along the way.
The easiest way I've found is to create a variable in my cBots to keep track of each entry.
I use a Dictionary<int,DateTime> object with the int key being the position number (starting with 1 and increasing each time I add to my position size) and the value being the datetime the position was successfully modified/updated.
Hope that helps.
@firemyst