I have an EA to open buy for two pairs simultaneously. Then I want to close when either difference or sum of the profit in pips is > TakeProfit. the only problem is I don't know how to get OrderOpenPrice for both currencies at the same time. Any insight would be appreciated
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
extern string Symbol_1 = "EURUSDm";
extern string Symbol_2 = "USDCHFm";
for(cnt = OrdersTotal(); cnt >= 0; cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if((MarketInfo(Symbol_1,MODE_BID)-OrderOpenPrice()) + (MarketInfo(Symbol_2,MODE_BID)-OrderOpenPrice())>TakeProfit*Point ||
(MarketInfo(Symbol_1,MODE_BID)-OrderOpenPrice()) - (MarketInfo(Symbol_2,MODE_BID)-OrderOpenPrice())>TakeProfit*Point ||
(MarketInfo(Symbol_2,MODE_BID)-OrderOpenPrice()) - (MarketInfo(Symbol_1,MODE_BID)-OrderOpenPrice())>TakeProfit*Point)
{
OrderClose(OrderTicket(),OrderLots( ),Bid,3,Violet);
return(0);
}
}
}
return(0)