Files
2018-06-20 15:35:55 +02:00

68 lines
5.5 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//+------------------------------------------------------------------+
//| Trailing.mqh |
//| Copyright 2016, Vasiliy Sokolov. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Vasiliy Sokolov."
#property link "http://www.mql5.com"
#include <Object.mqh>
#ifdef __HT__
#include "..\Position.mqh"
#else
#include "..\PositionMT5.mqh"
#endif
#include "..\Logs.mqh"
class CPosition;
//+------------------------------------------------------------------+
//| The base class of a trailing stop                                |
//+------------------------------------------------------------------+
class CTrailing : public CObject
{
protected:
CPosition *m_position; // The position whose trailing stop you want to modify.
CLog *Log;
public:
CTrailing(void);
void SetPosition(CPosition *position);
CPosition *GetPosition(void);
virtual bool Modify(void);
virtual CTrailing* Copy(void);
};
//+------------------------------------------------------------------+
//| Constructor. Receives a logger module                           |
//+------------------------------------------------------------------+
CTrailing::CTrailing(void)
{
Log=CLog::GetLog();
}
//+------------------------------------------------------------------+
//| Trailing stop modification method, which should be             |
//| overridden in the derived trailing class                     |
//+------------------------------------------------------------------+
bool CTrailing::Modify(void)
{
return false;
}
//+------------------------------------------------------------------+
//| Returns a copy of the instance                                   |
//+------------------------------------------------------------------+
CTrailing* CTrailing::Copy(void)
{
return new CTrailing();
}
//+------------------------------------------------------------------+
//| Sets a position, the stop loss of which should be modified |
//+------------------------------------------------------------------+
void CTrailing::SetPosition(CPosition *position)
{
m_position=position;
}
//+------------------------------------------------------------------+
//| Returns a position, the stop loss of which should be modified |
//+------------------------------------------------------------------+
CPosition *CTrailing::GetPosition(void)
{
return m_position;
}
//+------------------------------------------------------------------+