Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1285

 
Vitaly Muzichenko:

I did:

The difference is insignificant and also acceptable. But if the user decides to change the thickness or colour, they must be set in the input parameters since they have variables, your code won't change them without removing the trend.

In general, there is no need to argue about the tastes of the markers.

 
Alexey Viktorov:

Completely wrong decision. Deleting a graphical object and updating a graph in no way replace each other.

In my example, first we check if there is an object, in particular a trend with the name tfyu, which is name in the Russian keyboard layout)). Then, if it does not exist, the trend is drawn. If the drawing attempt is unsuccessful, the message is displayed and the function is exited with return false.

Everything after that, irrespective of whether the trend is already present or has just been drawn, it is assigned the specified parameters, time and coordinate prices, type, thickness and anything else you can add. After that the chart is updated and the function returns true.

In terms of speed of execution, it will be less expensive to check for the presence of the trend than to delete it and draw a new one.

But... the final decision is up to you and if you like scratching your left ear with your right little finger, I have no right to stop you.

Thank you very much. I'll take your advice and redo the code.

 
Vitaly Muzichenko:

I am:

Thank you very much. I'll redo the code. Already redone it, it's all ok.

 
string obj_symbol=ObjectGetString(ChartID(),obj_name,OBJPROP_SYMBOL);

Does it not work at all? Does it return an object character for anyone? I always get an empty string.

Or does it have to set this property first...?

 
leonerd:

Does it not work at all? Does it return an object character for anyone? I always get an empty string.

Or does it need to set this property first...?

It's a specific property - for a "Chart" object it returns a symbol. And for which type of object are you trying to get a symbol?

 
Vladimir Karputov:

This is a specific property - for a "Chart" object it returns a symbol. And what type of object are you trying to get a symbol for?

For a triangle. How do you know its "symbol"?

 
leonerd:

for a triangle. How do you know its "symbol"?

What do you mean? What is the symbol for the triangle object?

 
Vladimir Karputov:

What do you mean? What is the symbol for the Triangle object?

How do you know on which symbol chart the Triangle object was created?

For example, in OnChartEvent(). Or in the list of objects, when going through the list, how do you know which symbol chart the object is drawn on?

 
leonerd:

How do I know on which symbol chart the Triangle object was created?

For example, in OnChartEvent(). Or in the list of objects, when going through the list, how to find out which symbol's chart the object is drawn on.

OnChartEvent is triggered only for the current symbol - in this case it is meaningless to recognize the symbol: it is always positioned.

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

 
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.

OK, thanks

Reason: