Multiple operations same EA and same symbol

 

Hello folks,

Every time my EA receive a tick and validate as a buy signal, it executes:

myTradingControlPanel.BuyStop(lote,entryPrice,_Symbol,PFRLow - 0.01, PFRHigh + (PFRHigh - PFRLow) * 2,ORDER_TIME_DAY,0,"Preço Fech Rev");

The problem: if I already have an opened position  for same symbol, the method above changes TP and SL of all positions.

My intention is to open a new position, for same symbol, but do not change SL e TP of previous buy.

Expert Magic is already set, but since it is the same EA on same symbol, it is changing SL and TP since 

PositionGetInteger(POSITION_MAGIC) == Expert_MagicNumber

Also tried with PositionOpen method

myTradingControlPanel.PositionOpen(_Symbol, ORDER_TYPE_BUY_STOP, lote, entryPrice, PFRLow - 0.01, PFRHigh + (PFRHigh - PFRLow) * 2, "Preço Fech Rev"); 

but returns error 4014

Any idea on how to independently work with multiple positions using same EA and same symbol?

Thanks

 
the mql function OrderSend() can return a unique ticket number after every order opened.

you can only select one order of this ticket and modify it's SL and TP.

maybe you need to do some coding yourself.
 
Peng Sun:
the mql function OrderSend() can return a unique ticket number after every order opened.

you can only select one order of this ticket and modify it's SL and TP.

maybe you need to do some coding yourself.

Understood, but my intention isn't modify SL and TP of an opened position (which your suggestion fits great).

My intention is to open a new position for the same _Symbol. The positions have different EA_MagicNumber, so it can be used to avoid mixing EA conditions.

Each EA, despite running on same _Symbol, will have its own position.

 
look if you have an "OrderModify" somewhere
 
You can open two charts for one symbol and then you must change magic numbers for each EA
 
Mehmet Ozen:
You can open two charts for one symbol and then you must change magic numbers for each EA

Do you have something working in this way or was it a guess?

Because I have two charts opened, each one with an EA and EAs have different magic number. When a position was open for EA1 and there is a new signal for EA2, EA2 add bought quantity to EA1's position, price is weighted average and EA1's SL and TP are overwritten by EA2.

Please, share your code if you have something working like you suggested.

 
stanislass:
look if you have an "OrderModify" somewhere

CTrade.OrderModify() states: Modifies the pending order parameters.

Please, correct-me if I am wrong, but considering the open order was filled, it became a position. A position can have a SL and TP, but it does not mean this position has a pending order. When price reaches SL or TP, then a order is deployed.

AFAIK, if there is no pending order until SL or TP are reached, can't use OrderModify.

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The identifier of...
 

This article states for each account, for every financial instrument, there can be only one position. For each symbol, at any given time, there can be only one open position - long or short.

So, this problem was solved checking orders history and placing new orders according to each EA's exit rules. In my case, all orders placed are GTC (good till cancel).

Hope MetaTrader team changes this restriction and allow us to have multiple position for the same financial instrument.

Orders, Positions and Deals in MetaTrader 5
Orders, Positions and Deals in MetaTrader 5
  • www.mql5.com
The ultimate goal of a trader is to extract profits through the means of trading operations on the financial markets. This article describes the terms and processes of the MetaTrader 5 trading platform, the knowledge of which is necessary for a proper understanding of the work of trade functions of the MQL5 language. Orders — are the trade...
 
Henrique :

This article states for each account, for every financial instrument, there can be only one position. For each symbol, at any given time, there can be only one open position - long or short.

So, this problem was solved checking orders history and placing new orders according to each EA's exit rules. In my case, all orders placed are GTC (good till cancel).

Hope MetaTrader team changes this restriction and allow us to have multiple position for the same financial instrument.

For several years now, MetaTrader 5 has been able to open two types of trading accounts: netting - there can be only one position on one symbol and hedge - there can be several positions on one symbol.

 
Vladimir Karputov:

For several years now, MetaTrader 5 has been able to open two types of trading accounts: netting - there can be only one position on one symbol and hedge - there can be several positions on one symbol.

Excellent. Find out that my account is NETTING.

Already requested to my broker if it is possible to change.

Thanks for your clear answer.