Loading…

Resource Management Helper

A program that calls PlaySound("alert2.wav") or sets OBJPROP_BMPFILE to a bitmap path gets no useful error when the file is missing - PlaySound just plays nothing, and a bitmap object renders blank. On the downloader's own machine, whose Sounds and Images folders never contain the author's custom files, this is exactly what happens on first run, and nothing in the journal explains why. This header only checks what MQL4 can actually check: file presence inside the MQL4\Files sandbox, via FileIsExist() - the one location a program CAN see into. MQL4 has no API to check MQL4\Sounds\ or MQL4\Images\ directly, so this library asks custom resource files to be placed under Files\ instead, and does two different things with that verified presence. SafePlaySound() builds an absolute Windows path via TerminalInfoString(TERMINAL_DATA_PATH) and calls PlaySound() with it - which accepts a full path, unlike the sandboxed FileIsExist() itself - falling back to a standard terminal sound name when the custom file is missing. SafeCreateBitmapOrLabel() checks BEFORE calling ObjectCreate, since a bad OBJPROP_BMPFILE path has no failure signal to check afterward at all - MQL4 just renders a blank box - and substitutes a plain OBJ_LABEL with fallback text when the check fails, so the chart never shows a silently blank bitmap. Notes and limitations - FileIsExist() only sees into MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) (and \Common\) - it cannot confirm a file already placed directly into MQL4\Sounds\ or MQL4\Images\ by other means. This library's whole approach only works because it routes both sound and image access through the Files sandbox itself, rather than trying to verify those other folders. - For SafeCreateBitmapOrLabel(), the Files-sandbox check confirms the trader placed a copy under MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) - it does NOT confirm a matching copy also exists under MQL4\Images\, which is where OBJPROP_BMPFILE actually reads from. The two copies must be kept in sync by the trader; this library cannot verify that for you, and says so directly rather than implying otherwise. - SafePlaySound()'s fallback standard sound name (default "alert.wav") is never verified either, since MQL4 cannot check the Sounds folder at all - it is assumed present because every terminal installs it by default, not because this library confirmed it. - No resource is embedded or downloaded by this library - it only checks and reports on files the trader has already placed.

Script · MT4 · v1.0 · Free

About Resource Management Helper

Resource Management Helper is a script for MetaTrader 4. It has 2 settings, such as Sound relative path and Image relative path. MQL source code included.

Files in the download: ResourceManagementHelper.mqh, ResourceManagementHelper.txt, ResourceManagementHelperDemo.mq4.

Settings

SettingDefaultWhat it does
Sound relative pathMurodillo\\CustomAlert.wavSound file expected under MQL4\Files\
Image relative pathMurodillo\\CustomIcon.bmpImage file expected under MQL4\Files\

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: MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria