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

 

Why can't you share the code?

I'm getting an error: DLL usage detected

Please let me know how I can share the code.

I saw this: https://www.mql5.com/en/code/7673

And my code is similar.

Period Converter Optimized
Period Converter Optimized
  • www.mql5.com
Lastest Version: 1.4 2005.12.24  1.4      faster to detect if data changed by removing float point  operations, added support to output CSV file in real time.                             OutputCSVFile = 0 means no CSV.                             OutputCSVFile = 1 means CSV + HST.                             OutputCSVFile = 2 CSV only, no HST...
 

Hello. What am I doing wrong?

There is a histogram indicator. It shows the difference in the number of ticks up and down.

I am trying to use indicator values on 1, 2 and 3 bars in my EA.

double tbs1=iCustom(Symbol(),0,"tickbs",1,1);

double tbs2=iCustom(Symbol(),0,"tickbs",1,2);

double tbs3=iCustom(Symbol(),0,"tickbs",1,3);

In the tester, I get an error: tickbs EURUSD,M1: array out of range in 'tickbs.mq4' (26,19)

#property copyright "tickbs"
#property link      ""
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers    1
#property indicator_color1     clrGreen
//--- input parameter
extern color   ClrUpUp        = clrGreen;
extern int     HistWidth      = 2;
//--- buffers
double BufB[];
double dOldPrice, dNewPrice;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(1);
   SetIndexBuffer(0,BufB);  
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,HistWidth,ClrUpUp);       
   SetIndexLabel(0,"Hs");
   
   dOldPrice=Close[0];
   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[])
  {
   dNewPrice=Close[0];
   if (dNewPrice>dOldPrice){
      BufB[0]=BufB[0]+1;
      dOldPrice=dNewPrice;
   }
   else 
      if (dNewPrice<dOldPrice){
         BufB[0]=BufB[0]-1;
         dOldPrice=dNewPrice;
      }
   return(rates_total);
  }
//+------------------------------------------------------------------+

Thank you.

 
Oleg Bondarev:

Hello. What am I doing wrong?

There is a histogram indicator. It shows the difference in the number of ticks up and down.

I am trying to use indicator values on 1, 2 and 3 bars in my EA.


In the tester, I get an error: tickbs EURUSD,M1: array out of range in 'tickbs.mq4' (26,19)

Thank you.

Buffers are indexed from scratch.
 
Igor Makanu:

again and again.... A class is first and foremost a data type, like int, double...

You want an array of data of that type? - declare an array, if the array is dynamic, then resize it, then initialize EVERY ELEMENT with the necessary data - you need pointers, then initialize them with pointers to the class, you need class instances, then each element of the array will not be a pointer, but the object itself

that's the essence of OOP, any class is first of all a user data type.... i don't know how much to say about it, but the methodology is the same as with a regular data type, but what you will write inside the class is a personal matter, but the initialization of a new instance will always start with a constructor, and what constructor - by default, with parameters or without parameters - you can choose how to initialize the object...... ugh, but still read books, there is no way to do it in this way

Please advise what to read about OOP with examples for MT4. Or in general, with examples. The syntax and logic of the language is difficult to follow, and the language manual is not always clear to the end.

 
Valeriy Yastremskiy:

Please advise on what to read about OOP with examples for MT4. Or with examples in general. The syntax and logic of the language is difficult to grasp, and the language manual is not always completely clear.

Go to the Articles section here and browse - there is a lot on OOP, including for beginners.

Статьи по MQL5
Статьи по MQL5
  • www.mql5.com
Статьи по программированию на языке MQL5
 
Artyom Trishkin:

Please go to the Articles section here and browse through them - there are a lot of articles on OOP including those for beginners.

Thank you. That's helpful. Someone might need it.

PLO

https://www.mql5.com/ru/articles/357

https://www.mql5.com/ru/articles/703

https://www.mql5.com/ru/articles/116

https://www.mql5.com/ru/articles/70

https://www.mql5.com/ru/articles/351

GA

https://www.mql5.com/ru/articles/55

MQL4

https://www.mql5.com/ru/articles/1483

I liked it too)))

https://www.mql5.com/ru/articles/1499


Also a question, when you click on the articles, 18 pages of articles and the title appear:

Articles on Programming in MQL4 and MQL5

When I click on the second page MQL4 disappears. When I press on MT4, 6 pages will appear. And they are not in the initial selection.


Объектно-ориентированный подход к построению мультитаймфреймовых и мультивалютных панелей
Объектно-ориентированный подход к построению мультитаймфреймовых и мультивалютных панелей
  • www.mql5.com
В статье рассказывается о том, как объектно-ориентированный подход может быть использован для создания мультитаймфреймовых и мультивалютных индикаторов для MetaTrader 5. Главной целью является построение универсальной панели, которая может быть использована для отображения различных типов данных (цены, их изменения, значения индикаторов...
 
Alexey Viktorov:
Buffers are indexed from scratch.

Thank you.

 
Please, someone answer my query on the forum: https://www.mql5.com/ru/forum/336385
Как я могу скопировать symbols.raw и symgroups.raw в новый файл с дополнительной группой и символом в соответствующей группе MQL4/MT4?
Как я могу скопировать symbols.raw и symgroups.raw в новый файл с дополнительной группой и символом в соответствующей группе MQL4/MT4?
  • 2020.04.01
  • www.mql5.com
Я хочу знать, как я могу создать новый файл, скажем symbols_extra.raw и symgroups_extra.raw на MQL4, используя существующие symbols.raw и symgroups...
 
Valeriy Yastremskiy:

when clicking on the second page of MQL4 disappears. When you click on MT4 6 pages appear. And they are not in initial selection.

MQL4 and MQL5 are 99% identical (without SQlITE, OpenCL, DirectX), so you can feel free to read articles in MQL5, but considering that in terminals 4 and 5 the work with orders is different and there are nuances of working with timeseries

 
Igor Makanu:

Since MQL4 and MQL5 are 99% identical (without SQlITE, OpenCL and DirectX), you may read the articles on MQL5, but taking into account that in terminals 4 and 5 the work with orders is different and there are nuances of working with timeseries.

This is not the case, there are no articles on mql4 in the initial selection. This is misleading. By the way the same logic is in kodobase. But the headers just don't change there. I had to use the gut method to figure it out). Thank you, let's read)))

Reason: