MetaEditor HelpProjects and MQL5 StorageWorking with Storage

Working with Storage

The MQL5 Storage (or repository) only works with the MQL5 (or MQL4) folder of the trading platform, and with the special Shared Projects directory, which is used for group projects.

All operations with the MQL5 Storage are performed via the context menu of the Navigator window and through the context menu of the source code editor:

MQL5 Storage menu

Using the menu commands, you can perform the following actions in the MQL5 Storage:

  • Receive data from Storage;
  • Commit to Storage;
  • Add files/folders to Storage;
  • Delete files/folders from Storage;
  • Cancel current changes in the local copy of data;
  • View logs of data changes in Storage;
  • View changes in the working copy of the file.

Getting started #

Storage contains the information as a tree of files. When connecting to Storage, a MetaEditor user reads and writes these files. The user always works with a local copy of data and, if necessary, sends changes to Storage.

To begin to work with data in the MQL5 Storage, you must associate a local data folder with the appropriate folder in the repository:

  • If you have just created a repository, it is empty. You need to add a directory to it. After that, an appropriate directory is created for the specified directory in the repository (at the same path relative to the /MQL5 folder). This is a root directory. All operations with files are performed in this directory.
  • If the storage already has some data, download them to a local directory. To do this, click Update from Storage "Update files from Storage" in the context menu of the root MQL5 (or MQL4) element in the Navigator.

Versioned data storage

Version control is implemented for directories/files associated with the repository, therefore such directories/files have a version, i.e. a revision number. A revision number corresponds to each data update. Each time you update the directory/file in the repository, the revision number is incremented for this directory/file and for the entire root directory. A revision is a state of the directory/file at a point of time.

The root directories are the MQL5/MQL4 folder and folders of each shared project. Revisions are managed separately for each root directory, so they have individual revision numbers. When you commit changes made to the MQL5 directory, its revision number is increased, while the revision number of projects does not change (unless the projects use shared files from the MQL5 directory).

General operation scheme:

  • When you add a file to the MQL5 storage or extract it from the storage to a local PC, its versions (revision number) on the computer and in the storage will match.
  • The revision numbers of the local file (the working copy) and the appropriate file in the storage are initially equal. This happens if you just added a file or extracted it from the repository.
  • If you change the file and commit changes to the repository, the revision number will increase both locally and in the repository.
  • When you submit changes, it may turn out that the file has already been edited by someone and the revision number in the repository is greater than your local one. In this case, you should extract changes from the repository before sending your own changes. MQL5 Storage will try to merge changes in the repository and your local file. In this case, the revision number of the local file will be set equal to the revision number of the file in the repository.

Each transaction of changes is recorded in the Storage journal, and later the user can view when, by whom and what files were changed. The user can also update the local data copy to a selected revision and revert changes to a selected revision.

Adding to Storage #

To add a folder or file to the repository, select it and execute the Add File or Folder Add File or Folder command. This brings up a dialog box showing the list of folders and files to be added.

  • Files are added locally. To send changes to the repository, execute Commit to Storage Commit to Storage.
  • MQL5 Storage only works with the following types of files: mq4, mq5, mqh, cpp, h, bmp, wav, ex4, ex5, tpl and set. Other types of files cannot be added to the repository.
  • Files larger than 64 MB cannot be added to the storage.

Adding the folder to Storage

Tick ​​off the necessary files and folders and click OK.

  • The principle of storage operation does not allow to add files without the folder in which they are located. You cannot add a file located in the folder, which is not added to the repository.
  • You cannot add individual files to the root directory /MQL4 or /MQL5.
  • In the folder associated with the repository, only its child directories can be added. Folders that are lower in the hierarchy cannot be added without their parent folders.

Added files and folders are marked with Added to Storage:

Added files and folders

Next, these changes should be sent to the repository. Select the added folder/file and execute Commit to Storage Commit to Storage.

Committing to Storage

In this dialog, you can also choose the changes that should be sent to the repository. You can add a comment when committing changes. Detailed comments facilitate the analysis of changes in the future.

After committing the current changes in the repository, the corresponding folders and files are marked with No changes. This means that the local copy of data does not differ from the one that is in the storage at the time of the last commit/update operation.

  • If a folder that corresponds to the one you add already exists in the storage, error "Folder already exists, update it from storage" will appear. For such a folder select Update from Storage Update from Storage. After that, it will be bound to Storage, and data from the repository will be added to it. Then you can send your changes to the repository using the Commit to StorageCommit to Storage command.
  • If the file size exceeds 1 MB, selection is automatically removed from it in the commit dialog. Download large files with care to avoid overloading the storage system.

Checkout and update from the MQL5 Storage #

Primary data extraction is executed when the storage is activated in MetaEditor. Once you execute the Activate MQL5 Storage Activate MQL5 Storage command, MetaEditor will check if Storage contains any data.

  • If Storage contains data from the MQL5 (MQL4) directory, these data will be instantly downloaded to the computer.
  • If Storage has available shared projects, these projects will appear in the Shared Projects section. To download project files to a local computer, click Update from Storage Update from Storage in the context menu of the project.

