Files
xEaPacks/EURUSD-5M-V0.1/MQ5/Libraries/x-saherelm.xchma.oscillator.helper.lib.mq5
T
2024-01-25 04:08:38 +03:30

1536 lines
27 KiB
Plaintext

/////////////////////////////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XCHMA 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 ...
//
//
// XCHMA Cycles ...
enum ENUM_XCHMA_CYCLES
{
X_XCHMA_CYCLE_LONG,
X_XCHMA_CYCLE_MEDIUM,
X_XCHMA_CYCLE_SHORT,
};
//
// XCHMA Oscillator Hot State Presentation ...
enum ENUM_XCHMA_HOT_STATES
{
X_XCHMA_HOT_BULLISH = 1,
X_XCHMA_HOT_NEUTURAL = 0,
X_XCHMA_HOT_BEARISH = -1,
};
//
// XCHMA Oscillator Cycles State Presentation ...
enum ENUM_XCHMA_CYCLE_STATES
{
X_XCHMA_FAST_CROSSED_OVER_SLOW = 2,
X_XCHMA_FAST_OVER_SLOW = 1,
X_XCHMA_NEUTURAL = 0,
X_XCHMA_FAST_UNDER_SLOW = -1,
X_XCHMA_FAST_CROSSED_UNDER_SLOW = -2,
};
//
// XCHMA Oscillator Buffer Lines ...
enum ENUM_X_XCHMA_BUFFER_LINES
{
X_XCHMA_LC_FAST_LINE = 0,
X_XCHMA_LC_SLOW_LINE = 1,
X_XCHMA_LC_STATE_LINE = 6,
X_XCHMA_MC_FAST_LINE = 2,
X_XCHMA_MC_SLOW_LINE = 3,
X_XCHMA_MC_STATE_LINE = 7,
X_XCHMA_SC_FAST_LINE = 4,
X_XCHMA_SC_SLOW_LINE = 5,
X_XCHMA_SC_STATE_LINE = 8,
X_XCHMA_HOT_STATE_LINE = 9,
};
//
// END Enum Definitions ...
//
//
// START Inputs ...
//
input group "XCHMA Oscillator";
//
// Commons ...
input group "XCHMA Hot Areas";
input bool xCHMADrawHotAreas = false; // Draw Hot Areas Symbol;
input uchar xCHMAHotBullishArrowCode = 228; // Hot Bullish Arrow Code;
input color xCHMAHotBullishArrowColor = clrAqua; // Hot Bullish Arrow Color;
input uchar xCHMAHotBearishArrowCode = 230; // Hot Bearish Arrow Code;
input color xCHMAHotBearishArrowColor = clrFuchsia; // Hot Bearish Arrow Color;
//
// LC Inputs ...
input group "XCHMA Long Cycle";
input group "XCHMA LC Market";
input int xCHMALcFastLength = 288; // Fast Length
input int xCHMALcSlowLength = 576; // Slow Length
input ENUM_MA_METHOD xCHMALcMethod = MODE_EMA; // Calculation Method
input ENUM_APPLIED_PRICE xCHMALcAppliedTo = PRICE_CLOSE; // Applied To
input group "XCHMA LC Style";
input int xCHMALcDrawWidth = 1; // Draw Width
input ENUM_DRAW_TYPE xCHMALcDrawType = DRAW_LINE; // Draw Type
input ENUM_LINE_STYLE xCHMALcDrawStyle = STYLE_DOT; // Draw Style
input color xCHMALcFastColor = clrAqua; // Fast Color
input color xCHMALcSlowColor = clrFuchsia; // Slow Color
input group "XCHMA LC Drawings";
input bool xCHMALcDrawFast = true; // Draw Fast
input bool xCHMALcDrawSlow = true; // Draw Slow
input bool xCHMALcDrawCrosses = false; // Draw Cross Lines
//
// MC Inputs ...
input group "XCHMA Medium Cycle";
input group "XCHMA MC Market";
input int xCHMAMcFastLength = 72; // Fast Length
input int xCHMAMcSlowLength = 144; // Slow Length
input ENUM_MA_METHOD xCHMAMcMethod = MODE_EMA; // Calculation Method
input ENUM_APPLIED_PRICE xCHMAMcAppliedTo = PRICE_CLOSE; // Applied To
input group "XCHMA MC Style";
input int xCHMAMcDrawWidth = 1; // Draw Width
input ENUM_DRAW_TYPE xCHMAMcDrawType = DRAW_LINE; // Draw Type
input ENUM_LINE_STYLE xCHMAMcDrawStyle = STYLE_DOT; // Draw Style
input color xCHMAMcFastColor = clrLime; // Fast Color
input color xCHMAMcSlowColor = clrRed; // Slow Color
input group "XCHMA MC Drawings";
input bool xCHMAMcDrawFast = true; // Draw Fast
input bool xCHMAMcDrawSlow = true; // Draw Slow
input bool xCHMAMcDrawCrosses = false; // Draw Cross Lines
//
// SC Inputs ...
input group "XCHMA Short Cycle";
input group "XCHMA SC Market";
input int xCHMAScFastLength = 7; // Fast Length
input int xCHMAScSlowLength = 14; // Slow Length
input ENUM_MA_METHOD xCHMAScMethod = MODE_EMA; // Calculation Method
input ENUM_APPLIED_PRICE xCHMAScAppliedTo = PRICE_CLOSE; // Applied To
input group "XCHMA SC Style";
input int xCHMAScDrawWidth = 1; // Draw Width
input ENUM_DRAW_TYPE xCHMAScDrawType = DRAW_LINE; // Draw Type
input ENUM_LINE_STYLE xCHMAScDrawStyle = STYLE_SOLID; // Draw Style
input color xCHMAScFastColor = clrLightBlue; // Fast Color
input color xCHMAScSlowColor = clrLightSalmon; // Slow Color
input group "XCHMA SC Drawings";
input bool xCHMAScDrawFast = true; // Draw Fast
input bool xCHMAScDrawSlow = true; // Draw Slow
input bool xCHMAScDrawCrosses = false; // Draw Cross Lines
//
// END Inputs ...
//
//
// START Definitions ...
//
int xCHMAHandler = INVALID_HANDLE;
double xCHMALcFastBuffer[];
double xCHMALcSlowBuffer[];
double xCHMAMcFastBuffer[];
double xCHMAMcSlowBuffer[];
double xCHMAScFastBuffer[];
double xCHMAScSlowBuffer[];
//
// END Definitions ...
//
//
// START Handler Functions ...
//
//
// Init Oscillators ...
bool XCHMAInitHandlers()
{
//
bool result = false;
//
// Initialize Indicator/Oscillator Handlers ...
ResetLastError();
//
// XCHMA Handler ...
ArraySetAsSeries(xCHMALcFastBuffer, true);
ArraySetAsSeries(xCHMALcSlowBuffer, true);
ArraySetAsSeries(xCHMAMcFastBuffer, true);
ArraySetAsSeries(xCHMAMcSlowBuffer, true);
ArraySetAsSeries(xCHMAScFastBuffer, true);
ArraySetAsSeries(xCHMAScSlowBuffer, true);
xCHMAHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xchma.oscillator",
//
// Inputs ...
"",
xCHMADrawHotAreas,
xCHMAHotBullishArrowCode,
xCHMAHotBullishArrowColor,
xCHMAHotBearishArrowCode,
xCHMAHotBearishArrowColor,
//
// Long Cycle ...
"",
"",
xCHMALcFastLength,
xCHMALcSlowLength,
xCHMALcMethod,
xCHMALcAppliedTo,
"",
xCHMALcDrawWidth,
xCHMALcDrawType,
xCHMALcDrawStyle,
xCHMALcFastColor,
xCHMALcSlowColor,
"",
xCHMALcDrawFast,
xCHMALcDrawSlow,
xCHMALcDrawCrosses,
//
// Medium Cycle ...
"",
"",
xCHMAMcFastLength,
xCHMAMcSlowLength,
xCHMAMcMethod,
xCHMAMcAppliedTo,
"",
xCHMAMcDrawWidth,
xCHMAMcDrawType,
xCHMAMcDrawStyle,
xCHMAMcFastColor,
xCHMAMcSlowColor,
"",
xCHMAMcDrawFast,
xCHMAMcDrawSlow,
xCHMAMcDrawCrosses,
//
// Short Cycle ...
"",
"",
xCHMAScFastLength,
xCHMAScSlowLength,
xCHMAScMethod,
xCHMAScAppliedTo,
"",
xCHMAScDrawWidth,
xCHMAScDrawType,
xCHMAScDrawStyle,
xCHMAScFastColor,
xCHMAScSlowColor,
"",
xCHMAScDrawFast,
xCHMAScDrawSlow,
xCHMAScDrawCrosses);
if (xCHMAHandler == INVALID_HANDLE)
{
//
LogMessage("failed to Initialize XCHMA Oscillator: " + (string)GetLastError());
return result;
}
//
result = true;
//
return result;
}
//
// Release Oscillators ...
void XCHMAReleaseHandlers()
{
IndicatorRelease(xCHMAHandler);
}
//
// Handle Reading Buffers ...
void XCHMAReadBuffers(
int xCHMAItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
// XCHMA Long Cycle ...
//
// XCHMA Fast ...
CopyBuffer(
xCHMAHandler,
X_XCHMA_LC_FAST_LINE,
0,
xCHMAItemsPerTick,
xCHMALcFastBuffer);
//
// XCHMA Slow ...
CopyBuffer(
xCHMAHandler,
X_XCHMA_LC_SLOW_LINE,
0,
xCHMAItemsPerTick,
xCHMALcSlowBuffer);
//
// XCHMA Medium Cycle ...
//
// XCHMA Fast ...
CopyBuffer(
xCHMAHandler,
X_XCHMA_MC_FAST_LINE,
0,
xCHMAItemsPerTick,
xCHMAMcFastBuffer);
//
// XCHMA Slow ...
CopyBuffer(
xCHMAHandler,
X_XCHMA_MC_SLOW_LINE,
0,
xCHMAItemsPerTick,
xCHMAMcSlowBuffer);
//
// XCHMA Short Cycle ...
//
// XCHMA Fast ...
CopyBuffer(
xCHMAHandler,
X_XCHMA_SC_FAST_LINE,
0,
xCHMAItemsPerTick,
xCHMAScFastBuffer);
//
// XCHMA Slow ...
CopyBuffer(
xCHMAHandler,
X_XCHMA_SC_SLOW_LINE,
0,
xCHMAItemsPerTick,
xCHMAScSlowBuffer);
}
//
// END Handler Funcions ...
//
//
// START Signal Related Conditions ...
//
//
// XCHMA Long Conditions ...
bool XCHMAHasLongConditions(
int xCHMAItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
bool result = false;
//
bool isSCVale = XCHMAIsSCVale();
bool isSCFastOverSlow = XCHMAIsSCFastOverSlow(1);
bool isScFastCrossedOver = XCHMAIsSCFastCrossedOverSlow(1);
//
bool isMcVale = XCHMAIsMCVale();
bool isMCFastOverSlow = XCHMAIsMCFastOverSlow(1);
bool isMcFastCrossedOver = XCHMAIsMCFastCrossedOverSlow(1);
//
bool isLcVale = XCHMAIsLCVale();
bool isLCFastOverSlow = XCHMAIsLCFastOverSlow(1);
bool isLcFastCrossedOver = XCHMAIsLCFastCrossedOverSlow(1);
//
bool scHasSignal =
// isSCVale &&
isScFastCrossedOver &&
(
//
isMCFastOverSlow ||
isMcFastCrossedOver
//
) &&
(
//
isLCFastOverSlow ||
isLcFastCrossedOver
//
);
//
bool mcHasSignal =
// isMcVale &&
isMcFastCrossedOver &&
(
//
isSCFastOverSlow ||
isScFastCrossedOver
//
) &&
(
//
isLCFastOverSlow ||
isLcFastCrossedOver
//
);
;
//
bool lcHasSignal =
// isLcVale &&
isLcFastCrossedOver &&
(
//
isSCFastOverSlow ||
isScFastCrossedOver
//
) &&
(
//
isMCFastOverSlow ||
isMcFastCrossedOver
//
);
//
// Signal ...
bool hasSignal =
//
scHasSignal
//
||
//
mcHasSignal
//
||
//
lcHasSignal
//
;
//
result =
//
hasSignal
//
;
//
return result;
}
//
// XCHMA Short Conditions ...
bool XCHMAHasShortConditions(
int xCHMAItemsPerTick // Number Of Reading Buffer Items Per Tick
)
{
//
bool result = false;
//
bool scHasSignal = false; // XCHMAIsSCPeak();
bool mcHasSignal = false; // XCHMAIsMCPeak();
bool lcHasSignal = false; // XCHMAIsLCPeak();
//
// Signal ...
bool hasSignal =
//
scHasSignal
//
||
//
mcHasSignal
//
||
//
lcHasSignal
//
;
//
// Very Strong Signal ...
bool hasVeryStrongSignal =
//
scHasSignal
//
&&
//
mcHasSignal
//
&&
//
lcHasSignal
//
;
//
// Strong Signal ...
bool hasStrongSignal =
//
!hasVeryStrongSignal
//
&&
//
(
//
// SC and MC Provide Signal ...
(
//
scHasSignal
//
&&
//
mcHasSignal
//
)
//
||
//
// MC and LC Provide Signal ...
(
//
mcHasSignal
//
&&
//
lcHasSignal
//
)
//
||
//
// SC and LC Provide Signal ...
(
//
scHasSignal
//
&&
//
lcHasSignal
//
)
//
)
//
;
//
// Has Regular Signal ...
bool hasRegularSignal =
hasSignal && !hasStrongSignal && !hasVeryStrongSignal;
//
result =
//
lcHasSignal
//
||
//
mcHasSignal
//
||
//
scHasSignal
//
;
//
return result;
}
//
// END Signal Related Conditions ...
//
//
// START XCHMA Custom Functions ...
//
//
// Retrieve Max Cycles Value ...
double XCHMAGetMax(
int bar_index // Specified Index ...
)
{
//
double result = 0;
//
// Validate Args ...
if (!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
// SC Fast ...
result = MathMax(
result,
xCHMAScFastBuffer[bar_index]);
//
// SC Slow ...
result = MathMax(
result,
xCHMAScSlowBuffer[bar_index]);
//
// MC Fast ...
result = MathMax(
result,
xCHMAMcFastBuffer[bar_index]);
//
// MC Slow ...
result = MathMax(
result,
xCHMAMcSlowBuffer[bar_index]);
//
// LC Fast ...
result = MathMax(
result,
xCHMALcFastBuffer[bar_index]);
//
// LC Slow ...
result = MathMax(
result,
xCHMALcSlowBuffer[bar_index]);
//
return result;
}
//
// Retrieve Max Cycles Value ...
double XCHMAGetMin(
int bar_index // Specified Index ...
)
{
//
double result = 0;
//
// Validate Args ...
if (!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = xCHMAScFastBuffer[bar_index];
//
// SC Fast ...
result = MathMin(
result,
xCHMAScFastBuffer[bar_index]);
//
// SC Slow ...
result = MathMin(
result,
xCHMAScSlowBuffer[bar_index]);
//
// MC Fast ...
result = MathMin(
result,
xCHMAMcFastBuffer[bar_index]);
//
// MC Slow ...
result = MathMin(
result,
xCHMAMcSlowBuffer[bar_index]);
//
// LC Fast ...
result = MathMin(
result,
xCHMALcFastBuffer[bar_index]);
//
// LC Slow ...
result = MathMin(
result,
xCHMALcSlowBuffer[bar_index]);
//
return result;
}
//
// Long Cycle ...
//
//
// Check LC is Peak ...
bool XCHMAIsLCPeak()
{
//
bool result = false;
//
bool isIncreasing = IsIncreasing(
30,
9,
xCHMALcFastBuffer);
//
bool isDecreasing = IsDecreasing(
9,
1,
xCHMALcFastBuffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// Check LC is Vale ...
bool XCHMAIsLCVale()
{
//
bool result = false;
//
bool isIncreasing = IsIncreasing(
9,
1,
xCHMALcFastBuffer);
//
bool isDecreasing = IsDecreasing(
30,
9,
xCHMALcFastBuffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// Check LC Fast Crossed Over Slow ...
bool XCHMAIsLCFastCrossedOverSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossOver(
xCHMALcFastBuffer,
xCHMALcSlowBuffer,
bar_index);
//
return result;
}
//
// Check LC Fast Over Slow ...
bool XCHMAIsLCFastOverSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsOver(
xCHMALcFastBuffer,
xCHMALcSlowBuffer,
bar_index);
//
return result;
}
//
// Check LC Fast Crossed Under Slow ...
bool XCHMAIsLCFastCrossedUnderSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossUnder(
xCHMALcFastBuffer,
xCHMALcSlowBuffer,
bar_index);
//
return result;
}
//
// Check LC Fast Under Slow ...
bool XCHMAIsLCFastUnderSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsUnder(
xCHMALcFastBuffer,
xCHMALcSlowBuffer,
bar_index);
//
return result;
}
//
// Medium Cycle ...
//
//
// Check MC is Peak ...
bool XCHMAIsMCPeak()
{
//
bool result = false;
//
bool isIncreasing = IsIncreasing(
20,
6,
xCHMAMcFastBuffer);
//
bool isDecreasing = IsDecreasing(
6,
1,
xCHMAMcFastBuffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// Check MC is Vale ...
bool XCHMAIsMCVale()
{
//
bool result = false;
//
bool isIncreasing = IsIncreasing(
6,
1,
xCHMAMcFastBuffer);
//
bool isDecreasing = IsDecreasing(
20,
6,
xCHMAMcFastBuffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// Check MC Fast Crossed Over Slow ...
bool XCHMAIsMCFastCrossedOverSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossOver(
xCHMAMcFastBuffer,
xCHMAMcSlowBuffer,
bar_index);
//
return result;
}
//
// Check MC Fast Over Slow ...
bool XCHMAIsMCFastOverSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsOver(
xCHMAMcFastBuffer,
xCHMAMcSlowBuffer,
bar_index);
//
return result;
}
//
// Check MC Fast Crossed Under Slow ...
bool XCHMAIsMCFastCrossedUnderSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossUnder(
xCHMAMcFastBuffer,
xCHMAMcSlowBuffer,
bar_index);
//
return result;
}
//
// Check MC Fast Under Slow ...
bool XCHMAIsMCFastUnderSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsUnder(
xCHMAMcFastBuffer,
xCHMAMcSlowBuffer,
bar_index);
//
return result;
}
//
// Short Cycle ...
//
//
// Check SC is Peak ...
bool XCHMAIsSCPeak()
{
//
bool result = false;
//
bool isIncreasing = IsIncreasing(
10,
3,
xCHMAScFastBuffer);
//
bool isDecreasing = IsDecreasing(
3,
1,
xCHMAScFastBuffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// Check SC is Vale ...
bool XCHMAIsSCVale()
{
//
bool result = false;
//
bool isIncreasing = IsIncreasing(
3,
1,
xCHMAScFastBuffer);
//
bool isDecreasing = IsDecreasing(
10,
3,
xCHMAScFastBuffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// Check SC Fast Crossed Over Slow ...
bool XCHMAIsSCFastCrossedOverSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossOver(
xCHMAScFastBuffer,
xCHMAScSlowBuffer,
bar_index);
//
return result;
}
//
// Check SC Fast Over Slow ...
bool XCHMAIsSCFastOverSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsOver(
xCHMAScFastBuffer,
xCHMAScSlowBuffer,
bar_index);
//
return result;
}
//
// Check SC Fast Crossed Under Slow ...
bool XCHMAIsSCFastCrossedUnderSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsCrossUnder(
xCHMAScFastBuffer,
xCHMAScSlowBuffer,
bar_index);
//
return result;
}
//
// Check SC Fast Under Slow ...
bool XCHMAIsSCFastUnderSlow(
int bar_index // Specified Index ...
)
{
//
bool result = false;
//
if (
bar_index <= 0 ||
!XCHMAIsValidBuffersSize(bar_index + 1))
{
return result;
}
//
result = IsUnder(
xCHMAScFastBuffer,
xCHMAScSlowBuffer,
bar_index);
//
return result;
}
//
// Utility Functions ...
//
//
// Check all Buffers has valid Size ...
bool XCHMAIsValidBuffersSize(
int size // the size of buffers which min size for requirements
)
{
//
bool result = false;
//
if (
size <= 0 ||
//
ArraySize(xCHMALcFastBuffer) < size ||
ArraySize(xCHMALcSlowBuffer) < size ||
//
ArraySize(xCHMAMcFastBuffer) < size ||
ArraySize(xCHMAMcSlowBuffer) < size ||
//
ArraySize(xCHMAScFastBuffer) < size ||
ArraySize(xCHMAScSlowBuffer) < size
//
)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
//
// Get Cycle Fast Length ...
int XCHMAGetCycleFastLength(
ENUM_XCHMA_CYCLES cycle // Specified Cycle
)
{
//
int result = 0;
//
switch (cycle)
{
//
case X_XCHMA_CYCLE_LONG:
result = xCHMALcFastLength;
break;
//
case X_XCHMA_CYCLE_MEDIUM:
result = xCHMAMcFastLength;
break;
//
case X_XCHMA_CYCLE_SHORT:
result = xCHMAScFastLength;
break;
}
//
return result;
}
//
// Get Cycle Slow Length ...
int XCHMAGetCycleSlowLength(
ENUM_XCHMA_CYCLES cycle // Specified Cycle
)
{
//
int result = 0;
//
switch (cycle)
{
//
case X_XCHMA_CYCLE_LONG:
result = xCHMALcSlowLength;
break;
//
case X_XCHMA_CYCLE_MEDIUM:
result = xCHMAMcSlowLength;
break;
//
case X_XCHMA_CYCLE_SHORT:
result = xCHMAScSlowLength;
break;
}
//
return result;
}
//
// Retrieve Cycle Fast Buffer ...
void XCHMAGetCycleFastBuffer(
ENUM_XCHMA_CYCLES cycle, // Specified Cycle
double &result[] // Specified Result buffer to Hold Values ...
)
{
//
CleanBuffer(result);
ArraySetAsSeries(result, true);
//
switch (cycle)
{
//
case X_XCHMA_CYCLE_LONG:
//
ArrayCopy(
result,
xCHMALcFastBuffer);
break;
//
case X_XCHMA_CYCLE_MEDIUM:
//
ArrayCopy(
result,
xCHMAMcFastBuffer);
break;
//
case X_XCHMA_CYCLE_SHORT:
//
ArrayCopy(
result,
xCHMAScFastBuffer);
break;
}
}
//
// Retrieve Cycle Fast Buffer ...
void XCHMAGetCycleSlowBuffer(
ENUM_XCHMA_CYCLES cycle, // Specified Cycle
double &result[] // Specified Result buffer to Hold Values ...
)
{
//
CleanBuffer(result);
ArraySetAsSeries(result, true);
//
switch (cycle)
{
//
case X_XCHMA_CYCLE_LONG:
//
ArrayCopy(
result,
xCHMALcSlowBuffer);
break;
//
case X_XCHMA_CYCLE_MEDIUM:
//
ArrayCopy(
result,
xCHMAMcSlowBuffer);
break;
//
case X_XCHMA_CYCLE_SHORT:
//
ArrayCopy(
result,
xCHMAScSlowBuffer);
break;
}
}
//
// Check a Cycle is vale ...
bool XCHMAIsCycleVale(
ENUM_XCHMA_CYCLES cycle // Specified Cycle
)
{
//
bool result = false;
//
// Retrieve Length ...
int length = XCHMAGetCycleFastLength(cycle);
int halfLength = length / 2;
int thirdLength = length / 3;
int qLength = length / 4;
qLength = qLength < 3 ? 3 : qLength > 7 ? 7
: qLength;
//
double buffer[];
XCHMAGetCycleFastBuffer(
cycle,
buffer);
//
bool isIncreasing = IsIncreasing(
qLength,
1,
buffer);
//
bool isDecreasing = IsDecreasing(
thirdLength,
qLength,
buffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// Check a Cycle is peak ...
bool XCHMAIsCyclePeak(
ENUM_XCHMA_CYCLES cycle // Specified Cycle
)
{
//
bool result = false;
//
// Retrieve Length ...
int length = XCHMAGetCycleFastLength(cycle);
int halfLength = length / 2;
int thirdLength = length / 3;
int qLength = length / 4;
qLength = qLength < 3 ? 3 : qLength > 7 ? 7
: qLength;
//
double buffer[];
XCHMAGetCycleFastBuffer(
cycle,
buffer);
//
bool isIncreasing = IsIncreasing(
thirdLength,
qLength,
buffer);
//
bool isDecreasing = IsDecreasing(
qLength,
1,
buffer);
//
// Generating Result ...
result =
//
isIncreasing
//
&&
//
isDecreasing
//
;
//
return result;
}
//
// END XCHMA Custom Functions ...
//