I'm new to programming in MQL5 (and programming in general). I'm currently writing an expert advisor, and I need it to open multiple positions at once for the purpose of scaling out and making adjustments.
My MT5 is in hedging mode. I've figured out how to use cTrade to open positions. But what I want to be able to do is to open positions in 3 separate trades. When I look at my list of open trades, I want to see 3 separate trades in the same direction. Right when I open each part, I want to fetch a unique identifier for each part of the trade (magic number/ticket number?) and store it in a variable. This is something I could not figure out how to do, and I've done a lot of research. How can I fetch this unique identifier right after the trade is placed?
Then, say I want to close that trade based on some condition, or change the stop loss. I want to be able to refer to that part of the trade using the unique identifier stored in the variable and perform these operations only on that part of the trade. What function do I use to refer to the trade by identifier and make changes, to close the trade or change the stop loss? Is all of this possible to do using cTrade, or do I have to use something else?
Any help is much appreciated. I'm just beginning to understand MQL5 and I've found it tough to find answers to these questions, especially since MT5 started off as netting only.