Questions from Beginners MQL5 MT5 MetaTrader 5 - page 781

 
Vladimir Karputov:

Whether it's handles or objects of the "Trend.mqh::CiMA" class, you still need to create them all.

How to solve the problem in my case?

The full task is to get 3 timeframes for 28 symbols in OnTick body.
Is it necessary to have handles = 28*3 ?
Вопросы от начинающих MQL5 MT5 MetaTrader 5
Вопросы от начинающих MQL5 MT5 MetaTrader 5
  • 2017.09.15
  • www.mql5.com
Подскажите пожалуйста, такой показатель тестера в жизни реален? И хороший это или плохой результат за год с депо 3000...
 
Vitaly Muzichenko:

How do I solve the problem in my case?

Complete problem, get 3 timeframes for 28 characters in OnTick body.
Is it to have handels = 28*3 ?

Yes, of course.

 
Vladimir Karputov:

Yes. Of course.

Bummer, of course(

Vladimir, you wrote to service-desk, because it shouldn't be like that, and it can't be, we must be doing something wrong that we need to create under a hundred handles for a simple Expert Advisor.
 
Vitaly Muzichenko:

Itshouldn't be like this, and it can't be, we must be doing something wrong that we need to create under a hundred handles for a simple Expert Advisor.

What's the problem? You know what an array is, don't you? A structure?

Of course, if you create 100 variables, one for each handle... ...that would be a real bummer.

 
Alexey Kozitsyn:

What's the problem? You know what an array is, don't you? A structure?

Of course, if you create 100 variables, one for each handle... that'd be a real bummer.

Here, a structure indeed, but I can't figure out how to make one quickly, can I?

 
Vitaly Muzichenko:

Here, really a structure, but I can't figure out how to put it together quickly, can I?

struct SHandle
   {
    string symbol;
    int handleM1;
    int handleM5;
    int handleM15;
   };
//---- или
struct SHandle
   {
    string symbol;
    int timeframes[3];   // Не знаю точно, можно ли так написать, если что, через ArrayResize();
   };
//--- 
SHandle _handles[28];    

It goes something like this...

 

Colleagues, I'm having some trouble understanding it at all

It constantly falls outside the array array out of range. I've investigated and written so many codes that I keep getting the same mistakes. Please advise me if there is a place (a branch, an article) where I can find out how to correctly make loops that won't throw me out of the array. I lose a lot of time finding a bug ... sometimes I do not understand what I've fixed and why it works.

For example, the following code,if (q1[i] > q1[i+1]) q2[i]=1;

on q1[i+1]

in the on unit are

SetIndexBuffer(2,q1,INDICATOR_CALCULATIONS);

ArraySetAsSeries(q1,true);

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
  int sum,i,a ,start ;
  if (prev_calculated ==0) { start =0 ; q1[0]=q1[1];}
  else  start = prev_calculated;
  CopyBuffer(pulse_clear_Handle,0,start,rates_total,q1);
  for (i = start ; i < rates_total;i++)
  {if (q1[i] > q1[i+1]) q2[i]=1 ;
  else
  if (q1[i] < q1[i+1]) q2[i]=-1;
  else continue ;
 
LookingFor:

Colleagues, I'm having some trouble understanding it at all

It constantly falls outside the array array out of range. I've investigated and written so many codes that I keep getting the same mistakes. Please advise me if there is a place (a branch, an article) where I can find out how to correctly make loops that won't throw me out of the array. I lose a lot of time finding a bug ... sometimes I do not understand what I've fixed and why it works.

For example, the following code,if (q1[i] > q1[i+1]) q2[i]=1;

on q1[i+1]

on unit are

SetIndexBuffer(2,q1,INDICATOR_CALCULATIONS);

ArraySetAsSeries(q1,true);

for (i = start ; i < rates_total-1;i++)
 

Once again, thank you!

 

Colleagues, MathSum function, description here

https://www.mql5.com/ru/docs/standardlibrary/mathematics/stat/mathsubfunctions/statmathsum

is not recognized in build 1643 . Do I have to tear everything down and update it?

Документация по MQL5: Стандартная библиотека / Математика / Статистика / Вспомогательные функции / MathSum
Документация по MQL5: Стандартная библиотека / Математика / Статистика / Вспомогательные функции / MathSum
  • www.mql5.com
Стандартная библиотека / Математика / Статистика / Вспомогательные функции / MathSum - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5