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

 
Amon1953:

Glitches in MQL4 ?


Similar glitch in two other situations also with if() operator

And if you think carefully and try to understand the reason why this glitch is the only one for you? Maybe you have some kind of special terminal?

 
Alexey Viktorov:

And if you think carefully and try to understand the reason why you are the only one with such a glitch??? Maybe you have some kind of special terminal?

Terminal from InstaForex is not unusual. And this glitch did not appear right away. At first it was fine, but then all of a sudden it disappeared. Reinstalling the terminal did not help. I will have to check with another broker.
 
Amon1953:
I was using a terminal from InstaForex, nothing unusual. And this glitch did not appear right away. At first it was normal, but then all of a sudden it disappeared. Reinstalling the terminal did not help. I will have to check it with another broker.

Yeah, well... I didn't get the morse code. I'll have to get it out in the open...

Maybe we should look for errors in logic and in our own code?

 

A word of advice. I am optimizing, and let's say I do not need any parameters, for example, there are slow and fast muvings, and I do not need to get such periods of these muvings in the optimization results that the period of the fast one is longer than of the slow one.

How can I "skip" this step of optimization by condition?

 
Alexey Viktorov:

Yeah, well... I didn't get the morse code. I'll have to get it out in the open...

Maybe one should look for errors in logic and in one's own code?

This piece of code is independent of the general algorithm.

Here's the same block, but it's working properly. It uses two IF() operators, even though there is only one that can be used as described in the textbook. This demonstrates incorrect operation of the IF()/ operator.

//+------------------------------------------------------------------+
   if((cnt_OO>=2))
     {
      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);
     }
//+------------------------------------------------------------------+
 
Amon1953:

This piece of code is independent of the overall algorithm.

Here is the same block, but it works properly. It uses two IF() operators, although one could be used as described in the textbook. This demonstrates incorrect operation of the IF()/ operator.


This is just a demonstration of a bug. Before you speak of incorrect operation, you should print out the values of the variables used in if() operators and compare them to expected values.

And learn how to insert the code so that it can be read normally.

 
Alexey Viktorov:

This only shows we have a bug. Before you say it does not work correctly, you should print out the values of the variables used in the if() statements and compare them with the expected values.

And learn how to insert the code so that it can be read normally.

I just copied the program text. In the first post you can clearly see that there are 5 orders and the message that there are no orders like Next. this is the second third order etc.

The program is simple as a nail, cnt_OO is the number of open orders, if there is more than one it means there is an order Next, This is part of the block to restore the parameters in case of failure and restart of the EA

 
Amon1953:

I just copied the program text. In the first post you can clearly see that there are 5 orders and the message that there are no orders like Next. this is the second third order etc.

The program is as simple as a nail, cnt_OO is a number of open orders, if there is more than one it means there is an order Next, This is part of the parameter recovery block in case of failure and restart of the EA

Where is the guarantee that this is the case?

 
Amon1953:

I just copied the program text. In the first post you can clearly see that there are 5 orders and the message that there are no orders like Next. this is the second third order etc.

The program is simple as a nail, cnt_OO is number of open orders, if there is more than one it means there is an order Next, This is part of the block to recover parameters in case of failure and restart of the EA

  1. Use Alt+S to paste the code, or use the format bar buttons in your post:



  2. Your logic does not work, not the conditional if() operator
  3. I corrected the code in your post to normal for those helping you - respect them please. Next time people won't try to help by looking at the scrips you offer.
 
Artyom Trishkin:
  1. Use Alt+S to paste the code, or use the format bar buttons on your post:



  2. Your logic does not work, not the conditional if() operator
  3. I corrected the code in your post to normal for those helping you - respect them please. Next time people won't try to help by looking at the scrips you offer.
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. - Zeitnote.
Reason: