Closing price and time
Closing price and time
29 Jun 2023, 22:22
Hello all,
please how can I get closing price and time of position ?
Replies
AlexFrei
30 Jun 2023, 09:38
RE:
firemyst said:
You can do it in a position closing event method. Rough example below:
//In the OnStart method: Positions.Closed += Positions_Closed; //In the method itself once the event is defined: private void Positions_Closed(PositionClosedEventArgs args) { Position p1 = args.Position; //do whatever you have to do //Now get the historical trade stuff. HistoricalTrade ht = History.FindLast(p1.Label, p1.SymbolName, p1.TradeType); Print("Position \"{0} {1}\" closed for reason \"{2}\" with {3} profit. Entry Price {4}, Closing Price {5}, StopLoss {6}, ClosingTime {7}", p1.Id, p1.Label, args.Reason, String.Format("{0:$#,###.00}", p1.GrossProfit), p1.EntryPrice, p1.ClosingPrice, p1.StopLoss, ht.ClosingTime); //finish off whatever you have to do }
Hi Firemyst, thank you so much !! I didnt know about History collection. Great. Thanks ! Have a great day
@AlexFrei
jim.tollan
30 Jun 2023, 11:32
RE: RE: RE:
firemyst said:
AlexFrei said:
Hi Firemyst, thank you so much !! I didnt know about History collection. Great. Thanks ! Have a great day
No worries. That's what the forums are for :-)
also thank you so much for this nugget. i've been wrestling with as issue regarding completed orders and this looks to address the problem i was facing... ;)
@jim.tollan
AlexFrei
30 Jun 2023, 12:10
RE: RE: RE:
firemyst said:
AlexFrei said:
Hi Firemyst, thank you so much !! I didnt know about History collection. Great. Thanks ! Have a great day
No worries. That's what the forums are for :-)
Thank you for having people like you. Many others usually make me look like an idiot if I ask some basics
@AlexFrei
firemyst
30 Jun 2023, 03:33
You can do it in a position closing event method. Rough example below:
@firemyst