59 lines
1.9 KiB
MQL5
59 lines
1.9 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| use_error_handling.mq5 |
|
|
//| Copyright 2025, MetaQuotes Ltd. |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2025, MetaQuotes Ltd."
|
|
#property link "https://www.mql5.com"
|
|
#property version "1.00"
|
|
#property indicator_chart_window
|
|
#include <PublicMQL/Global/ErrorHandeling/Models/Logs.mqh>
|
|
|
|
CLog *log;
|
|
|
|
class Error_Test
|
|
{
|
|
public:
|
|
int init_var;
|
|
};
|
|
|
|
Error_Test *error_obj;
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Custom indicator initialization function |
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
log = CLog::GetLog();
|
|
|
|
if (CheckPointer(error_obj) == POINTER_INVALID)
|
|
{
|
|
log.AddMessage(new CMessage(MESSAGE_ERROR, __FUNCTION__, "Error_Test object is not initialized"));
|
|
}
|
|
else
|
|
{
|
|
Print(error_obj.init_var);
|
|
}
|
|
|
|
return (INIT_SUCCEEDED);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Custom indicator iteration function |
|
|
//+------------------------------------------------------------------+
|
|
int OnCalculate(const int32_t rates_total,
|
|
const int32_t prev_calculated,
|
|
const datetime &time[],
|
|
const double &open[],
|
|
const double &high[],
|
|
const double &low[],
|
|
const double &close[],
|
|
const long &tick_volume[],
|
|
const long &volume[],
|
|
const int32_t &spread[])
|
|
{
|
|
//---
|
|
|
|
//--- return value of prev_calculated for next call
|
|
return (rates_total);
|
|
}
|
|
//+------------------------------------------------------------------+
|