For this you can define a magic number in the request:
magic | Expert Advisor ID. It allows organizing analytical processing of trade orders. Each Expert Advisor can set its own unique ID when sending a trade request. |
(from https://www.mql5.com/en/docs/constants/structures/mqltraderequest
And with PositionGetInteger() (or OrderGetInteger() ...) you can get and check it so each EA is able to know whether a position is its or not.
- www.mql5.com
For this you can define a magic number in the request:
magic | Expert Advisor ID. It allows organizing analytical processing of trade orders. Each Expert Advisor can set its own unique ID when sending a trade request. |
(from https://www.mql5.com/en/docs/constants/structures/mqltraderequest
And with PositionGetInteger() (or OrderGetInteger() ...) you can get and check it so each EA is able to know whether a position is its or not.
add 2) requote: https://www.mql5.com/en/search#!keyword=requote&module=mql5_module_articles
add 3) depends on the symbol (specifications), broker, market, ...
add 2) requote: https://www.mql5.com/en/search#!keyword=requote&module=mql5_module_articles
add 3) depends on the symbol (specifications), broker, market, ...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I faced some problems about running multiple EAs on same pair, same timeframe and different chart window.
1. Example: ea1 and ea2 open each own a 'buy' position with different (or same) price, sl, tp, lotSize, time opening and store position ticket number. But both ea1, ea2 store the same ticket number, therefor ea that didn't open this ticket number can modify this position.
FYI, each EA have unique magic number, use PositionGetTicket(0) to get ticket number and store it in global variable, each ea check that can not open more than 1 position, open position using cTrade.PositionOpen(currentSymbol, orderType, lotSize, price, sl, tp, "comment").
When modify position, I select it by PositionSelectByTicket(ticketNumber).
2. Another problem is that sometimes ea can not open position using PositionOpen function, MT5 notify for me like: request requote ... (deviation: 10)
3. I have function to modify position using PositionClosePartial function, but sometimes it doesn't work (deviation value = 1). Is this better to use deviation default value = ULONG_MAX or set it > 1 like 10 or 15?