Discussion of article "20 Trade Signals in MQL5" - page 3

 

Here I have a practical question.

Why is it necessary to check the indicator handle for disability at each call of CopyBuffer()? In my EA I made this procedure once (with the arrival of the first tick, after checking the data synchronisation), and later I started to receive error 4807 Error indicator handle. CSymTotal=7. Handles were received in an array:

      for (int i=0;i<CSymTotal;i++)
      {
      H_Ind[i]=iSAR(CSymList[i],PSARTF,PSARStep,PSARMax);
      }
Print check shows that all seven H_Ind[0..6] have values 10..15 respectively, i.e. different from -1. The handles seem to be valid, but in response to CopyBuffer(H_Ind[0-6]...) I get CopyBuffer=-1, LastError=4807(!!!).Sometimes it goes normally, and sometimes it gets errors.

After I introduced checks like in this article,

   if(H_Ind[CSymListItem]==INVALID_HANDLE)//--- if the handle is invalid
     {
      //--- создадим его снова                                                      
      H_Ind[CSymListItem]=iSAR(CSymList[CSymListItem],PSARTF,PSARStep,PSARMax);
      //--- exit the function
      return(0);
     }
   else
     {
      cb=CopyBuffer(H_Ind[CSymListItem],0,0,BarsCheck,PSARBuffer);
...

so far everything is working properly. Mystery...

I don't understand what my fault is.... And most importantly, why is it necessary to check the handle for validityevery time I use CopyBuffer() and create it again? Isn't it saved until the Expert Advisor finishes its work? Is it a necessity in general, or is it just for the convenience of the example?

Документация по MQL5: Получение рыночной информации / SymbolIsSynchronized
Документация по MQL5: Получение рыночной информации / SymbolIsSynchronized
  • www.mql5.com
Получение рыночной информации / SymbolIsSynchronized - Документация по MQL5
 
pronych:

Here I have a practical question.

Why is it necessary to check the indicator handle for disability at each call of CopyBuffer()? In my EA I made this procedure once (with the arrival of the first tick, after checking the data synchronisation), and later I started to receive error 4807 Error indicator handle. CSymTotal=7. Handles were received in an array:

Print check shows that all seven H_Ind[0..6] have values 10..15 respectively, i.e. different from -1. The handles seem to be valid, but in response to CopyBuffer(H_Ind[0-6]...) I get CopyBuffer=-1, LastError=4807(!!!).Sometimes it goes normally, and sometimes it gets errors.

After I introduced checks like in this article,

so far everything is working properly. Mystery...

I don't understand what my fault is.... And most importantly, why is it necessary to check the handle for validityevery time I use CopyBuffer() and create it again? Isn't it saved until the Expert Advisor finishes its work? Is it a necessity at all, or is it just for the convenience of the example?

in my examples the condition looks like this: if the handle is valid, we proceed to copying data. if not, we create the indicator again and exit this function, as the calculation of the indicator takes time. the same happens with copying, during copying the indicator can be recalculated, so CopyBuffer() returns -1, as soon as the data is ready the function will do its work, that's why it is necessary to check it all.
 

In general, the question should be formulated more broadly:

What checks, conditions, or delays should be introduced BEFORE and AFTER CopyBuffer(), in order to GUARANTEEDLY get those 400(0) indicator values, which I need now(!), on seven (ten) instruments in maximum speed conditions (in a loop)?

For, return(0) = "ah, well, it didn't work now, maybe next time it will work...".

Here, by the way, the rest of Copy is next to it...

PS. Perhaps it's already off-topic. Well, the question is not for the author, but for everyone who can clarify...

 
sergey1294:
In my examples the condition looks like this: if the handle is valid, we proceed to copying data. if not, we create the indicator again and exit this function, as the calculation of the indicator takes time. the same happens with copying, during copying the indicator can be recalculated, so CopyBuffer() returns -1, as soon as the data is ready the function will do its work, that's why it is necessary to check it all.

Yes, Sergey, I understand. I didn't mean to cast any shade on the article or the author. The article is excellent. This is not a complaint, but an attempt to find an answer. It's just the closest discussion I've found on the subject. You'd probably like to know the answer more accurately, too, wouldn't you? )

Maybe we should put it in a separate thread?

 
pronych:

Maybe put it in a separate thread?

https://www.mql5.com/ru/forum/1880.

Here, put it in the topic. Sergey, I apologise for going beyond the scope of the article. I will be glad...)))

ДО и ПОСЛЕ CopyBuffer(..)
ДО и ПОСЛЕ CopyBuffer(..)
  • www.mql5.com
Какие проверки, условия, или задержки надо внести ДО и ПОСЛЕ CopyBuffer(), для того, чтоб, ГАРАНТИРОВАННО получить те 400(0) значений индикатора, которые необходимы сейчас(!
 
We really like this article. So far we have created 10 expert advisors with our visual wizard software using those signals. You can see them here: http://www.molanis.com/products/expert-advisor-visual-wizard/expert-advisors-mt5
Expert Advisors for MT5 - Examples
  • Molanis Marketing
  • www.molanis.com
Please note that these Expert Advisors were created for educational purposes and do not constitute any financial advice. Before using the following EAs, please take into account the following: THE DOWNLOAD FILES ARE IN MOL5 FORMAT (MOLANIS 5 FORMAT - A .MOL5 FILE FOR THE EA VISUAL WIZARD). TO OBTAIN THE EA FOR MT5, DOWNLOAD THE STRATEGY...
 
I have tried to download some of EAs but without success.
 

wish someone can give 20 methods for Money Management !!!!!! 

 

For this article, the idea is very good. But you have forgotten the concept of OOP and programming in general: ABSTRACTNESS. Inside your functions are hard-coded inicators, current symbol, current period, indicator parameters. The idea is good, but it is not fully implemented, it is far from perfection. For example - I want to check the crossing of indicator lines, each of them from a different timeframe and from different symbols - that's one. Second - what happens to your functions if the terminal temporarily lost connection with the server and missed the very three bars that you are processing? There is a signal - but the input is missed. The search for a signal should be carried out with a CHARGE. Then the signal should be checked if it has already been processed. You may have so many intersections that you will be surprised yourself. It is enough to pass parameters (indicator number, symbol, timeframe, start of search, end of search, indicator line...) to the functions. - and you will make your system more flexible and the Expert Advisor will be able to see what is inaccessible to humans - the intersection of lines of different symbols and different timeframes. This is much better than the functions given here. You also need to work out the concept of naming variables - you have too few variables with names that don't mean anything - but this is a separate topic. This is called programming style. Everyone has his own style. But I see that you are slowly getting closer to the concepts that I tried to use in MT4 - that's very encouraging.

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Линии индикаторов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Линии индикаторов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Линии индикаторов - Документация по MQL5
 
1CMaster:

For this article, the idea is very good. But you have forgotten the concept of OOP and programming in general: ABSTRACTNESS. Inside your functions are hard-coded inicators, current symbol, current period, indicator parameters. The idea is good, but it is not fully implemented, it is far from perfection. For example - I want to check the crossing of indicator lines, each of them from a different timeframe and from different symbols - that's one. Second - what happens to your functions if the terminal temporarily lost connection with the server and missed the very three bars that you are processing? There is a signal - but the input is missed. The search for a signal should be carried out with a CHARGE. Then the signal should be checked if it has already been processed. You may have so many intersections that you will be surprised yourself. It is enough to pass parameters (indicator number, symbol, timeframe, start of search, end of search, indicator line...) to the functions. - and you will make your system more flexible and the Expert Advisor will be able to see what is inaccessible to humans - the intersection of lines of different symbols and different timeframes. This is much better than the functions given here. You also need to work out the concept of naming variables - you have too few variables with names that don't mean anything - but this is a separate topic. This is called programming style. Everyone has his own style. But I see that they are slowly getting closer to the concepts that I tried to use in MT4 - this is very encouraging.

The article was written according to the technical task, If you want to check the intersection, who prevents you from doing so.