cleanup workspace ...
This commit is contained in:
@@ -1,607 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XAMA 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 ...
|
||||
//
|
||||
|
||||
//
|
||||
// XAMA Indicator States ...
|
||||
enum ENUM_X_XAMA_STATES
|
||||
{
|
||||
X_XAMA_BULLISH = 1,
|
||||
X_XAMA_BEARISH = -1,
|
||||
X_XAMA_NEUTURAL = 0,
|
||||
};
|
||||
|
||||
//
|
||||
// XAMA Indicator Buffer Lines ...
|
||||
enum ENUM_X_XAMA_BUFFER_LINES
|
||||
{
|
||||
X_XAMA_MA_LINE = 0,
|
||||
X_XAMA_MC_COLOR_LINE = 1,
|
||||
X_XAMA_STATE_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// END Enum Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
// input group "XAMA Indicator";
|
||||
|
||||
//
|
||||
// input int xAMALength = 18; // Market Length
|
||||
// input int xAMAFastEMA = 2; // Fast EMA Period
|
||||
// input int xAMASlowEMA = 30; // Slow EMA Period
|
||||
// input int xAMAShift = 0; // Shift
|
||||
// input ENUM_APPLIED_PRICE xAMAAppliedTo = PRICE_CLOSE; // Applied To
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
int xAMALength = 18; // Market Length
|
||||
int xAMAFastEMA = 2; // Fast EMA Period
|
||||
int xAMASlowEMA = 30; // Slow EMA Period
|
||||
int xAMAShift = 0; // Shift
|
||||
ENUM_APPLIED_PRICE xAMAAppliedTo = PRICE_CLOSE; // Applied To
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
int xAMAHandler = INVALID_HANDLE;
|
||||
double xAMAMaBuffer[];
|
||||
double xAMAStateBuffer[];
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Handler Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool XAMAValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
xAMALength > 2 &&
|
||||
xAMAFastEMA < xAMALength &&
|
||||
xAMAFastEMA < xAMASlowEMA &&
|
||||
xAMAShift >= 0;
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XAMA Indicator Inputs Validation Failed ...");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Init Indicators ...
|
||||
bool XAMAInitHandlers()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initialize Indicator/Indicator Handlers ...
|
||||
ResetLastError();
|
||||
|
||||
//
|
||||
// XAMA Handler ...
|
||||
ArraySetAsSeries(xAMAMaBuffer, true);
|
||||
ArraySetAsSeries(xAMAStateBuffer, true);
|
||||
xAMAHandler = iCustom(
|
||||
_Symbol,
|
||||
_Period,
|
||||
"x-saherelm.xama.indicator",
|
||||
//
|
||||
// Inputs ...
|
||||
xAMALength,
|
||||
xAMAFastEMA,
|
||||
xAMASlowEMA,
|
||||
xAMAShift,
|
||||
xAMAAppliedTo
|
||||
//
|
||||
);
|
||||
if (xAMAHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("failed to Initialize XAMA Indicator: " + (string)GetLastError());
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Release Indicators ...
|
||||
void XAMAReleaseHandlers()
|
||||
{
|
||||
IndicatorRelease(xAMAHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Reading Buffers ...
|
||||
void XAMAReadBuffers(
|
||||
int xAMAItemsPerTick // Number Of Reading Buffer Items Per Tick
|
||||
)
|
||||
{
|
||||
//
|
||||
// XAMA Ma Buffer ...
|
||||
CopyBuffer(
|
||||
xAMAHandler,
|
||||
X_XAMA_MA_LINE,
|
||||
0,
|
||||
xAMAItemsPerTick,
|
||||
xAMAMaBuffer);
|
||||
|
||||
//
|
||||
// XAMA State Buffer ...
|
||||
CopyBuffer(
|
||||
xAMAHandler,
|
||||
X_XAMA_STATE_LINE,
|
||||
0,
|
||||
xAMAItemsPerTick,
|
||||
xAMAStateBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// END Handler Funcions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START XAMA Custom Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Check SC is Peak ...
|
||||
bool XAMAIsPeak(
|
||||
int bar_index, // Specified Index ...
|
||||
int length = 10 // Specified Length ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
length <= 0 ||
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + length + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Must Decreasing ...
|
||||
bool isIncreasing = IsIncreasing(
|
||||
bar_index + length,
|
||||
bar_index,
|
||||
xAMAMaBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check SC is Vale ...
|
||||
bool XAMAIsVale(
|
||||
int bar_index, // Specified Index ...
|
||||
int length = 10 // Specified Length ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
length <= 0 ||
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + length + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsDecreasing(
|
||||
bar_index + length,
|
||||
bar_index,
|
||||
xAMAMaBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Crossed Up ...
|
||||
bool XAMAIsStartBullish(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_BULLISH &&
|
||||
xAMAStateBuffer[bar_index + 1] != X_XAMA_BULLISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Crossed Up After Neutural State ...
|
||||
bool XAMAIsStartBullishAfterNeutural(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_BULLISH &&
|
||||
xAMAStateBuffer[bar_index + 1] == X_XAMA_NEUTURAL
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM In Up State ...
|
||||
bool XAMAIsBullish(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_BULLISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Ends Up State ...
|
||||
bool XAMAIsEndBullish(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] != X_XAMA_BULLISH &&
|
||||
xAMAStateBuffer[bar_index + 1] == X_XAMA_BULLISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Ends Up State By Neutural ...
|
||||
bool XAMAIsEndBullishByNeutural(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_NEUTURAL &&
|
||||
xAMAStateBuffer[bar_index + 1] == X_XAMA_BULLISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Crossed Down ...
|
||||
bool XAMAIsStartBearish(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_BEARISH &&
|
||||
xAMAStateBuffer[bar_index + 1] != X_XAMA_BEARISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Crossed Down After Neutural State ...
|
||||
bool XAMAIsStartBearishAfterNeutural(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_BEARISH &&
|
||||
xAMAStateBuffer[bar_index + 1] == X_XAMA_NEUTURAL
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM In Down State ...
|
||||
bool XAMAIsBearish(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_BEARISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Ends Down State ...
|
||||
bool XAMAIsEndBearish(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] != X_XAMA_BEARISH &&
|
||||
xAMAStateBuffer[bar_index + 1] == X_XAMA_BEARISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM Ends Down State By Neutural ...
|
||||
bool XAMAIsEndBearishByNeutural(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_NEUTURAL &&
|
||||
xAMAStateBuffer[bar_index + 1] == X_XAMA_BEARISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check TM In Neutural State ...
|
||||
bool XAMAIsNeutural(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
bar_index <= 0 ||
|
||||
!XAMAIsValidBuffersSize(bar_index + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
xAMAStateBuffer[bar_index] == X_XAMA_NEUTURAL
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check all Buffers has valid Size ...
|
||||
bool XAMAIsValidBuffersSize(
|
||||
int size // the size of buffers which min size for requirements
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
size <= 0 ||
|
||||
//
|
||||
ArraySize(xAMAMaBuffer) < size
|
||||
//
|
||||
)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END XAMA Custom Functions ...
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,358 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XFI 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 ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Enum Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
// input group "XFI Oscillator";
|
||||
|
||||
// //
|
||||
// input int xFILength = 18; // Market Length
|
||||
// input ENUM_MA_METHOD xFIMethod = MODE_SMA; // MA Method
|
||||
// input ENUM_APPLIED_VOLUME xFIAppliedTo = VOLUME_TICK; // Applied To
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
int xFILength = 18; // Market Length
|
||||
ENUM_MA_METHOD xFIMethod = MODE_SMA; // MA Method
|
||||
ENUM_APPLIED_VOLUME xFIAppliedTo = VOLUME_TICK; // Applied To
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
int xFIHandler = INVALID_HANDLE;
|
||||
double xFIBuffer[];
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Handler Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool XFIValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = xFILength > 2;
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XFI Oscillator Inputs Validation Failed ...");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Init Oscillators ...
|
||||
bool XFIInitHandlers()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initialize Indicator/Oscillator Handlers ...
|
||||
ResetLastError();
|
||||
|
||||
//
|
||||
// XFI Handler ...
|
||||
ArraySetAsSeries(xFIBuffer, true);
|
||||
xFIHandler = iCustom(
|
||||
_Symbol,
|
||||
_Period,
|
||||
"x-saherelm.xfi.oscillator",
|
||||
//
|
||||
// Inputs ...
|
||||
xFILength,
|
||||
xFIMethod,
|
||||
xFIAppliedTo
|
||||
//
|
||||
);
|
||||
if (xFIHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("failed to Initialize XFI Oscillator: " + (string)GetLastError());
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Release Oscillators ...
|
||||
void XFIReleaseHandlers()
|
||||
{
|
||||
IndicatorRelease(xFIHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Reading Buffers ...
|
||||
void XFIReadBuffers(
|
||||
int xFIItemsPerTick // Number Of Reading Buffer Items Per Tick
|
||||
)
|
||||
{
|
||||
//
|
||||
// XFI Signal ...
|
||||
CopyBuffer(
|
||||
xFIHandler,
|
||||
0,
|
||||
0,
|
||||
xFIItemsPerTick,
|
||||
xFIBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// END Handler Funcions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START XFI Custom Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Check SC is Peak ...
|
||||
bool XFIIsPeak(
|
||||
int bar_index, // Specified Index ...
|
||||
int length = 10 // Specified Length ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
length <= 0 ||
|
||||
bar_index <= 0 ||
|
||||
!XFIIsValidBuffersSize(bar_index + length + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Must Decreasing ...
|
||||
bool isIncreasing = IsIncreasing(
|
||||
bar_index + length,
|
||||
bar_index,
|
||||
xFIBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check SC is Vale ...
|
||||
bool XFIIsVale(
|
||||
int bar_index, // Specified Index ...
|
||||
int length = 10 // Specified Length ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
length <= 0 ||
|
||||
bar_index <= 0 ||
|
||||
!XFIIsValidBuffersSize(bar_index + length + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsDecreasing(
|
||||
bar_index + length,
|
||||
bar_index,
|
||||
xFIBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect XFI Crossed Over Zero ...
|
||||
bool XFIIsCrossedOverZero(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
bar_index < 0 ||
|
||||
!XFIIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xFIBuffer[bar_index] > 0 &&
|
||||
xFIBuffer[bar_index + 1] <= 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect XFI Over Zero ...
|
||||
bool XFIIsOverZero(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
bar_index < 0 ||
|
||||
!XFIIsValidBuffersSize(bar_index + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xFIBuffer[bar_index] > 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect XFI Crossed Under Zero ...
|
||||
bool XFIIsCrossedUnderZero(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
bar_index < 0 ||
|
||||
!XFIIsValidBuffersSize(bar_index + 2))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xFIBuffer[bar_index] < 0 &&
|
||||
xFIBuffer[bar_index + 1] >= 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect XFI Under Zero ...
|
||||
bool XFIIsUnderZero(
|
||||
int bar_index // Specified Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
bar_index < 0 ||
|
||||
!XFIIsValidBuffersSize(bar_index + 1))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
xFIBuffer[bar_index] < 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check all Buffers has valid Size ...
|
||||
bool XFIIsValidBuffersSize(
|
||||
int size // the size of buffers which min size for requirements
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (
|
||||
size <= 0 ||
|
||||
//
|
||||
ArraySize(xFIBuffer) < size
|
||||
//
|
||||
)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END XFI Custom Functions ...
|
||||
//
|
||||
@@ -1,668 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
int xLHLength = 72; // Length
|
||||
ENUM_SERIESMODE xLHHHMode = MODE_HIGH; // Highest High Calculation Method
|
||||
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 ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool XLHValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = xLHLength >= 2;
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XLH Indicator Inputs Validation Failed ...");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
@@ -1,249 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
int xOBDLength = 5; // Swing Length
|
||||
uchar xOBDSwingHighArrowCode = 108; // Swing High Arrow Code
|
||||
color xOBDSwingHighArrowColor = clrMagenta; // Swing High Arrow Color
|
||||
uchar xOBDSwingLowArrowCode = 108; // Swing Low Arrow Code
|
||||
color xOBDSwingLowArrowColor = clrAqua; // Swing Low Arrow Color
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
int xOBDHandler = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
double xOBDBuffer[];
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Handler Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool XOBDValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = xOBDLength >= 2;
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XOBD Indicator Inputs Validation Failed ...");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
@@ -1,433 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 = clrRed; // 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 = clrRed; // 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 = clrRed; // Long Exit Level Color
|
||||
// input ENUM_LINE_STYLE xRSILongExitLineStyle = STYLE_DOT; // Long Exit Style
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
int xRSILength = 18; // Market Length
|
||||
ENUM_APPLIED_PRICE xRSIAppliedTo = PRICE_OPEN; // Applied To
|
||||
|
||||
//
|
||||
double xRSIShortEntryValue = 70; // Short Entry Level
|
||||
color xRSIShortEntryColor = clrRed; // Short Entry Level Color
|
||||
ENUM_LINE_STYLE xRSIShortEntryLineStyle = STYLE_SOLID; // Short Entry Style
|
||||
|
||||
//
|
||||
double xRSIShortExitValue = 40; // Short Exit Level
|
||||
color xRSIShortExitColor = clrRed; // Short Exit Level Color
|
||||
ENUM_LINE_STYLE xRSIShortExitLineStyle = STYLE_DOT; // Short Exit Style
|
||||
|
||||
//
|
||||
double xRSILongEntryValue = 30; // Long Entry Level
|
||||
color xRSILongEntryColor = clrRed; // Long Entry Level Color
|
||||
ENUM_LINE_STYLE xRSILongEntryLineStyle = STYLE_SOLID; // Long Entry Style
|
||||
|
||||
//
|
||||
double xRSILongExitValue = 60; // Long Exit Level
|
||||
color xRSILongExitColor = clrRed; // Long Exit Level Color
|
||||
ENUM_LINE_STYLE xRSILongExitLineStyle = STYLE_DOT; // Long Exit Style
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
int xRSIHandler = INVALID_HANDLE;
|
||||
double xRSIBuffer[];
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Handler Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool XRSIValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
xRSILongEntryValue < xRSILongExitValue &&
|
||||
xRSIShortEntryValue > xRSIShortExitValue &&
|
||||
xRSIShortEntryValue > xRSILongExitValue &&
|
||||
xRSIShortExitValue < xRSILongExitValue;
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XRSI Oscillator Inputs Validation Failed ...");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
@@ -1,931 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
int xTDLength = 18; // Market Length
|
||||
bool xTDDrawCrosses = false; // Draw Cross Arrows
|
||||
uchar xTDBullishArrowCode = 228; // Cross Over Arrow Code
|
||||
color xTDBullishArrowColor = clrAqua; // Cross Over Arrow Color
|
||||
uchar xTDBearishArrowCode = 230; // Cross Under Arrow Code
|
||||
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 ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool XTDValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = xTDLength >= 2;
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTD Oscillator Inputs Validation Failed ...");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
@@ -1,598 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
int xTMMaPeriod = 18; // Period
|
||||
int xTMMaShift = 0; // Shift
|
||||
ENUM_MA_METHOD xTMMaMethod = MODE_EMA; // Method
|
||||
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 ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool XTMValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = xTMMaPeriod >= 2;
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
LogMessage("XTM Indicator Inputs Validation Failed ...");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user