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

 
Roman Sharanov:

nothing, empty

Askhere.

 
Artyom Trishkin:

Askhere.

If it helps, it should draw arrows, on the euro, on the euro-yen, the aussie, on the others it does not

Files:
Hydra.mq4  9 kb
 
Roman Sharanov:

If it helps, it should draw arrows, on the euro, on the euro-yen, the aussie, on others it does not

Just a guess.

There is such a value in the settings:

input int so_slowma = 233;//Медленная МА

And then in OnInit():

   //---- установка номера бара, начиная с которого будет отрисовываться индикатор 
   SetIndexDrawBegin(0,so_slowma);
   SetIndexDrawBegin(1,so_slowma);

I see that daily bar data is used for the calculation:

if(so > so_minsize && fto > fto_minsize && fo[1] < 0 && fo[0] > 0 && (iHigh(_Symbol,PERIOD_D1,0)-iLow(_Symbol,PERIOD_D1,0))/daily_atr <= 0.6) buf_1[i+1] = Low[i+1] - 10 * Point;  
if(so < -so_minsize && fto < -fto_minsize && fo[1] > 0 && fo[0] < 0 && (iHigh(_Symbol,PERIOD_D1,0)-iLow(_Symbol,PERIOD_D1,0))/daily_atr <= 0.6) buf_2[i+1] = High[i+1] + 10 * Point; 

Are you sure there are enough bars on the symbols where there is no drawing? Put a smaller value in so_slowma variable - at least 100. If there will be rendering, then you don't have enough historical data.

It's just an assumption that came to mind the first time I looked at the code. And it may be wrong. But you need to check it first.

 

How can I make a rectangle https://docs.mql4.com/ru/constants/objectconstants/enum_object/obj_rectangle be drawn on top of another rectangle without mixing their colours?

Here, for example, a later horizontal line is drawn on top of an earlier horizontal line without mixing their colours, but I don't see what causes the difference from rectangles.

Thanks.

OBJ_RECTANGLE - Типы объектов - Константы объектов - Константы, перечисления и структуры - Справочник MQL4
OBJ_RECTANGLE - Типы объектов - Константы объектов - Константы, перечисления и структуры - Справочник MQL4
  • docs.mql4.com
Следующий скрипт создает и перемещает на графике прямоугольник. Для создания и изменения свойств графического объекта написаны специальные функции, которые вы можете использовать "как есть" в своих собственных программах. //| Cоздает прямоугольник по заданным координатам                    |               time1=0,           ...
 
Artyom Trishkin:

Just a guess.

There is such a value in the settings:

and then in OnInit():

I see that daily bar data is used for the calculation:

Are you sure there are enough bars on symbols where there is no rendering? Put a smaller value in so_slowma variable - at least 100. If there will be rendering, then you don't have enough historical data.

It's just an assumption that came to mind the first time I looked at the code. And it may be wrong. But you need to check it first of all.

That is, because I take data from a daily chart somewhere in the code, the indicator will not draw the first 233 days?
 
Roman Sharanov:
That is, because I take data from the daily data once in the code, the indicator will not draw the first 233 days?

No, it is not. This value indicates from which bar number the indicator will start drawing on the chart. But this number of bars is used to calculate the moving average. If there are less bars in the chart, the MA will not be calculated. In order to avoid this situation, at line 73, the code contains return from OnCalculate() in case of absence of bars for calculation:

if (Bars <= so_slowma) return (0);

Well, about the daily data - it may not be present, but it is more like "continuation of history"...

 
Artyom Trishkin:

No, it is not. This value indicates from which bar number the indicator will start drawing on the chart. But this number of bars is used to calculate the moving average. If there are less bars in the chart, the MA will not be calculated. To avoid this situation, in the code, at line 73 we wrote return from OnCalculate() in case of absence of bars for calculation:

Well, about the daily data - it may not be there too, but it's more like "continuation of history"...

The pound, for example, has more than 1000 bars on the daily and on m15, but it does not draw...

 
Roman Sharanov:

Well the pound for example, both on the daily and on m15 is over 1000 bars, but it doesn't draw...

You have the source code. Print out the values of all the variables in the log and see what they get.

 
Artyom Trishkin:

You have the source code. Print out the values of all the variables in the log and see what they get.

Where is this coming from?


 
Roman Sharanov:

Where does this come out of?


Rubbish in the buffers. First you have to enter a blank value into all the buffers to be drawn (if they are arrow buffers), and only then perform the calculation of the indicator. I can't see the code from my mobile, so I can't say exactly.