거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

Logging library for mql4 - MetaTrader 4용 라이브러리

조회수:
4573
평가:
(23)
게시됨:
2021.06.08 18:39
업데이트됨:
2021.06.09 07:46
\MQL4\Include\
Logger.mqh (5.49 KB) 조회
\MQL4\Scripts\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

This is a logging library to quickly add logging capabilities to your code without  much hassle. The library's default behavior matches most cases however most of the functionality can be customized using pre-processor substitutions (#define)

See the example scripts on how to use library.

How to use

#include <Logger.mqh>

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   DEBUG("This id debug");
   INFO("This is info");
   ERROR("This is an error");
  }
//+------------------------------------------------------------------+


Customization notes

    • The logger uses following format to print logs
      // [time, except LOGGER_PRINT,LOGGER_ALERT] [level] [prefix] [message] [last error, only Logger::Error]
      sample output: 2021.06.08 17:35:34 | Error | OnStart | This is a test error | invalid function parameter value


        • Use following logging functions/digits to assign them to logging levels. define as 0 if the level needs to be disabled
          #define LOGGER_PRINT    1     // print to log
          #define LOGGER_ALERT    2     // trigger alert
          #define LOGGER_FILE     4     // write to a file
          #define LOGGER_NOTIFY   8     // send a notification

          example:

          #define LOGGER_SET_DEBUG 0       // DEBUG is disabled
          #define LOGGER_SET_INFO  1|2     // Print and alert
          #define LOGGER_SET_ERROR 1|2|4   // Print, alert and file write 


          • Customize the prefix section as follows
          #define LOGGER_PREFIX __FILE__ + " | Line:" + IntegerToString(__LINE__) // [filename] | [Line number]
          an example prefix output will be : with_customization.mq4 | Line:36


          • Customize file name by a string constant or a function call
          #define LOGGER_FILENAME "backtest_debug.log"
          // or
          #define LOGGER_FILENAME IntegerToString(AccountNumber())



          Notes:

          • #define before the Logger.mqh is included.
          • To disable a logger level set the level as zero.
          • LOGGER_NOTIFY and LOGGER_FILE execution errors are handled as a print statements. Do not customize it to use library's own error handling, the program might trigger an infinite loop or a stack overflow.


          SCT - The Overall Percent Risk - MT4 SCT - The Overall Percent Risk - MT4

          Building good trading habits by seeing things in terms of percentage not in terms of money.

          Tipu MACD EA Tipu MACD EA

          Tipu MACD EA is a simple EA created to automate buy/sell orders based on the MACD indicator. You can automate entries and manage trades. This EA comes with many useful functions that can used to by anyone to create their own EA.

          moving average moving average

          candle cross 3 moving averages

          Validate Me framework Validate Me framework

          Checks a trading robot must pass