.

Getting unique identifiers to refer to and manage open trades in MQL5 (hedging)

#1
Hi,

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.

Thanks,
VoidSurf


  1. Similar Topics

    1. open simultaneous multiple trades mt4

      0 Replies 137 Views

      by ahmedalhoseny, Sat Feb 01, 2020 10:12 pm in Trading Platform Discussion

      0 Replies
      137 Views
    2. Looking for Harmonacci Patterns and Hedging EA

      1 Replies 147 Views

      by shahrooz, Sun Mar 22, 2020 9:17 pm in MT4 Indicators

      1 Replies
      147 Views

Return to “Coding Help”

Who is online

Users browsing this forum: CommonCrawl [Bot], Google [Bot] and 2 guests