Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
I am trying to close orders from different currency pairs ( long and short ) but with the same magic number when the profit reach define target " lets say 15 pips" without touching the other orders with different magic number
so I wrote this code to check open trades and count the profit on trades with magic number 111
// Did we make a profit
//======================
if(profit>0 && CurrentProfit>=(profit*Point))
{
while(true)
{
CloseAllOrd(111);
}//while
}//if(profit>0 && CurrentProfit>=(profit*Point))
if we make a profit I call the function CloseAllOrd
PHP Code:
//+------------------------------------------------------------------+
//| Close all |
//+------------------------------------------------------------------+
void CloseAllOrd(int magic)
{
RefreshRates();
int total = OrdersTotal();
for (int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == magic)
if(IsTradeContextBusy()) Sleep(1000);
if(IsTradeContextBusy()) Sleep(2000);
Because you are working with any symbol you can not use things such as bid , ask, point but rather MarketInfo( OrderSymbol(), MODE_BID ), MarketInfo( OrderSymbol(), MODE_ASK ) etc ...
I am trying to close orders from different currency pairs ( long and short ) but with the same magic number when the profit reach define target " lets say 15 pips" without touching the other orders with different magic number
Yes but that would close trades on profit , I am looking at the combined trades menaing that EURUSD could be in 30pips+ and USDCHF could be in -15 pips so I look at the overall profit of trades with magic number 111 if the total profit from all those trades reach 15 pips I close all orders of magic number 111 only at combined profit of 15 pips
Yes but that would close trades on profit , I am looking at the combined trades menaing that EURUSD could be in 30pips+ and USDCHF could be in -15 pips so I look at the overall profit of trades with magic number 111 if the total profit from all those trades reach 15 pips I close all orders of magic number 111 only at combined profit of 15 pips
Okay now I get your point.. If you don't mind using a big array..