information about positions during backtesting

Created at 22 Nov 2021, 11:07
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!
yomm0401's avatar

yomm0401

Joined 11.04.2020

information about positions during backtesting
22 Nov 2021, 11:07


How can I get information about my positions during backtesting?
It is not possible in the following way.

var positions = Positions.FindAll("", symbolname);

best regards.


@yomm0401
Replies

amusleh
23 Nov 2021, 09:53

Hi,

All the positions your cBot opens during back test and live is in Positions collection.

You don't have to use the FindAll method with empty label parameter, if you want to filter the current symbol positions you can do it by using Linq Where:

var positions = Positions.Where(position => position.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase));

If you have provided a label for your positions then use FindAll method.


@amusleh