Initial Commit ...

This commit is contained in:
2024-01-25 04:09:42 +03:30
commit b2037e07eb
1991 changed files with 668083 additions and 0 deletions
@@ -0,0 +1,956 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XCHLH Oscillator 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
//
// Includes ...
#include "..\Libraries\x-saherelm.log.lib.mq5"
#include "..\Libraries\x-saherelm.common.lib.mq5"
//
// START Enum Definitions ...
//
//
// Cycles Enumeration ...
enum ENUM_X_XCHLH_CYCLES
{
X_XCHLH_CYCLE_LONG,
X_XCHLH_CYCLE_MEDIUM,
X_XCHLH_CYCLE_SHORT,
};
//
// XCHLH Hot States ...
enum ENUM_X_XCHLH_HOT_STATES
{
X_XCHLH_HOT_HH = 1,
X_XCHLH_NEUTURAL = 0,
X_XCHLH_HOT_LL = -1,
};
//
// XCHLH Buffer Lines ...
enum ENUM_X_XCHLH_BUFFER_LINES
{
X_XCHLH_LC_HH_LINE = 0,
X_XCHLH_LC_LL_LINE = 1,
X_XCHLH_MC_HH_LINE = 2,
X_XCHLH_MC_LL_LINE = 3,
X_XCHLH_SC_HH_LINE = 4,
X_XCHLH_SC_LL_LINE = 5,
X_XCHLH_SIGNAL_T_LINE = 6,
X_XCHLH_SIGNAL_B_LINE = 7,
X_XCHLH_HOT_STATE_LINE = 8,
};
//
// END Enum Definitions ...
//
//
// START Inputs ...
//
//
input group "XCHLH Oscillator";
//
// Common ...
input group "XCHLH Hot Areas";
input bool xCHLHDrawHotAreas = false; // Draw Hot Areas Symbol
input uchar xCHLHHotHHArrowCode = 234; // Hot HH Arrow Code
input color xCHLHHotHHArrowColor = clrAqua; // Hot HH Arrow Color
input uchar xCHLHHotLLArrowCode = 233; // Hot LL Arrow Code
input color xCHLHHotLLArrowColor = clrFuchsia; // Hot LL Arrow Color
//
// LC Inputs ...
input group "XCHLH Long Cycle";
input group "XCHLH LC Market";
input int xCHLHLcLength = 288; // Length
input double xCHLHLcThresholdInPips = 0.3; // Threshold In Pips
input ENUM_SERIESMODE xCHLHLcHHMode = MODE_HIGH; // Highest High Calculation Method
input ENUM_SERIESMODE xCHLHLcLLMode = MODE_LOW; // Lowest Low Calculation Method
input group "XCHLH LC Style";
input int xCHLHLcDrawWidth = 1; // Draw Width
input ENUM_DRAW_TYPE xCHLHLcDrawType = DRAW_LINE; // Draw Type
input ENUM_LINE_STYLE xCHLHLcDrawStyle = STYLE_DOT; // Draw Style
input color xCHLHLcHHColor = clrAqua; // Highest High Color
input color xCHLHLcLLColor = clrFuchsia; // Lowest Low Color
input group "XCHLH LC Drawings";
input bool xCHLHLcDrawHH = true; // Draw Highest High
input bool xCHLHLcDrawLL = true; // Draw Lowest Low
//
// MC Inputs ...
input group "XCHLH Medium Cycle";
input group "XCHLH MC Market";
input int xCHLHMcLength = 72; // Length
input double xCHLHMcThresholdInPips = 0.3; // Threshold In Pips
input ENUM_SERIESMODE xCHLHMcHHMode = MODE_HIGH; // Highest High Calculation Method
input ENUM_SERIESMODE xCHLHMcLLMode = MODE_LOW; // Lowest Low Calculation Method
input group "XCHLH MC Style";
input int xCHLHMcDrawWidth = 1; // Draw Width
input ENUM_DRAW_TYPE xCHLHMcDrawType = DRAW_LINE; // Draw Type
input ENUM_LINE_STYLE xCHLHMcDrawStyle = STYLE_DOT; // Draw Style
input color xCHLHMcHHColor = clrLime; // Highest High Color
input color xCHLHMcLLColor = clrRed; // Lowest Low Color
input group "XCHLH MC Drawings";
input bool xCHLHMcDrawHH = true; // Draw Highest High
input bool xCHLHMcDrawLL = true; // Draw Lowest Low
//
// SC Inputs ...
input group "XCHLH Short Cycle";
input group "XCHLH SC Market";
input int xCHLHScLength = 7; // Length
input double xCHLHScThresholdInPips = 0.3; // Threshold In Pips
input ENUM_SERIESMODE xCHLHScHHMode = MODE_HIGH; // Highest High Calculation Method
input ENUM_SERIESMODE xCHLHScLLMode = MODE_LOW; // Lowest Low Calculation Method
input group "XCHLH SC Style";
input int xCHLHScDrawWidth = 1; // Draw Width
input ENUM_DRAW_TYPE xCHLHScDrawType = DRAW_LINE; // Draw Type
input ENUM_LINE_STYLE xCHLHScDrawStyle = STYLE_DOT; // Draw Style
input color xCHLHScHHColor = clrLightBlue; // Highest High Color
input color xCHLHScLLColor = clrLightSalmon; // Lowest Low Color
input group "XCHLH SC Drawings";
input bool xCHLHScDrawHH = true; // Draw Highest High
input bool xCHLHScDrawLL = true; // Draw Lowest Low
//
// END Inputs ...
//
//
// START Definitions ...
//
int xCHLHHandler = INVALID_HANDLE;
double xCHLHLcHHBuffer[];
double xCHLHLcLLBuffer[];
double xCHLHMcHHBuffer[];
double xCHLHMcLLBuffer[];
double xCHLHScHHBuffer[];
double xCHLHScLLBuffer[];
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
// Init Oscillators ...
bool XCHLHInitHandlers()
{
//
bool result = false;
//
// Initialize Indicator/Oscillator Handlers ...
ResetLastError();
//
// XCHLH Handler ...
ArraySetAsSeries(xCHLHLcHHBuffer, true);
ArraySetAsSeries(xCHLHLcLLBuffer, true);
ArraySetAsSeries(xCHLHMcHHBuffer, true);
ArraySetAsSeries(xCHLHMcLLBuffer, true);
ArraySetAsSeries(xCHLHScHHBuffer, true);
ArraySetAsSeries(xCHLHScLLBuffer, true);
xCHLHHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xchlh.oscillator",
//
// Inputs ...
//
// Commons ...
"",
xCHLHDrawHotAreas,
xCHLHHotHHArrowCode,
xCHLHHotHHArrowColor,
xCHLHHotLLArrowCode,
xCHLHHotLLArrowColor,
//
// LC ...
"",
"",
xCHLHLcLength,
xCHLHLcThresholdInPips,
xCHLHLcHHMode,
xCHLHLcLLMode,
"",
xCHLHLcDrawWidth,
xCHLHLcDrawType,
xCHLHLcDrawStyle,
xCHLHLcHHColor,
xCHLHLcLLColor,
"",
xCHLHLcDrawHH,
xCHLHLcDrawLL,
//
// MC ...
"",
"",
xCHLHMcLength,
xCHLHMcThresholdInPips,
xCHLHMcHHMode,
xCHLHMcLLMode,
"",
xCHLHMcDrawWidth,
xCHLHMcDrawType,
xCHLHMcDrawStyle,
xCHLHMcHHColor,
xCHLHMcLLColor,
"",
xCHLHMcDrawHH,
xCHLHMcDrawLL,
//
// SC ...
"",
"",
xCHLHScLength,
xCHLHScThresholdInPips,
xCHLHScHHMode,
xCHLHScLLMode,
"",
xCHLHScDrawWidth,
xCHLHScDrawType,
xCHLHScDrawStyle,
xCHLHScHHColor,
xCHLHScLLColor,
"",
xCHLHScDrawHH,
xCHLHScDrawLL);
if (xCHLHHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize XCHLH Indicator: " + (string)GetLastError());
return result;
}
//
result = true;
//
return result;
}
//
// Release Oscillators ...
void XCHLHReleaseHandlers()
{
IndicatorRelease(xCHLHHandler);
}
//
// Handle Reading Buffers ...
void XCHLHReadBuffers(
int xCHLHItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
// XCHLH LC HH Buffer ...
CopyBuffer(
xCHLHHandler,
X_XCHLH_LC_HH_LINE,
0,
xCHLHItemsPerTick,
xCHLHLcHHBuffer);
//
// XCHLH LC LL Buffer ...
CopyBuffer(
xCHLHHandler,
X_XCHLH_LC_LL_LINE,
0,
xCHLHItemsPerTick,
xCHLHLcLLBuffer);
//
// XCHLH MC HH Buffer ...
CopyBuffer(
xCHLHHandler,
X_XCHLH_MC_HH_LINE,
0,
xCHLHItemsPerTick,
xCHLHMcHHBuffer);
//
// XCHLH MC LL Buffer ...
CopyBuffer(
xCHLHHandler,
X_XCHLH_MC_LL_LINE,
0,
xCHLHItemsPerTick,
xCHLHMcLLBuffer);
//
// XCHLH SC HH Buffer ...
CopyBuffer(
xCHLHHandler,
X_XCHLH_SC_HH_LINE,
0,
xCHLHItemsPerTick,
xCHLHScHHBuffer);
//
// XCHLH SC LL Buffer ...
CopyBuffer(
xCHLHHandler,
X_XCHLH_SC_LL_LINE,
0,
xCHLHItemsPerTick,
xCHLHScLLBuffer);
}
//
// END Handler Funcions ...
//
//
// START XCHLH Custom Functions ...
//
//
// Check LC and MC has Same HH ...
bool XCHLHIsLCMCHasSameHH(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double lcValue = xCHLHLcHHBuffer[bar_index];
double mcValue = xCHLHMcHHBuffer[bar_index];
//
result = lcValue == mcValue;
//
return result;
}
//
// Check LC and MC has Same LL ...
bool XCHLHIsLCMCHasSameLL(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double lcValue = xCHLHLcLLBuffer[bar_index];
double mcValue = xCHLHMcLLBuffer[bar_index];
//
result = lcValue == mcValue;
//
return result;
}
//
// Check LC and SC has Same HH ...
bool XCHLHIsLCSCHasSameHH(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double lcValue = xCHLHLcHHBuffer[bar_index];
double scValue = xCHLHScHHBuffer[bar_index];
//
result = lcValue == scValue;
//
return result;
}
//
// Check LC and SC has Same LL ...
bool XCHLHIsLCSCHasSameLL(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double lcValue = xCHLHLcLLBuffer[bar_index];
double scValue = xCHLHScLLBuffer[bar_index];
//
result = lcValue == scValue;
//
return result;
}
//
// Check MC and SC has Same HH ...
bool XCHLHIsMCSCHasSameHH(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double mcValue = xCHLHMcHHBuffer[bar_index];
double scValue = xCHLHScHHBuffer[bar_index];
//
result = mcValue == scValue;
//
return result;
}
//
// Check MC and SC has Same LL ...
bool XCHLHIsMCSCHasSameLL(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double mcValue = xCHLHMcLLBuffer[bar_index];
double scValue = xCHLHScLLBuffer[bar_index];
//
result = mcValue == scValue;
//
return result;
}
//
// Check Is Same Highest Highs ...
bool XCHLHIsSameHHs(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double lcValue = xCHLHLcHHBuffer[bar_index];
double mcValue = xCHLHMcHHBuffer[bar_index];
double scValue = xCHLHScHHBuffer[bar_index];
//
result =
//
lcValue == mcValue &&
mcValue == scValue
//
;
//
return result;
}
//
// Check Is Same Lowest Lows ...
bool XCHLHIsSameLLs(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
double lcValue = xCHLHLcLLBuffer[bar_index];
double mcValue = xCHLHMcLLBuffer[bar_index];
double scValue = xCHLHScLLBuffer[bar_index];
//
result =
//
lcValue == mcValue &&
mcValue == scValue
//
;
//
return result;
}
//
// Check Medium Cycle is On Top of Long Cycle's Mid ...
bool XCHLHIsMCOnTopOfLC(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (
bar_index < 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
ENUM_X_XCHLH_CYCLES sCycle = X_XCHLH_CYCLE_MEDIUM;
ENUM_X_XCHLH_CYCLES dCycle = X_XCHLH_CYCLE_LONG;
//
result =
//
XCHLHCheckCycleIsOnTopOfAnother(
bar_index,
sCycle,
dCycle)
//
;
//
return result;
}
//
// Check Medium Cycle is In Bottom of Long Cycle's Mid ...
bool XCHLHIsMCInBottomOfLC(
int bar_index // Specified Bar Index ...
)
{
//
bool result = false;
//
// Validate Args ...
if (
bar_index < 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
ENUM_X_XCHLH_CYCLES sCycle = X_XCHLH_CYCLE_MEDIUM;
ENUM_X_XCHLH_CYCLES dCycle = X_XCHLH_CYCLE_LONG;
//
result =
//
XCHLHCheckCycleIsInBottomOfAnother(
bar_index,
sCycle,
dCycle)
//
;
//
return result;
}
//
// Check and Validate Buffer Sizes ...
bool XCHLHIsValidBufferSizes(
int size // Specified Min Size
)
{
//
bool result = false;
//
result =
//
ArraySize(xCHLHLcHHBuffer) > size &&
ArraySize(xCHLHLcLLBuffer) > size &&
//
ArraySize(xCHLHMcHHBuffer) > size &&
ArraySize(xCHLHMcLLBuffer) > size &&
//
ArraySize(xCHLHScHHBuffer) > size &&
ArraySize(xCHLHScLLBuffer) > size;
//
return result;
}
//
// Get Cycle Middle Value ...
double XCHLHGetCycleMid(
int bar_index, // Specified Bar Index ...
ENUM_X_XCHLH_CYCLES cycle // Specified Cycle ...
)
{
//
double result = 0;
//
// Validate Args ...
if (
bar_index < 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
// Retrieve Cycle Max Value ...
double iMax = XCHLHGetCycleMax(
bar_index,
cycle);
//
// Retrieve Cycle Min Value ...
double iMin = XCHLHGetCycleMin(
bar_index,
cycle);
//
result = (iMax - iMin) / 2;
//
return result;
}
//
// Get Cycle Max Value ...
double XCHLHGetCycleMax(
int bar_index, // Specified Bar Index ...
ENUM_X_XCHLH_CYCLES cycle // Specified Cycle ...
)
{
//
double result = 0;
//
// Validate Args ...
if (
bar_index < 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
switch (cycle)
{
//
// Long Cycle ...
case X_XCHLH_CYCLE_LONG:
result = xCHLHLcHHBuffer[1];
break;
//
// Medium Cycle ...
case X_XCHLH_CYCLE_MEDIUM:
result = xCHLHMcHHBuffer[1];
break;
//
// Short Cycle ...
case X_XCHLH_CYCLE_SHORT:
result = xCHLHScHHBuffer[1];
break;
}
//
return result;
}
//
// Get Specified Cycles Max Value ...
double XCHLHGetCyclesMax(
int bar_index, // Specified Bar Index ...
ENUM_X_XCHLH_CYCLES &cycles[] // Specified Cycle ...
)
{
//
bool result = 0;
//
// Validate Args ...
if (
bar_index < 0 ||
ArraySize(cycles) <= 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
// Loop Through Cycles ...
for (int i = 0; i < ArraySize(cycles); i++)
{
//
ENUM_X_XCHLH_CYCLES iCycle = cycles[i];
//
double iValue = XCHLHGetCycleMax(
bar_index,
iCycle);
//
result = result == 0 || result < iValue ? iValue : result;
}
//
return result;
}
//
// Get Cycle Min Value ...
double XCHLHGetCycleMin(
int bar_index, // Specified Bar Index ...
ENUM_X_XCHLH_CYCLES cycle // Specified Cycle ...
)
{
//
double result = 0;
//
// Validate Args ...
if (
bar_index < 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
switch (cycle)
{
//
// Long Cycle ...
case X_XCHLH_CYCLE_LONG:
result = xCHLHLcLLBuffer[1];
break;
//
// Medium Cycle ...
case X_XCHLH_CYCLE_MEDIUM:
result = xCHLHMcLLBuffer[1];
break;
//
// Short Cycle ...
case X_XCHLH_CYCLE_SHORT:
result = xCHLHScLLBuffer[1];
break;
}
//
return result;
}
//
// Get Specified Cycles Min Value ...
double XCHLHGetCyclesMin(
int bar_index, // Specified Bar Index ...
ENUM_X_XCHLH_CYCLES &cycles[] // Specified Cycle ...
)
{
//
bool result = 0;
//
// Validate Args ...
if (
bar_index < 0 ||
ArraySize(cycles) <= 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
// Loop Through Cycles ...
for (int i = 0; i < ArraySize(cycles); i++)
{
//
ENUM_X_XCHLH_CYCLES iCycle = cycles[i];
//
double iValue = XCHLHGetCycleMin(
bar_index,
iCycle);
//
result = result == 0 || result > iValue ? iValue : result;
}
//
return result;
}
//
// Check a Cycle is On Top of Another Cycle's Mid ...
bool XCHLHCheckCycleIsOnTopOfAnother(
int bar_index, // Specified Bar Index ...
ENUM_X_XCHLH_CYCLES sourceCycle, // Specified Source Cycle which Checks ...
ENUM_X_XCHLH_CYCLES destCycle // Specified Dest Cycle which source Checked based on it ...
)
{
//
bool result = false;
//
// Validate Args ...
if (
bar_index < 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
// Retrieve Min Value of Source Cycle ...
double iMin = XCHLHGetCycleMin(
bar_index,
sourceCycle);
//
// Retrieve Mid Value of Dest Cycle ...
double iMid = XCHLHGetCycleMid(
bar_index,
destCycle);
//
// Generate Result ...
result =
//
iMin >= iMid
//
;
//
return result;
}
//
// Check a Cycle is Under Bottom of Another Cycle's Mid ...
bool XCHLHCheckCycleIsInBottomOfAnother(
int bar_index, // Specified Bar Index ...
ENUM_X_XCHLH_CYCLES sourceCycle, // Specified Source Cycle which Checks ...
ENUM_X_XCHLH_CYCLES destCycle // Specified Dest Cycle which source Checked based on it ...
)
{
//
bool result = false;
//
// Validate Args ...
if (
bar_index < 0 ||
!XCHLHIsValidBufferSizes(bar_index + 1))
{
return result;
}
//
// Retrieve Max Value of Source Cycle ...
double iMax = XCHLHGetCycleMax(
bar_index,
sourceCycle);
//
// Retrieve Mid Value of Dest Cycle ...
double iMid = XCHLHGetCycleMid(
bar_index,
destCycle);
//
// Generate Result ...
result =
//
iMax <= iMid
//
;
//
return result;
}
//
// END XCHLH Custom Functions ...
//
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,640 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XLH 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
//
// Includes ...
#include "..\Libraries\x-saherelm.log.lib.mq5"
#include "..\Libraries\x-saherelm.common.lib.mq5"
//
// START Enum Definitions ...
//
//
// XLH Indicator Buffer Lines ...
enum ENUM_X_XLH_BUFFER_LINES
{
X_XLH_HH_LINE = 0,
X_XLH_LL_LINE = 1,
X_XLH_SIGNAL_LINE = 2,
};
//
// END Enum Definitions ...
//
//
// START Inputs ...
//
input group "XLH Indicator";
input int xLHLength = 72; // Length
input ENUM_SERIESMODE xLHHHMode = MODE_HIGH; // Highest High Calculation Method
input ENUM_SERIESMODE xLHLLMode = MODE_LOW; // Lowest Low Calculation Method
//
// END Inputs ...
//
//
// START Definitions ...
//
//
int xLHHandler = INVALID_HANDLE;
//
double xLHHHBuffer[];
double xLHLLBuffer[];
double xLHSignalBuffer[];
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
// Init Indicators ...
bool XLHInitHandlers()
{
//
bool result = false;
//
// Initialize Indicator/Oscillator Handlers ...
ResetLastError();
//
// XLH Handler ...
ArraySetAsSeries(xLHHHBuffer, true);
ArraySetAsSeries(xLHLLBuffer, true);
ArraySetAsSeries(xLHSignalBuffer, true);
//
xLHHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xlh.indicator",
//
// Inputs ...
xLHLength,
xLHHHMode,
xLHLLMode
//
);
if (xLHHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize XLH Indicator: " + (string)GetLastError());
return result;
}
//
result = true;
//
return result;
}
//
// Release Indicators ...
void XLHReleaseHandlers()
{
IndicatorRelease(xLHHandler);
}
//
// Handle Reading Buffers ...
void XLHReadBuffers(
int xLHItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
// HH Buffer ...
CopyBuffer(
xLHHandler,
X_XLH_HH_LINE,
0,
xLHItemsPerTick,
xLHHHBuffer
//
);
//
// LL Buffer ...
CopyBuffer(
xLHHandler,
X_XLH_LL_LINE,
0,
xLHItemsPerTick,
xLHLLBuffer
//
);
//
// Signal Buffer ...
CopyBuffer(
xLHHandler,
X_XLH_SIGNAL_LINE,
0,
xLHItemsPerTick,
xLHSignalBuffer
//
);
}
//
// END Handler Funcions ...
//
//
// START XLH Custom Functions ...
//
//
// TODO: What we have to Implement ...
// - []
//
// Check Candle High is HH ...
bool XLHIsHighAttachedHH(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
XOHCL candle = GetCandle(bar_index);
//
result =
//
candle.high == xLHHHBuffer[bar_index]
//
;
//
return result;
}
//
// Check Candle Low is LL ...
bool XLHIsLowAttachedLL(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
XOHCL candle = GetCandle(bar_index);
//
result =
//
candle.low == xLHLLBuffer[bar_index]
//
;
//
return result;
}
//
// Check Price Jumping Up Signal ...
bool XLHIsPriceCrossedOverSignal(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
XOHCL candle1 = GetCandle(bar_index);
XOHCL candle2 = GetCandle(bar_index + 1);
//
result =
//
candle1.low > xLHSignalBuffer[bar_index] &&
candle2.low < xLHSignalBuffer[bar_index + 1]
//
;
//
return result;
}
//
// Check Price Over Signal ...
bool XLHIsPriceOverSignal(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
XOHCL candle1 = GetCandle(bar_index);
//
result =
//
candle1.low > xLHSignalBuffer[bar_index]
//
;
//
return result;
}
//
// Check Price Jumping Down Signal ...
bool XLHIsPriceCrossedUnderSignal(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
XOHCL candle1 = GetCandle(bar_index);
XOHCL candle2 = GetCandle(bar_index + 1);
//
result =
//
candle1.high < xLHSignalBuffer[bar_index] &&
candle2.high > xLHSignalBuffer[bar_index + 1]
//
;
//
return result;
}
//
// Check Price Down Signal ...
bool XLHIsPriceUnderSignal(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
XOHCL candle1 = GetCandle(bar_index);
//
result =
//
candle1.high < xLHSignalBuffer[bar_index]
//
;
//
return result;
}
//
// Check Price Ranging Signal ...
bool XLHIsPriceInSignalRange(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
XOHCL candle1 = GetCandle(bar_index);
//
result =
//
candle1.high > xLHSignalBuffer[bar_index] &&
candle1.low < xLHSignalBuffer[bar_index]
//
;
//
return result;
}
//
// Check HH Increased ...
bool XLHIsHHIncreased(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsIncreasing(
bar_index + length,
bar_index,
xLHHHBuffer
//
);
//
return result;
}
//
// Check HH Decreased ...
bool XLHIsHHDecreased(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsDecreasing(
bar_index + length,
bar_index,
xLHHHBuffer
//
);
//
return result;
}
//
// Check LL Increased ...
bool XLHIsLLIncreased(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsIncreasing(
bar_index + length,
bar_index,
xLHLLBuffer
//
);
//
return result;
}
//
// Check LL Decreased ...
bool XLHIsLLDecreased(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsDecreasing(
bar_index + length,
bar_index,
xLHLLBuffer
//
);
//
return result;
}
//
// Check HH Same in Length ...
bool XLHIsHHSameInLength(
int bar_index, // Specified Index ...
int length = 5 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
double value1 = xLHHHBuffer[bar_index];
//
// Loop ...
result = true;
for (int i = bar_index + 1; i < bar_index + length + 1; i++) {
//
double iValue = xLHHHBuffer[i];
if (iValue != value1) {
//
result = false;
//
break;
}
}
//
return result;
}
//
// Check LL Same in Length ...
bool XLHIsLLSameInLength(
int bar_index, // Specified Index ...
int length = 5 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XLHIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
double value1 = xLHLLBuffer[bar_index];
//
// Loop ...
result = true;
for (int i = bar_index + 1; i < bar_index + length + 1; i++) {
//
double iValue = xLHLLBuffer[i];
if (iValue != value1) {
//
result = false;
//
break;
}
}
//
return result;
}
//
// Check all Buffers has valid Size ...
bool XLHIsValidBuffersSize(
int size // the size of buffers which min size for requirements
)
{
//
bool result = false;
//
if (
size <= 0 ||
//
ArraySize(xLHHHBuffer) < size ||
ArraySize(xLHLLBuffer) < size ||
ArraySize(xLHSignalBuffer) < size
//
)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
//
// END XLH Custom Functions ...
//
@@ -0,0 +1,219 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XOBD 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
//
// Includes ...
#include "..\Libraries\x-saherelm.log.lib.mq5"
#include "..\Libraries\x-saherelm.common.lib.mq5"
//
// START Enum Definitions ...
//
//
// END Enum Definitions ...
//
//
// START Inputs ...
//
input group "XOBD Indicator";
input int xOBDLength = 5; // Swing Length
input uchar xOBDSwingHighArrowCode = 108; // Swing High Arrow Code
input color xOBDSwingHighArrowColor = clrMagenta; // Swing High Arrow Color
input uchar xOBDSwingLowArrowCode = 108; // Swing Low Arrow Code
input color xOBDSwingLowArrowColor = clrAqua; // Swing Low Arrow Color
//
// END Inputs ...
//
//
// START Definitions ...
//
//
int xOBDHandler = INVALID_HANDLE;
//
double xOBDBuffer[];
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
// Init Indicators ...
bool XOBDInitHandlers()
{
//
bool result = false;
//
// Initialize Indicator/Oscillator Handlers ...
ResetLastError();
//
// XOBD Handler ...
ArraySetAsSeries(xOBDBuffer, true);
//
xOBDHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xobd.indicator",
//
// Inputs ...
xOBDLength,
xOBDSwingHighArrowCode,
xOBDSwingHighArrowColor,
xOBDSwingLowArrowCode,
xOBDSwingLowArrowColor
//
);
if (xOBDHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize XOBD Indicator: " + (string)GetLastError());
return result;
}
//
result = true;
//
return result;
}
//
// Release Indicators ...
void XOBDReleaseHandlers()
{
IndicatorRelease(xOBDHandler);
}
//
// Handle Reading Buffers ...
void XOBDReadBuffers(
int xOBDItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
// OBD Buffer ...
CopyBuffer(
xOBDHandler,
0,
0,
xOBDItemsPerTick,
xOBDBuffer
//
);
}
//
// END Handler Funcions ...
//
//
// START XOBD Custom Functions ...
//
//
// Check is Swing Low Occured or not ...
bool XOBDIsSwingLow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XOBDIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result = xOBDBuffer[bar_index] == X_SWING_LOW;
//
return result;
}
//
// Check is Swing High Occured or not ...
bool XOBDIsSwingHigh(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XOBDIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result = xOBDBuffer[bar_index] == X_SWING_HIGH;
//
return result;
}
//
// Check all Buffers has valid Size ...
bool XOBDIsValidBuffersSize(
int size // the size of buffers which min size for requirements
)
{
//
bool result = false;
//
if (
size <= 0 ||
//
ArraySize(xOBDBuffer) < size
//
)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
//
// END XOBD Custom Functions ...
//
@@ -0,0 +1,383 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XRSI Oscillator 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
//
// Includes ...
#include "..\Libraries\x-saherelm.log.lib.mq5"
#include "..\Libraries\x-saherelm.common.lib.mq5"
//
// START Enum Definitions ...
//
//
// XRSI Oscillator Buffer Lines ...
//
//
// END Enum Definitions ...
//
//
// START Inputs ...
//
input group "XRSI Oscillator";
//
input group "XRSI Market";
input int xRSILength = 18; // Market Length
input ENUM_APPLIED_PRICE xRSIAppliedTo = PRICE_OPEN; // Applied To
//
input group "XRSI Short Entry";
input double xRSIShortEntryValue = 70; // Short Entry Level
input color xRSIShortEntryColor = clrRed; // Short Entry Level Color
input ENUM_LINE_STYLE xRSIShortEntryLineStyle = STYLE_SOLID; // Short Entry Style
//
input group "XRSI Short Exit";
input double xRSIShortExitValue = 40; // Short Exit Level
input color xRSIShortExitColor = clrFuchsia; // Short Exit Level Color
input ENUM_LINE_STYLE xRSIShortExitLineStyle = STYLE_DOT; // Short Exit Style
//
input group "XRSI Long Entry";
input double xRSILongEntryValue = 30; // Long Entry Level
input color xRSILongEntryColor = clrGreen; // Long Entry Level Color
input ENUM_LINE_STYLE xRSILongEntryLineStyle = STYLE_SOLID; // Long Entry Style
//
input group "XRSI Long Exit";
input double xRSILongExitValue = 60; // Long Exit Level
input color xRSILongExitColor = clrAqua; // Long Exit Level Color
input ENUM_LINE_STYLE xRSILongExitLineStyle = STYLE_DOT; // Long Exit Style
//
// END Inputs ...
//
//
// START Definitions ...
//
int xRSIHandler = INVALID_HANDLE;
double xRSIBuffer[];
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
// Init Oscillators ...
bool XRSIInitHandlers()
{
//
bool result = false;
//
// Initialize Indicator/Oscillator Handlers ...
ResetLastError();
//
// XRSI Handler ...
ArraySetAsSeries(xRSIBuffer, true);
xRSIHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xrsi.oscillator",
//
// Inputs ...
//
// Market ...
"",
xRSILength,
xRSIAppliedTo,
//
// Short Entry ...
"",
xRSIShortEntryValue,
xRSIShortEntryColor,
xRSIShortEntryLineStyle,
//
// Short Exit ...
"",
xRSIShortExitValue,
xRSIShortExitColor,
xRSIShortExitLineStyle,
//
// Long Entry ...
"",
xRSILongEntryValue,
xRSILongEntryColor,
xRSILongEntryLineStyle,
//
// Long Exit ...
"",
xRSILongExitValue,
xRSILongExitColor,
xRSILongExitLineStyle
//
);
if (xRSIHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize XRSI Oscillator: " + (string)GetLastError());
return result;
}
//
result = true;
//
return result;
}
//
// Release Oscillators ...
void XRSIReleaseHandlers()
{
IndicatorRelease(xRSIHandler);
}
//
// Handle Reading Buffers ...
void XRSIReadBuffers(
int xRSIItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
// XRSI Signal ...
CopyBuffer(
xRSIHandler,
0,
0,
xRSIItemsPerTick,
xRSIBuffer);
}
//
// END Handler Funcions ...
//
//
// START XRSI Custom Functions ...
//
//
// Check SC is Peak ...
bool XRSIIsPeak(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XRSIIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
// Must Decreasing ...
bool isIncreasing = IsIncreasing(
bar_index + length,
bar_index,
xRSIBuffer
//
);
//
return result;
}
//
// Check SC is Vale ...
bool XRSIIsVale(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XRSIIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsDecreasing(
bar_index + length,
bar_index,
xRSIBuffer
//
);
//
return result;
}
//
// RSI Value GO Up from Long Entry ...
bool XRSIIsCrossedOverLongEntry(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XRSIIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
xRSIBuffer[bar_index + 1] > xRSILongEntryValue &&
xRSIBuffer[bar_index + 2] <= xRSILongEntryValue;
//
return result;
}
//
// RSI Value GO Up from Long Exit ...
bool XRSIIsCrossedOverLongExit(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XRSIIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
xRSIBuffer[bar_index + 1] > xRSILongExitValue &&
xRSIBuffer[bar_index + 2] <= xRSILongExitValue;
//
return result;
}
//
// RSI Value Go Down Short Entry ...
bool XRSIIsCrossedUnderShortEntry(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XRSIIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
xRSIBuffer[bar_index + 1] < xRSIShortEntryValue &&
xRSIBuffer[bar_index + 2] >= xRSIShortEntryValue;
//
return result;
}
//
// RSI Value Go Down Short Exit ...
bool XRSIIsCrossedUnderShortExit(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XRSIIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
xRSIBuffer[bar_index + 1] < xRSIShortExitValue &&
xRSIBuffer[bar_index + 2] >= xRSIShortExitValue;
//
return result;
}
//
// Check all Buffers has valid Size ...
bool XRSIIsValidBuffersSize(
int size // the size of buffers which min size for requirements
)
{
//
bool result = false;
//
if (
size <= 0 ||
//
ArraySize(xRSIBuffer) < size
//
)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
//
// END XRSI Custom Functions ...
//
@@ -0,0 +1,900 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XTD Oscillator 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
//
// Includes ...
#include "..\Libraries\x-saherelm.log.lib.mq5"
#include "..\Libraries\x-saherelm.common.lib.mq5"
//
// START Enum Definitions ...
//
//
// XTD Oscillator States ...
enum ENUM_X_XTD_STATES
{
X_XTD_BULLISH_CROSSED_OVER_BEARISH = 2,
X_XTD_BULLISH_OVER_BEARISH = 1,
X_XTD_NEUTURAL = 0,
X_XTD_BULLISH_UNDER_BEARISH = -1,
X_XTD_BULLISH_CROSSED_UNDER_BEARISH = -2
};
//
// XTD Oscillator Buffer Lines ...
enum ENUM_X_XTD_BUFFER_LINES
{
X_XTD_BULLISH_POWER_LINE = 0,
X_XTD_BEARISH_POWER_LINE = 1,
X_XTD_SIGNAL_LINE = 2,
};
//
// END Enum Definitions ...
//
//
// START Inputs ...
//
input group "XTD Oscillator";
input int xTDLength = 18; // Market Length
input bool xTDDrawCrosses = false; // Draw Cross Arrows
input uchar xTDBullishArrowCode = 228; // Cross Over Arrow Code
input color xTDBullishArrowColor = clrAqua; // Cross Over Arrow Color
input uchar xTDBearishArrowCode = 230; // Cross Under Arrow Code
input color xTDBearishArrowColor = clrMagenta; // Cross Under Arrow Color
//
// END Inputs ...
//
//
// START Definitions ...
//
int xTDHandler = INVALID_HANDLE;
double xTDBullishBuffer[];
double xTDBearishBuffer[];
double xTDSignalBuffer[];
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
// Init Oscillators ...
bool XTDInitHandlers()
{
//
bool result = false;
//
// Initialize Indicator/Oscillator Handlers ...
ResetLastError();
//
// XTD Handler ...
ArraySetAsSeries(xTDBullishBuffer, true);
ArraySetAsSeries(xTDBearishBuffer, true);
ArraySetAsSeries(xTDSignalBuffer, true);
xTDHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xtd.oscillator",
//
// Inputs ...
xTDLength,
xTDDrawCrosses,
xTDBullishArrowCode,
xTDBullishArrowColor,
xTDBearishArrowCode,
xTDBearishArrowColor);
if (xTDHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize XTD Oscillator: " + (string)GetLastError());
return result;
}
//
result = true;
//
return result;
}
//
// Release Oscillators ...
void XTDReleaseHandlers()
{
IndicatorRelease(xTDHandler);
}
//
// Handle Reading Buffers ...
void XTDReadBuffers(
int xTDItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
// XTD Bullish Buffer ...
CopyBuffer(
xTDHandler,
X_XTD_BULLISH_POWER_LINE,
0,
xTDItemsPerTick,
xTDBullishBuffer);
//
// XTD Bullish Buffer ...
CopyBuffer(
xTDHandler,
X_XTD_BEARISH_POWER_LINE,
0,
xTDItemsPerTick,
xTDBearishBuffer);
//
// XTD Signal Buffer ...
CopyBuffer(
xTDHandler,
X_XTD_SIGNAL_LINE,
0,
xTDItemsPerTick,
xTDSignalBuffer);
}
//
// END Handler Funcions ...
//
//
// START XTD Custom Functions ...
//
//
// Check Signal Vale ...
bool XTDIsSignalVale(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsDecreasing(
bar_index + length,
bar_index,
xTDSignalBuffer
//
);
//
return result;
}
//
// Check Signal Peak ...
bool XTDIsSignalPeak(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
// Must Decreasing ...
bool isIncreasing = IsIncreasing(
bar_index + length,
bar_index,
xTDSignalBuffer
//
);
//
return result;
}
//
// Check Signal Vale ...
bool XTDIsBullishVale(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsDecreasing(
bar_index + length,
bar_index,
xTDBullishBuffer
//
);
//
return result;
}
//
// Check Signal Peak ...
bool XTDIsBullishPeak(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
// Must Decreasing ...
bool isIncreasing = IsIncreasing(
bar_index + length,
bar_index,
xTDBullishBuffer
//
);
//
return result;
}
//
// Check Signal Vale ...
bool XTDIsBearishVale(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsDecreasing(
bar_index + length,
bar_index,
xTDBearishBuffer
//
);
//
return result;
}
//
// Check Signal Peak ...
bool XTDIsBearishPeak(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
// Must Decreasing ...
bool isIncreasing = IsIncreasing(
bar_index + length,
bar_index,
xTDBearishBuffer
//
);
//
return result;
}
//
// Check Signal Peak ...
//
// Check Bullish Crossed Over Bearish ...
bool XTDIsBullCrossedOverBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossOver(
xTDBullishBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check Bullish Over Bearish ...
bool XTDIsBullOverBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsOver(
xTDBullishBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check Bullish Crossed Under Bearish ...
bool XTDIsBullCrossedUnderBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossUnder(
xTDBullishBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check Bullish Under Bearish ...
bool XTDIsBullUnderBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsUnder(
xTDBullishBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check Signal Crossed Over Bearish ...
bool XTDIsSignalCrossedOverBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossOver(
xTDSignalBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check Signal Over Bearish ...
bool XTDIsSignalOverBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsOver(
xTDSignalBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check Signal Crossed Under Bearish ...
bool XTDIsSignalCrossedUnderBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossUnder(
xTDSignalBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check Signal Under Bearish ...
bool XTDIsSignalUnderBear(
int bar_index // Specified Bar Index
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTDIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsUnder(
xTDSignalBuffer,
xTDBearishBuffer,
1);
//
return result;
}
//
// Check all Buffers has valid Size ...
bool XTDIsValidBuffersSize(
int size // the size of buffers which min size for requirements
)
{
//
bool result = false;
//
if (
size <= 0 ||
ArraySize(xTDBullishBuffer) < size ||
ArraySize(xTDBullishBuffer) < size ||
ArraySize(xTDSignalBuffer) < size)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
//
// Count Signal Crossed Over Bear ...
int XTDCountSignalCrossedOverBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = 0;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsSignalCrossedOverBear(i);
if (isCrossedOnI)
{
result++;
}
}
//
return result;
}
//
// Count Signal Crossed Under Bear ...
int XTDCountSignalCrossedUnderBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = 0;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsSignalCrossedUnderBear(i);
if (isCrossedOnI)
{
result++;
}
}
//
return result;
}
//
// Count Bull Crossed Over Bear ...
int XTDCountBullCrossedOverBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = 0;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsBullCrossedOverBear(i);
if (isCrossedOnI)
{
result++;
}
}
//
return result;
}
//
// Count Bull Crossed Under Bear ...
int XTDCountBullCrossedUnderBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = 0;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsBullCrossedUnderBear(i);
if (isCrossedOnI)
{
result++;
}
}
//
return result;
}
//
// Find Last Signal Crossed Over Bear ...
int XTDFindLastSignalCrossedOverBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = -1;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsSignalCrossedOverBear(i);
if (isCrossedOnI)
{
//
result = i;
break;
}
}
//
return result;
}
//
// Find Last Signal Crossed Onder Bear ...
int XTDFindLastSignalCrossedUnderBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = -1;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsSignalCrossedUnderBear(i);
if (isCrossedOnI)
{
//
result = i;
break;
}
}
//
return result;
}
//
// Find Last Bull Crossed Over Bear ...
int XTDFindLastBullCrossedOverBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = -1;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsBullCrossedOverBear(i);
if (isCrossedOnI)
{
//
result = i;
break;
}
}
//
return result;
}
//
// Find Last Bull Crossed Under Bear ...
int XTDFindLastBullCrossedUnderBearIndex(
int bar_index // Specified Bar Index
)
{
//
int result = -1;
//
int count = ArraySize(xTDSignalBuffer) - 1;
if (
bar_index <= 0 ||
count <= bar_index + 1)
{
return result;
}
//
// Loop Through ...
for (int i = bar_index + 1; i < count && result == -1; i++)
{
//
// Check Cross On i Point ...
bool isCrossedOnI = XTDIsBullCrossedUnderBear(i);
if (isCrossedOnI)
{
//
result = i;
break;
}
}
//
return result;
}
//
// END XTD Custom Functions ...
//
@@ -0,0 +1,569 @@
/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XTM 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
//
// Includes ...
#include "..\Libraries\x-saherelm.log.lib.mq5"
#include "..\Libraries\x-saherelm.common.lib.mq5"
//
// START Enum Definitions ...
//
//
// XTM Indicator States ...
enum ENUM_X_XTM_STATES
{
X_XTM_BULLISH = 1,
X_XTM_BEARISH = -1,
X_XTM_NEUTURAL = 0,
};
//
// XTM Indicator Buffer Lines ...
enum ENUM_X_XTM_BUFFER_LINES
{
X_XTM_MA_LINE = 0,
X_XTM_MC_COLOR_LINE = 1,
X_XTM_STATE_LINE = 2,
};
//
// END Enum Definitions ...
//
//
// START Inputs ...
//
input group "XTM Indicator";
input int xTMMaPeriod = 18; // Period
input int xTMMaShift = 0; // Shift
input ENUM_MA_METHOD xTMMaMethod = MODE_EMA; // Method
input ENUM_APPLIED_PRICE xTMMaAppliedTo = PRICE_OPEN; // Applied To
//
// END Inputs ...
//
//
// START Definitions ...
//
int xTMHandler = INVALID_HANDLE;
double xTMMaBuffer[];
double xTMStateBuffer[];
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
// Init Indicators ...
bool XTMInitHandlers()
{
//
bool result = false;
//
// Initialize Indicator/Oscillator Handlers ...
ResetLastError();
//
// XTM Handler ...
ArraySetAsSeries(xTMMaBuffer, true);
ArraySetAsSeries(xTMStateBuffer, true);
xTMHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xtm.indicator",
//
// Inputs ...
xTMMaPeriod,
xTMMaShift,
xTMMaMethod,
xTMMaAppliedTo);
if (xTMHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize XTM Indicator: " + (string)GetLastError());
return result;
}
//
result = true;
//
return result;
}
//
// Release Indicators ...
void XTMReleaseHandlers()
{
IndicatorRelease(xTMHandler);
}
//
// Handle Reading Buffers ...
void XTMReadBuffers(
int xTMItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
// Ma Buffer ...
CopyBuffer(
xTMHandler,
X_XTM_MA_LINE,
0,
xTMItemsPerTick,
xTMMaBuffer);
//
// State Buffer ...
CopyBuffer(
xTMHandler,
X_XTM_STATE_LINE,
0,
xTMItemsPerTick,
xTMStateBuffer);
}
//
// END Handler Funcions ...
//
//
// START XTM Custom Functions ...
//
//
// Find Peak based On this Indicator ...
bool XTMIsPeak(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
// Must Decreasing ...
bool isIncreasing = IsIncreasing(
bar_index + length,
bar_index,
xTMMaBuffer
//
);
//
return result;
}
//
// Find Vale based On this Indicator ...
bool XTMIsVale(
int bar_index, // Specified Index ...
int length = 10 // Specified Length ...
)
{
//
bool result = false;
//
if (
length <= 0 ||
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + length + 1))
{
return result;
}
//
result = IsDecreasing(
bar_index + length,
bar_index,
xTMMaBuffer
//
);
//
return result;
}
//
// Check TM Crossed Up ...
bool XTMIsStartBullish(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_BULLISH &&
xTMStateBuffer[bar_index + 1] != X_XTM_BULLISH
//
;
//
return result;
}
//
// Check TM Crossed Up After Neutural State ...
bool XTMIsStartBullishAfterNeutural(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_BULLISH &&
xTMStateBuffer[bar_index + 1] == X_XTM_NEUTURAL
//
;
//
return result;
}
//
// Check TM In Up State ...
bool XTMIsBullish(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_BULLISH
//
;
//
return result;
}
//
// Check TM Ends Up State ...
bool XTMIsEndBullish(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] != X_XTM_BULLISH &&
xTMStateBuffer[bar_index + 1] == X_XTM_BULLISH
//
;
//
return result;
}
//
// Check TM Ends Up State By Neutural ...
bool XTMIsEndBullishByNeutural(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_NEUTURAL &&
xTMStateBuffer[bar_index + 1] == X_XTM_BULLISH
//
;
//
return result;
}
//
// Check TM Crossed Down ...
bool XTMIsStartBearish(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_BEARISH &&
xTMStateBuffer[bar_index + 1] != X_XTM_BEARISH
//
;
//
return result;
}
//
// Check TM Crossed Down After Neutural State ...
bool XTMIsStartBearishAfterNeutural(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_BEARISH &&
xTMStateBuffer[bar_index + 1] == X_XTM_NEUTURAL
//
;
//
return result;
}
//
// Check TM In Down State ...
bool XTMIsBearish(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_BEARISH
//
;
//
return result;
}
//
// Check TM Ends Down State ...
bool XTMIsEndBearish(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] != X_XTM_BEARISH &&
xTMStateBuffer[bar_index + 1] == X_XTM_BEARISH
//
;
//
return result;
}
//
// Check TM Ends Down State By Neutural ...
bool XTMIsEndBearishByNeutural(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 2))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_NEUTURAL &&
xTMStateBuffer[bar_index + 1] == X_XTM_BEARISH
//
;
//
return result;
}
//
// Check TM In Neutural State ...
bool XTMIsNeutural(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XTMIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result =
//
xTMStateBuffer[bar_index] == X_XTM_NEUTURAL
//
;
//
return result;
}
//
// Check all Buffers has valid Size ...
bool XTMIsValidBuffersSize(
int size // the size of buffers which min size for requirements
)
{
//
bool result = false;
//
if (
size <= 0 ||
//
ArraySize(xTMMaBuffer) < size ||
ArraySize(xTMStateBuffer) < size
//
)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
//
// END XTM Custom Functions ...
//