How to get all closed orders?

Created at 29 Aug 2013, 23:10
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!
ST

stoko

Joined 05.07.2013

How to get all closed orders?
29 Aug 2013, 23:10


How can I get all closed orders?

I guess Positions will only give me open positions?

Is there some class that I can use?


@stoko
Replies

tradermatrix
30 Aug 2013, 10:51

RE:

stoko said:

How can I get all closed orders?

I guess Positions will only give me open positions?

Is there some class that I can use?

        foreach (var openedPosition in Account.Positions)
       
        {

        Trade.Close(openedPosition);

        }

        foreach (var pendingOrder in Account.PendingOrders)
       
        {

        Trade.DeletePendingOrder(pendingOrder);

        }


@tradermatrix

stoko
30 Aug 2013, 11:31

RE: RE:

tradermatrix said:

stoko said:

How can I get all closed orders?

I guess Positions will only give me open positions?

Is there some class that I can use?

        foreach (var openedPosition in Account.Positions)
       
        {

        Trade.Close(openedPosition);

        }

        foreach (var pendingOrder in Account.PendingOrders)
       
        {

        Trade.DeletePendingOrder(pendingOrder);

        }

I do not want to close orders. I want to read/get all closed orders.


@stoko

atrader
30 Aug 2013, 14:11

You can add them to a list in the OnPositionClosed event but that is limited to the closed orders by the same robot.


@atrader

stoko
30 Aug 2013, 14:14

RE:

atrader said:

You can add them to a list in the OnPositionClosed event but that is limited to the closed orders by the same robot.

yep. not good :)

I guess there is no way then :(


@stoko

atrader
30 Aug 2013, 15:53

You can have a robot that logs all the account open positions to a file and then continuously cross checks the positions in the file against the currently open positions under the account and the ones that do not correspond to the ones in the file have been closed.

Maybe you can log the closed ones to another file which can be accessed by other robots. 

Or you will just have the one file which logs each time a position has been opened and then in your robots you just compare the open positions to the ones in the file.


@atrader