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

 

@Oleg

Ask the developers to put the error number as in the Documentation, it is not clear why it is in the Documentation and not used in the Editor in the Description

https://www.mql5.com/ru/docs/constants/errorswarnings/errorscompile

Документация по MQL5: Константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
Документация по MQL5: Константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
  • www.mql5.com
Импортируемая функция не может иметь такого параметра (нельзя передавать указатель, класс или структуру, содержащую динамический массив, указатель, класс и т.д.) Недопустимый возвращаемый тип. Например, такая ошибка будет выдана для функций, импортированных из...
 
Alexandr Sokolov:

simply specify the buffer index to be assigned during initialisation in SetIndexBufer


I'm not good at programming, there is no buffer in the code of the indicator through which it outputs data

 
edelweiss7:

I am not good at programming, in the code of the indicator there is no buffer through which it outputs data

I haven't dug deep into your code, but I understand it draws levels


... you need the OnChartEvent handler

https://www.mql5.com/ru/docs/event_handlers/onchartevent

monitor the creation of new objects (it'sCHARTEVENT_OBJECT_CREATE), and if the name prefix is from your indicator - take the properties of the created line (there the price and time of its points)

Документация по MQL5: Обработка событий / OnChartEvent
Документация по MQL5: Обработка событий / OnChartEvent
  • www.mql5.com
//|                                          OnChartEvent_Sample.mq5 | //|                        Copyright 2018, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | //| Expert initialization function                                   |...
 
Alexandr Sokolov:

I didn't go into your code in depth, but I understand it draws levels


... you need an OnChartEvent handler

https://www.mql5.com/ru/docs/event_handlers/onchartevent

monitor the creation of new objects (it'sCHARTEVENT_OBJECT_CREATE), and if the name prefix is from your indicator - take the properties of the created line (price and time of its points there)

How to implement this in an EA
 

Please help me to correct an error that appears in my log:

MQL4 Market: failed to load products (get header failed [12150])

 
The handler (mt5, indictaor) handles button presses repeatedly. What could be the reason for this?
 
Yevhenii Levchenko:
The handler (mt5, indictaor) handles button presses repeatedly. What can be the reason for this?

redraw - ChartRedraw()

 
Yevhenii Levchenko:
The event handler (mt5, indictaor) handles button presses sometimes. What can be the reason?

without a sample diagram of how you process events is just guessing

Alternatively, run it in the Indicators folder Examle\SimplePanel

and if this code works correctly ... guess for yourself ;)

 
Yevhenii Levchenko:
The handler (mt5, indictaor) handles the button presses in a time interval. What could be the reason for this?

just did the same bug this morning :-)

The button is adapted to work in the tester and works by polling, not completely in the OnChartEvent.

The error was in the check type

if (ObjectGetInteger(....,OBJPROP_STATE)!=state /* это баг, должен быть 0 */) {

    // состояние поменялось

    state=!state;

}

 

Good morning.

The point is that the last 50 candles are calculated for the average.

Question. What to add, fix in the code to calculate once and not every tick. The problem is that in ON-LINE there is an accumulation of value.

for(int j=rates_total-50-1; j<rates_total-1; j++)
     {
      if(open[j]>close[j])
         candleOC+=open[j]-close[j];
      if(close[j]>open[j])
         candleOC+=close[j]-open[j];
      candleHL+=high[j]-low[j];
      bar+=1;
     }
   if(bar>0)
     {
      filterOC=candleOC/bar;
      filterOC=NormalizeDouble(filterOC,_Digits);
      filterHL=candleHL/bar;
      filterHL=NormalizeDouble(filterHL,_Digits);
     }
//filterHL=0.00500;  //пример среднего значения HL
//filterOC=0.00250;  //пример среднего значения OC
Reason: