826 lines
26 KiB
Plaintext
826 lines
26 KiB
Plaintext
|
|
int CountKIFastTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetKIFast(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
int CountKISlowTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetKISlow(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
int CountKISuperSlowTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetKISuperSlow(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
int CountKIUpperTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetKIUpper(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
int CountKILowerTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetKILower(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
int CountMAFastTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetMAFast(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
int CountMASlowTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetMASlow(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
int CountMASuperSlowTouches(
|
|
int barIndex = 0,
|
|
int loopback = 5,
|
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
|
ENUM_X_BOUNDARY_PRICE priceType = X_BOUNDARY_PRICE_HIGH_LOW //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
loopback = NormalizeInt(loopback, 1);
|
|
barIndex = NormalizeBarIndex(barIndex);
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool has = false;
|
|
double iValue = 0;
|
|
double affectedValue = 0;
|
|
double iConfirnValue = 0;
|
|
bool isBullish = !HasDirection(forDir) || IsXBullish(forDir);
|
|
bool isBearish = !HasDirection(forDir) || IsXBearish(forDir);
|
|
ENUM_X_PRICE bullishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bullishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
ENUM_X_PRICE bearishTouchUpperPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_UP;
|
|
ENUM_X_PRICE bearishTouchLowerPriceType = priceType == X_BOUNDARY_PRICE_HIGH_LOW
|
|
? X_PRICE_LOW
|
|
: X_PRICE_DOWN;
|
|
for (int i = barIndex; i < barIndex + loopback; i++)
|
|
{
|
|
//
|
|
has = iBar.Init(symbol, period, i);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
affectedValue = helper.GetMASuperSlow(i);
|
|
|
|
//
|
|
// Bullish Touches ...
|
|
if (isBullish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bullishTouchLowerPriceType);
|
|
iConfirnValue = iBar.GetPrice(bullishTouchUpperPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue <= affectedValue &&
|
|
iConfirnValue >= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Bearish Touches ...
|
|
if (isBearish)
|
|
{
|
|
//
|
|
iValue = iBar.GetPrice(bearishTouchUpperPriceType);
|
|
iConfirnValue = iBar.GetPrice(bearishTouchLowerPriceType);
|
|
has =
|
|
NotEmptyZero(iValue) &&
|
|
NotEmptyZero(affectedValue) &&
|
|
NotEmptyZero(iConfirnValue) &&
|
|
iValue >= affectedValue &&
|
|
iConfirnValue <= affectedValue;
|
|
if (has)
|
|
{
|
|
result++;
|
|
}
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|