last ...
This commit is contained in:
@@ -246,6 +246,42 @@ class XCXFIMAPOIDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool AnalyseMarketUsingZigZag(
|
||||
XOHCL &bar,
|
||||
ENUM_TIMEFRAMES forPeriod,
|
||||
XZigZagAnalysis &analysis //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
analysis.Clean();
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = bar.period;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading XZigZag Points ...
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Implementing Patrren Detector ...
|
||||
|
||||
|
||||
@@ -411,4 +411,199 @@ struct XZigZagPoint
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Specified ZigZag based Market Analysis ...
|
||||
**/
|
||||
struct XZigZagAnalysis
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
string symbol; // Symbol ...
|
||||
datetime time; // Time ...
|
||||
ENUM_TIMEFRAMES period; // Period ...
|
||||
XZigZagPoint pivots[]; // ZigZag Pivots ...
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION dir; // Direction ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XZigZagAnalysis()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup Model ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
time = NULL;
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
dir = X_DIRECTION_NONE;
|
||||
SpecifiedClean(pivots);
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
HasChild(pivots) &&
|
||||
HasDirection(dir) &&
|
||||
IsSpecifiedValid(time) &&
|
||||
IsSpecifiedValid(symbol) &&
|
||||
IsSpecifiedValid(period);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate Analysis Age, based on Specified Time Frame ...
|
||||
*
|
||||
* @param forPeriod: ENUM_TIMEFRAMES, Specified Period ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetAge(
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = period;
|
||||
}
|
||||
|
||||
//
|
||||
result = GetBarIndex(
|
||||
symbol,
|
||||
forPeriod,
|
||||
time //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check two item is Same or not ...
|
||||
*
|
||||
* @param item: XZigZagAnalysis, dest model for Checking ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSameAs(XZigZagAnalysis &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
item.IsValid() &&
|
||||
time == item.time &&
|
||||
IsSameMarketAs(item);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to model Has Same Symbol ...
|
||||
*
|
||||
* @param item: XZigZagAnalysis, dest model for Checking ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSameSymbolAs(XZigZagAnalysis &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
item.IsValid() &&
|
||||
symbol == item.symbol;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to model Has Same Period ...
|
||||
*
|
||||
* @param item: XZigZagAnalysis, dest model for Checking ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSamePeriodAs(XZigZagAnalysis &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
item.IsValid() &&
|
||||
period == item.period;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to model Has Same Symbol/Period ...
|
||||
*
|
||||
* @param item: XZigZagAnalysis, dest model for Checking ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSameMarketAs(XZigZagAnalysis &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid() &&
|
||||
item.IsValid() &&
|
||||
IsSameSymbolAs(item) &&
|
||||
IsSamePeriodAs(item);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user