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

 
Сергей Таболин:

As I, a dilettante, who can't understand the sacred meaning of all classes, and why OOP is needed in our (trading) business in general, understand - classes are all written (both by MQ and guru) code-libraries, designed to "facilitate" life for "non-guru code-writers".

The trouble is, and I've already said this, that using all this "relief" doesn't make writing code any easier. Because you always have to double-check all the orders you send yourself! Because practically everyone insists on me checking some "transactions" too. All the more so because these "...shares" come at random.

I give the order - to hammer a nail in this place at such an angle. That's it. Next I get a reply - the nail is hammered in. And then I get a warning that:

  • maybe the nail was the wrong size - need to check.
  • Maybe it's the wrong angle - need tocheck.
  • Maybe it's hammered in the wrong place - need tocheck.

So why do I need such performers (classes)?

I may be exaggerating a little, but the point doesn't change.

And why? Because any data processed in classes can be changed so that the class won't even suspect that it has been changed.


I see.

I agree, by the way, that OOP doesn't make programming easier.

OOP makes it easier to maintain large projects, but tends to make it harder to create small ones.

OOP is harder for beginners.

Using other people's classes is, to some extent, using black boxes.

 
Hello. Could you please tell me where I made a mistake and why the indicator does not show arrows?
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window


double      Buy[];            // Буфер для покупок
double      Sell[];           // Буфер для продаж


input int tenkan_sen1 = 9;
input int kijun_sen1  = 26;
input int senkou_span_b1 = 52;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 
//--- indicator buffers mapping
   SetIndexBuffer(0,Buy);
   SetIndexBuffer(1,Sell);  
   // Устанавливаем нулевые значения для индикатора, при которых не будет сигнальных стрелок
   SetIndexEmptyValue (0, 0);
   SetIndexEmptyValue (1, 0);
   //Определяем стиль отображения индикаторных линий - стрелка
   SetIndexStyle (0, DRAW_ARROW);
   SetIndexStyle (1, DRAW_ARROW); 
   // Установим значки "стрелки" для буферов
   SetIndexArrow(0, 234);  //Стрелка "вниз" для продаж
   SetIndexArrow(1, 233);  //Стрелка "вверх" для покупок
   //Устанавливаем текст описания стрелок индикатора для отображения информации в всплывающей подсказке.
   SetIndexLabel(0, "Продаём");
   SetIndexLabel(1, "Покупаем");
   //Определяем разрядность значений индикаторных линий - приравниваем разрядности фин. инструмента
   IndicatorDigits (Digits);
   //Строка с кратким названием индикатора выводится в сплывающей подсказке при наведении указателя мыши на стрелку
   IndicatorShortName ("Мой первый индикатор");
   
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
    int limit=rates_total-prev_calculated-1;
   if(limit<1) return(0);
   for(int i=limit;i>=0;i--)
     {
      // Снимем показания индикатора
      double tenkan_sen = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_TENKANSEN,i);
      double kijun_sen = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_KIJUNSEN,i);
      double senkou_span_b = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_SENKOUSPANA,i);
      double senkou_span_a = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_SENKOUSPANB,i);
      double chikou_span = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_CHIKOUSPAN,i);
            
      if(tenkan_sen>kijun_sen)
         Buy[i]=high[i];
         
     if(tenkan_sen<kijun_sen)
         Sell[i]=low[i];
     }
   /*input int tenkan_sen = 9;
input int kijun_sen  = 26;
input int senkou_span_b = 52;*/
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
jarikn:
Hello. Could you please tell me where I made a mistake and why the indicator does not show arrows?
#property indicator_buffers 2
 
MakarFX:

I put in the missing line but still no arrows!

 
jarikn:

I put in the missing line but still no arrows!

show

 
MakarFX:

show

//+------------------------------------------------------------------+
//|                                                     ishimocu.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2

//--- input parameters
double      Buy[];            // Буфер для покупок
double      Sell[];           // Буфер для продаж


input int tenkan_sen1 = 9;
input int kijun_sen1  = 26;
input int senkou_span_b1 = 52;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 
//--- indicator buffers mapping
   SetIndexBuffer(0,Buy);
   SetIndexBuffer(1,Sell);  
   // Устанавливаем нулевые значения для индикатора, при которых не будет сигнальных стрелок
   SetIndexEmptyValue (0, 0);
   SetIndexEmptyValue (1, 0);
   //Определяем стиль отображения индикаторных линий - стрелка
   SetIndexStyle (0, DRAW_ARROW);
   SetIndexStyle (1, DRAW_ARROW); 
   // Установим значки "стрелки" для буферов
   SetIndexArrow(0, 234);  //Стрелка "вниз" для продаж
   SetIndexArrow(1, 233);  //Стрелка "вверх" для покупок
   //Устанавливаем текст описания стрелок индикатора для отображения информации в всплывающей подсказке.
   SetIndexLabel(0, "Продаём");
   SetIndexLabel(1, "Покупаем");
   //Определяем разрядность значений индикаторных линий - приравниваем разрядности фин. инструмента
   IndicatorDigits (Digits);
   //Строка с кратким названием индикатора выводится в сплывающей подсказке при наведении указателя мыши на стрелку
   IndicatorShortName ("Мой первый индикатор");
   
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
  
   
 
  
    int limit=rates_total-prev_calculated-1;
   if(limit<1) return(0);
   for(int i=limit;i>=0;i--)
     {
      // Снимем показания индикатора
      double tenkan_sen = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_TENKANSEN,i);
      double kijun_sen = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_KIJUNSEN,i);
      double senkou_span_b = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_SENKOUSPANA,i);
      double senkou_span_a = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_SENKOUSPANB,i);
      double chikou_span = iIchimoku(NULL,0,tenkan_sen1,kijun_sen1,senkou_span_b1,MODE_CHIKOUSPAN,i);
            
      if(tenkan_sen>kijun_sen)
         Buy[i]=high[i];
         
     if(tenkan_sen<kijun_sen)
         Sell[i]=low[i];
     }
   /*input int tenkan_sen = 9;
input int kijun_sen  = 26;
input int senkou_span_b = 52;*/
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
jarikn:

I have a drawing...


 
MakarFX:

I'm drawing...


Fucking hell. wrong ishimoku run )))) thank you very much

 
Alexey Viktorov:

Yeah... Minimal writing and maximum headache...

What is it exactly? Maybe I'm just doing something wrong.

 
Andrey Sokolov:

What is it exactly? Am I doing something wrong?

Forum on trading, automated trading systems and strategy testing

OOP for schoolboys.

Alexey Viktorov, 2019.10.04 16:01

I think mql has very limited set of problems to be solved by OOP. The language itself, it seems to me, is nothing but OOP in C++ or whatever. And this OOP is offered in the form of a standard library. And to this OOP it is suggested to add, otherwise it cannot be said, another OOP. And then another step... Rightly said Warlock, though angry, but benevolent, for my tasks OOP is like a dog turntable. And what good is defining a task and then implementing it using OOP, if this task can be solved in procedural style without any problems.

For example, take .mqh from fxsaber`a to write codes for MT5 as well as for MT4. Maybe someone may need it, but look who. To someone who does not want or absolutely cannot master mql5. Or take iCanvas from Nikolay ... I forget his last name. It seems to be a useful library, but it is not easy to understand it, and there is no documentation, even a smallest description. It's not a complaint, sorry Nikolay, it's a fact. So, when I decided to try writing a graphical label, it was easier to write it without reference to either standard library or Nikolai's library.

And then you can read the whole thread.