Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 606

 
Amon1953:
Thanks for the advice. I'm not a very experienced programmer. and I use a style that's comfortable for me, I haven't learned how to bring it to a common style on this site yet. - I have not yet learned how to do it.

But you can paste the code into your post (Alt+S), albeit with your style. However, you can always use the styler in the editor (Ctrl+,) to bring the style to the adopted on the site. Although it's not convenient for everyone, it's better than something unreadable.

 
Artyom Trishkin:

But you can insert the code into your post (Alt+S), albeit with your style. However, you can always use the styling tool in the editor (Ctrl+,) to bring the style to that of the site. Although it's not convenient for everyone, it's better than something unreadable.

 
 if((cnt_OO > 1))
  {
   for(int h = OrdersTotal()-1; h >= 0; h--)
    {
     if(OrderSelect(h, SELECT_BY_POS))
      {
       if((OrderMagicNumber() == Magic))
        {
         Nextstep  = NextStep;
         BaseNext  = OrderOpenPrice();
         LotsNext  = NormalizeDouble(OrderLots()*K,lotDigit);
         if(NewPB > 0)
          {
           PBcloseON = true;
          } 
         Alert ("Pospedny Order NEXT  ",OrderTicket());
         Alert ("Otkritih orderov  ",cnt_OO);
         break;
    }}} }
       if((cnt_OO == 1))
        {
         LotsNext    = NormalizeDouble(Lots*Prikup,lotDigit); 
         Alert ("Otkritih orderov NEXT net ");
         Alert ("Otkritih orderov  ",cnt_OO);
        }
Well, I've got something. Only in essence I did not understand where my mistake
 
Amon1953:
Well, I got something. Only in essence I didn't understand where my mistake is

What do you want to achieve anyway?

From what you have shown it is impossible to understand - there is no data about the values of the variables used.

 
Artyom Trishkin:

What do you want to achieve anyway?

From what you have shown it is impossible to understand - there is no data on the values of the variables used.

The second if statement is optional, but it doesn't work without it
 
Amon1953:
The second if statement is optional, but it doesn't work without it

Forum on trading, automated trading systems & strategy testing

Any questions for newbies on MQL4, help and discussion on algorithms and codes

Artyom Trishkin, 2018.08.21 22:14

What do you want to achieve anyway?

From what you have shown it is impossible to understand - there is no data on the values of the variables used.


 
Artyom Trishkin:

I have already shown one of the results of this unit

RESULT: Otkritih orders NEXT net

Otkritih ordersov 5

 
Amon1953:

I have already shown one of the results of this unit

RESULT: Otkritih orders NEXT net

Otkritih ordersov 5

I see - stream of consciousness. I removed myself from the discussion...

Read on.

 

Anton1953 If you are referring to the work of the block that was the very first without if, there is an error. I'll give you a hint - try to run that piece of code with orders with other majiks, there are a lot of orders, but they do not pass the majik condition. Do you need further advice or will you figure it out on your own?

By the way, correct coding helps a lot when searching for such errors because you mark them in your usual style and the error just becomes obvious!

 
Vitaly Gorbunov:

Anton1953 If you are referring to the work of the block that was the very first without if, there is an error. I'll give you a hint - try to run that piece of code with orders with other majiks, there are a lot of orders, but they do not pass the majik condition. Do you need further advice or will you figure it out on your own?

By the way, correct coding helps a lot when searching for such errors because the error is so obvious when you mark them in your usual style!

There are several Expert Advisors running, with different majors. cnt_OO - this is the number of open orders with a certain mode. The block is designed like this: if there is more than one order cnt_OO>1, we select from all open ordersOrdersTotal() the one with the necessary modeif((OrderMagicNumber() == Magic)) and do the necessary actions.

Otherwise we perform other actions. But "otherwise" doesn't work, we have to enterif((cnt_OO == 1)) without it, it doesn't work


	          
 
Amon1953:

Several EAs are running, with different majors. cnt_OO - defined earlier - this is the number of open orders with a particular mode. The block is designed like this: if there is more than one order cnt_OO>1, we select from all open ordersOrdersTotal() the one with the necessary modeif((OrderMagicNumber() == Magic)) and do the necessary actions.

Otherwise we perform other actions. But "otherwise" is not performed, we have to enterif((cnt_OO == 1)) without it it does not work

The fact that you have defined somewhere the number of necessary orders is good, but in this block, you again run through all the orders and check them!

Break the code down properly and you will see at once!