Loading…

Delete All Chart Objects

A chart accumulates trendlines, text labels, rectangles and Fibonacci tools from months of manual analysis, and clearing it by hand means clicking each one or hunting through the Object List dialog. Across a watchlist of charts that is not a two-second job. The naive version of this script only clears the main chart window. Any object drawn inside an indicator subwindow - a trendline on an RSI panel, a horizontal level on a custom oscillator - is left behind, because the delete call defaults to window 0 when a subwindow is not specified. This script passes -1 explicitly, which means every subwindow and the main window in one call, so nothing survives the sweep by accident. The other place this kind of script usually goes wrong is scope. "Delete all" sounds like it should include indicators, since visually they clutter the chart the same way objects do. It does not, deliberately: an indicator is a running program with its own settings and buffers, an object is a static drawing, and a button that can silently remove a study someone is relying on is not a button anyone should trust. This script never calls IndicatorRelease or touches the indicator list - only ObjectsDeleteAll. Deleting an object is immediate and does not reload the chart, unlike applying a template or changing a chart's symbol or period. So unlike the other bulk chart scripts in this catalogue, there is no "current chart last" trap here - the chart running the script is processed in its ordinary turn in the list. Notes and limitations - Objects only. Chart indicators, Expert Advisors and scripts attached to a chart are never touched. - The chart walk is capped at 200 charts as a defensive limit; a normal terminal session will never come close to that. - Deleted objects cannot be recovered by this script. There is no undo beyond the terminal's own object history, which is why the confirmation prompt shows the real count rather than an estimate. - Object visibility timeframe flags and other per-object settings are irrelevant here - every matching object is removed regardless of which timeframes it was set to show on.

Script · MT4 · v1.0 · Free

About Delete All Chart Objects

Delete All Chart Objects is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as All charts and Confirm first. MQL source code included.

Files in the download: DeleteAllObjects.ex4, DeleteAllObjects.mq4, DeleteAllObjects.txt.

Settings

SettingDefaultWhat it does
All chartsfalseApply to every open chart, not just this one
Confirm firsttrueAsk for confirmation before deleting

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: RSI · Fibonacci · Trend · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria