forked from nique_372/MQLArticles
//+------------------------------------------------------------------+
| |
//| AMA.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_IND_AMA_MQH
| |
#define MQLARTICLES_POSMGMT_TSL_INT_IND_AMA_MQH
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#include "Base.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| Indices de MqlParam para CTrailingStopAMA::SetVariables |
| |
//+------------------------------------------------------------------+
| |
#define TSNMQLA_TSL_AMA_PARAM_INDEX 0 // int: indice
| |
#define TSNMQLA_TSL_AMA_PARAM_TIMEFRAME 1 // ENUM_TIMEFRAMES
| |
#define TSNMQLA_TSL_AMA_PARAM_PERIOD 2 // int: periodo AMA
| |
#define TSNMQLA_TSL_AMA_PARAM_SLOW_PERIOD 3 // int: periodo lento
| |
#define TSNMQLA_TSL_AMA_PARAM_FAST_PERIOD 4 // int: periodo rapido
| |
#define TSNMQLA_TSL_AMA_NPARAMS 5 // numero de parametros
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
namespace TSN
| |
{
| |
//+------------------------------------------------------------------+
| |
//| Trailing Stop by AMA |
| |
//+------------------------------------------------------------------+
| |
class CTrailingStopAMA : public CTrailingStopIndicators
| |
{
| |
public:
| |
CTrailingStopAMA()
| |
: CTrailingStopIndicators(TSNMQLA_TSL_AMA_NPARAMS, TRAILING_STOP_MODE_BASIC_AMA) {}
| |
~CTrailingStopAMA() {}
| |
| |
//---
| |
bool SetVariables(const MqlParam ¶ms[]) override final;
| |
};
| |
| |
TSNMQLA_TRAILINGSTOP_REGISTER_CREATOR(CTrailingStopAMA, SimpleAma, TRAILING_STOP_MODE_BASIC_AMA)
| |
| |
//+------------------------------------------------------------------+
| |
bool CTrailingStopAMA::SetVariables(const MqlParam & params[])
| |
{
| |
//---
| |
m_index = (int)params[TSNMQLA_TSL_AMA_PARAM_INDEX].integer_value;
| |
m_timeframe = (ENUM_TIMEFRAMES)params[TSNMQLA_TSL_AMA_PARAM_TIMEFRAME].integer_value;
| |
const int ama_period = (int)params[TSNMQLA_TSL_AMA_PARAM_PERIOD].integer_value;
| |
const int slow_period = (int)params[TSNMQLA_TSL_AMA_PARAM_SLOW_PERIOD].integer_value;
| |
const int fast_period = (int)params[TSNMQLA_TSL_AMA_PARAM_FAST_PERIOD].integer_value;
| |
| |
//---
| |
::ResetLastError();
| |
m_handle = iAMA(m_symbol, m_timeframe, ama_period, fast_period, slow_period, 0, PRICE_CLOSE);
| |
| |
//---
| |
if(m_handle == INVALID_HANDLE)
| |
return CErrorTrace::FailInit<CBasicTSLFormater>(TSN_TRAILING_TYPES_BASIC_ERR_INVALID_H, m_type, ::GetLastError());
| |
| |
//---
| |
return true;
| |
}
| |
| |
//---
| |
}
| |
#endif // MQLARTICLES_POSMGMT_TSL_INT_IND_AMA_MQH
| |
//+------------------------------------------------------------------+
|