Watch how to download trading robots for free
Find us on Facebook!
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

Comment - library for MetaTrader 5

Views:
1991
Rating:
(10)
Published:
2024.11.14 17:29
Updated:
2024.12.05 16:27
Example.mq5 (0.94 KB) view
Comm.mqh (19.43 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

A simple replacement for a comment. Works in the tester 50 times faster than the standard function.


It is known that the standard "Comment" function slows down the tester very much.

Here is an example of code and its execution time in the tester.

void OnTick()
  {
   MqlTick tick;
   SymbolInfoTick(_Symbol, tick);
   if(tick.ask != 0 && tick.bid != 0)
     {
      string str = StringFormat("ask  = %.5f\nbid  = %.5f\ntime = %s", tick.ask, tick.bid, TimeToString(tick.time, TIME_DATE | TIME_SECONDS));
      Comment(str);
     }
  }
//+------------------------------------------------------------------+

11 minutes 28 seconds  !!!

Just add the code  #include <Comm.mqh>

#include <Comm.mqh>
//+------------------------------------------------------------------+
void OnTick()
  {
   MqlTick tick;
   SymbolInfoTick(_Symbol, tick);
   if(tick.ask != 0 && tick.bid != 0)
     {
      string str = StringFormat("ask  = %.5f\nbid  = %.5f\ntime = %s", tick.ask, tick.bid, TimeToString(tick.time, TIME_DATE | TIME_SECONDS));
      Comment(str);
     }
  }
//+------------------------------------------------------------------+

14  seconds !!!  

14 seconds instead of 11 minutes 28 seconds

11*60+28=688,    688/14=49,   49 times faster!!!




Example of usage with default settings.

No need to declare an instance of the class.

#include <Comm.mqh>
//+------------------------------------------------------------------+
void OnTick()
  {
   string str = "PROGRAM_NAME = " + MQLInfoString(MQL_PROGRAM_NAME) + "\n" + (string)TimeCurrent();
   Comment(str);
  }
//+------------------------------------------------------------------+

Example of use with the ability to change settings.

#include <Comm.mqh>
//+------------------------------------------------------------------+
void OnTick()
  {
   string str = "PROGRAM_NAME = " + MQLInfoString(MQL_PROGRAM_NAME) + "\n" + (string)TimeCurrent();
   Comment(str, _Xpx, _Ypx, _clrText, _FontSize, _clrBack, _Transparency, _Font, _corner);
  }
//+------------------------------------------------------------------+

Example of using multiple instances of a comment.

#include <Comm.mqh>
CComm comm1;
CComm comm2;
CComm comm3;
CComm comm4;
//+------------------------------------------------------------------+
void OnTick()
  {
   MqlTick tick;
   SymbolInfoTick(_Symbol, tick);
   if(tick.ask != 0 && tick.bid != 0)
     {
      string str = StringFormat("ask  = %.5f\nbid  = %.5f\ntime = %s", tick.ask, tick.bid, TimeToString(tick.time, TIME_DATE | TIME_SECONDS));
      Comment(str);
      comm1.Comm(str, _Xpx, _Ypx + 80, _clrText, _FontSize, _clrBack, _Transparency, _Font, _corner);
      comm2.Comm(str, _Xpx + 10, _Ypx + 20, _clrText, _FontSize, clrGreen, _Transparency, _Font, CORNER_LEFT_LOWER);
      comm3.Comm(str, _Xpx + 30, _Ypx, clrGreen, _FontSize, _clrBack, _Transparency, _Font, CORNER_RIGHT_LOWER);
      comm4.Comm(str, _Xpx, _Ypx + 50, clrBlack, _FontSize, _clrBack, _Transparency, _Font, CORNER_RIGHT_UPPER);
     }
  }
//+------------------------------------------------------------------+




update 05.12.2024   version   1.06

update 05.12.2024   version   1.07


Volume weighted line chart with smoothing Volume weighted line chart with smoothing

A smoother line chart which cuts out a lot of the market noise and uses volume in the formula

simple mt5 trade copier simple mt5 trade copier

this is a copier template

SUPERMACBOT SUPERMACBOT

The SUPERMACBOT is a fully automated trading robot that combines the power of the Moving Average Crossover strategy with the MACD Indicator to deliver precise and reliable trade signals. This Expert Advisor is designed to work seamlessly on all symbols and timeframes, offering versatility and adaptability for traders across various market conditions.

MT4 to MT5 Convertor (MT5Compat.mqh) MT4 to MT5 Convertor (MT5Compat.mqh)

A new interface library has been developed to simplify the process of converting MT4 indicators and Expert Advisors (EAs) to MT5. This library supports most of the MetaTrader 4 functions, offering developers a unified solution for cross-platform compatibility.