I try to draw a horizontal line, when a button is pressed.
In addition, when the same button is pressed for a second time, I like to remove the horizontal line. So on so forth.
The problem is that if I insert code related to drawing objects inside the inner if conditional block, the behavior of the OnChartEvent() becomes totally unstable.
Just add the highlighted part to further filter the chart events:
if (btn_test1.Pressed() && id==CHARTEVENT_MOUSE_MOVE)
Libraries can make programming easier, but it seems to make it more complicated.
I don't know what's going on.
Instead, I extracted the functions of the panel display from the ranking board which I use and created a new program as follows.
This is a "indicator", not "EA".
I plan to make trade orders in this code, so I suppose I need an EA.
But I would like to thank for your attention.
![Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions](https://c.mql5.com/36/33/documentation-on-mql5-constants__28.png)
- www.mql5.com
Just add the highlighted part to further filter the chart events:
Thank you very much.
It works.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I try to draw a horizontal line, when a button is pressed.
In addition, when the same button is pressed for a second time, I like to remove the horizontal line. So on so forth.
The problem is that if I insert code related to drawing objects inside the inner if conditional block, the behavior of the OnChartEvent() becomes totally unstable.
I added Print() lines in order to debug it where Print() functions executed several times and sometimes the line is not deleted.
I could not figured out, what is going on.
Please while testing also try to comment out the ObjectDelete() function, and vice versa.
Click at least 10 times to the button, then check the Experts tab for printed lines.
Thank you.