ClosePrice of a position

Created at 23 Nov 2012, 01:54
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
lec0456's avatar

lec0456

Joined 14.11.2012

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???  


@lec0456
Replies

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

lec0456
24 Nov 2012, 05:11

RE:
Have you gotten the closing price of a position using that code? if so how?

@lec0456

Stray
24 Nov 2012, 18:18

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


@Stray

lec0456
25 Nov 2012, 03:30

RE:
Stray said:

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

Right, but I was asking if it was something included in the API like, closedPosition.ClosingPrice.  If not I think it should be.

@lec0456

admin
26 Nov 2012, 11:24

Thank you for the suggestion. We will consider it for the next updates.

 


@admin

cedric.boudreau
23 Nov 2016, 03:53

i THINK THEY FORGET THA UPDATE.


@cedric.boudreau

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. 

/api/reference/position

This cBot demonstrate the use of it. Information and download link: Bought and Sold cBot


@kricka