Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1286

 
Vladimir Karputov:

OnChartEvent is only triggered for the current symbol anyway - in this case there is no point in recognising the symbol: it is always placed.

The second way is to bypass the list of all charts - ObjectFind.

In the meantime, could you tell me what kind of error is this?

2021.02.02 18:06:55.780 GDICache        pen creation error [87]
2021.02.02 18:06:56.251 GDICache        pen creation error [87]
2021.02.02 18:06:56.556 GDICache        pen creation error [87]
2021.02.02 18:06:56.677 GDICache        pen creation error [87]
2021.02.02 18:06:56.969 GDICache        pen creation error [87]

I found out the reason. Came up during debug when specifying line properties. Line style was left value. It's just strange that I haven't found any mention of this error anywhere.

 
Aleksandr Prishenko:

It used to work wonderfully. I should have tried it on free hosting. Anyway gave the methaquotes 15 quid ))))

Thanks for the reply!

Migrated (regretted the 15) but the checks are quite strange.

Migrator does not understand indicator installation path from EA, have to clean charts:

2021.02.02 19:57:39.442 Virtual Hosting 6215402: check for load "C:\Users\Crucian\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\BBS_9.ex5::Indicators\Band Width1.ex5"

2021.02.02 19:57:39.442 Virtual Hosting 6215402: failed to load program


Migrator even asks to recompile technical indicators )):

2021.02.02 19:44:12.708 Virtual Hosting 6215402: obsolete version of imported module "ZigZag.ex5" should be recompiled before transfer to the hosting server



 
Afternoon, have seen many articles on how to build an EA from an indicator or how to get data from an indicator into an EA. And how to do the opposite, how to visualise an EA, say it has calculated an array of data how to transfer it to a custom indicator?
 
VANDER:
Afternoon, have seen many articles on how to build an EA from an indicator or how to get data from an indicator into an EA. And how to do the opposite, how to visualize an EA, say it has calculated an array of data how to transfer it to a custom indicator?

Through a pluggable .mqh in which everything is counted and the EA takes from there, and the indicator...

 

Hello! How can I make the MT5 platform magnetise the line in the Moving Averages indicator? To make the trend line stand up clearly and be magnetized to the indicator line. In the platform settings in the charts there is a "magnetizing" item, there the trend line is put on the opening price. Is there such a way for a moving average and a simple trendline?


 
leonerd:

Start the debugger, put a breakpoint on the type variable. I draw a triangle (Insert - Objects - Shapes - Triangle) on the chart. Press Delete, triangle is removed. I catch an event, type in above code is always 0. type_str, respectively, is OBJ_VLINE (first value in enumeration).

The same code returns OBJ_TRIANGLE as the correct object type when a graphic object's properties are changed or dragged.

Output. When deleting a graphical object it fails to get the object type in OnChartEvent.

It's still unclear how to get the type of a deleted object. The object name in OnChartEvent() comes correct but the type is always 0. Is the above described a bug or should it be done in some other way?

//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_DELETE)
     {
      string object_name=sparam;
      ENUM_OBJECT object_type=(ENUM_OBJECT)ObjectGetInteger(ChartID(),object_name,OBJPROP_TYPE); // object_type всегда VLINE
     }
  }
 
leonerd:

It's still not clear how to find out the type of the deleted object. The object name in OnChartEvent() comes correct, but the type is always 0. Is the above described a bug or should it be done differently?

ObjectType(sparam)
 
Vitaly Muzichenko:

What is ObjectType() function?

It seems to be a branch about MQL5.

Obviously, it was designed that way. The other parameters of the deleted object cannot be retrieved. It receives only the name. Coordinates, etc. are all zero. Is there any way to retrieve them from event of deleting a graphical object?

 
leonerd:

What is ObjectType() function?

It seems to be a branch about MQL5.

Obviously, it was designed that way. The other parameters of the deleted object cannot be retrieved. It receives only the name. Coordinates, etc. are all zero. Is there any way to get them from deleting a graphical object?

Yes, I didn't expect it in mql5, but there is an analogue:

ObjectGetInteger(0,name,OBJPROP_TYPE)

You want to get the object's parameters by the deletion event, i.e. after it's already gone.

 
leonerd:

What is ObjectType() function?

It seems to be a branch about MQL5.

Obviously, it was designed that way. The other parameters of the deleted object cannot be retrieved. It receives only the name. Coordinates, etc. are all zero. Is there any way to get them from the event of deleting a graphical object?

Probably, such possibility doesn't exist and is not expected. After all the object already exists...

I see such way out: At creation of object, in an array structure to write the name and all required parameters, and on removal, after reading the required parameters remove from the array structure record about it.

Reason: