Need help on programming structure


Hey everyone!

I recently started trying to program my own EA, and discovered this new world of expert advisor programming. I've programmed in Python and R in the past, as well as a bit of C++, therefore I am not too lost so far. However, I would like to create a mechanism that requires a specific way to store running trades I think: basically, let's imagine I open a position (#1). I want the EA to react when this #1 position reaches a certain point (so this would be in the OnTick()), by opening a second position (#2), that is linked to it. My problem here is that I would like to maintain a way to keep track of this link betweek #1 and #2, so that when #1 reaches SL for instance, I can close all positions linked to #1 as well (or specific ones based on some other conditions).

Should I use arrays to store these? The problem is, I have no idea what would be the dimension of the array that would store trade tickets, also I am not sure if this is the optimal way to do so, since at every tick I would loop multiple times through all open trades.

Thanks in advance!