ClosePrice of a position
ClosePrice of a position
23 Nov 2012, 01:54
I can see the close price of each trade in the log but I do not see how I can get it returned in the robot. The Position object has entry price but no closePrice???
Replies
lec0456
25 Nov 2012, 03:30
RE:
Right, but I was asking if it was something included in the API like, closedPosition.ClosingPrice. If not I think it should be.I think the close price can be calculated as we know EntryPrice and Pips.
If position is long ClosedPrice = EntryPrice + Pips*PipSize,
if short ClosedPrice = EntryPrice - Pips*PipSize
@lec0456
kricka
23 Nov 2016, 17:45
Price when closed
The trade.EntryPrice and trade.ClosingPrice in the API can be used to retrieve the actual price when the position is closed.
This cBot demonstrate the use of it. Information and download link: Bought and Sold cBot
@kricka
Zenner
23 Nov 2012, 14:48
Hi
Have you tried accessing the Position object in the OnPositionClosed method:
protected override void OnPositionClosed(Position closedPosition)
{
//Do something with position
}
@Zenner