Today we are going to create a simple script for Metatrader 5 that will instantly delete all objects on the active chart window. If you are experimenting with graphical objects or if you are using indicators that do not redraw graphical objects automatically, the script will save your time.

First, open MetaEditor 5 and press the "New" button. The MQL5 Wizard will start up. Select "Script" and press "Next":

Delete all Objects Script for Metatrader 5

Now give a name to your script and fill your copyright information - author and website, then press "Next":

Delete all Objects Script for Metatrader 5

A window with the code for your script will appear. Our script is probably the easiest one, because it contains only one line of code. Add this line of code as shown on the picture:


ObjectsDeleteAll(0);
//---


Now press the "Compile" button and make sure that no errors appear in the debugging window below:

Delete all Objects Script for Metatrader 5

The script is saved in your Scripts folder. Now open Metatrader 5 terminal and add some graphical objects to the chart. Now open the navigator window, select your script and drag it to the chart window. All graphical objects will instantly disappear. It's much faster than doing it by hand, isn't it?

Delete all Objects Script for Metatrader 5

As you can read in the MQL5 reference guide, the ObjectsDeleteAll function removes all objects from the specified chart. You can also specify such variables as chart id, type of object that will be removed, etc. In our case "0" means the current chart. If you want to learn more about this function, search for "ObjectsDeleteAll" in the MQL5 reference guide.

1 comments

Jenny said... @ February 13, 2022 at 6:48 PM

Bellow are some common mistakes you should avoid

The cryptocurrency craze is growing like wildfire, gaining widespread acceptance and attracting the attention of all and sundry for investment and trading. Such is the frenzy that recently the global crypto market cap had even topped the $3 trillion mark for the first time. Suddenly, everyone wants a part of the crypto pie.
As a crypto trader, if you want to make the most of your investments, here are 5 common mistakes you must avoid.

1. Not having a goal
Starting crypto trading without setting a goal can make your investments go haywire and not prove as cost-effective and lucrative as they can be otherwise. A well-planned goal helps you navigate cautiously in the crypto world. You should have a clear purpose in mind before jumping onto the crypto bandwagon. The motive should not be driven by Fear of missing out (FOMO) or by the desire to make a quick buck.

2. Thinking short term
It is highly advisable for investors to view the crypto investment as long-term due to the volatile and immature nature of the market. Since new things are being tested constantly in the crypto market, it is still nascent and unpredictable. The market could be booming at one moment and withering at the other moment. A long-term approach will help you reap better returns.

3. Directly jumping to trading without any knowhow
It is wise to not trade in the crypto market directly without proper know-how due to the highly mercurial nature of cryptocurrencies. Thorough research including fundamental knowledge and technical analysis about cryptocurrencies is extremely essential before investing in cryptos. Moreover, there are trading simulators that can help you sharpen your crypto trading skills.

You should join crypto quantum leap crypto course and earn Crypto without any loss

Post a Comment