310 lines
4.5 KiB
Plaintext
310 lines
4.5 KiB
Plaintext
/////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 XMCHLP Indicator Helper for Signal Providers
|
|
// --------------------------------------------------------------------------
|
|
//
|
|
// 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
|
|
|
|
//
|
|
// START Includes ...
|
|
//
|
|
|
|
//
|
|
// Includes ...
|
|
#include "../../Libraries/x-saherelm.alert.lib.mq5"
|
|
#include "../../Libraries/x-saherelm.models.lib.mq5"
|
|
#include "../../Libraries/x-saherelm.common.lib.mq5"
|
|
|
|
//
|
|
// END Includes ...
|
|
//
|
|
|
|
//
|
|
// START Constants/Enums ...
|
|
//
|
|
|
|
//
|
|
// XMC Exported Buffers ...
|
|
enum ENUM_X_XMC_BUFFERS
|
|
{
|
|
//
|
|
X_MC_FAST_LINE = 0,
|
|
X_MC_SLOW_LINE = 1,
|
|
X_MC_VERIFIER_LINE = 2,
|
|
};
|
|
|
|
//
|
|
// END Constants/Enums ...
|
|
//
|
|
|
|
//
|
|
// START Definitions ...
|
|
//
|
|
|
|
//
|
|
double mcFastBuffer[];
|
|
double mcSlowBuffer[];
|
|
double mcVerifierBuffer[];
|
|
|
|
//
|
|
int mcHandler = INVALID_HANDLE;
|
|
|
|
//
|
|
// END Definitions ...
|
|
//
|
|
|
|
//
|
|
// START Handler Functions ...
|
|
//
|
|
|
|
//
|
|
bool XMCHLPOnInit()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
ArraySetAsSeries(mcFastBuffer, true);
|
|
ArraySetAsSeries(mcSlowBuffer, true);
|
|
ArraySetAsSeries(mcVerifierBuffer, true);
|
|
|
|
//
|
|
// Initial Handler ...
|
|
mcHandler = iCustom(
|
|
_Symbol,
|
|
_Period,
|
|
"x-saherelm.x121.xmc",
|
|
//
|
|
// Inputs ...
|
|
//
|
|
// FAST ...
|
|
"",
|
|
9,
|
|
0,
|
|
MODE_EMA,
|
|
PRICE_CLOSE,
|
|
//
|
|
// SLOW ...
|
|
"",
|
|
18,
|
|
0,
|
|
MODE_EMA,
|
|
PRICE_CLOSE,
|
|
//
|
|
// VERIFIER ...
|
|
"",
|
|
50,
|
|
0,
|
|
MODE_EMA,
|
|
PRICE_CLOSE,
|
|
//
|
|
"",
|
|
false,
|
|
false,
|
|
false
|
|
//
|
|
);
|
|
result = mcHandler != INVALID_HANDLE;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void XMCHLPOnDeInit()
|
|
{
|
|
//
|
|
// Release Indicators ...
|
|
IndicatorRelease(mcHandler);
|
|
}
|
|
|
|
//
|
|
void XMCHLPReadBuffers()
|
|
{
|
|
//
|
|
// FAST ...
|
|
CopyBuffer(
|
|
mcHandler,
|
|
X_MC_FAST_LINE,
|
|
0,
|
|
52,
|
|
mcFastBuffer);
|
|
|
|
//
|
|
// SLOW ...
|
|
CopyBuffer(
|
|
mcHandler,
|
|
X_MC_SLOW_LINE,
|
|
0,
|
|
52,
|
|
mcSlowBuffer);
|
|
|
|
//
|
|
// VERIFIER ...
|
|
CopyBuffer(
|
|
mcHandler,
|
|
X_MC_VERIFIER_LINE,
|
|
0,
|
|
52,
|
|
mcVerifierBuffer);
|
|
}
|
|
|
|
//
|
|
// END Handler Functions ...
|
|
//
|
|
|
|
//
|
|
// START Helper Functions ...
|
|
//
|
|
|
|
//
|
|
// Check Fast Over Slow ...
|
|
bool XMCHLPIsFastOverSlow(
|
|
int bar_index // Bar Index ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (!XMCHLPIsValidArraySize(bar_index))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsOver(
|
|
mcFastBuffer,
|
|
mcSlowBuffer,
|
|
bar_index)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Over Slow ...
|
|
bool XMCHLPIsFastCrossedOverSlow(
|
|
int bar_index // Bar Index ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (!XMCHLPIsValidArraySize(bar_index))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsCrossOver(
|
|
mcFastBuffer,
|
|
mcSlowBuffer,
|
|
bar_index)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Under Slow ...
|
|
bool XMCHLPIsFastUnderSlow(
|
|
int bar_index // Bar Index ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (!XMCHLPIsValidArraySize(bar_index))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsUnder(
|
|
mcFastBuffer,
|
|
mcSlowBuffer,
|
|
bar_index)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Under Slow ...
|
|
bool XMCHLPIsFastCrossedUnderSlow(
|
|
int bar_index // Bar Index ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (!XMCHLPIsValidArraySize(bar_index))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsCrossUnder(
|
|
mcFastBuffer,
|
|
mcSlowBuffer,
|
|
bar_index)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool XMCHLPIsValidArraySize(int bar_index)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int rCount = ArraySize(mcFastBuffer);
|
|
result = rCount > bar_index + 1;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// END Helper Functions ...
|
|
//
|