hi everyone .. little help please for coder beginner

 

I have an expert opening to many orders .

buy I can't close them all at once .

all I need is this equation:

if one open orders closed (TP or SL) then Close all orders.


Can anyone help??
 
Mohamed Abdelwaged: Can anyone help??
Help you with what? You haven't stated a problem.
You have only four choices:
  1. Search for it,
  2. learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  3. Beg at Coding help - MQL4 and MetaTrader 4 - MQL4 programming forum or Need help with coding - General - MQL5 programming forum or Free MQL4 To MQL5 Converter - General - MQL5 programming forum or Requests & Ideas (MQL5 only!),
  4. or pay (Freelance) someone to code it.
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.
 
Mohamed Abdelwaged:

I have an expert opening to many orders .

buy I can't close them all at once .

all I need is this equation:

if one open orders closed (TP or SL) then Close all orders.


Can anyone help??

https://book.mql4.com/trading/orderclose

Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
  • book.mql4.com
Trade requests for closing of market orders are formed using the function OrderClose(). Function OrderClose() It is a function used to close a market order. The function returns TRUE, if the trade is performed successfully. It returns FALSE, if the trade fails. ticket - the unique number of the order. lots - the amount of lots to be closed. It...
 
Gurmeet Budhraja:

https://book.mql4.com/trading/orderclose

Can you wrote to me the Condition Line:

"If one of opened orders closed "

 
It's a lot more than one one. Post your attempt (using CODE button) and state the nature of your problem.
 
whroeder1:
It's a lot more than one one. Post your attempt (using CODE button) and state the nature of your problem.
Mohamed Abdelwaged:

Can you wrote to me the Condition Line:

"If one of opened orders closed "

 I don't know if I understood your condition correctly but I am assuming something it should be something like this.

static int PrevOpenedOrders = 0;

if(PrevOpenedOrders < OrdersTotal())
{
        PrevOpenedOrders = OrdersTotal();
}

else if(OrdersTotal()< PrevOpenedOrders)//This can be OrdersTotal()==PrevOpenedOrders -1 but I didn't write it because if there were 2 orders hit TP at once there will be an error
{
        for(int i = OrdersTotal() - 1; i>=0; i--)
        {
                if(OrdersSelect(i,SELECT_BY_POS))
                {
                   bool res = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage);
                   if(!res)
                     Print("Error in closing the order #",OrderTicket()); 
                     
                }
		PrevOpenedOrders = 0;
        }
}
 
  1. The first if invalidates the second. Remove it.

  2. Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. After Sleep and between server calls the market will have changed. You must update your variables. To use any pre-defined variables and series arrays you must call RefreshRates
              RefreshRates - Timeseries and Indicators Access - MQL4 Reference

  4. "and state the nature of your problem."

 
Ahoj, mám otázku od EA, z nějakého důvodu: Trik se otevře (např.) 0001, když se obchod zavře. kdy trik se vrátí na 001, nebude znovu (pokud by měl). Můžete mi poradit, abych udělal chybu?
 
Stanislav Milka:
Ahoj, mám otázku od EA, z nějakého důvodu: Trik se otevře (např.) 0001, když se obchod zavře. kdy trik se vrátí na 001, nebude znovu (pokud by měl). Můžete mi poradit, abych udělal chybu?
This is absolutely nonsense, even in Czech.
 
Petr Nosek:
This is absolutely nonsense, even in Czech.

Překladač to hodil do cze automaticky:) Díky


The translator translated it into Czech. THx

 
Hi, I have a question from EA, for some reason: Market opens (eg) 0001, the store closes at TP. when the market returns to 001, it does not trade again (though it should).
Can you advise another end of the status line than return? I did not find Repeat anywhere.
Reason: