Complete Rejection Bar POi Detection mechanism ...
This commit is contained in:
@@ -1277,6 +1277,508 @@ struct XOHCL
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool HasStrongLowShadow(
|
||||
double percent = 50, // Percent of Body
|
||||
int __loopback = 2,
|
||||
double _sharpRatio = 2.5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() && Index() > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
(GetRange() * percent) / 100 <= GetLowShadow();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (__loopback < 0)
|
||||
{
|
||||
__loopback = 2;
|
||||
}
|
||||
|
||||
//
|
||||
if (_sharpRatio < 0)
|
||||
{
|
||||
_sharpRatio = 2.5;
|
||||
}
|
||||
|
||||
//
|
||||
result = Index() > __loopback;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Highest High and Lowest Low in loopback Range ...
|
||||
int startIndex = Index() - __loopback;
|
||||
int endIndex = Index() + __loopback;
|
||||
int requiredBars = MathAbs(endIndex - startIndex);
|
||||
|
||||
//
|
||||
// Highs ...
|
||||
double highs[];
|
||||
int copiedHighs = CopyHigh(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
highs //
|
||||
);
|
||||
|
||||
//
|
||||
result = copiedHighs == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int highestHighIDX = ArrayMaximum(highs);
|
||||
result = IsValidIndex(highestHighIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double highestHigh = highs[highestHighIDX];
|
||||
|
||||
//
|
||||
// Lows ...
|
||||
double lows[];
|
||||
int copiedLows = CopyLow(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
lows //
|
||||
);
|
||||
|
||||
//
|
||||
result = copiedLows == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int lowestLowIDX = ArrayMinimum(lows);
|
||||
result = IsValidIndex(lowestLowIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double lowestLow = lows[lowestLowIDX];
|
||||
|
||||
//
|
||||
result = low == lowestLow &&
|
||||
highestHigh > high;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to Validate Sharp Ratio ...
|
||||
|
||||
//
|
||||
Clean(highs);
|
||||
Clean(lows);
|
||||
|
||||
//
|
||||
// Left Side ...
|
||||
startIndex = Index() + 1;
|
||||
endIndex = startIndex + (__loopback / 2) - 1;
|
||||
requiredBars = MathAbs(endIndex - startIndex);
|
||||
|
||||
//
|
||||
copiedHighs = CopyHigh(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
highs //
|
||||
);
|
||||
result = copiedHighs == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHighIDX = ArrayMaximum(highs);
|
||||
result = IsValidIndex(highestHighIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHigh = highs[highestHighIDX];
|
||||
|
||||
//
|
||||
copiedLows = CopyLow(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
lows //
|
||||
);
|
||||
result = copiedLows == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLowIDX = ArrayMinimum(lows);
|
||||
result = IsValidIndex(lowestLowIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLow = lows[lowestLowIDX];
|
||||
|
||||
//
|
||||
double leftDiff = highestHigh - lowestLow;
|
||||
|
||||
//
|
||||
Clean(highs);
|
||||
Clean(lows);
|
||||
|
||||
//
|
||||
// Right Side ...
|
||||
startIndex = Index() - 1;
|
||||
endIndex = startIndex - (__loopback / 2) + 1;
|
||||
requiredBars = MathAbs(endIndex - startIndex);
|
||||
|
||||
//
|
||||
copiedHighs = CopyHigh(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
highs //
|
||||
);
|
||||
result = copiedHighs == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHighIDX = ArrayMaximum(highs);
|
||||
result = IsValidIndex(highestHighIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHigh = highs[highestHighIDX];
|
||||
|
||||
//
|
||||
copiedLows = CopyLow(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
lows //
|
||||
);
|
||||
result = copiedLows == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLowIDX = ArrayMinimum(lows);
|
||||
result = IsValidIndex(lowestLowIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLow = lows[lowestLowIDX];
|
||||
|
||||
//
|
||||
double rightDiff = highestHigh - lowestLow;
|
||||
double diff = MathMax(leftDiff, rightDiff);
|
||||
result = GetLowShadow() >= (diff / 100) * _sharpRatio;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool HasStrongHighShadow(
|
||||
double percent = 50, // Percent of Body
|
||||
int __loopback = 2,
|
||||
double _sharpRatio = 2.5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() && Index() > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
(GetRange() * percent) / 100 <= GetHighShadow();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (__loopback < 0)
|
||||
{
|
||||
__loopback = 2;
|
||||
}
|
||||
|
||||
//
|
||||
if (_sharpRatio < 0)
|
||||
{
|
||||
_sharpRatio = 2.5;
|
||||
}
|
||||
|
||||
//
|
||||
result = Index() > __loopback;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Highest High and Lowest Low in loopback Range ...
|
||||
int startIndex = Index() - __loopback;
|
||||
int endIndex = Index() + __loopback;
|
||||
int requiredBars = MathAbs(endIndex - startIndex);
|
||||
|
||||
//
|
||||
// Highs ...
|
||||
double highs[];
|
||||
int copiedHighs = CopyHigh(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
highs //
|
||||
);
|
||||
|
||||
//
|
||||
result = copiedHighs == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int highestHighIDX = ArrayMaximum(highs);
|
||||
result = IsValidIndex(highestHighIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double highestHigh = highs[highestHighIDX];
|
||||
|
||||
//
|
||||
// Lows ...
|
||||
double lows[];
|
||||
int copiedLows = CopyLow(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
lows //
|
||||
);
|
||||
|
||||
//
|
||||
result = copiedLows == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int lowestLowIDX = ArrayMinimum(lows);
|
||||
result = IsValidIndex(lowestLowIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double lowestLow = lows[lowestLowIDX];
|
||||
|
||||
//
|
||||
result = high == highestHigh &&
|
||||
lowestLow < low;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to Validate Sharp Ratio ...
|
||||
|
||||
//
|
||||
Clean(highs);
|
||||
Clean(lows);
|
||||
|
||||
//
|
||||
// Left Side ...
|
||||
startIndex = Index() + 1;
|
||||
endIndex = startIndex + (__loopback / 2) - 1;
|
||||
requiredBars = MathAbs(endIndex - startIndex);
|
||||
|
||||
//
|
||||
copiedHighs = CopyHigh(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
highs //
|
||||
);
|
||||
result = copiedHighs == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHighIDX = ArrayMaximum(highs);
|
||||
result = IsValidIndex(highestHighIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHigh = highs[highestHighIDX];
|
||||
|
||||
//
|
||||
copiedLows = CopyLow(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
lows //
|
||||
);
|
||||
result = copiedLows == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLowIDX = ArrayMinimum(lows);
|
||||
result = IsValidIndex(lowestLowIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLow = lows[lowestLowIDX];
|
||||
|
||||
//
|
||||
double leftDiff = highestHigh - lowestLow;
|
||||
|
||||
//
|
||||
Clean(highs);
|
||||
Clean(lows);
|
||||
|
||||
//
|
||||
// Right Side ...
|
||||
startIndex = Index() - 1;
|
||||
endIndex = startIndex - (__loopback / 2) + 1;
|
||||
requiredBars = MathAbs(endIndex - startIndex);
|
||||
|
||||
//
|
||||
copiedHighs = CopyHigh(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
highs //
|
||||
);
|
||||
result = copiedHighs == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHighIDX = ArrayMaximum(highs);
|
||||
result = IsValidIndex(highestHighIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
highestHigh = highs[highestHighIDX];
|
||||
|
||||
//
|
||||
copiedLows = CopyLow(
|
||||
symbol,
|
||||
period,
|
||||
startIndex,
|
||||
requiredBars,
|
||||
lows //
|
||||
);
|
||||
result = copiedLows == requiredBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLowIDX = ArrayMinimum(lows);
|
||||
result = IsValidIndex(lowestLowIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
lowestLow = lows[lowestLowIDX];
|
||||
|
||||
//
|
||||
double rightDiff = highestHigh - lowestLow;
|
||||
double diff = MathMax(leftDiff, rightDiff);
|
||||
result = GetHighShadow() >= (diff / 100) * _sharpRatio;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsStrongBullish(
|
||||
double percent = 50 // Percent of Body
|
||||
@@ -8038,7 +8540,8 @@ datetime GetUTCTime(
|
||||
int gmtOffset = TimeGMTOffset();
|
||||
int offsetDelte = gmtOffset + cLocalOffset;
|
||||
int requiredUTCOffset = GetUTCRequiredTimeOffset();
|
||||
if (requiredUTCOffset > 0) {
|
||||
if (requiredUTCOffset > 0)
|
||||
{
|
||||
requiredUTCOffset = -1 * requiredUTCOffset;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user