Further updates can be received from the Storage using the Update from Storage Update from Storage command in the context menu of files and folders in the Navigator.

If the storage contains folders that do not exist in your local working copy, execute Update from Storage at the MQL5 (or MQL4) root element in the Navigator window. All data from the Storage will be downloaded to the corresponding local folders. The revision number of data will match the revision of data in the storage.

Updating data

If a local folder contains data, then during checkout data obtained from the repository will be added to it. New files will be added. For files with matching names and paths it will try to merge data.

Updating to revision #

MQL5 Storage stores the entire history of changes committed by users to the storage. Each commit of changes is a new revision (state of the storage at a particular time). During parallel work of multiple users with data through the storage, you need to periodically receive changes made by other users. Update to Revision Update to revision allows you to gradually update the local copy of data from the repository.

For example, since the last update of the local copy of data, three new revisions appeared in the storage. You can first upgrade to the first revision, then to the second and to the third one.

To update to a specific revision, select a file or folder and call the storage log by clicking Show Storage Log Show Storage Log.

Updating to revision

In the window that opens, select the required revision and run the Update to Revision Update to Revision command.

  • A local copy of data can only be updated to a higher (later) revision.
  • Data obtained from the repository are added to the local copy. For files with matching names and paths, it will try to merge data. If files have been added to a revision, they will be added to the local copy. If files have been deleted from a revision, they will be deleted from the local copy.

Reverting to revision #

MQL5 Storage stores the entire history of changes committed by users to the storage. Each commit of changes is a new revision (state of the storage at a particular time). At any time, you can return to one of the previous states of a file or folder.

To revert to a specific revision, select a file or folder and call the storage log by clicking Show Storage Log Show Storage Log.

Reverting to revision

In the opened window, select the required revision and click Revert to This Revision Revert to This Revision.

After reverting to the revision, the selected file/folder will fully return to the specified state. You can revert both to earlier and to later revisions.

Committing changes to Storage #

As mentioned earlier, you can work with the data only in their local copies. To transfer local changes to the repository, use the Commit to Storage Commit to Storage command. Local files and folders that have been changed are marked with an icon Changed.

Before committing changes, you can view them by selecting a file and selecting Difference of Versions Difference of Versions in the context menu.

Committing to Storage

In the commit dialog, you can select changed files and folders that should be committed to the repository. You can add a comment when committing changes. Detailed comments facilitated the analysis of changes in the future.

  • Local changes are of higher priority, in any case they are added to Storage.
  • If the revision number in the storage is above the local revision (modified from another source, and local data is not updated from the repository), then you will get an error like "Out of date" when trying to commit the changes. In this case, first execute the Update from Storage Update from Storage command to merge data, and then select the Commit to Storage Commit to Storage.
  • Be careful when updating bmp and wav files. When merged, these files are completely replaced by newer revisions. Thus, during update they may be replaced with files from the repository. To avoid such situations, save copies of these files separately, execute the Update from Storage Update from Storage command to increase the number of the local revision, move the previously copied files back and commit changes to Storage.

Deleting #

If you want to delete a file or a folder, use the command Delete File or Folder Delete File or Folder. The folder/file will be deleted from the local copy of data. To delete a file or a folder from the repository, commit these changes using the Commit to Storage Commit to Storage.

  • Deletion of a file or folder by the standard Delete Delete command of the Navigator window does not influence the MQL5 Storage. With the next update, the deleted data will be restored from Storage.
  • The root directory linked to Storage cannot be deleted.

Reverting changes #

If you want to undo the changes made in the current local copy of data, execute the Revert Changes Revert Changes command for a necessary file or folder. The file/folder returns to a state that was saved locally during the previous synchronization with the repository.

When you revert changes, the initial local revision is restored, not the current revision in the repository.

Storage log #

Each commit of changes to Storage using the Commit to Storage Commit to Storage command is saved in the log. The logs help you to easily analyze the history of changes in your projects. To view the change log of a file/folder, select Show Storage Log Show Storage Log.

Viewing the log

The upper part shows a list of changes:

  • Revision – the unique number of the commit;
  • Author – the name of the user (same as the login of the MQL5.community account), who made these changes;
  • Date – date when the changes were committed in the UTC format;
  • Comment – comment to changes.

Using the context menu command Update to Revision Update to Revision, you can update the local copy of data to a selected revision.

The bottom of the window displays a list of files modified in the selected revision. Icons show the types of changes:

  • Added – file added;
  • Changed – file changed;
  • Deleted – file deleted.

Using the context menu of the list of modified files, you can analyze the changes:

  • Compare with Working Copy Compare with Working Copy – compare the selected file with its working copy.
  • Compare with Previous Revision Compare with Previous Revision – compare the selected file with its previous revision.
  • Compare Revisions Compare Revisions – compare two revisions of a file pre-selecting them at the top of the window.