last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -501,7 +501,8 @@ struct XTrend
|
||||
//
|
||||
if (IsValid())
|
||||
{
|
||||
result = "XTRND_" + ToXString(dir) + "_" + ToXString(TimeToSeconds(time));
|
||||
double ifv = NormalizePrice(fromValue, symbol);
|
||||
result = "XTRND_" + ToXString(dir) + "_" + ToXString(ifv) + "_" + ToXString(TimeToSeconds(fromTime));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -1882,6 +1882,350 @@ class XCXFIMAHelperParser : XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Over HK Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsOverHKBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetHKBandLower(barIndex);
|
||||
result =
|
||||
result &&
|
||||
price > value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Over HK Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsOverHKBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetHKBandUpper(barIndex);
|
||||
result =
|
||||
result &&
|
||||
price > value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Under HK Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsUnderHKBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetHKBandLower(barIndex);
|
||||
result =
|
||||
result &&
|
||||
price < value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Under HK Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsUnderHKBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetHKBandUpper(barIndex);
|
||||
result =
|
||||
result &&
|
||||
price < value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Crossed Over HK Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedOverHKBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsOverHKBandLower(barIndex, priceType);
|
||||
bool isP = IsOverHKBandLower(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Crossed Under HK Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedUnderHKBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsUnderHKBandLower(barIndex, priceType);
|
||||
bool isP = IsUnderHKBandLower(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Crossed Over HK Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedOverHKBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsOverHKBandUpper(barIndex, priceType);
|
||||
bool isP = IsOverHKBandUpper(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Crossed Under HK Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedUnderHKBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsUnderHKBandUpper(barIndex, priceType);
|
||||
bool isP = IsUnderHKBandUpper(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count Bullish HK(s) ...
|
||||
*
|
||||
@@ -2988,6 +3332,361 @@ class XCXFIMAHelperParser : XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
|
||||
/**
|
||||
* Check Price is Over ATR Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsOverATRBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result =
|
||||
IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetATRBandLower(barIndex);
|
||||
result =
|
||||
result &&
|
||||
NotEmptyZero(value) &&
|
||||
NotEmptyZero(price) &&
|
||||
price > value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Over ATR Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsOverATRBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result =
|
||||
IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetATRBandUpper(barIndex);
|
||||
result =
|
||||
result &&
|
||||
NotEmptyZero(value) &&
|
||||
NotEmptyZero(price) &&
|
||||
price > value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Under ATR Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsUnderATRBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result =
|
||||
IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetATRBandLower(barIndex);
|
||||
result =
|
||||
result &&
|
||||
NotEmptyZero(value) &&
|
||||
NotEmptyZero(price) &&
|
||||
price < value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Under ATR Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsUnderATRBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result =
|
||||
IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(symbol, period, barIndex);
|
||||
double price = bar.GetPrice(priceType);
|
||||
double value = helper.GetATRBandUpper(barIndex);
|
||||
result =
|
||||
result &&
|
||||
NotEmptyZero(value) &&
|
||||
NotEmptyZero(price) &&
|
||||
price < value;
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Crossed Over ATR Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedOverATRBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsOverATRBandLower(barIndex, priceType);
|
||||
bool isP = IsOverATRBandLower(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Crossed Under ATR Band Lower ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedUnderATRBandLower(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsUnderATRBandLower(barIndex, priceType);
|
||||
bool isP = IsUnderATRBandLower(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Crossed Over ATR Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedOverATRBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsOverATRBandUpper(barIndex, priceType);
|
||||
bool isP = IsOverATRBandUpper(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price is Crossed Under ATR Band Upper ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsCrossedUnderATRBandUpper(
|
||||
int barIndex = 0,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isC = IsUnderATRBandUpper(barIndex, priceType);
|
||||
bool isP = IsUnderATRBandUpper(barIndex + 1, priceType);
|
||||
|
||||
//
|
||||
result = isC && !isP;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Cycles Tools ...
|
||||
|
||||
@@ -7469,7 +8168,7 @@ class XCXFIMAHelperParser : XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Cycles MA(s) ...
|
||||
*
|
||||
*
|
||||
* @param scMA: double, reference to holds cycle value ...
|
||||
* @param mcMA: double, reference to holds cycle value ...
|
||||
* @param lcMA: double, reference to holds cycle value ...
|
||||
@@ -7512,7 +8211,7 @@ class XCXFIMAHelperParser : XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Cycles MA State(s) ...
|
||||
*
|
||||
*
|
||||
* @param scMAState: double, reference to holds cycle value ...
|
||||
* @param mcMAState: double, reference to holds cycle value ...
|
||||
* @param lcMAState: double, reference to holds cycle value ...
|
||||
@@ -8507,6 +9206,115 @@ class XCXFIMAHelperParser : XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Other Tools ...
|
||||
|
||||
int CollectPivots(
|
||||
XPivot &pivots[],
|
||||
int barIndex = 0,
|
||||
int loopback = 500 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
loopback = NormalizeInt(loopback, 50);
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = IsValid();
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
has = false;
|
||||
XOHCL tmpBar;
|
||||
XPivot tmpPivot;
|
||||
double tmpValue;
|
||||
datetime tmpTime;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
string tmpSymbol = symbol;
|
||||
ENUM_TIMEFRAMES tmpPeriod = period;
|
||||
ENUM_X_DIRECTION tmpDir = X_DIRECTION_NONE;
|
||||
for (int i = barIndex; i < barIndex + loopback; i++)
|
||||
{
|
||||
//
|
||||
tmpBar.Clean();
|
||||
tmpPivot.Clean();
|
||||
|
||||
//
|
||||
has = tmpBar.Init(tmpSymbol, tmpPeriod, i);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// XSAR ...
|
||||
isBullish = IsSARSwitchedToBullish(i);
|
||||
isBearish = IsSARSwitchedToBearish(i);
|
||||
has = isBullish || isBearish;
|
||||
if (has)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// XMA Fast / Slow ...
|
||||
|
||||
//
|
||||
// States ...
|
||||
isBullish = IsMASlowSwitchedToBullish(i);
|
||||
isBearish = IsMASlowSwitchedToBearish(i);
|
||||
has = isBullish || isBearish;
|
||||
if (has)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Crossed Fast Slow ...
|
||||
isBullish = IsMAFastCrossedOverSlow(i);
|
||||
isBearish = IsMAFastCrossedUnderSlow(i);
|
||||
has = isBullish || isBearish;
|
||||
if (has)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Crossed Last ...
|
||||
isBullish = IsMASlowCrossedOverLast(i);
|
||||
isBearish = IsMASlowCrossedUnderLast(i);
|
||||
has = isBullish || isBearish;
|
||||
if (has)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
isBullish = IsHKSwitchedToBullish(i);
|
||||
isBearish = IsHKSwitchedToBearish(i);
|
||||
has = isBullish || isBearish;
|
||||
if (has)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
|
||||
@@ -1564,10 +1564,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
|
||||
//
|
||||
// Signaller Flags ...
|
||||
bool useSignaller1 = true;
|
||||
bool useSignaller2 = false;
|
||||
bool useSignaller3 = false;
|
||||
bool useSignaller4 = false;
|
||||
bool useSignaller1 = false;
|
||||
bool useSignaller2 = true;
|
||||
bool useSignaller3 = true;
|
||||
bool useSignaller4 = true;
|
||||
|
||||
//
|
||||
XBoxZone tmpZone;
|
||||
@@ -2049,6 +2049,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
//
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
XOHCL p3Bar;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
@@ -2057,56 +2058,19 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
result = result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
result = result &&
|
||||
p2Bar.GetPreviousBar(p3Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
p3Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Conditions ...
|
||||
int pullBackStartBar = -1;
|
||||
bool isPullBack = result &&
|
||||
poiDetector.IsPullbackPattern(
|
||||
pBar,
|
||||
zone,
|
||||
dir,
|
||||
2,
|
||||
false // Force Break ...
|
||||
);
|
||||
bool isPullbackBullish = isPullBack &&
|
||||
IsXBullish(dir);
|
||||
bool isPullbackBearish = isPullBack &&
|
||||
IsXBearish(dir);
|
||||
if (isPullBack)
|
||||
{
|
||||
pullBackStartBar = zone.FromIndex();
|
||||
}
|
||||
|
||||
//
|
||||
// Reading HK Band ...
|
||||
|
||||
//
|
||||
double pHKBandUpper = fimaHelper.GetHKBandUpper(pBar.Index());
|
||||
double pHKBandLower = fimaHelper.GetHKBandLower(pBar.Index());
|
||||
int overHKBandUpperCount = fimaParser.CountOverHKBandUpper(pullBackStartBar, X_PRICE_LOW);
|
||||
int underHKBandLowerCount = fimaParser.CountUnderHKBandLower(pullBackStartBar, X_PRICE_HIGH);
|
||||
|
||||
//
|
||||
// Reading PV Requirements ...
|
||||
|
||||
//
|
||||
int lastPeakOverLastIDX = -1;
|
||||
int lastValeUnderLastIDX = -1;
|
||||
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||
int samePeaks = fimaParser.CountSamePeaks(pBar.Index());
|
||||
int sameVales = fimaParser.CountSameVales(pBar.Index());
|
||||
fimaParser.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
|
||||
fimaParser.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
|
||||
|
||||
//
|
||||
// Reading pBar Patterns ...
|
||||
XPatternAnalysis pBarPatterns;
|
||||
@@ -2115,9 +2079,18 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
pBarPatterns,
|
||||
structureConfig.barsAnalysisConfig //
|
||||
);
|
||||
bool hasSupport = pBarPatterns.IsSupport();
|
||||
bool hasResistance = pBarPatterns.IsResistance();
|
||||
|
||||
//
|
||||
// Check Bar Patterns ...
|
||||
// Check Boundary Trend ...
|
||||
XTrend boundaryTrend;
|
||||
bool hasBoundaryTrend = fimaParser.HasBoundaryTrend(boundaryTrend, pBar.Index());
|
||||
bool hasBoundaryBullishTrend = hasBoundaryTrend && boundaryTrend.IsBullish();
|
||||
bool hasBoundaryBearishTrend = hasBoundaryTrend && boundaryTrend.IsBearish();
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool isPBarHasBullishPatterns =
|
||||
(bar.close > pBar.low ||
|
||||
bar.open > pBar.low) &&
|
||||
@@ -2130,6 +2103,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
pBarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool isPBarHasBearishPatterns =
|
||||
(bar.close < pBar.high ||
|
||||
bar.open < pBar.high) &&
|
||||
@@ -2144,94 +2120,78 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
);
|
||||
|
||||
//
|
||||
// Check PBar Close Over Under Fast Ma ...
|
||||
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
||||
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
||||
|
||||
//
|
||||
// Try To Find Affected Zone ...
|
||||
|
||||
//
|
||||
// Collecting Zones ...
|
||||
XBoxZone zones[];
|
||||
XBoxZone affectedZones[];
|
||||
XBoxZone affectedZonesBullish[];
|
||||
XBoxZone affectedZonesBearish[];
|
||||
int zonesCount = poiDetector.CollectZones(
|
||||
// Check Pull Back Pattern ...
|
||||
XBoxZone pullbackZone;
|
||||
ENUM_X_DIRECTION pullbackDir;
|
||||
bool isPullback = poiDetector.IsPullbackPattern(
|
||||
pBar,
|
||||
zones, //
|
||||
5, // Zones Loopback ...
|
||||
3 // Zones Validation Length ...
|
||||
// Required Zones ...
|
||||
// Loopback ...
|
||||
pullbackZone,
|
||||
pullbackDir //
|
||||
);
|
||||
int affectedZonesCount = ExtractAffectedZones(
|
||||
bool isBullishPullback = isPullback && IsXBullish(pullbackDir);
|
||||
bool isBearishPullback = isPullback && IsXBearish(pullbackDir);
|
||||
|
||||
//
|
||||
// Force P2Bar is Pin Bar ...
|
||||
ENUM_X_DIRECTION p2Dir;
|
||||
bool isP2BarPinned = poiDetector.IsPinnedBar(
|
||||
p2Bar,
|
||||
p2Dir //
|
||||
);
|
||||
bool isP2BarBullishPinned =
|
||||
isP2BarPinned &&
|
||||
IsXBullish(p2Dir);
|
||||
bool isP2BarBearishPinned =
|
||||
isP2BarPinned &&
|
||||
IsXBearish(p2Dir);
|
||||
|
||||
//
|
||||
// Checking For Leg Pattern ...
|
||||
XLeg _leg;
|
||||
XBoxZone legZone;
|
||||
bool hasLeg = poiDetector.IsLegPattern(
|
||||
pBar,
|
||||
zones,
|
||||
affectedZones //
|
||||
);
|
||||
int affectedZonesBullishCount = ExtractByDirection(
|
||||
affectedZonesBullish,
|
||||
affectedZones,
|
||||
X_DIRECTION_BULLISH //
|
||||
);
|
||||
int affectedZonesBearishCount = ExtractByDirection(
|
||||
affectedZonesBearish,
|
||||
affectedZones,
|
||||
X_DIRECTION_BEARISH //
|
||||
_leg,
|
||||
3,
|
||||
100 //
|
||||
);
|
||||
if (hasLeg)
|
||||
{
|
||||
hasLeg = _leg.ToBox(legZone);
|
||||
}
|
||||
bool hasBullishLeg = hasLeg && _leg.IsBullish();
|
||||
bool hasBearishLeg = hasLeg && _leg.IsBearish();
|
||||
|
||||
//
|
||||
int insideBullishIDX = -1;
|
||||
int insideBearishIDX = -1;
|
||||
bool hasBullishInside =
|
||||
pBar.IsBullish() &&
|
||||
HasInside(
|
||||
insideBullishIDX,
|
||||
pBar,
|
||||
affectedZonesBullish //
|
||||
);
|
||||
bool hasBearishInside =
|
||||
pBar.IsBearish() &&
|
||||
HasInside(
|
||||
insideBearishIDX,
|
||||
pBar,
|
||||
affectedZonesBearish //
|
||||
);
|
||||
// Check Based On LC and HC MA State ...
|
||||
|
||||
//
|
||||
// Detecting Boundary Trend ...
|
||||
XTrend boundaryTrend;
|
||||
bool hasBoundaryTrend = fimaParser.HasBoundaryTrend(boundaryTrend, pBar.Index());
|
||||
bool hasBoundaryBullishTrend = hasBoundaryTrend && boundaryTrend.IsBullish();
|
||||
bool hasBoundaryBearishTrend = hasBoundaryTrend && boundaryTrend.IsBearish();
|
||||
bool isLCMABullish = fimaParser.IsLCMABullish(pBar.Index());
|
||||
bool isHCMABullish = fimaParser.IsHCMABullish(pBar.Index());
|
||||
bool isCycleMABullish = isLCMABullish && isHCMABullish;
|
||||
|
||||
//
|
||||
// Do ...
|
||||
bool isLCMABearish = fimaParser.IsLCMABearish(pBar.Index());
|
||||
bool isHCMABearish = fimaParser.IsHCMABearish(pBar.Index());
|
||||
bool isCycleMABearish = isLCMABearish && isHCMABearish;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
hasBullishInside &&
|
||||
isPullbackBullish &&
|
||||
isPBarHasBullishPatterns &&
|
||||
fimaParser.IsSARBullish(pBar.Index()) &&
|
||||
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
|
||||
pVale <= affectedZonesBullish[insideBullishIDX].upper)
|
||||
//
|
||||
;
|
||||
hasBullishLeg &&
|
||||
isCycleMABullish &&
|
||||
isBullishPullback &&
|
||||
isP2BarBullishPinned;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
hasBearishInside &&
|
||||
isPullbackBearish &&
|
||||
isPBarHasBearishPatterns &&
|
||||
fimaParser.IsSARBearish(pBar.Index()) &&
|
||||
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
|
||||
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
|
||||
//
|
||||
;
|
||||
hasBearishLeg &&
|
||||
isCycleMABearish &&
|
||||
isBearishPullback &&
|
||||
isP2BarBearishPinned;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
@@ -2255,48 +2215,35 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
if (isBullish)
|
||||
{
|
||||
zone = affectedZonesBullish[insideBullishIDX];
|
||||
}
|
||||
else
|
||||
{
|
||||
zone = affectedZonesBearish[insideBearishIDX];
|
||||
}
|
||||
zone = pullbackZone;
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
// Zone Validations ...
|
||||
// Draws ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (boundaryTrend.IsValid())
|
||||
{
|
||||
poiDrawer.DrawTrendLine(boundaryTrend, structureDrawConfig.drawConfig);
|
||||
}
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.trendRayLeft = false;
|
||||
iConfig.trendRayRight = false;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||
poiDrawer.DrawZone(legZone, iConfig);
|
||||
poiDrawer.DrawZone(pullbackZone, iConfig);
|
||||
|
||||
//
|
||||
// poiDrawer.DrawTrendLine(boundaryTrend, iConfig);
|
||||
// poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||
poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||
|
||||
//
|
||||
iConfig.Clean();
|
||||
|
||||
//
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
// Reset Flags ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
isBullish = false;
|
||||
isBearish = false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2316,12 +2263,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
}
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
XClean(zones);
|
||||
p3Bar.Clean();
|
||||
pullbackZone.Clean();
|
||||
pBarPatterns.Clean();
|
||||
boundaryTrend.Clean();
|
||||
XClean(affectedZones);
|
||||
XClean(affectedZonesBullish);
|
||||
XClean(affectedZonesBearish);
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user