Dealing with aggregated positions

Created at 25 Aug 2016, 13:16
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!
CL

cloesd

Joined 28.02.2015

Dealing with aggregated positions
25 Aug 2016, 13:16


I'm developing a bot that needs to deal with aggregated positions. The bot is designed to 'support' manual trading by

automatically closing positions, opening positions and controlling risk on manually opened trades.

 

Sometimes I will open a grid of 10 positions on one symbol each of them small size like 0.05lots.

 

I want to be able to get things like 'total margin used' and 'net profit' for that 'aggregated' postions. What's the best way to do this? Is there any inbuilt functions?

 

I was thinking of using a 2D  array, and putting something in onTick that will periodically check all open positions and 'collect' them by symbol and store things like net profit for each symbol. Then when the symbol is closed it will delete that entry. But this seems like complex way to do it. 

 

Is there any other suggestion on how to implement this?


@cloesd
Replies

cloesd
25 Aug 2016, 13:24

RE:

cloesd said:

I'm developing a bot that needs to deal with aggregated positions. The bot is designed to 'support' manual trading by

automatically closing positions, opening positions and controlling risk on manually opened trades.

 

Sometimes I will open a grid of 10 positions on one symbol each of them small size like 0.05lots.

 

I want to be able to get things like 'total margin used' and 'net profit' for that 'aggregated' postions. What's the best way to do this? Is there any inbuilt functions?

 

I was thinking of using a 2D  array, and putting something in onTick that will periodically check all open positions and 'collect' them by symbol and store things like net profit for each symbol. Then when the symbol is closed it will delete that entry. But this seems like complex way to do it. 

 

Is there any other suggestion on how to implement this?

Another idea is using classes.

If I create a class called 'aggregated position' that stores symbol name, netprofit and margin used.

 

Then the challenge is how to create the objects for each 'symbol' that's open, and where to store all objects so they can be searched on tick or on bar with something like if (GBPUSD.netprofit > 25)


@cloesd