2026-10-24 17:50:46 -05:00
//+------------------------------------------------------------------+
//| Def.mqh |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
# property copyright " Copyright 2026, Niquel Mendoza. "
# property link " https://www.mql5.com "
# property strict
# ifndef MQLARTICLES_POSMGMT_TSL_INT_DEF_MQH
# define MQLARTICLES_POSMGMT_TSL_INT_DEF_MQH
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
//| |
//+------------------------------------------------------------------+
# include "..\\Basic\\Main.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
enum ENUM_TSN_TRAILING_STOP_MODE_BASIC
{
TRAILING_STOP_MODE_BASIC_SAR = 0 , // Trailing by Sar Indicador
TRAILING_STOP_MODE_BASIC_SWINGS , // Trailing by Market Swings
TRAILING_STOP_MODE_BASIC_POINTS , // Trailing by Fixed Points
TRAILING_STOP_MODE_BASIC_MA , // Trailing by MA
TRAILING_STOP_MODE_BASIC_PREV_LOHI , // Trailing by pre low high
TRAILING_STOP_MODE_BASIC_ATR , // Trailing by atr
TRAILING_STOP_MODE_BASIC_AMA , // Trailing by AMA
TRAILING_STOP_MODE_BASIC_TOTAL ,
} ;
2026-11-05 17:09:00 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
// Propio de estos 9 tipos de trailing stop
enum ENUM_TSN_TRAILING_TYPES_BASIC_ERR
{
TSN_TRAILING_TYPES_BASIC_ERR_NOT ,
//--- general
TSN_TRAILING_TYPES_BASIC_ERR_INVALID_H ,
//--- swing
TSN_TRAILING_TYPES_BASIC_ERR_SHL_INVALID_INDEX ,
TSN_TRAILING_TYPES_BASIC_ERR_SHL_INVALID_RANGE ,
TSN_TRAILING_TYPES_BASIC_ERR_SHL_INVALID_LENGHT ,
2026-11-05 17:23:04 -05:00
//--- fixed points
TSN_TRAILING_TYPES_BASIC_ERR_FIXED_STEP_LOWER_STOPLEVEL ,
//--- atr
TSN_TRAILING_TYPES_BASIC_ERR_ATR_INVALID_PTR ,
2026-11-05 17:09:00 -05:00
} ;
2026-11-05 17:23:04 -05:00
//+------------------------------------------------------------------+
//| Formater de los errores de los 9 tipos de trailing stop (Imp) |
//+------------------------------------------------------------------+
class CBasicTSLFormater
{
public :
2026-11-06 10:40:44 -05:00
static void FormatTrace ( const TSNErrorFrame & trace [ ] , int & trace_idx , string & out ) ;
2026-11-05 17:23:04 -05:00
} ;
//+------------------------------------------------------------------+
2026-11-06 10:40:44 -05:00
static void CBasicTSLFormater::FormatTrace ( const TSNErrorFrame & trace [ ] , int & trace_idx , string & out )
2026-11-05 17:23:04 -05:00
{
TSNSTD_ERRMAN_PUSHINI ( out , trace_idx )
switch ( trace [ trace_idx ] . code )
{
case TSN_TRAILING_TYPES_BASIC_ERR_NOT :
TSNSTD_ERRMAN_PUSHOUT ( out , " Not error " , trace_idx )
break ;
case TSN_TRAILING_TYPES_BASIC_ERR_INVALID_H :
TSNSTD_ERRMAN_PUSHOUT ( out , StringFormat ( " Failed to create the indicator handle for trailing stop type [%d], last err = %d " , int ( trace [ trace_idx ] . info ) , trace [ trace_idx ] . mql_err ) , trace_idx )
break ;
case TSN_TRAILING_TYPES_BASIC_ERR_SHL_INVALID_INDEX :
TSNSTD_ERRMAN_PUSHOUT ( out , StringFormat ( " Swing trailing stop, invalid index [%d] (must be >= 0) " , int ( trace [ trace_idx ] . info ) ) , trace_idx )
break ;
case TSN_TRAILING_TYPES_BASIC_ERR_SHL_INVALID_RANGE :
TSNSTD_ERRMAN_PUSHOUT ( out , StringFormat ( " Swing trailing stop, invalid range [%d] (must be > 0) " , int ( trace [ trace_idx ] . info ) ) , trace_idx )
break ;
case TSN_TRAILING_TYPES_BASIC_ERR_SHL_INVALID_LENGHT :
TSNSTD_ERRMAN_PUSHOUT ( out , StringFormat ( " Swing trailing stop, invalid length [%d] (must be > 0 and < range) " , int ( trace [ trace_idx ] . info ) ) , trace_idx )
break ;
case TSN_TRAILING_TYPES_BASIC_ERR_FIXED_STEP_LOWER_STOPLEVEL :
TSNSTD_ERRMAN_PUSHOUT ( out , StringFormat ( " Fixed points trailing stop, step [%d points] is lower than the symbol trade stops level " , int ( trace [ trace_idx ] . info ) ) , trace_idx )
break ;
case TSN_TRAILING_TYPES_BASIC_ERR_ATR_INVALID_PTR :
TSNSTD_ERRMAN_PUSHOUT ( out , StringFormat ( " Atr trailing stop, could not create the atr [period = %d | index = %d] " , int ( trace [ trace_idx ] . info ) , int ( trace [ trace_idx ] . info > > 32 ) ) , trace_idx )
break ;
default :
TSNSTD_ERRMAN_PUSHOUT ( out , " Unknow error " , trace_idx )
break ;
}
}
2026-10-24 17:50:46 -05:00
}
//+------------------------------------------------------------------+
# endif // MQLARTICLES_POSMGMT_TSL_INT_DEF_MQH