Questions from Beginners MQL4 MT4 MetaTrader 4 - page 89

 
Alexey Kozitsyn:
You shouldn't do that. It's a big drain on resources. And what's wrong with a fast response time without looping?
Thank you. It's just that the official mql4 tutorial gives it as an example, that's why I'm interested. I thought it might somehow work better than the usual way.
 
LRA:
A tick is the arrival of new data from the server. And it must be processed immediately after it arrives. If you do it in loop with 5ms delay, then most of the ticks will come exactly during this delay. Thus, processing will be delayed by 0 ... 5 ms.
Yes, there is logic in that. I just thought that the start() function itself also spends time on its loop, and perhaps its iteration steals some fraction of seconds or more (it may require addressing a server to get a large data batch at once), unlike a pure loop. Maybe, it's just my imagination, because I don't understand the inner mechanisms, but there's a reason why this method was included in mql4 tutorial.
 
smart_man:
Thank you. It's just that the official mql4 tutorial gives this as an example, so I was interested. I thought maybe it somehow works better than the usual way.
Yes, but the tutorial is somewhat outdated. Of course, it's better than nothing, but it's useful to look through documentation at the same time and check if the functions like start() are still in it. It's better to use OnTick() handler for Expert Advisors now.
 

Good afternoon!

 
Good afternoon, can you tell me the most convenient broker for USD/RUB currency pair, minimum spread and minimum swap etc with commission...?
 
kanybek06:
Hello, Can you tell me the most convenient broker for USD/RUB currency pair?

Since you are just starting out, you will be very happy with anyone. Do a search on the internet and compare them. Communicate with them, ask questions. You'll get an answer.

Here we are discussing questions about programming and the Metatrader trading platform.

 

What is the best way to close counter orders if you need to close them simultaneously

1) each one individually (either manually or by TP/SL)

or

2) In pairs with OrderCloseBy (manual only)?

Will there be a single spread saving with OrderCloseBy as written in the tutorial? Do not the DCs prohibit such a close and will this spread be given back? How to check this technically?

Thank you.

 
There is a template class for working with an array.
#property strict
#include <ObjectVariables.mqh>
#include <Arrays\varQSort.mqh>
#include <Arrays\objQSort.mqh>

template<typename T1>
class ArrayList
{
   private:
      T1 array[];
      QuickSorts<T1> *qs;
      int size;
      int index;

   public:
      //прочие функции
      void QuickSort();//отсортировать массив
      //прочие функции
};
//+------------------------------------------------------------------+
//| Сортировка массива
template<typename T1>
void ArrayList::QuickSort()
{
   int idx = index;//сохранение положения индекса
   if(IsPointer(array[0])) // true - массив содержит указатели класса
      qs /*ошибка 2*/ = new ObjQSort<T1>();
   else
      qs /*ошибка 2*/ = new VarQSort<T1>();
   qs.Sort(array, 0, index);
   index = idx;
}

For this template-class, we need to implement sorting, given the fact that an array can store complex data types. For example:
ArrayList<PP*> *dde; // PP - класс

You can write different functions for simple types and complex types, but the compiler doesn't understand that functions are strictly delimited by data type and keeps on swearing:
'<' - illegal operation use ArrayList.mqh

So I decided to embed the interface:

#property strict
template <typename T1>
interface QuickSorts
{
   void Sort(T1 &array[], int beg, int end);
};
#property strict
#include <Arrays\QuickSorts.mqh>
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
template <typename T1>
class VarQSort : public /*ошибка 1*/ QuickSorts
{
private:

public:
   void Sort(T1 &array[], int beg, int end);
   VarQSort(){}
   ~VarQSort(){}
};
template <typename T1>
void VarQSort::Sort(T1 &array[], int beg,int end)
{
   //алгоритм функции
}
#property strict
#include <Arrays\QuickSorts.mqh>
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
template <typename T1>
class ObjQSort : public /*ошибка 1*/ QuickSorts
{
private:

public:
   void Sort(T1 &array[], int beg, int end){}
   ObjQSort(){}
   ~ObjQSort(){}
};

All parts of the construct compile. But if you try to declare it:
ArrayList<PP*> *dde; // PP - класс
then, when compiling the file, these are the errors:

'QuickSorts' - template mismatch varQSort.mqh /*error 1*/
'=' - type mismatch ArrayList.mqh /*error 2*/


What should I fix in the code to eliminate this type mismatch? I don't understand why it has appeared at all.

P.S.
'<' - illegal operation use varQSort.mqh
haunts me in this construct as well. It is this very error I wanted to get rid of. But I understand this error, and I don't understand those two.
 
виталик:
Hello, please help with a piece of code to sort out ripped from an indicator PivotsDaily v2.mq4 how to convert it to an hour or half-hour, only in one way or another, so it would be clearer changes, please help, thank you in advance.

You already wrote in one thread. It is enough. There is no need to cluster in others.
 
Hello, Could you please advise me, I wrote an EA 1.5 years ago, it worked, everything was fine. Haven't used it all this time, now it won't install on a chart. Who knows what may be the reason? May it be due to some MT4 updates?
Reason: