Community of Expertise - page 7

 
This is a check for the special case where the difference == 0
This loop goes through the series backwards until it finds a difference other than zero.

This can be omitted, but then there is a chance of missing the intersection if we accidentally hit a bar when M1 == M2.

We can replace < with <=, then this case of intersection will be caught,
but the condition will also produce an intersection when two rows touch without crossing.

In general, it is more correct to use the text which is written in
(but I just need to check it in work - I haven't checked it).

As for the speed, it will be the same.
This loop will be triggered very rarely,
and practically always no more than 1 additional check.
 
Question for developers: will there be a debugger for the meta-editor?

Question to fellow chaos wrestlers: will MQL4 support access to any database?
 
Has anyone tried stitching Japanese candlesticks into an EA?
(Theoretically, there's no problem for that).
 
Question to the developers: will there be a debugger for the meta-editor?

Yes, there will be - it is planned. Most likely it will be together with the new version of the MQL4 compiler.
 
Question to those who might know:

What is the execution time of compiled code in MQL4 compared to other programming languages? For example C++ is the fastest, Java is much slower...
 
I have to look in the archives, at one time Renat boasted, and I have to say, not for nothing. The experts are very quick indeed
 
A built-in function (method) is very much needed

All sales moments count as buying moments

All buying moments count as selling moments

Is there such a thing or not? And if not, as it seems to me (maybe I'm wrong), it would be good for developers to include such a built-in function.

Or maybe there is one after all?
 
Question to someone who might know:<br / translate="no">
What is the execution time of compiled code in MQL4 compared to other programming languages? For example C++ is the fastest, Java is much slower...

"MQL4, MQL2, EasyLanguage, Wealth-Lab 3.0 and VC++: Speed comparison".
 
I've already given you this code.
It's just as an example, just throw out the extra stuff :))

Before closing a position, we close all opposite positions.
int _OrderCloseAll(int _type = EMPTY, int Slippage = 5) { int count = 1; int limit = 5; while(count > 0 && limit > 0) { int n = OrdersTotal(); count = 0; limit--; for(int i = 0; i < n; i++) { if (OrderSelect(i, SELECT_BY_POS) == false) continue; if (OrderSymbol() != Symbol()) continue; if (_Magic != 0 && OrderMagicNumber() != _Magic) continue; if (OrderType() == OP_BUY && (_type == EMPTY || _type == OP_BUY)) { WaitOrderTimeOut(); if (OrderSelect(i, SELECT_BY_POS)) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage); count++;
         } else if (OrderType() == OP_SELL && (_type == EMPTY || _type == OP_SELL)) { WaitOrderTimeOut(); if (OrderSelect(i, SELECT_BY_POS)) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage); count++; } } return (0); }
 
I already gave you this code. <br / translate="no"> This is just as an example, just throw out the excess :))

Close all opposite positions before opening them.
int _OrderCloseAll(int _type = EMPTY, int Slippage = 5)
{
   int count = 1;
   int limit = 5;

   while(count > 0 && limit > 0)
   {
      int n = OrdersTotal();

      count = 0;
      limit--;

      for(int i = 0; i < n; i++)
      {
      }
   }
   return (0);
}


I've already provided a link to our English forum about closing all positions. apparently, no one has read the entire thread. the reverse cycle would be more correct.
      for(int i = n-1; i >= 0; i--)


You are deleting a position and it is removed from the list. The next position takes its place and the counter is incremented and this very position is just skipped.