182 lines
3.2 KiB
Plaintext
182 lines
3.2 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// --------------------------------------
|
|
// Name: XCPositionDrawer
|
|
// Description: Provides Position
|
|
// Drawing Tools ...
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://www.saherelm.ir"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../Classes/x-saherelm.base.class.mq5"
|
|
#include "../Classes/x-saherelm.x-cobject.class.mq5"
|
|
#include "../Classes/x-saherelm.x-trade.class.mq5"
|
|
#include "../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
|
#include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Implementation ...
|
|
|
|
class XCPositionDrawer : public XCBase
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
XCTrade *trader;
|
|
CArrayObj positionObjects;
|
|
|
|
//
|
|
// Constructor ...
|
|
XCPositionDrawer(
|
|
XCTrade *_trader //
|
|
) : XCBase()
|
|
{
|
|
//
|
|
Init(
|
|
_trader //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XCPositionDrawer()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
void Init(
|
|
XCTrade *_trader //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has = _trader != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
trader = _trader;
|
|
}
|
|
|
|
void Destroy()
|
|
{
|
|
}
|
|
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
trader != NULL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
void Update(int barIndex = 0)
|
|
{
|
|
//
|
|
// Normalize ...
|
|
barIndex = NormalizeInt(barIndex, 0);
|
|
|
|
//
|
|
// Validate ...
|
|
bool has = IsValid();
|
|
if (!has) {
|
|
return;
|
|
}
|
|
|
|
//
|
|
|
|
}
|
|
|
|
//
|
|
// Trade Event Handlers ...
|
|
|
|
/**
|
|
* Add Executed Signal ...
|
|
*
|
|
* @param signal: XSignal, reference to Executed Signal ...
|
|
*/
|
|
void AddExecutedSignal(XSignal &signal)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (!signal.IsValid() || !signal.IsExecuted())
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle Stop Loss Event Triggered ...
|
|
*
|
|
* @param deal: XDeal instance refrence, provides Triggered Deal info ...
|
|
*/
|
|
void HandleOnStopLossTriggered(const XDeal &deal)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Handle Take Profit Event Triggered ...
|
|
*
|
|
* @param deal: XDeal instance refrence, provides Triggered Deal info ...
|
|
*/
|
|
void HandleOnTakeProfitTriggered(const XDeal &deal)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Handle Position Force Closed Event ...
|
|
*
|
|
* @param ticket: ulong, triggered Positions ticket ...
|
|
* @param position: XPosition instance refrence, Triggered Position ...
|
|
* @param comment: string, Comment ...
|
|
*/
|
|
void HandleOnPositionForceClosed(
|
|
const ulong ticket,
|
|
const XPosition &position,
|
|
const string comment //
|
|
)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
|
|
//
|
|
};
|
|
|
|
// |