241 lines
4.1 KiB
Plaintext
241 lines
4.1 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Library
|
|
// -------------------------------------------------
|
|
// Name: XCXFIMAEALib ...
|
|
// Description: XFIMAEA Library ...
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://saherelm.ir"
|
|
#property version "1.00"
|
|
#property description "SaherElm XFIMAEA Library"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Enumerations ...
|
|
|
|
//
|
|
// ZigZag Point Type ...
|
|
enum ENUM_X_ZIGZAG_POINT_TYPE
|
|
{
|
|
X_ZIGZAG_POINT_TYPE_NONE = 0, // None
|
|
X_ZIGZAG_POINT_TYPE_PEAK = 1, // PEAK
|
|
X_ZIGZAG_POINT_TYPE_VALE = 2, // VALE
|
|
};
|
|
|
|
/**
|
|
* Validate ...
|
|
*
|
|
* @param value: ENUM_X_ZIGZAG_POINT_TYPE ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsXValid(ENUM_X_ZIGZAG_POINT_TYPE value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = value != X_ZIGZAG_POINT_TYPE_NONE;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Represent Specified ZigZag Point Type as String ...
|
|
*
|
|
* @param value: ENUM_X_ZIGZAG_POINT_TYPE ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string ToXString(ENUM_X_ZIGZAG_POINT_TYPE value)
|
|
{
|
|
return EnumToString(value);
|
|
}
|
|
|
|
//
|
|
// Structs ...
|
|
|
|
/**
|
|
* Specified ZigZag Point ...
|
|
**/
|
|
struct XZigZagPoint
|
|
{
|
|
//
|
|
// Props ...
|
|
double value; // Value
|
|
datetime time; // Time
|
|
ENUM_X_DIRECTION dir; // Direction
|
|
ENUM_X_ZIGZAG_POINT_TYPE type; // Type
|
|
|
|
//
|
|
// Constructor ...
|
|
XZigZagPoint()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
/**
|
|
* Cleanup Model ...
|
|
*/
|
|
void Clean()
|
|
{
|
|
//
|
|
value = 0;
|
|
time = NULL;
|
|
dir = X_DIRECTION_NONE;
|
|
type = X_ZIGZAG_POINT_TYPE_NONE;
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
/**
|
|
* Validate Model ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
value > 0 &&
|
|
IsXValid(type) &&
|
|
HasDirection(dir) &&
|
|
IsSpecifiedValid(time);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Check Point is Bullish or not ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsBullish()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsValid() &&
|
|
IsSpecifiedBullish(dir);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Check Point is Bearish or not ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsBearish()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsValid() &&
|
|
IsSpecifiedBearish(dir);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Extract Specified Token of Struct ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string GetTag()
|
|
{
|
|
return GetToken(this);
|
|
}
|
|
|
|
/**
|
|
* Represent an String Unique Identifier for Chart Objects ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string GetObjectID()
|
|
{
|
|
//
|
|
string result = "";
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = GetTag() + "_" + ToXString(dir) + "_" + ToXString(type) + "_" + ToXString(TimeToSeconds(time));
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Represent a Point as String ...
|
|
*
|
|
* @param spacer: string, How to Represent Spaces ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string GetMessage(string spacer = NULL)
|
|
{
|
|
//
|
|
string result = "";
|
|
|
|
//
|
|
// Normalize Spacer ...
|
|
if (!IsSpecifiedValid(spacer))
|
|
{
|
|
spacer = " ";
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
ToXString(dir) + spacer + GetTag() + ":" + spacer +
|
|
"Value: " + ToXString(value) + spacer +
|
|
"Time: " + ToXString(time) + spacer;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|