add MQL5Test Workspace Content as BKP Solution ...

This commit is contained in:
2024-04-22 07:42:50 +03:30
parent ec0a03203e
commit f7fd579a9d
197 changed files with 80113 additions and 0 deletions
@@ -0,0 +1,235 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XATRSLHLP 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 ...
//
//
// XPeaksAndVales Exported Buffers ...
enum ENUM_X_XATRSL_BUFFERS
{
//
X_ATRSL_UP_LINE = 0,
X_ATRSL_DOWN_LINE = 1,
X_ATRSL_SAR_LINE = 2,
X_ATRSL_RMA_LINE = 3,
X_ATRSL_WMA_LINE = 4,
X_ATRSL_MA1_LINE = 5,
X_ATRSL_SMA_LINE = 6,
X_ATRSL_EMA_LINE = 7,
X_ATRSL_ATR_LINE = 8,
};
//
// END Constants/Enums ...
//
//
// START Definitions ...
//
//
double atrslUpBuffer[];
double atrslDownBuffer[];
double atrslSarBuffer[];
//
int atrslHandler = INVALID_HANDLE;
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
bool XATRSLHLPOnInit()
{
//
bool result = false;
//
ArraySetAsSeries(atrslUpBuffer, true);
ArraySetAsSeries(atrslSarBuffer, true);
ArraySetAsSeries(atrslDownBuffer, true);
//
// Initial Handler ...
atrslHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.x121.xatrsl",
//
// Inputs ...
//
// MARKET ...
"",
14,
0.02,
0.2,
PRICE_HIGH,
PRICE_LOW,
//
// PRESENTATION ...
"",
false,
false,
true
//
);
result = atrslHandler != INVALID_HANDLE;
//
return result;
}
//
void XATRSLHLPOnDeInit()
{
//
// Release Indicators ...
IndicatorRelease(atrslHandler);
}
//
void XATRSLHLPReadBuffers()
{
//
// UP ...
CopyBuffer(
atrslHandler,
X_ATRSL_UP_LINE,
0,
10,
atrslUpBuffer);
//
// DOWN ...
CopyBuffer(
atrslHandler,
X_ATRSL_DOWN_LINE,
0,
10,
atrslDownBuffer);
//
// SAR ...
CopyBuffer(
atrslHandler,
X_ATRSL_SAR_LINE,
0,
10,
atrslSarBuffer);
}
//
// END Handler Functions ...
//
//
// START Helper Functions ...
//
//
// Calculate Change Rate For Specific Bar ...
double XATRSLHLPGetChangeRate(
int bar_index // Bar Index ...
)
{
//
double result = 0;
//
if (!XATRSLHLPIsValidArraySize(bar_index))
{
return result;
}
//
result = MathAbs(atrslUpBuffer[bar_index] - atrslDownBuffer[bar_index]);
//
return result;
}
//
// Calculate Change Rate For Specific Lenght ...
double XATRSLHLPGetRangeChangeRate(
int bar_index, // Bar Index ...
int length = 5 // Loopback Length ...
)
{
//
double result = 0;
//
int size = bar_index + length;
if (!XATRSLHLPIsValidArraySize(size))
{
return result;
}
//
double summary = 0;
for (int i = bar_index; i < size; i++)
{
summary += MathAbs(atrslUpBuffer[i] - atrslDownBuffer[i]);
}
//
result = summary / size;
//
return result;
}
//
// Check Array Size ...
bool XATRSLHLPIsValidArraySize(int bar_index)
{
//
bool result = false;
//
int rCount = ArraySize(atrslUpBuffer);
result = rCount > bar_index + 1;
//
return result;
}
//
// END Helper Functions ...
//
@@ -0,0 +1,938 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XICHIHLP 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 ...
//
//
// Ichimoku Lines Calculator Mode ...
enum ENUM_X_ICHIMOKU_CALCULATION_MODE
{
//
X_XICH_HH_LL_MODE = 1, // Highest High and Lowest Low
X_XICH_HO_LC_MODE = 2, // Highest Open and Lowest Close
};
//
// Ichimoku Indicator Exported Buffers ...
enum ENUM_X_ICHIMOKU_BUFFERS
{
//
X_TENKANSEN_LINE = 0,
X_KIJUNSEN_LINE = 1,
X_CHIKOUSPAN_LINE = 4,
X_SENKOUSPAN_A_LINE = 5,
X_SENKOUSPAN_B_LINE = 6,
};
//
// Model Ichimoku Data ...
struct XIchiInfo
{
//
int bar;
//
double tenkanSen;
double kijunSen;
//
double chikouSpan;
//
double senkouSpanA;
double senkouSpanB;
//
double senkouSpanAFuture;
double senkouSpanBFuture;
};
//
double ichiPivots[];
//
// END Constants/Enums ...
//
//
// START Definitions ...
//
//
double ichiTenkanSenBuffer[];
double ichiKijunSenBuffer[];
double ichiChikouSpanBuffer[];
double ichiSenkouSpanABuffer[];
double ichiSenkouSpanBBuffer[];
//
int ichiHandler = INVALID_HANDLE;
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
bool XICHIHLPOnInit()
{
//
bool result = false;
//
ArraySetAsSeries(ichiTenkanSenBuffer, true);
ArraySetAsSeries(ichiKijunSenBuffer, true);
ArraySetAsSeries(ichiChikouSpanBuffer, true);
ArraySetAsSeries(ichiSenkouSpanABuffer, true);
ArraySetAsSeries(ichiSenkouSpanBBuffer, true);
//
ArraySetAsSeries(ichiPivots, true);
//
// Initial Handler ...
ichiHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.x121.xich",
//
// Inputs ...
//
// TENKANSEN ...
"",
9,
X_XICH_HH_LL_MODE,
//
// KIJUNSEN ...
"",
26,
X_XICH_HH_LL_MODE,
//
// SENKOUSPANB ...
"",
52,
X_XICH_HH_LL_MODE,
//
// CHIKOUSPAN ...
"",
PRICE_CLOSE,
//
// PRESENTATION ...
"",
true,
true,
false,
false,
false,
false,
false,
true,
true // Shift Kumo ...
//
);
result = ichiHandler != INVALID_HANDLE;
//
return result;
}
//
void XICHIHLPOnDeInit()
{
//
// Release Indicators ...
IndicatorRelease(ichiHandler);
}
//
void XICHIHLPReadBuffers()
{
//
// TENKANSEN ...
CopyBuffer(
ichiHandler,
X_TENKANSEN_LINE,
0,
26,
ichiTenkanSenBuffer);
//
// KIJUNSEN ...
CopyBuffer(
ichiHandler,
X_KIJUNSEN_LINE,
0,
26,
ichiKijunSenBuffer);
//
// CHIKOUSPAN ...
CopyBuffer(
ichiHandler,
X_CHIKOUSPAN_LINE,
27,
52,
ichiChikouSpanBuffer);
//
// SENKOUSPANA ...
CopyBuffer(
ichiHandler,
X_SENKOUSPAN_A_LINE,
-26,
52,
ichiSenkouSpanABuffer);
//
// SENKOUSPANB ...
CopyBuffer(
ichiHandler,
X_SENKOUSPAN_B_LINE,
-26,
52,
ichiSenkouSpanBBuffer);
//
XICHIHLPFindPivotPoints();
}
//
// END Handler Functions ...
//
//
// START Helper Functions ...
//
//
// Retrieve Ichimoku Data at Specific Bar Index ...
XIchiInfo XICHIHLPGetInfo(
int bar_index // Bar Index ...
)
{
//
XIchiInfo result = {};
//
result.bar = bar_index;
result.tenkanSen = ichiTenkanSenBuffer[bar_index];
result.kijunSen = ichiKijunSenBuffer[bar_index];
result.chikouSpan = ichiChikouSpanBuffer[bar_index + 26];
result.senkouSpanA = ichiSenkouSpanABuffer[bar_index + 26];
result.senkouSpanB = ichiSenkouSpanBBuffer[bar_index + 26];
result.senkouSpanAFuture = ichiSenkouSpanABuffer[bar_index];
result.senkouSpanBFuture = ichiSenkouSpanBBuffer[bar_index];
//
return result;
}
//
// Check Tenkan Sen Over Kijun Sen ...
bool XICHIHLPIsTenkanSenOverKijunSen(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
//
result =
//
point.tenkanSen > point.kijunSen
//
;
//
return result;
}
//
// Is Tenkan Sen Under Kijun Sen ...
bool XICHIHLPIsTenkanSenUnderKijunSen(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
//
result =
//
point.tenkanSen < point.kijunSen
//
;
//
return result;
}
//
// Tenkan Sen Croosed Over Kijun Sen ...
bool XICHIHLPIsTenkanSenCrossedOverKijunSen(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
result =
//
point.tenkanSen > point.kijunSen &&
pointPrev.tenkanSen <= pointPrev.kijunSen
//
;
//
return result;
}
//
// Tenkan Sen Croosed Under Kijun Sen ...
bool XICHIHLPIsTenkanSenCrossedUnderKijunSen(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
result =
//
point.tenkanSen < point.kijunSen &&
pointPrev.tenkanSen >= pointPrev.kijunSen
//
;
//
return result;
}
//
// Check Kumo is Bullish ...
bool XICHIHLPIsKumoBullish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double ssa = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double ssb = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
result =
//
ssa > ssb
//
;
//
return result;
}
//
// Check Kumo is Bearish ...
bool XICHIHLPIsKumoBearish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double ssa = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double ssb = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
result =
//
ssa < ssb
//
;
//
return result;
}
//
// Check Kumo is Change to Bullish ...
bool XICHIHLPIsKumoSwitchedToBullish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double ssa = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double ssb = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
double ssaPrev = onFuture
? pointPrev.senkouSpanAFuture
: pointPrev.senkouSpanA;
//
double ssbPrev = onFuture
? pointPrev.senkouSpanBFuture
: pointPrev.senkouSpanB;
//
result =
//
ssa > ssb &&
ssaPrev <= ssbPrev
//
;
//
return result;
}
//
// Check Kumo is Change to Bearish ...
bool XICHIHLPIsKumoSwitchedToBearish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double ssa = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double ssb = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
double ssaPrev = onFuture
? pointPrev.senkouSpanAFuture
: pointPrev.senkouSpanA;
//
double ssbPrev = onFuture
? pointPrev.senkouSpanBFuture
: pointPrev.senkouSpanB;
//
result =
//
ssa < ssb &&
ssaPrev >= ssbPrev
//
;
//
return result;
}
//
// TENKANSEN and SENKOUSPAN ...
//
bool XICHIHLPIsTenkanSenCrossedOverSenkouSpanA(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double destPrev = onFuture
? pointPrev.senkouSpanAFuture
: pointPrev.senkouSpanA;
//
result =
//
point.tenkanSen > dest &&
pointPrev.tenkanSen <= destPrev
//
;
//
return result;
}
//
bool XICHIHLPIsTenkanSenCrossedUnderSenkouSpanA(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double destPrev = onFuture
? pointPrev.senkouSpanAFuture
: pointPrev.senkouSpanA;
//
result =
//
point.tenkanSen < dest &&
pointPrev.tenkanSen >= destPrev
//
;
//
return result;
}
//
bool XICHIHLPIsTenkanSenCrossedOverSenkouSpanB(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
double destPrev = onFuture
? pointPrev.senkouSpanBFuture
: pointPrev.senkouSpanB;
//
result =
//
point.tenkanSen > dest &&
pointPrev.tenkanSen <= destPrev
//
;
//
return result;
}
//
bool XICHIHLPIsTenkanSenCrossedUnderSenkouSpanB(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
double destPrev = onFuture
? pointPrev.senkouSpanBFuture
: pointPrev.senkouSpanB;
//
result =
//
point.tenkanSen < dest &&
pointPrev.tenkanSen >= destPrev
//
;
//
return result;
}
//
// KIJUNSEN and SENKOUSPAN ...
//
bool XICHIHLPIsKijunSenCrossedOverSenkouSpanA(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double destPrev = onFuture
? pointPrev.senkouSpanAFuture
: pointPrev.senkouSpanA;
//
result =
//
point.kijunSen > dest &&
pointPrev.kijunSen <= destPrev
//
;
//
return result;
}
//
bool XICHIHLPIsKijunSenCrossedUnderSenkouSpanA(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanAFuture
: point.senkouSpanA;
//
double destPrev = onFuture
? pointPrev.senkouSpanAFuture
: pointPrev.senkouSpanA;
//
result =
//
point.kijunSen < dest &&
pointPrev.kijunSen >= destPrev
//
;
//
return result;
}
//
bool XICHIHLPIsKijunSenCrossedOverSenkouSpanB(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
double destPrev = onFuture
? pointPrev.senkouSpanBFuture
: pointPrev.senkouSpanB;
//
result =
//
point.kijunSen > dest &&
pointPrev.kijunSen <= destPrev
//
;
//
return result;
}
//
bool XICHIHLPIsKijunSenCrossedUnderSenkouSpanB(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
XIchiInfo point = XICHIHLPGetInfo(bar_index);
XIchiInfo pointPrev = XICHIHLPGetInfo(bar_index + 1);
//
double dest = onFuture
? point.senkouSpanBFuture
: point.senkouSpanB;
//
double destPrev = onFuture
? pointPrev.senkouSpanBFuture
: pointPrev.senkouSpanB;
//
result =
//
point.kijunSen < dest &&
pointPrev.kijunSen >= destPrev
//
;
//
return result;
}
//
bool XICHIHLPIsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(ichiTenkanSenBuffer);
result = rCount > bar_index + 1;
//
return result;
}
//
// SUPPORT and RESISTANCE ...
//
// Find Pivot Areas in Ichimooku ...
void XICHIHLPFindPivotPoints()
{
//
double smoothingPoint = 3;
int verifications = 3;
//
// FLATS ...
double tmpFlats[];
int tmpFlatsCount = 0;
//
// TenkanSen Flats ...
FindSameValueInBuffer(
tmpFlats,
ichiTenkanSenBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
ichiPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// KijunSen Flats ...
FindSameValueInBuffer(
tmpFlats,
ichiKijunSenBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
ichiPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// SenkouSpanA Flats ...
FindSameValueInBuffer(
tmpFlats,
ichiSenkouSpanABuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
ichiPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// SenkouSpanB Flats ...
FindSameValueInBuffer(
tmpFlats,
ichiSenkouSpanBBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
ichiPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
}
//
// Extract Support and Resistances ...
XOHCLSupRes XICHIHLPFindCandleSupprtAndResistance(
int bar_index, // Bar Index ...
int count = 3 // Number of Requireds ...
)
{
//
XOHCLSupRes result = ExtractSupportAndResistance(
bar_index,
ichiPivots,
count,
_Symbol,
_Period);
//
return result;
}
//
// END Helper Functions ...
//
@@ -0,0 +1,309 @@
/////////////////////////////////////////////////////////////////////////////
//
// 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 ...
//
@@ -0,0 +1,314 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XMRBHLP 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 ...
//
//
// XMRB Exported Buffers ...
enum ENUM_X_XMRB_BUFFERS
{
//
X_MRB_FAST_LINE = 0,
X_MRB_SLOW_LINE = 1,
//
X_MRB_FAST_1_LINE = 2,
X_MRB_FAST_2_LINE = 3,
X_MRB_FAST_3_LINE = 4,
X_MRB_FAST_4_LINE = 5,
X_MRB_FAST_5_LINE = 6,
//
X_MRB_SLOW_1_LINE = 7,
X_MRB_SLOW_2_LINE = 8,
X_MRB_SLOW_3_LINE = 9,
X_MRB_SLOW_4_LINE = 10,
X_MRB_SLOW_5_LINE = 11,
};
//
// END Constants/Enums ...
//
//
// START Definitions ...
//
//
double mrbFastBuffer[];
double mrbSlowBuffer[];
//
int mrbHandler = INVALID_HANDLE;
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
bool XMRBHLPOnInit()
{
//
bool result = false;
//
ArraySetAsSeries(mrbFastBuffer, true);
ArraySetAsSeries(mrbSlowBuffer, true);
//
// Initial Handler ...
mrbHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.x121.xmrb",
//
// Inputs ...
//
"",
3,
5,
//
"",
8,
13,
//
"",
21,
34,
//
"",
55,
89,
//
"",
144,
233,
//
"",
MODE_EMA,
PRICE_CLOSE,
//
"",
false,
false,
false
//
);
result = mrbHandler != INVALID_HANDLE;
//
return result;
}
//
void XMRBHLPOnDeInit()
{
//
// Release Indicators ...
IndicatorRelease(mrbHandler);
}
//
void XMRBHLPReadBuffers()
{
//
// FAST ...
CopyBuffer(
mrbHandler,
X_MRB_FAST_LINE,
0,
52,
mrbFastBuffer);
//
// SLOW ...
CopyBuffer(
mrbHandler,
X_MRB_SLOW_LINE,
0,
52,
mrbSlowBuffer);
}
//
// END Handler Functions ...
//
//
// START Helper Functions ...
//
//
// Check Fast Over Slow ...
bool XMRBHLPIsFastOverSlow(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!XMRBHLPIsValidArraySize(bar_index))
{
return result;
}
//
result =
//
IsOver(
mrbFastBuffer,
mrbSlowBuffer,
bar_index)
//
;
//
return result;
}
//
// Check Fast Crossed Over Slow ...
bool XMRBHLPIsFastCrossedOverSlow(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!XMRBHLPIsValidArraySize(bar_index))
{
return result;
}
//
result =
//
IsCrossOver(
mrbFastBuffer,
mrbSlowBuffer,
bar_index)
//
;
//
return result;
}
//
// Check Fast Under Slow ...
bool XMRBHLPIsFastUnderSlow(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!XMRBHLPIsValidArraySize(bar_index))
{
return result;
}
//
result =
//
IsUnder(
mrbFastBuffer,
mrbSlowBuffer,
bar_index)
//
;
//
return result;
}
//
// Check Fast Crossed Under Slow ...
bool XMRBHLPIsFastCrossedUnderSlow(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!XMRBHLPIsValidArraySize(bar_index))
{
return result;
}
//
result =
//
IsCrossUnder(
mrbFastBuffer,
mrbSlowBuffer,
bar_index)
//
;
//
return result;
}
//
bool XMRBHLPIsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(mrbFastBuffer);
result = rCount > bar_index + 1;
//
return result;
}
//
// END Helper Functions ...
//
@@ -0,0 +1,803 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XPVHLP 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 ...
//
//
// XPeaksAndVales Exported Buffers ...
enum ENUM_X_XPV_BUFFERS
{
//
// PEAKSANDVALES ...
X_PV_P_LINE = 0,
X_PV_V_LINE = 1,
//
// SUPPORTRESISTANCE ...
X_PV_R_LINE = 2,
X_PV_S_LINE = 4,
//
// SHORT ...
X_PV_SHH_LINE = 6,
X_PV_SLL_LINE = 7,
//
// MEDIUM ...
X_PV_MHH_LINE = 8,
X_PV_MLL_LINE = 9,
//
// LONG ...
X_PV_LHH_LINE = 10,
X_PV_LLL_LINE = 11,
//
// HIND ...
X_PV_HHH_LINE = 12,
X_PV_HLL_LINE = 13,
};
//
// END Constants/Enums ...
//
//
// START Definitions ...
//
//
double pvPivots[];
//
double pvPBuffer[];
double pvVBuffer[];
double pvRBuffer[];
double pvSBuffer[];
double pvSHHBuffer[];
double pvSLLBuffer[];
double pvMHHBuffer[];
double pvMLLBuffer[];
double pvLHHBuffer[];
double pvLLLBuffer[];
double pvHHHBuffer[];
double pvHLLBuffer[];
//
int mpvHandler = INVALID_HANDLE;
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
bool XPVHLPOnInit()
{
//
bool result = false;
//
ArraySetAsSeries(pvPivots, true);
//
ArraySetAsSeries(pvPBuffer, true);
ArraySetAsSeries(pvVBuffer, true);
ArraySetAsSeries(pvRBuffer, true);
ArraySetAsSeries(pvSBuffer, true);
ArraySetAsSeries(pvSHHBuffer, true);
ArraySetAsSeries(pvSLLBuffer, true);
ArraySetAsSeries(pvMHHBuffer, true);
ArraySetAsSeries(pvMLLBuffer, true);
ArraySetAsSeries(pvLHHBuffer, true);
ArraySetAsSeries(pvLLLBuffer, true);
ArraySetAsSeries(pvHHHBuffer, true);
ArraySetAsSeries(pvHLLBuffer, true);
//
// Initial Handler ...
mpvHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.x121.xpv",
//
// Inputs ...
//
// MARKET ...
"",
9,
17,
26,
35,
//
// TREND ...
"",
10,
//
// DETECTION ...
"",
MODE_HIGH,
MODE_LOW,
//
"",
true,
false,
false,
false
//
);
result = mpvHandler != INVALID_HANDLE;
//
return result;
}
//
void XPVHLPOnDeInit()
{
//
// Release Indicators ...
IndicatorRelease(mpvHandler);
}
//
void XPVHLPReadBuffers(int bar_index = 0)
{
//
// PEAKS ...
CopyBuffer(
mpvHandler,
X_PV_P_LINE,
bar_index,
bar_index + 100,
pvPBuffer);
//
// VALES ...
CopyBuffer(
mpvHandler,
X_PV_V_LINE,
bar_index,
bar_index + 100,
pvVBuffer);
//
// R ...
CopyBuffer(
mpvHandler,
X_PV_R_LINE,
bar_index,
bar_index + 100,
pvRBuffer);
//
// S ...
CopyBuffer(
mpvHandler,
X_PV_S_LINE,
bar_index,
bar_index + 100,
pvSBuffer);
//
// SHORT ...
//
// HIGH ...
CopyBuffer(
mpvHandler,
X_PV_SHH_LINE,
bar_index,
bar_index + 100,
pvSHHBuffer);
//
// LOW ...
CopyBuffer(
mpvHandler,
X_PV_SLL_LINE,
bar_index,
bar_index + 100,
pvSLLBuffer);
//
// MEIUM ...
//
// HIGH ...
CopyBuffer(
mpvHandler,
X_PV_MHH_LINE,
bar_index,
bar_index + 100,
pvMHHBuffer);
//
// LOW ...
CopyBuffer(
mpvHandler,
X_PV_MLL_LINE,
bar_index,
bar_index + 100,
pvMLLBuffer);
//
// LONG ...
//
// HIGH ...
CopyBuffer(
mpvHandler,
X_PV_LHH_LINE,
bar_index,
bar_index + 100,
pvLHHBuffer);
//
// LOW ...
CopyBuffer(
mpvHandler,
X_PV_LLL_LINE,
bar_index,
bar_index + 100,
pvLLLBuffer);
//
// HIND ...
//
// HIGH ...
CopyBuffer(
mpvHandler,
X_PV_HHH_LINE,
bar_index,
bar_index + 100,
pvHHHBuffer);
//
// LOW ...
CopyBuffer(
mpvHandler,
X_PV_HLL_LINE,
bar_index,
bar_index + 100,
pvHLLBuffer);
//
XPVHLPFindPivotPoints();
}
//
// END Handler Functions ...
//
//
// START Helper Functions ...
//
//
// Check isPeak ...
bool XPVHLPIsPeak(int bar_index)
{
//
bool result = false;
//
if (!XPVHLPIsValidArraySize(bar_index))
{
return result;
}
//
result = pvRBuffer[bar_index] == pvHHHBuffer[bar_index] &&
pvHHHBuffer[bar_index] == pvLHHBuffer[bar_index] &&
pvLHHBuffer[bar_index] == pvMHHBuffer[bar_index] &&
pvMHHBuffer[bar_index] == pvSHHBuffer[bar_index];
//
return result;
}
//
// Check isVale ...
bool XPVHLPIsVale(int bar_index)
{
//
bool result = false;
//
if (!XPVHLPIsValidArraySize(bar_index))
{
return result;
}
//
result = pvSBuffer[bar_index] == pvHLLBuffer[bar_index] &&
pvHLLBuffer[bar_index] == pvLLLBuffer[bar_index] &&
pvLLLBuffer[bar_index] == pvMLLBuffer[bar_index] &&
pvMLLBuffer[bar_index] == pvSLLBuffer[bar_index];
//
return result;
}
//
// Is Strong Support ...
bool XPVHLPIsStrongSupport(int bar_index)
{
//
bool result = false;
//
if (!XPVHLPIsValidArraySize(bar_index + 3))
{
return result;
}
//
result =
//
pvHLLBuffer[bar_index + 1] == pvHLLBuffer[bar_index + 2] &&
pvHLLBuffer[bar_index + 2] == pvHLLBuffer[bar_index + 3] &&
//
pvLLLBuffer[bar_index + 1] == pvLLLBuffer[bar_index + 2] &&
pvLLLBuffer[bar_index + 2] == pvLLLBuffer[bar_index + 3] &&
//
pvMLLBuffer[bar_index + 1] == pvMLLBuffer[bar_index + 2] &&
pvMLLBuffer[bar_index + 2] == pvMLLBuffer[bar_index + 3] &&
//
pvSLLBuffer[bar_index + 1] == pvSLLBuffer[bar_index + 2] &&
pvSLLBuffer[bar_index + 2] == pvSLLBuffer[bar_index + 3]
//
;
//
return result;
}
//
// Is Strong Resistance ...
bool XPVHLPIsStrongResistance(int bar_index)
{
//
bool result = false;
//
if (!XPVHLPIsValidArraySize(bar_index + 2))
{
return result;
}
//
result =
//
pvHHHBuffer[bar_index + 1] == pvHHHBuffer[bar_index + 2] &&
pvHHHBuffer[bar_index + 2] == pvHHHBuffer[bar_index + 3] &&
//
pvLHHBuffer[bar_index + 1] == pvLHHBuffer[bar_index + 2] &&
pvLHHBuffer[bar_index + 2] == pvLHHBuffer[bar_index + 3] &&
//
pvMHHBuffer[bar_index + 1] == pvMHHBuffer[bar_index + 2] &&
pvMHHBuffer[bar_index + 2] == pvMHHBuffer[bar_index + 3] &&
//
pvSHHBuffer[bar_index + 1] == pvSHHBuffer[bar_index + 2] &&
pvSHHBuffer[bar_index + 2] == pvSHHBuffer[bar_index + 3]
//
;
//
return result;
}
//
// Retrieve Highs ...
double XPVHLPGetMaxHH(int bar_index)
{
//
double result = 0;
//
if (!XPVHLPIsValidArraySize(bar_index))
{
return result;
}
//
result = MathMax(pvSHHBuffer[bar_index], pvMHHBuffer[bar_index]);
result = MathMax(result, pvLHHBuffer[bar_index]);
result = MathMax(result, pvHHHBuffer[bar_index]);
//
return result;
}
double XPVHLPGetMinHH(int bar_index)
{
//
double result = 0;
//
if (!XPVHLPIsValidArraySize(bar_index))
{
return result;
}
//
result = MathMin(pvSHHBuffer[bar_index], pvMHHBuffer[bar_index]);
result = MathMin(result, pvLHHBuffer[bar_index]);
result = MathMin(result, pvHHHBuffer[bar_index]);
//
return result;
}
//
// Retrieve Lows ...
double XPVHLPGetMaxLL(int bar_index)
{
//
double result = 0;
//
if (!XPVHLPIsValidArraySize(bar_index))
{
return result;
}
//
result = MathMax(pvSLLBuffer[bar_index], pvMLLBuffer[bar_index]);
result = MathMax(result, pvLLLBuffer[bar_index]);
result = MathMax(result, pvHLLBuffer[bar_index]);
//
return result;
}
double XPVHLPGetMinLL(int bar_index)
{
//
double result = 0;
//
if (!XPVHLPIsValidArraySize(bar_index))
{
return result;
}
//
result = MathMin(pvSLLBuffer[bar_index], pvMLLBuffer[bar_index]);
result = MathMin(result, pvLLLBuffer[bar_index]);
result = MathMin(result, pvHLLBuffer[bar_index]);
//
return result;
}
//
bool XPVHLPIsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(pvRBuffer);
result = rCount > bar_index + 1;
//
return result;
}
//
// SUPPORT and RESISTANCE ...
//
// Find Pivot Areas in PV ...
void XPVHLPFindPivotPoints()
{
//
double smoothingPoint = 3;
int verifications = 26;
//
// FLATS ...
double tmpFlats[];
int tmpFlatsCount = 0;
//
// PEAKS and VALES ...
//
// R ...
FindSameValueInBuffer(
tmpFlats,
pvRBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// S ...
FindSameValueInBuffer(
tmpFlats,
pvSBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// CYCLES ...
//
// SHORT ...
// LEVEL 1 ...
//
// HH ...
FindSameValueInBuffer(
tmpFlats,
pvSHHBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// LL ...
FindSameValueInBuffer(
tmpFlats,
pvSLLBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// MEDIUM ...
// LEVEL 2 ...
//
// HH ...
FindSameValueInBuffer(
tmpFlats,
pvMHHBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// LL ...
FindSameValueInBuffer(
tmpFlats,
pvMLLBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// LONG ...
// LEVEL 3 ...
//
// HH ...
FindSameValueInBuffer(
tmpFlats,
pvLHHBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// LL ...
FindSameValueInBuffer(
tmpFlats,
pvLLLBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// HINDMOST ...
// LEVEL 4 ...
//
// HH ...
FindSameValueInBuffer(
tmpFlats,
pvHHHBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// LL ...
FindSameValueInBuffer(
tmpFlats,
pvHLLBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// PEAKS and VALES ...
//
// PEAKS ...
FindSameValueInBuffer(
tmpFlats,
pvPBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
//
// VALES ...
FindSameValueInBuffer(
tmpFlats,
pvVBuffer);
tmpFlatsCount = ArraySize(tmpFlats);
if (tmpFlatsCount > 0)
{
//
AddsIfNotExists(
tmpFlats,
pvPivots,
smoothingPoint);
//
Clean(tmpFlats);
}
}
//
// Extract Support and Resistances ...
XOHCLSupRes XPVHLPFindCandleSupprtAndResistance(
int bar_index, // Bar Index ...
int count = 3 // Number of Requireds ...
)
{
//
XOHCLSupRes result = ExtractSupportAndResistance(
bar_index,
pvPivots,
count,
_Symbol,
_Period);
//
return result;
}
//
// END Helper Functions ...
//
@@ -0,0 +1,324 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XATRSL Indicator Provider
// Description: ATR Stop Loss ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// XPeaksAndVales Exported Buffers ...
enum ENUM_X_XATRSL_BUFFERS
{
//
X_ATRSL_UP_LINE = 0,
X_ATRSL_DOWN_LINE = 1,
X_ATRSL_SAR_LINE = 2,
X_ATRSL_RMA_LINE = 3,
X_ATRSL_WMA_LINE = 4,
X_ATRSL_MA1_LINE = 5,
X_ATRSL_SMA_LINE = 6,
X_ATRSL_EMA_LINE = 7,
X_ATRSL_ATR_LINE = 8,
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXATRSLHelper
{
//
public:
//
// Properties ...
double upBuffer[];
double downBuffer[];
double sarBuffer[];
double rmaBuffer[];
double wmaBuffer[];
double ma1Buffer[];
double smaBuffer[];
double emaBuffer[];
double atrBuffer[];
//
// Constructor ...
void XSCXATRSLHelper() {
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXATRSLHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52,
//
// MARKET ...
int length = 14, // Length
double step = 0.02, // Increment Step
double maximum = 0.2, // Maximum
ENUM_APPLIED_PRICE highAppliedTo = PRICE_HIGH, // High Line Applied To
ENUM_APPLIED_PRICE lowAppliedTo = PRICE_LOW // Low Line Applied To
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
// MARKET ...
mLength = length;
mStep = step;
mMaximum = maximum;
mHighAppliedTo = highAppliedTo;
mLowAppliedTo = lowAppliedTo;
//
mTag = "XATRSL " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xatrsl",
//
// Inputs ...
//
// MARKET ...
"",
mLength,
mStep,
mMaximum,
mHighAppliedTo,
mLowAppliedTo,
//
// PRESENTATION ...
"",
false,
false,
false
//
);
if (mHandler == INVALID_HANDLE)
{
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
ArraySetAsSeries(upBuffer, true);
ArraySetAsSeries(downBuffer, true);
ArraySetAsSeries(sarBuffer, true);
ArraySetAsSeries(rmaBuffer, true);
ArraySetAsSeries(wmaBuffer, true);
ArraySetAsSeries(ma1Buffer, true);
ArraySetAsSeries(smaBuffer, true);
ArraySetAsSeries(emaBuffer, true);
ArraySetAsSeries(atrBuffer, true);
}
//
// DeConstructor ...
void ~XSCXATRSLHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// UP ...
CopyBuffer(
mHandler,
X_ATRSL_UP_LINE,
0,
mNumberOfItemsReadPerTick,
upBuffer);
//
// DOWN ...
CopyBuffer(
mHandler,
X_ATRSL_DOWN_LINE,
0,
mNumberOfItemsReadPerTick,
downBuffer);
//
// SAR ...
CopyBuffer(
mHandler,
X_ATRSL_SAR_LINE,
0,
mNumberOfItemsReadPerTick,
sarBuffer);
//
// RMA ...
CopyBuffer(
mHandler,
X_ATRSL_RMA_LINE,
0,
mNumberOfItemsReadPerTick,
rmaBuffer);
//
// WMA ...
CopyBuffer(
mHandler,
X_ATRSL_WMA_LINE,
0,
mNumberOfItemsReadPerTick,
wmaBuffer);
//
// MA1 ...
CopyBuffer(
mHandler,
X_ATRSL_MA1_LINE,
0,
mNumberOfItemsReadPerTick,
ma1Buffer);
//
// MA 1 ...
CopyBuffer(
mHandler,
X_ATRSL_SMA_LINE,
0,
mNumberOfItemsReadPerTick,
smaBuffer);
//
// EMA ...
CopyBuffer(
mHandler,
X_ATRSL_EMA_LINE,
0,
mNumberOfItemsReadPerTick,
emaBuffer);
//
// ATR ...
CopyBuffer(
mHandler,
X_ATRSL_ATR_LINE,
0,
mNumberOfItemsReadPerTick,
atrBuffer);
}
//
// START Tools Functions ...
//
//
// END Tools Functions ...
//
//
protected:
//
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
// MARKET ...
//
// Length ...
int mLength;
//
// Increment Step ...
double mStep;
//
// Maximum ...
double mMaximum;
//
// High Line Applied To ...
ENUM_APPLIED_PRICE mHighAppliedTo;
//
// Low Line Applied To ...
ENUM_APPLIED_PRICE mLowAppliedTo;
//
string mTag;
//
int mHandler;
};
@@ -0,0 +1,215 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XHikenAshi Indicator Provider
// Description: Provides Features ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// XHikenAshi Exported Buffers ...
enum ENUM_X_HIKENASHI_BUFFERS
{
//
X_HK_OPEN_LINE = 0,
X_HK_HIGH_LINE = 1,
X_HK_LOW_LINE = 2,
X_HK_CLOSE_LINE = 3,
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXHKHelper
{
//
public:
//
// Properties ...
double openBuffer[];
double highBuffer[];
double lowBuffer[];
double closeBuffer[];
//
// Constructor ...
void XSCXHKHelper() {
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXHKHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
mTag = "XHK " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xhk",
//
// Inputs ...
"",
false,
false
//
);
if (mHandler == INVALID_HANDLE)
{
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
ArraySetAsSeries(openBuffer, true);
ArraySetAsSeries(highBuffer, true);
ArraySetAsSeries(lowBuffer, true);
ArraySetAsSeries(closeBuffer, true);
}
//
// DeConstructor ...
void ~XSCXHKHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// OPEN ...
CopyBuffer(
mHandler,
X_HK_OPEN_LINE,
0,
mNumberOfItemsReadPerTick,
openBuffer);
//
// HIGH ...
CopyBuffer(
mHandler,
X_HK_HIGH_LINE,
0,
mNumberOfItemsReadPerTick,
highBuffer);
//
// LOW ...
CopyBuffer(
mHandler,
X_HK_LOW_LINE,
0,
mNumberOfItemsReadPerTick,
lowBuffer);
//
// CLOSE ...
CopyBuffer(
mHandler,
X_HK_CLOSE_LINE,
0,
mNumberOfItemsReadPerTick,
closeBuffer);
}
//
// START Tools Functions ...
//
//
// END Tools Functions ...
//
//
protected:
//
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
string mTag;
//
int mHandler;
};
@@ -0,0 +1,690 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XIchimoku Indicator Provider
// Description: Provides Features ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// Ichimoku Lines Calculator Mode ...
enum ENUM_X_ICHIMOKU_CALCULATION_MODE
{
//
X_XICH_HH_LL_MODE = 1, // Highest High and Lowest Low
X_XICH_HO_LC_MODE = 2, // Highest Open and Lowest Close
};
//
// Ichimoku Indicator Exported Buffers ...
enum ENUM_X_ICHIMOKU_BUFFERS
{
//
X_TENKANSEN_LINE = 0,
X_KIJUNSEN_LINE = 1,
X_CHIKOUSPAN_LINE = 4,
X_SENKOUSPAN_A_LINE = 5,
X_SENKOUSPAN_B_LINE = 6,
};
//
// Model Ichimoku Data ...
struct XIchiInfo
{
//
int bar;
//
double tenkanSen;
double kijunSen;
//
double senkouSpanA;
double senkouSpanB;
//
double senkouSpanAFuture;
double senkouSpanBFuture;
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXICHHelper
{
//
// Public ...
public:
//
// Properties ...
double tenkanSenBuffer[];
double kijunSenBuffer[];
double chikouSpanBuffer[];
double senkouSpanABuffer[];
double senkouSpanBBuffer[];
//
// Constructor ...
void XSCXICHHelper()
{
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXICHHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52,
//
// TenkanSen ...
int tenkanSenLength = 9,
ENUM_X_ICHIMOKU_CALCULATION_MODE tenkanSenMode = X_XICH_HH_LL_MODE,
//
// KijunSen ...
int kijunSenLength = 26,
ENUM_X_ICHIMOKU_CALCULATION_MODE kijunSenMode = X_XICH_HH_LL_MODE,
//
// Senkou Span B ...
int senkouSpanBLength = 52,
ENUM_X_ICHIMOKU_CALCULATION_MODE senkouSpanBMode = X_XICH_HH_LL_MODE,
//
// Chikou Span ...
ENUM_APPLIED_PRICE chikuoSpanAppliedTo = PRICE_CLOSE
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
// TenkanSen ...
mKijunSenMode = kijunSenMode;
mKijunSenLength = kijunSenLength;
//
// KijunSen ...
mTenkanSenMode = tenkanSenMode;
mTenkanSenLength = tenkanSenLength;
//
// Senkou Span B ...
mSenkouSpanBMode = senkouSpanBMode;
mSenkouSpanBLength = senkouSpanBLength;
//
mSenkouSpanBTopMode = NULL;
mSenkouSpanBBottomMode = NULL;
//
// Chikou Span ...
mChikuoSpanAppliedTo = chikuoSpanAppliedTo;
//
mTag = "XICH " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xich",
//
// Inputs ...
//
// TENKANSEN ...
"",
mTenkanSenLength,
mTenkanSenMode,
//
// KIJUNSEN ...
"",
kijunSenLength,
kijunSenMode,
//
// SENKOUSPANB ...
"",
senkouSpanBLength,
senkouSpanBMode,
//
// CHIKOUSPAN ...
"",
mChikuoSpanAppliedTo,
//
// PRESENTATION ...
"",
false,
false,
false,
false,
false,
false,
false,
false,
true // Shift Kumo ...
//
);
if (mHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
ArraySetAsSeries(tenkanSenBuffer, true);
ArraySetAsSeries(kijunSenBuffer, true);
ArraySetAsSeries(chikouSpanBuffer, true);
ArraySetAsSeries(senkouSpanABuffer, true);
ArraySetAsSeries(senkouSpanBBuffer, true);
}
//
// DeConstructor ...
void ~XSCXICHHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// TENKANSEN ...
CopyBuffer(
mHandler,
X_TENKANSEN_LINE,
0,
mNumberOfItemsReadPerTick,
tenkanSenBuffer);
//
// KIJUNSEN ...
CopyBuffer(
mHandler,
X_KIJUNSEN_LINE,
0,
mNumberOfItemsReadPerTick,
kijunSenBuffer);
//
// CHIKOUSPAN ...
CopyBuffer(
mHandler,
X_CHIKOUSPAN_LINE,
mKijunSenLength - 1,
mNumberOfItemsReadPerTick,
chikouSpanBuffer);
//
// SENKOUSPANA ...
CopyBuffer(
mHandler,
X_SENKOUSPAN_A_LINE,
-mKijunSenLength + 1,
mNumberOfItemsReadPerTick,
senkouSpanABuffer);
//
// SENKOUSPANB ...
CopyBuffer(
mHandler,
X_SENKOUSPAN_B_LINE,
-mKijunSenLength + 1,
mNumberOfItemsReadPerTick,
senkouSpanBBuffer);
}
//
// START Tools Functions ...
//
//
// Retrieve Ichimoku Data at Specific Bar Index ...
XIchiInfo GetInfo(
int bar_index // Bar Index ...
)
{
//
XIchiInfo result = {};
//
result.bar = bar_index;
result.tenkanSen = tenkanSenBuffer[bar_index];
result.kijunSen = kijunSenBuffer[bar_index];
result.senkouSpanA = senkouSpanABuffer[bar_index + mKijunSenLength];
result.senkouSpanB = senkouSpanBBuffer[bar_index + mKijunSenLength];
result.senkouSpanAFuture = senkouSpanABuffer[bar_index];
result.senkouSpanBFuture = senkouSpanBBuffer[bar_index];
//
return result;
}
//
// Check Tenkan Sen Over Kijun Sen ...
bool IsTenkanSenOverKijunSen(
int bar_index // Bar Index ...
) {
//
bool result = false;
//
if (!IsValidArraySize(bar_index))
{
return result;
}
//
result =
//
tenkanSenBuffer[bar_index] > kijunSenBuffer[bar_index]
//
;
//
return result;
}
//
// Is Tenkan Sen Under Kijun Sen ...
bool IsTenkanSenUnderKijunSen(
int bar_index // Bar Index ...
) {
//
bool result = false;
//
if (!IsValidArraySize(bar_index))
{
return result;
}
//
result =
//
tenkanSenBuffer[bar_index] < kijunSenBuffer[bar_index]
//
;
//
return result;
}
//
// Tenkan Sen Croosed Over Kijun Sen ...
bool IsTenkanSenCrossedOverKijunSen(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 2))
{
return result;
}
//
result = IsCrossOver(
tenkanSenBuffer,
kijunSenBuffer,
bar_index);
//
return result;
}
//
// Tenkan Sen Croosed Under Kijun Sen ...
bool IsTenkanSenCrossedUnderKijunSen(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 2))
{
return result;
}
//
result = IsCrossUnder(
tenkanSenBuffer,
kijunSenBuffer,
bar_index);
//
return result;
}
//
// Check Kumo is Bullish ...
bool IsKumoBullish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
int start = 0;
//
if (!onFuture)
{
start = (mKijunSenLength - bar_index);
}
else
{
start = (mKijunSenLength - bar_index) * 2;
}
//
if (!IsValidArraySize(start))
{
return result;
}
//
result =
//
senkouSpanABuffer[start + 1] > senkouSpanBBuffer[start + 1] &&
senkouSpanABuffer[start] > senkouSpanBBuffer[start]
//
;
//
return result;
}
//
// Check Kumo is Bearish ...
bool IsKumoBearish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
int start = 0;
//
if (!onFuture)
{
start = (mKijunSenLength - bar_index);
}
else
{
start = (mKijunSenLength - bar_index) * 2;
}
//
if (!IsValidArraySize(start))
{
return result;
}
//
result =
//
senkouSpanABuffer[start + 1] < senkouSpanBBuffer[start + 1] &&
senkouSpanABuffer[start] < senkouSpanBBuffer[start]
//
;
//
return result;
}
//
// Check Kumo is Change to Bullish ...
bool IsKumoSwitchedToBullish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
int start = 0;
//
if (!onFuture)
{
start = (mKijunSenLength - bar_index);
}
else
{
start = (mKijunSenLength - bar_index) * 2;
}
//
if (!IsValidArraySize(start))
{
return result;
}
//
result =
//
senkouSpanABuffer[start + 1] > senkouSpanBBuffer[start + 1] &&
senkouSpanABuffer[start] <= senkouSpanBBuffer[start]
//
;
//
return result;
}
//
// Check Kumo is Change to Bearish ...
bool IsKumoSwitchedToBearish(
int bar_index, // Bar Index ...
bool onFuture = false // Future Check ...
)
{
//
bool result = false;
//
int start = 0;
//
if (!onFuture)
{
start = (mKijunSenLength - bar_index);
}
else
{
start = (mKijunSenLength - bar_index) * 2;
}
//
if (!IsValidArraySize(start))
{
return result;
}
//
result =
//
senkouSpanABuffer[start + 1] < senkouSpanBBuffer[start + 1] &&
senkouSpanABuffer[start] >= senkouSpanBBuffer[start]
//
;
//
return result;
}
//
// Check Ichimokou Common Conditions for Long Trades ...
// TenkanSen > Kumo
// KijunSen > Kumo
// ChikouSpan > Kumo
// Kumo has Good Body
bool CheckCommonLongConditions() {
//
bool result = false;
//
// TODO: Complete this ...
//
return result;
}
//
// Check Ichimoku Common Conditions for Short Trades ...
// TenkanSen < Kumo
// KijunSen < Kumo
// ChikouSpan < Kumo
// Kumo has Good Body
bool CheckCommonShortConditions() {
//
bool result = false;
//
// TODO: Complete this ...
//
return result;
}
//
// END Tools Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
// TenkanSen ...
int mTenkanSenLength;
ENUM_X_ICHIMOKU_CALCULATION_MODE mTenkanSenMode;
//
// KijunSen ...
int mKijunSenLength;
ENUM_X_ICHIMOKU_CALCULATION_MODE mKijunSenMode;
//
// Senkou Span B ...
int mSenkouSpanBLength;
ENUM_X_ICHIMOKU_CALCULATION_MODE mSenkouSpanBMode;
//
ENUM_SERIESMODE mSenkouSpanBTopMode;
ENUM_SERIESMODE mSenkouSpanBBottomMode;
//
// Chikou Span ...
ENUM_APPLIED_PRICE mChikuoSpanAppliedTo;
//
string mTag;
//
int mHandler;
//
bool IsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(tenkanSenBuffer);
result = rCount > bar_index + 1;
//
return result;
}
};
@@ -0,0 +1,418 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XMC Indicator Provider
// Description: Provides Features ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// XMC Exported Buffers ...
enum ENUM_X_XMC_BUFFERS
{
//
X_MC_FAST_LINE = 0,
X_MC_SLOW_LINE = 1,
X_MC_VERIFIER_LINE = 2,
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXMCHelper
{
//
public:
//
// Properties ...
double fastBuffer[];
double slowBuffer[];
double verifierBuffer[];
//
// Constructor ...
void XSCXMCHelper() {
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXMCHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52,
//
// FAST ...
int fastMaLength = 9,
int fastMaShift = 0,
ENUM_MA_METHOD fastMaMethod = MODE_EMA,
ENUM_APPLIED_PRICE fastMaAppliedTo = PRICE_CLOSE,
//
// SLOW ...
int slowMaLength = 18,
int slowMaShift = 0,
ENUM_MA_METHOD slowMaMethod = MODE_EMA,
ENUM_APPLIED_PRICE slowMaAppliedTo = PRICE_CLOSE,
//
// VERIFIER ...
int verifierMaLength = 50,
int verifierMaShift = 0,
ENUM_MA_METHOD verifierMaMethod = MODE_EMA,
ENUM_APPLIED_PRICE verifierMaAppliedTo = PRICE_CLOSE
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
// FAST ...
mFastMaLength = fastMaLength;
mFastMaShift = fastMaShift;
mFastMaMethod = fastMaMethod;
mFastMaAppliedTo = fastMaAppliedTo;
//
// SLOW ...
mSlowMaLength = slowMaLength;
mSlowMaShift = slowMaShift;
mSlowMaMethod = slowMaMethod;
mSlowMaAppliedTo = slowMaAppliedTo;
//
// VERIFIER ...
mVerifierMaLength = verifierMaLength;
mVerifierMaShift = verifierMaShift;
mVerifierMaMethod = verifierMaMethod;
mVerifierMaAppliedTo = verifierMaAppliedTo;
//
mTag = "XMC " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xmc",
//
// Inputs ...
//
// FAST ...
"",
mFastMaLength,
mFastMaShift,
mFastMaMethod,
mFastMaAppliedTo,
//
// SLOW ...
"",
mSlowMaLength,
mSlowMaShift,
mSlowMaMethod,
mSlowMaAppliedTo,
//
// VERIFIER ...
"",
mVerifierMaLength,
mVerifierMaShift,
mVerifierMaMethod,
mVerifierMaAppliedTo,
//
"",
false,
false,
false
//
);
if (mHandler == INVALID_HANDLE)
{
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
ArraySetAsSeries(fastBuffer, true);
ArraySetAsSeries(slowBuffer, true);
ArraySetAsSeries(verifierBuffer, true);
}
//
// DeConstructor ...
void ~XSCXMCHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// FAST ...
CopyBuffer(
mHandler,
X_MC_FAST_LINE,
0,
mNumberOfItemsReadPerTick,
fastBuffer);
//
// SLOW ...
CopyBuffer(
mHandler,
X_MC_SLOW_LINE,
0,
mNumberOfItemsReadPerTick,
slowBuffer);
//
// VERIFIER ...
CopyBuffer(
mHandler,
X_MC_VERIFIER_LINE,
0,
mNumberOfItemsReadPerTick,
verifierBuffer);
}
//
// START Tools Functions ...
//
//
// Check Fast Over Slow ...
bool IsFastOverSlow(
int bar_index // Bar Index ...
) {
//
bool result = false;
//
if (!IsValidArraySize(bar_index)) {
return result;
}
//
result =
//
IsOver(
fastBuffer,
slowBuffer,
bar_index
)
//
;
//
return result;
}
//
// Check Fast Crossed Over Slow ...
bool IsFastCrossedOverSlow(
int bar_index // Bar Index ...
) {
//
bool result = false;
//
if (!IsValidArraySize(bar_index)) {
return result;
}
//
result =
//
IsCrossOver(
fastBuffer,
slowBuffer,
bar_index
)
//
;
//
return result;
}
//
// Check Fast Under Slow ...
bool IsFastUnderSlow(
int bar_index // Bar Index ...
) {
//
bool result = false;
//
if (!IsValidArraySize(bar_index)) {
return result;
}
//
result =
//
IsUnder(
fastBuffer,
slowBuffer,
bar_index
)
//
;
//
return result;
}
//
// Check Fast Crossed Under Slow ...
bool IsFastCrossedUnderSlow(
int bar_index // Bar Index ...
) {
//
bool result = false;
//
if (!IsValidArraySize(bar_index)) {
return result;
}
//
result =
//
IsCrossUnder(
fastBuffer,
slowBuffer,
bar_index
)
//
;
//
return result;
}
//
// END Tools Functions ...
//
//
protected:
//
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
// FAST ...
int mFastMaLength;
int mFastMaShift;
ENUM_MA_METHOD mFastMaMethod;
ENUM_APPLIED_PRICE mFastMaAppliedTo;
//
// SLOW ...
int mSlowMaLength;
int mSlowMaShift;
ENUM_MA_METHOD mSlowMaMethod;
ENUM_APPLIED_PRICE mSlowMaAppliedTo;
//
// VERIFIER ...
int mVerifierMaLength;
int mVerifierMaShift;
ENUM_MA_METHOD mVerifierMaMethod;
ENUM_APPLIED_PRICE mVerifierMaAppliedTo;
//
string mTag;
//
int mHandler;
//
bool IsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(fastBuffer);
result = rCount > bar_index + 1;
//
return result;
}
};
@@ -0,0 +1,575 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XPPSR Indicator Provider
// Description: Provides Features ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// XPERIOD Calculation Method ...
// USED For Multiple Time Frames ...
enum ENUM_X_PERIOD_METHOD
{
//
X_PERIOD_NOTHING,
//
X_PERIOD_AUTO,
//
X_PERIOD_MANUALLY
};
//
// XPPSR Exported Buffers ...
enum ENUM_X_XPPSR_BUFFERS
{
//
// LEVEL 1 ...
X_PPSR_L1_R_LINE = 0,
X_PPSR_L1_R1_LINE = 1,
X_PPSR_L1_R2_LINE = 2,
X_PPSR_L1_S_LINE = 3,
X_PPSR_L1_S1_LINE = 4,
X_PPSR_L1_S2_LINE = 5,
//
// LEVEL 2 ...
X_PPSR_L2_R_LINE = 6,
X_PPSR_L2_R1_LINE = 7,
X_PPSR_L2_R2_LINE = 8,
X_PPSR_L2_S_LINE = 9,
X_PPSR_L2_S1_LINE = 10,
X_PPSR_L2_S2_LINE = 11,
//
// LEVEL 3 ...
X_PPSR_L3_R_LINE = 12,
X_PPSR_L3_R1_LINE = 13,
X_PPSR_L3_R2_LINE = 14,
X_PPSR_L3_S_LINE = 15,
X_PPSR_L3_S1_LINE = 16,
X_PPSR_L3_S2_LINE = 17,
//
// LEVEL 4 ...
X_PPSR_L4_R_LINE = 18,
X_PPSR_L4_R1_LINE = 19,
X_PPSR_L4_R2_LINE = 20,
X_PPSR_L4_S_LINE = 21,
X_PPSR_L4_S1_LINE = 22,
X_PPSR_L4_S2_LINE = 23,
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXPPSRHelper
{
//
public:
//
// Properties ...
//
// LEVEL 1 ...
double l1RBuffer[];
double l1R1Buffer[];
double l1R2Buffer[];
double l1SBuffer[];
double l1S1Buffer[];
double l1S2Buffer[];
//
// LEVEL 2 ...
double l2RBuffer[];
double l2R1Buffer[];
double l2R2Buffer[];
double l2SBuffer[];
double l2S1Buffer[];
double l2S2Buffer[];
//
// LEVEL 3 ...
double l3RBuffer[];
double l3R1Buffer[];
double l3R2Buffer[];
double l3SBuffer[];
double l3S1Buffer[];
double l3S2Buffer[];
//
// LEVEL 4 ...
double l4RBuffer[];
double l4R1Buffer[];
double l4R2Buffer[];
double l4SBuffer[];
double l4S1Buffer[];
double l4S2Buffer[];
//
// Constructor ...
void XSCXPPSRHelper()
{
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXPPSRHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52,
//
// LEVEL 1 ...
ENUM_X_PERIOD_METHOD l1Method = X_PERIOD_AUTO,
ENUM_TIMEFRAMES l1Period = NULL,
ENUM_SERIESMODE l1HHMode = MODE_HIGH,
ENUM_SERIESMODE l1LLMode = MODE_LOW,
//
// LEVEL 2 ...
ENUM_X_PERIOD_METHOD l2Method = X_PERIOD_AUTO,
ENUM_TIMEFRAMES l2Period = NULL,
ENUM_SERIESMODE l2HHMode = MODE_HIGH,
ENUM_SERIESMODE l2LLMode = MODE_LOW,
//
// LEVEL 3 ...
ENUM_X_PERIOD_METHOD l3Method = X_PERIOD_AUTO,
ENUM_TIMEFRAMES l3Period = NULL,
ENUM_SERIESMODE l3HHMode = MODE_HIGH,
ENUM_SERIESMODE l3LLMode = MODE_LOW,
//
// LEVEL 4 ...
ENUM_X_PERIOD_METHOD l4Method = X_PERIOD_AUTO,
ENUM_TIMEFRAMES l4Period = NULL,
ENUM_SERIESMODE l4HHMode = MODE_HIGH,
ENUM_SERIESMODE l4LLMode = MODE_LOW
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
// LEVEL 1 ...
mL1Method = l1Method;
mL1Period = l1Period;
mL1HHMode = l1HHMode;
mL1LLMode = l1LLMode;
//
// LEVEL 2 ...
mL2Method = l2Method;
mL2Period = l2Period;
mL2HHMode = l2HHMode;
mL2LLMode = l2LLMode;
//
// LEVEL 3 ...
mL3Method = l3Method;
mL3Period = l3Period;
mL3HHMode = l3HHMode;
mL3LLMode = l3LLMode;
//
// LEVEL 4 ...
mL4Method = l4Method;
mL4Period = l4Period;
mL4HHMode = l4HHMode;
mL4LLMode = l4LLMode;
//
mTag = "XPPSR " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xppsr",
//
// Inputs ...
//
// LEVEL 1 ...
"",
mL1Method,
mL1Period,
mL1HHMode,
mL1LLMode,
//
// LEVEL 2 ...
"",
mL2Method,
mL2Period,
mL2HHMode,
mL2LLMode,
//
// LEVEL 3 ...
"",
mL3Method,
mL3Period,
mL3HHMode,
mL3LLMode,
//
// LEVEL 4 ...
"",
mL4Method,
mL4Period,
mL4HHMode,
mL4LLMode,
//
"",
"",
false,
false,
false,
false,
"",
false,
false,
false,
false
//
);
if (mHandler == INVALID_HANDLE)
{
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
// LEVEL 1 ...
ArraySetAsSeries(l1RBuffer, true);
ArraySetAsSeries(l1R1Buffer, true);
ArraySetAsSeries(l1R2Buffer, true);
ArraySetAsSeries(l1SBuffer, true);
ArraySetAsSeries(l1S1Buffer, true);
ArraySetAsSeries(l1S2Buffer, true);
//
// LEVEL 2 ...
ArraySetAsSeries(l2RBuffer, true);
ArraySetAsSeries(l2R1Buffer, true);
ArraySetAsSeries(l2R2Buffer, true);
ArraySetAsSeries(l2SBuffer, true);
ArraySetAsSeries(l2S1Buffer, true);
ArraySetAsSeries(l2S2Buffer, true);
//
// LEVEL 3 ...
ArraySetAsSeries(l3RBuffer, true);
ArraySetAsSeries(l3R1Buffer, true);
ArraySetAsSeries(l3R2Buffer, true);
ArraySetAsSeries(l3SBuffer, true);
ArraySetAsSeries(l3S1Buffer, true);
ArraySetAsSeries(l3S2Buffer, true);
//
// LEVEL 4 ...
ArraySetAsSeries(l4RBuffer, true);
ArraySetAsSeries(l4R1Buffer, true);
ArraySetAsSeries(l4R2Buffer, true);
ArraySetAsSeries(l4SBuffer, true);
ArraySetAsSeries(l4S1Buffer, true);
ArraySetAsSeries(l4S2Buffer, true);
}
//
// DeConstructor ...
void ~XSCXPPSRHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// LEVEL 1 ...
CopyBuffer(
mHandler,
X_PPSR_L1_R_LINE,
0,
mNumberOfItemsReadPerTick,
l1RBuffer);
CopyBuffer(
mHandler,
X_PPSR_L1_R1_LINE,
0,
mNumberOfItemsReadPerTick,
l1R1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L1_R2_LINE,
0,
mNumberOfItemsReadPerTick,
l1R2Buffer);
CopyBuffer(
mHandler,
X_PPSR_L1_S_LINE,
0,
mNumberOfItemsReadPerTick,
l1SBuffer);
CopyBuffer(
mHandler,
X_PPSR_L1_S1_LINE,
0,
mNumberOfItemsReadPerTick,
l1S1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L1_S2_LINE,
0,
mNumberOfItemsReadPerTick,
l1S2Buffer);
//
// LEVEL 2 ...
CopyBuffer(
mHandler,
X_PPSR_L2_R_LINE,
0,
mNumberOfItemsReadPerTick,
l2RBuffer);
CopyBuffer(
mHandler,
X_PPSR_L2_R1_LINE,
0,
mNumberOfItemsReadPerTick,
l2R1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L2_R2_LINE,
0,
mNumberOfItemsReadPerTick,
l2R2Buffer);
CopyBuffer(
mHandler,
X_PPSR_L2_S_LINE,
0,
mNumberOfItemsReadPerTick,
l2SBuffer);
CopyBuffer(
mHandler,
X_PPSR_L2_S1_LINE,
0,
mNumberOfItemsReadPerTick,
l2S1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L2_S2_LINE,
0,
mNumberOfItemsReadPerTick,
l2S2Buffer);
//
// LEVEL 3 ...
CopyBuffer(
mHandler,
X_PPSR_L3_R_LINE,
0,
mNumberOfItemsReadPerTick,
l3RBuffer);
CopyBuffer(
mHandler,
X_PPSR_L3_R1_LINE,
0,
mNumberOfItemsReadPerTick,
l3R1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L3_R2_LINE,
0,
mNumberOfItemsReadPerTick,
l3R2Buffer);
CopyBuffer(
mHandler,
X_PPSR_L3_S_LINE,
0,
mNumberOfItemsReadPerTick,
l3SBuffer);
CopyBuffer(
mHandler,
X_PPSR_L3_S1_LINE,
0,
mNumberOfItemsReadPerTick,
l3S1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L3_S2_LINE,
0,
mNumberOfItemsReadPerTick,
l3S2Buffer);
//
// LEVEL 4 ...
CopyBuffer(
mHandler,
X_PPSR_L4_R_LINE,
0,
mNumberOfItemsReadPerTick,
l4RBuffer);
CopyBuffer(
mHandler,
X_PPSR_L4_R1_LINE,
0,
mNumberOfItemsReadPerTick,
l4R1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L4_R2_LINE,
0,
mNumberOfItemsReadPerTick,
l4R2Buffer);
CopyBuffer(
mHandler,
X_PPSR_L4_S_LINE,
0,
mNumberOfItemsReadPerTick,
l4SBuffer);
CopyBuffer(
mHandler,
X_PPSR_L4_S1_LINE,
0,
mNumberOfItemsReadPerTick,
l4S1Buffer);
CopyBuffer(
mHandler,
X_PPSR_L4_S2_LINE,
0,
mNumberOfItemsReadPerTick,
l4S2Buffer);
}
//
// START Tools Functions ...
//
//
// END Tools Functions ...
//
//
protected:
//
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
// LEVEL 1 ...
ENUM_X_PERIOD_METHOD mL1Method;
ENUM_TIMEFRAMES mL1Period;
ENUM_SERIESMODE mL1HHMode;
ENUM_SERIESMODE mL1LLMode;
//
// LEVEL 2 ...
ENUM_X_PERIOD_METHOD mL2Method;
ENUM_TIMEFRAMES mL2Period;
ENUM_SERIESMODE mL2HHMode;
ENUM_SERIESMODE mL2LLMode;
//
// LEVEL 3 ...
ENUM_X_PERIOD_METHOD mL3Method;
ENUM_TIMEFRAMES mL3Period;
ENUM_SERIESMODE mL3HHMode;
ENUM_SERIESMODE mL3LLMode;
//
// LEVEL 4 ...
ENUM_X_PERIOD_METHOD mL4Method;
ENUM_TIMEFRAMES mL4Period;
ENUM_SERIESMODE mL4HHMode;
ENUM_SERIESMODE mL4LLMode;
//
string mTag;
//
int mHandler;
//
bool IsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(l1RBuffer);
result = rCount > bar_index + 1;
//
return result;
}
};
@@ -0,0 +1,707 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XPV Indicator Provider
// Description: Peaks and Vales ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// XPeaksAndVales Exported Buffers ...
enum ENUM_X_XPV_BUFFERS
{
//
// PEAKSANDVALES ...
X_PV_P_LINE = 0,
X_PV_V_LINE = 1,
//
// SUPPORTRESISTANCE ...
X_PV_R_LINE = 2,
X_PV_S_LINE = 4,
//
// SHORT ...
X_PV_SHH_LINE = 6,
X_PV_SLL_LINE = 7,
//
// MEDIUM ...
X_PV_MHH_LINE = 8,
X_PV_MLL_LINE = 9,
//
// LONG ...
X_PV_LHH_LINE = 10,
X_PV_LLL_LINE = 11,
//
// HIND ...
X_PV_HHH_LINE = 12,
X_PV_HLL_LINE = 13,
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXPVHelper
{
//
public:
//
// Properties ...
double pBuffer[];
double vBuffer[];
double rBuffer[];
double sBuffer[];
double sHHBuffer[];
double sLLBuffer[];
double mHHBuffer[];
double mLLBuffer[];
double lHHBuffer[];
double lLLBuffer[];
double hHHBuffer[];
double hLLBuffer[];
//
// Constructor ...
void XSCXPVHelper()
{
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXPVHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52,
//
// MARKET ...
int shortLength = 9,
int mediumLength = 17,
int longLength = 26,
int hindLength = 35,
//
// TREND ...
int numOfShoulder = 10,
//
// DETECTION ...
ENUM_SERIESMODE hhMode = MODE_HIGH,
ENUM_SERIESMODE llMode = MODE_LOW
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
// MARKET ...
mShortLength = shortLength;
mMediumLength = mediumLength;
mLongLength = longLength;
mHindLength = hindLength;
//
// TREND ...
mNumOfShoulder = numOfShoulder;
//
// DETECTION ...
mHhMode = hhMode;
mLlMode = llMode;
//
mTag = "XPV " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xpv",
//
// Inputs ...
//
// MARKET ...
"",
mShortLength,
mMediumLength,
mLongLength,
mHindLength,
//
// TREND ...
"",
mNumOfShoulder,
//
// DETECTION ...
"",
mHhMode,
mLlMode,
//
"",
false,
false,
false,
false
//
);
if (mHandler == INVALID_HANDLE)
{
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
// PEAKSANDVALES ...
ArraySetAsSeries(pBuffer, true);
ArraySetAsSeries(vBuffer, true);
//
// RESISTANCESUPPORT ...
ArraySetAsSeries(rBuffer, true);
ArraySetAsSeries(sBuffer, true);
//
// SHORT ...
ArraySetAsSeries(sHHBuffer, true);
ArraySetAsSeries(sLLBuffer, true);
//
// MEDIUM ...
ArraySetAsSeries(mHHBuffer, true);
ArraySetAsSeries(mLLBuffer, true);
//
// LONG ...
ArraySetAsSeries(lHHBuffer, true);
ArraySetAsSeries(lLLBuffer, true);
//
// HIND ...
ArraySetAsSeries(lHHBuffer, true);
ArraySetAsSeries(lLLBuffer, true);
}
//
// DeConstructor ...
void ~XSCXPVHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// PEAKS ...
CopyBuffer(
mHandler,
X_PV_P_LINE,
0,
mNumberOfItemsReadPerTick,
pBuffer);
//
// VALES ...
CopyBuffer(
mHandler,
X_PV_V_LINE,
0,
mNumberOfItemsReadPerTick,
vBuffer);
//
// R ...
CopyBuffer(
mHandler,
X_PV_R_LINE,
0,
mNumberOfItemsReadPerTick,
rBuffer);
//
// S ...
CopyBuffer(
mHandler,
X_PV_S_LINE,
0,
mNumberOfItemsReadPerTick,
sBuffer);
//
// SHORT ...
//
// HIGH ...
CopyBuffer(
mHandler,
X_PV_SHH_LINE,
0,
mNumberOfItemsReadPerTick,
sHHBuffer);
//
// LOW ...
CopyBuffer(
mHandler,
X_PV_SLL_LINE,
0,
mNumberOfItemsReadPerTick,
sLLBuffer);
//
// MEIUM ...
//
// HIGH ...
CopyBuffer(
mHandler,
X_PV_MHH_LINE,
0,
mNumberOfItemsReadPerTick,
mHHBuffer);
//
// LOW ...
CopyBuffer(
mHandler,
X_PV_MLL_LINE,
0,
mNumberOfItemsReadPerTick,
mLLBuffer);
//
// LONG ...
//
// HIGH ...
CopyBuffer(
mHandler,
X_PV_LHH_LINE,
0,
mNumberOfItemsReadPerTick,
lHHBuffer);
//
// LOW ...
CopyBuffer(
mHandler,
X_PV_LLL_LINE,
0,
mNumberOfItemsReadPerTick,
lLLBuffer);
//
// HIND ...
//
// HIGH ...
CopyBuffer(
mHandler,
X_PV_HHH_LINE,
0,
mNumberOfItemsReadPerTick,
hHHBuffer);
//
// LOW ...
CopyBuffer(
mHandler,
X_PV_HLL_LINE,
0,
mNumberOfItemsReadPerTick,
hLLBuffer);
}
//
// START Tools Functions ...
//
//
// Check isPeak ...
bool IsPeak(int bar_index)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index))
{
return result;
}
//
result = rBuffer[bar_index] == hHHBuffer[bar_index] &&
hHHBuffer[bar_index] == lHHBuffer[bar_index] &&
lHHBuffer[bar_index] == mHHBuffer[bar_index] &&
mHHBuffer[bar_index] == sHHBuffer[bar_index];
//
return result;
}
//
// Check isVale ...
bool IsVale(int bar_index)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index))
{
return result;
}
//
result = sBuffer[bar_index] == hLLBuffer[bar_index] &&
hLLBuffer[bar_index] == lLLBuffer[bar_index] &&
lLLBuffer[bar_index] == mLLBuffer[bar_index] &&
mLLBuffer[bar_index] == sLLBuffer[bar_index];
//
return result;
}
//
// Is Strong Support ...
bool IsStrongSupport(int bar_index)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 3))
{
return result;
}
//
result =
//
hLLBuffer[bar_index + 1] == hLLBuffer[bar_index + 2] &&
hLLBuffer[bar_index + 2] == hLLBuffer[bar_index + 3] &&
//
lLLBuffer[bar_index + 1] == lLLBuffer[bar_index + 2] &&
lLLBuffer[bar_index + 2] == lLLBuffer[bar_index + 3] &&
//
mLLBuffer[bar_index + 1] == mLLBuffer[bar_index + 2] &&
mLLBuffer[bar_index + 2] == mLLBuffer[bar_index + 3] &&
//
sLLBuffer[bar_index + 1] == sLLBuffer[bar_index + 2] &&
sLLBuffer[bar_index + 2] == sLLBuffer[bar_index + 3]
//
;
//
return result;
}
//
// Is Strong Resistance ...
bool IsStrongResistance(int bar_index)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 2))
{
return result;
}
//
result =
//
hHHBuffer[bar_index + 1] == hHHBuffer[bar_index + 2] &&
hHHBuffer[bar_index + 2] == hHHBuffer[bar_index + 3] &&
//
lHHBuffer[bar_index + 1] == lHHBuffer[bar_index + 2] &&
lHHBuffer[bar_index + 2] == lHHBuffer[bar_index + 3] &&
//
mHHBuffer[bar_index + 1] == mHHBuffer[bar_index + 2] &&
mHHBuffer[bar_index + 2] == mHHBuffer[bar_index + 3] &&
//
sHHBuffer[bar_index + 1] == sHHBuffer[bar_index + 2] &&
sHHBuffer[bar_index + 2] == sHHBuffer[bar_index + 3]
//
;
//
return result;
}
//
// Find Last Strong Support ...
double GetLastStrongSupport(
int bar_index, // Bar Index ...
int length // LoopBack ...
)
{
//
double result = 0;
//
bool isBarIndexSupport = IsStrongSupport(bar_index);
if (isBarIndexSupport)
{
length += bar_index;
}
//
if (!IsValidArraySize(bar_index + length + 1))
{
return result;
}
//
for (int i = bar_index; i < bar_index + length; i++)
{
//
if (IsStrongSupport(i))
{
//
result = sLLBuffer[i];
break;
}
}
//
return result;
}
//
// Find Last Strong Resistance ...
double GetLastStrongResistance(
int bar_index, // Bar Index ...
int length // LoopBack ...
)
{
//
double result = 0;
//
bool isBarIndexResistance = IsStrongResistance(bar_index);
if (isBarIndexResistance)
{
length += bar_index;
}
//
if (!IsValidArraySize(bar_index + length + 1))
{
return result;
}
//
for (int i = bar_index; i < bar_index + length; i++)
{
//
if (IsStrongResistance(i))
{
//
result = sHHBuffer[i];
break;
}
}
//
return result;
}
//
// Find Strong Support Break Stop ...
bool IsSupportBreakedStop(
int bar_index, // Bar Index ...
int length // LoopBack ...
)
{
//
bool result = false;
//
bool isBaIndexSupport = IsStrongSupport(bar_index);
if (isBaIndexSupport)
{
return result;
}
//
if (!IsValidArraySize(bar_index + length + 1))
{
return result;
}
//
bool isAllStrongSupport = true;
for (int i = bar_index; i < bar_index + length; i++)
{
//
if (!IsStrongSupport(i) && isAllStrongSupport)
{
//
isAllStrongSupport = false;
break;
}
}
//
result = !isBaIndexSupport && isAllStrongSupport;
//
return result;
}
//
// Find Strong Resistance Break Stop ...
bool IsResistanceBreakedStop(
int bar_index, // Bar Index ...
int length // LoopBack ...
)
{
//
bool result = false;
//
bool isBaIndexResistance = IsStrongResistance(bar_index);
if (isBaIndexResistance)
{
return result;
}
//
if (!IsValidArraySize(bar_index + length + 1))
{
return result;
}
//
bool isAllStrongResistance = true;
for (int i = bar_index; i < bar_index + length; i++)
{
//
if (!IsStrongResistance(i) && isAllStrongResistance)
{
//
isAllStrongResistance = false;
break;
}
}
//
result = !isBaIndexResistance && isAllStrongResistance;
//
return result;
}
//
// END Tools Functions ...
//
//
protected:
//
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
// MARKET ...
int mShortLength;
int mMediumLength;
int mLongLength;
int mHindLength;
//
// TREND ...
int mNumOfShoulder;
//
// DETECTION ...
ENUM_SERIESMODE mHhMode;
ENUM_SERIESMODE mLlMode;
//
string mTag;
//
int mHandler;
//
bool IsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(rBuffer);
result = rCount > bar_index + 1;
//
return result;
}
};
@@ -0,0 +1,332 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XSSLC Indicator Provider
// Description: SSL Channel ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// XPeaksAndVales Exported Buffers ...
enum ENUM_X_XSSLC_BUFFERS
{
//
X_SSLC_UP_LINE = 0,
X_SSLC_DOWN_LINE = 1,
X_SSLC_UP_MA_LINE = 2,
X_SSLC_DOWN_MA_LINE = 3,
X_SSLC_KPI_LINE = 4,
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXSSLCHelper
{
//
public:
//
// Properties ...
double upBuffer[];
double downBuffer[];
double kpiBuffer[];
//
// Constructor ...
void XSCXSSLCHelper()
{
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXSSLCHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52,
//
// MARKET ...
int length = 10, // Length
//
// CALCULATION ...
ENUM_MA_METHOD method = MODE_SMA, // Method
ENUM_APPLIED_PRICE upAppliedTo = PRICE_HIGH, // Up Applied To
ENUM_APPLIED_PRICE downAppliedTo = PRICE_LOW // Down Applied To
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
// MARKET ...
mLength = length;
//
// CALCULATION ...
mMethod = method;
mUpAppliedTo = upAppliedTo;
mDownAppliedTo = downAppliedTo;
//
mTag = "XSSLC " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xsslc",
//
// Inputs ...
//
// MARKET ...
"",
mLength,
//
// CALCULATION ...
"",
mMethod,
mUpAppliedTo,
mDownAppliedTo,
//
// PRESENTATION ...
"",
false,
false
//
);
if (mHandler == INVALID_HANDLE)
{
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
ArraySetAsSeries(upBuffer, true);
ArraySetAsSeries(downBuffer, true);
ArraySetAsSeries(kpiBuffer, true);
}
//
// DeConstructor ...
void ~XSCXSSLCHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// UP ...
CopyBuffer(
mHandler,
X_SSLC_UP_LINE,
0,
mNumberOfItemsReadPerTick,
upBuffer);
//
// DOWN ...
CopyBuffer(
mHandler,
X_SSLC_DOWN_LINE,
0,
mNumberOfItemsReadPerTick,
downBuffer);
//
// KPI ...
CopyBuffer(
mHandler,
X_SSLC_KPI_LINE,
0,
mNumberOfItemsReadPerTick,
kpiBuffer);
}
//
// START Tools Functions ...
//
//
// Check Up Buffer Crossed Over Down ...
bool IsUpCrossedOverDown(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 1))
{
return result;
}
//
result =
//
upBuffer[bar_index] > downBuffer[bar_index] &&
upBuffer[bar_index + 1] <= downBuffer[bar_index + 1]
//
;
//
return result;
}
//
// Check Up Buffer Crossed Under Down ...
bool IsUpCrossedUnderDown(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 1))
{
return result;
}
//
result =
//
upBuffer[bar_index] < downBuffer[bar_index] &&
upBuffer[bar_index + 1] >= downBuffer[bar_index + 1]
//
;
//
return result;
}
//
// END Tools Functions ...
//
//
protected:
//
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
// MARKET ...
//
// Length ...
int mLength;
//
// CALCULATION ...
//
// Method ...
ENUM_MA_METHOD mMethod;
//
// Up Applied To
ENUM_APPLIED_PRICE mUpAppliedTo;
//
// Down Applied To
ENUM_APPLIED_PRICE mDownAppliedTo;
//
string mTag;
//
int mHandler;
//
bool IsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(upBuffer);
result = rCount > bar_index + 1;
//
return result;
}
};
@@ -0,0 +1,469 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XTRND Indicator Provider
// Description: Trend Finder ...
//
//
// 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 Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.alert.lib.mq5"
#include "../Libraries/x-saherelm.models.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Definitions ...
//
//
// XPeaksAndVales Exported Buffers ...
enum ENUM_X_XTRND_BUFFERS
{
//
X_TRND_UP_LINE = 0,
X_TRND_UP_STATE_LINE = 1,
//
X_TRND_DOWN_LINE = 2,
X_TRND_DOWN_STATE_LINE = 3,
};
//
// Trend State at unique Bar ...
enum ENUM_X_XTRND_STATE
{
X_TRND_STATE_RANGE = 0,
X_TRND_STATE_CONSOLIDATION = 1,
X_TRND_STATE_UP = 2,
X_TRND_STATE_DOWN = 3,
};
//
// END Definitions ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
class XSCXTRNDHelper
{
//
public:
//
// Properties ...
double upBuffer[];
double upStateBuffer[];
double downBuffer[];
double downStateBuffer[];
//
// Constructor ...
void XSCXTRNDHelper()
{
mSymbol = _Symbol;
mPeriod = _Period;
}
void XSCXTRNDHelper(
//
// Symbol ...
string symbol,
//
// Period ...
ENUM_TIMEFRAMES period,
//
// Buffer Reading ...
int numberOfItemsReadPerTick = 52,
//
// MARKET ...
int cycleLength = 2, // Cycle Length to Check
int numberOfVerifications = 2, // Number of Verifications
//
// CALCULATION ...
ENUM_SERIESMODE hhMode = MODE_HIGH, // Detect Up
ENUM_SERIESMODE llMode = MODE_LOW // Detect Low
//
)
{
//
// Setting Requirements ...
//
// Symbol ...
mSymbol = symbol;
//
// Period ...
mPeriod = period;
//
// Number of Reading Buffer Items per Tick ...
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
//
// MARKET ...
mCycleLength = cycleLength;
mNumberOfVerifications = numberOfVerifications;
//
// CALCULATIONS ...
mHHMode = hhMode;
mLLMode = llMode;
//
mTag = "XTRND " + mSymbol + ", " + ToString(mPeriod);
//
// Initial Handler ...
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.x121.xtrnd",
//
// Inputs ...
//
// MARKET ...
"",
mCycleLength,
mNumberOfVerifications,
//
// CALCULATIONS ...
"",
mHHMode,
mLLMode,
//
// PRESENTATION ...
"",
false,
false
//
);
if (mHandler == INVALID_HANDLE)
{
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
}
//
ArraySetAsSeries(upBuffer, true);
ArraySetAsSeries(upStateBuffer, true);
ArraySetAsSeries(downBuffer, true);
ArraySetAsSeries(downStateBuffer, true);
}
//
// DeConstructor ...
void ~XSCXTRNDHelper()
{
//
// Release Indicators ...
IndicatorRelease(mHandler);
}
//
// Reading Buffers ...
void ReadBuffers()
{
//
// UP ...
CopyBuffer(
mHandler,
X_TRND_UP_LINE,
0,
mNumberOfItemsReadPerTick,
upBuffer);
//
// UP STATE ...
CopyBuffer(
mHandler,
X_TRND_UP_STATE_LINE,
0,
mNumberOfItemsReadPerTick,
upStateBuffer);
//
// DOWN ...
CopyBuffer(
mHandler,
X_TRND_DOWN_LINE,
0,
mNumberOfItemsReadPerTick,
downBuffer);
//
// DOWN STATE ...
CopyBuffer(
mHandler,
X_TRND_DOWN_STATE_LINE,
0,
mNumberOfItemsReadPerTick,
downStateBuffer);
}
//
// START Tools Functions ...
//
//
// Detect Trend Up ...
bool IsTrendBullish(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index))
{
return result;
}
//
result =
//
upStateBuffer[bar_index] == X_TRND_STATE_UP &&
downStateBuffer[bar_index] == X_TRND_STATE_UP
//
;
//
return result;
}
//
// Detect Trend Switched Up ...
bool IsTrendSwitchedBullish(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 1))
{
return result;
}
//
result =
//
IsTrendBullish(bar_index) &&
!IsTrendBullish(bar_index + 1)
//
;
//
return result;
}
//
// Detect Trend Down ...
bool IsTrendBearish(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index))
{
return result;
}
//
result =
//
upStateBuffer[bar_index] == X_TRND_STATE_DOWN &&
downStateBuffer[bar_index] == X_TRND_STATE_DOWN
//
;
//
return result;
}
//
// Detect Trend Switched Down ...
bool IsTrendSwitchedBearish(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 1))
{
return result;
}
//
result =
//
IsTrendBearish(bar_index) &&
!IsTrendBearish(bar_index + 1)
//
;
//
return result;
}
//
// Detect Trend Consolidation ...
bool IsTrendConsolidation(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index))
{
return result;
}
//
result =
//
(upStateBuffer[bar_index] == X_TRND_STATE_RANGE ||
upStateBuffer[bar_index] == X_TRND_STATE_CONSOLIDATION)
//
&&
//
(downStateBuffer[bar_index] == X_TRND_STATE_RANGE ||
downStateBuffer[bar_index] == X_TRND_STATE_CONSOLIDATION)
//
;
//
return result;
}
//
// Detect Trend Switched Consolidation ...
bool IsTrendSwitchedConsolidation(
int bar_index // Bar Index ...
)
{
//
bool result = false;
//
if (!IsValidArraySize(bar_index + 1))
{
return result;
}
//
result =
//
IsTrendConsolidation(bar_index) &&
!IsTrendConsolidation(bar_index + 1)
//
;
//
return result;
}
//
// END Tools Functions ...
//
//
protected:
//
private:
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Buffer Reading ...
int mNumberOfItemsReadPerTick;
//
string mTag;
//
int mHandler;
//
// INPUTS ...
//
// MARKET ...
//
// Cycle Length to Check ...
int mCycleLength;
//
// Number of Verifications ...
int mNumberOfVerifications;
//
// CALCULATIONS ...
//
// Detect Up ...
ENUM_SERIESMODE mHHMode;
//
// Detect Low ...
ENUM_SERIESMODE mLLMode;
//
bool IsValidArraySize(int bar_index)
{
//
bool result = false;
//
if (bar_index < 0)
{
return result;
}
//
int rCount = ArraySize(upBuffer);
result = rCount > bar_index + 1;
//
return result;
}
};