Dealing with aggregated positions
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
25 Aug 2016, 13:24
RE:
cloesd said:
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