last ...
This commit is contained in:
@@ -1254,13 +1254,128 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar has MA Cross or not ...
|
||||
*
|
||||
* @param dir: reference for holds cross Direction ...
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param validCrossDiffMultiplier: double, validate diff between MAs on Cross happens ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasMACross(
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int barIndex = 0,
|
||||
double validCrossDiffMultiplier = 1 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
validCrossDiffMultiplier = NormalizeDouble(validCrossDiffMultiplier, 0);
|
||||
|
||||
//
|
||||
double fast[];
|
||||
double slow[];
|
||||
double upper[];
|
||||
double lower[];
|
||||
int count = ReadMAValues(
|
||||
fast,
|
||||
slow,
|
||||
upper,
|
||||
lower,
|
||||
barIndex,
|
||||
2 //
|
||||
);
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
// Validate Readed Values ...
|
||||
result = IsValidSize(count) && count >= 2;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Detect Direction Change ...
|
||||
|
||||
//
|
||||
bool notEmpty =
|
||||
NotEmptyZero(fast[0]) &&
|
||||
NotEmptyZero(fast[1]) &&
|
||||
NotEmptyZero(slow[0]) &&
|
||||
NotEmptyZero(slow[1]);
|
||||
|
||||
//
|
||||
isBullish =
|
||||
notEmpty &&
|
||||
fast[0] > slow[0] &&
|
||||
fast[1] < slow[1];
|
||||
|
||||
//
|
||||
isBearish =
|
||||
notEmpty &&
|
||||
fast[0] < slow[0] &&
|
||||
fast[1] > slow[1];
|
||||
|
||||
//
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
|
||||
//
|
||||
// Validate Direction Change ...
|
||||
if (result &&
|
||||
validCrossDiffMultiplier > 0)
|
||||
{
|
||||
//
|
||||
double _points = GetPoints(GetSymbol());
|
||||
double diff = MathAbs(fast[0] - slow[0]);
|
||||
|
||||
//
|
||||
result = diff >= (validCrossDiffMultiplier * _points);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Setting Direction ...
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: isBearish
|
||||
? X_DIRECTION_BEARISH
|
||||
: X_DIRECTION_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
XClean(fast);
|
||||
XClean(slow);
|
||||
XClean(upper);
|
||||
XClean(lower);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Specified Kind of Pivots ...
|
||||
*
|
||||
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
|
||||
* @param validationLength: int, Specified Pivots Validation Length ignore if <= 0 ...
|
||||
* @param validCrossDiffMultiplier: double, validate diff between MAs on Cross happens ...
|
||||
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
|
||||
*
|
||||
* @return ( int )
|
||||
@@ -1269,7 +1384,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
XPivot &pivots[],
|
||||
int barIndex = 0,
|
||||
int requiredNumberOFPivots = 50,
|
||||
int validationLength = 0,
|
||||
double validCrossDiffMultiplier = 1,
|
||||
int maxAllowedLoopbackLength = 1500 //
|
||||
)
|
||||
{
|
||||
@@ -1283,9 +1398,9 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
validationLength = NormalizeInt(validationLength, 0);
|
||||
requiredNumberOFPivots = NormalizeInt(requiredNumberOFPivots, 2);
|
||||
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50);
|
||||
validCrossDiffMultiplier = NormalizeDouble(validCrossDiffMultiplier, 0);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
@@ -1362,18 +1477,22 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
|
||||
//
|
||||
// Validate Value ...
|
||||
has = NotEmptyZero(iFValue) &&
|
||||
NotEmptyZero(iSValue) &&
|
||||
NotEmptyZero(pFValue) &&
|
||||
NotEmptyZero(pSValue);
|
||||
has =
|
||||
HasMACross(
|
||||
iDir,
|
||||
idx,
|
||||
validCrossDiffMultiplier //
|
||||
) &&
|
||||
NotEmptyZero(iFValue) &&
|
||||
NotEmptyZero(iSValue) &&
|
||||
NotEmptyZero(pFValue) &&
|
||||
NotEmptyZero(pSValue);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Check Direction Changed ...
|
||||
isSwitchedToBullish = iFValue > iSValue &&
|
||||
pFValue < pSValue;
|
||||
isSwitchedToBearish = iFValue < iSValue &&
|
||||
pFValue > pSValue;
|
||||
isSwitchedToBullish = IsXBullish(iDir);
|
||||
isSwitchedToBearish = IsXBearish(iDir);
|
||||
has =
|
||||
isSwitchedToBullish ||
|
||||
isSwitchedToBearish;
|
||||
@@ -1400,15 +1519,6 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
has = has &&
|
||||
HasDirection(iDir);
|
||||
|
||||
//
|
||||
// Check Validation ...
|
||||
if (has &&
|
||||
validationLength > 0)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
}
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user