Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

CTsLogger is a simple and flexible logging system - library for MetaTrader 5

Views:
321
Rating:
(5)
Published:
2025.05.20 11:38
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

CTsLogger is a simple and flexible logging system specially designed for creating and debugging trading systems in MQL5. The main advantage of CTsLogger is the ability to temporarily enable the debugging mode for specific modules or code sections while maintaining a lower global logging level. Thus, you can get detailed logging of certain code sections without "drowning" in the flow of messages, and then disable it with one command.

.

CTsLogger supports 4 levels of logging, in ascending order of detail:

1. LOG_LEVEL_ERROR - errors only

2. LOG_LEVEL_WARNING - warnings and errors

3. LOG_LEVEL_INFO - information messages, warnings and errors

4. LOG_LEVEL_DEBUG - debug messages, informational messages, warnings and errors


CTsLogger supports hierarchical module identifiers separated by a dot, which allows you to organise modules into a logical structure. The hierarchy can have any nesting depth.

Full API

Creation and initialisation

- `CTsLogger()` - constructor

- `~CTsLogger()` - destructor

- `Initialize(string logFileName, bool logToTerminal = true)` - initialisation of the logger

- `SetGlobalLogLevel(ENUM_LOG_LEVEL level)` - set global logging level

Methods of logging

-`Error(string moduleId, string message)` - logging of errors

-`Warning(string moduleId, string message)` - logging warnings

- `Info(string moduleId, string message)` - logging of information messages

-`Debug(string moduleId, string message)` - logging debug messages

Basic debug mode control

- `EnableDebugMode(string moduleId)` - enabling debug mode for a module

- `DisableDebugMode(string moduleId)` - disable debug mode for a module and all its child modules

- `IsInDebugMode(string moduleId)` - check if debug mode is enabled

- `EnableDebugModeAll()` - enable debug mode for all modules

- `DisableDebugModeAll()` - disable global debug mode with saving of modules settings

Advanced debug mode control

- `PauseDebugMode()` - temporary suspension of debug mode for all modules

- `ResumeDebugMode()` - resume debug mode for previously configured modules

- `IsDebugModePaused()` - check if debug mode is paused

- `ResetDebugModules()` - complete reset of all debug modules

- `HasChildDebugModules(string parentModule)` - check if child modules are in debug mode



Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/58105

EquiPeak Drawdown Tracker EquiPeak Drawdown Tracker

EquiPeak Drawdown Tracker is an indicator designed to monitor and record the maximum drawdown of your trading account in real time. It is not just an alerter of current drawdown; it is especially useful for visually comparing your current drawdown with the maximum historical drawdown you expect or have previously recorded.

DailyHighLow Indicator for MQL5 DailyHighLow Indicator for MQL5

The DailyHighLow indicator is a versatile tool designed for MetaTrader 5 (MQL5) to display high and low price levels on a chart based on a specified timeframe. This indicator is particularly useful for traders who rely on key price levels for decision-making, offering flexibility through customizable timeframes and price calculation methods.

Butterfly Strategy Expert Advisor with Multiple TimeFrames Butterfly Strategy Expert Advisor with Multiple TimeFrames

Butterfly Strategy Expert Advisor This Expert Advisor (EA) implements the Butterfly harmonic trading pattern across multiple timeframes (M2 to D1) for automated forex trading. It detects bullish and bearish Butterfly patterns using pivot points and executes trades with customizable risk management and multiple take-profit levels.

Auto SL TP by Risk Reward Ratio Auto SL TP by Risk Reward Ratio

The Auto SL TP by Risk Reward Ratio script is a simple yet powerful tool designed for MetaTrader 5 traders who want to streamline their risk management process. This script automates the process of setting Stop Loss (SL) and Take Profit (TP) levels for open positions based on a user-defined Risk:Reward ratio and Stop Loss in pips. Whether you're a beginner or an experienced trader, this script saves time and ensures consistent risk management.