forked from nique_372/MQLArticles
//+------------------------------------------------------------------+
| |
//| BasicPoints.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_BE_IMP_BASICPOINTS_MQH
| |
#define MQLARTICLES_POSMGMT_BE_IMP_BASICPOINTS_MQH
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#include "..\\Base\\BEBase.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
namespace TSN
| |
{
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#define TSNMQLART_POSMGMT_BE_BPOINTS_NPARMS (2)
| |
#define TSNMQLART_POSMGMT_BE_BPOINTS_I_POINT_BE (0)
| |
#define TSNMQLART_POSMGMT_BE_BPOINTS_I_EPOINT_BE (1)
| |
| |
| |
//+------------------------------------------------------------------+
| |
//| class CBreakEvenSimple |
| |
//+------------------------------------------------------------------+
| |
class CBreakEvenSimple : public CBreakEvenBase
| |
{
| |
private:
| |
int m_extra_points_be, m_points_be;
| |
public:
| |
CBreakEvenSimple(string symbol_, ulong magic_)
| |
: CBreakEvenBase(symbol_, magic_, TSNMQLART_POSMGMT_BE_BPOINTS_NPARMS), m_extra_points_be(0), m_points_be(0) {}
| |
| |
//---
| |
bool Add(ulong post_ticket, double open_price, double sl_price, ENUM_POSITION_TYPE position_type, datetime open_time, const string& sym) override final;
| |
bool Set(const BreakEvenParams ¶ms[]) override final;
| |
};
| |
| |
//+------------------------------------------------------------------+
| |
//| Set attributes of CBreakEvenSimple class with MqlParam array |
| |
//+------------------------------------------------------------------+
| |
bool CBreakEvenSimple::Set(const BreakEvenParams ¶ms[])
| |
{
| |
//---
| |
m_points_be = (int)params[TSNMQLART_POSMGMT_BE_BPOINTS_I_POINT_BE].integer_value; //0
| |
m_extra_points_be = (int)params[TSNMQLART_POSMGMT_BE_BPOINTS_I_EPOINT_BE].integer_value; //1
| |
| |
//---
| |
if(m_extra_points_be < 0)
| |
return CErrorTrace::FailInit<CBasicBEFormater>(TSNMQLART_BE_TYPES_ERR_BPOINTS_INV_EPOINTSBE, m_extra_points_be);
| |
if(m_extra_points_be >= m_points_be)
| |
return CErrorTrace::FailInit<CBasicBEFormater>(TSNMQLART_BE_TYPES_ERR_BPOINTS_EPOINTS_MUSTBE_MINOR_PNORM, ulong(uint(m_extra_points_be)) | ulong(uint(m_points_be)) << 32);
| |
return true;
| |
}
| |
| |
//+----------------------------------------------------------------------------------------------+
| |
//| Create a new structure and add it to the main array using the 'AddToArrayBe' function |
| |
//+----------------------------------------------------------------------------------------------+
| |
bool CBreakEvenSimple::Add(ulong post_ticket, double open_price, double sl_price, ENUM_POSITION_TYPE position_type, datetime open_time, const string& sym)
| |
{
| |
//---
| |
if(sym != m_symbol)
| |
return CErrorTrace::FailInit<CBasicBEFormater>(TSNMQLART_BE_TYPES_ERR_INV_SYMBOL, post_ticket);
| |
| |
//---
| |
MQLARTICLES_BREAKEVEN_PROLOGO(position_type, post_ticket)
| |
| |
//---
| |
m_pos_be[m_pos_be_s].breakeven_price = position_type == POSITION_TYPE_BUY ? open_price + (m_point_value * m_extra_points_be) : open_price - (m_point_value * m_extra_points_be);
| |
m_pos_be[m_pos_be_s].price_to_beat = position_type == POSITION_TYPE_BUY ? open_price + (m_point_value * m_points_be) : open_price - (m_point_value * m_points_be) ;
| |
| |
//---
| |
m_pos_be_s++;
| |
| |
//---
| |
return true;
| |
}
| |
| |
//---
| |
}
| |
| |
#endif // MQLARTICLES_POSMGMT_BE_IMP_BASICPOINTS_MQH
|