Last ...
This commit is contained in:
@@ -3667,6 +3667,267 @@ struct XPOIState
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Consolidation Zone ...
|
||||
struct XConsolidationZone
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string symbol; // Symbol ...
|
||||
ENUM_TIMEFRAMES period; // Period ...
|
||||
|
||||
//
|
||||
double upper; // Upper ...
|
||||
double lower; // Lower ...
|
||||
|
||||
//
|
||||
int loopback; // Loopback ...
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION breakDirection; // Break Direction ...
|
||||
XOHCL breakerBar; // Breaker Bar ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XConsolidationZone()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Initialize Zone ...
|
||||
*
|
||||
* @param _symbol: String ...
|
||||
* @param _period: ENUM_TIMEFRAMES member ...
|
||||
* @param _upper: Double ...
|
||||
* @param _lower: Double ...
|
||||
* @param _loopback: Integer ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Init(
|
||||
string _symbol,
|
||||
ENUM_TIMEFRAMES _period,
|
||||
double _upper,
|
||||
double _lower,
|
||||
int _loopback //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
_symbol = NormalizeSymbol(_symbol);
|
||||
_period = NormalizePeriod(_period);
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
_upper > 0 &&
|
||||
_lower > 0 &&
|
||||
_loopback > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
upper = _upper;
|
||||
lower = _lower;
|
||||
symbol = _symbol;
|
||||
period = _period;
|
||||
loopback = _loopback;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
upper = 0;
|
||||
lower = 0;
|
||||
loopback = 0;
|
||||
breakerBar.Clean();
|
||||
breakDirection = X_DIRECTION_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
upper > 0 &&
|
||||
lower > 0 &&
|
||||
loopback > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Zone is Breaked or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBreaked()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = breakerBar.IsValid() &&
|
||||
HasDirection(breakDirection);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Supply Zone if Exists ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasSupplyZone(
|
||||
XCSupplyZone *&zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsBreaked() &&
|
||||
breakDirection == X_DIRECTION_BEARISH;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Implment Zone Finding ...
|
||||
int index = breakerBar.Index();
|
||||
int hhIDX = iHighest(
|
||||
symbol,
|
||||
period,
|
||||
MODE_HIGH,
|
||||
loopback,
|
||||
index //
|
||||
);
|
||||
result = IsValidIndex(hhIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL hhBar;
|
||||
result = hhBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
hhIDX //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
zone = new XCSupplyZone();
|
||||
result = zone.Init(
|
||||
hhBar,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Demand Zone if Exists ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasDemandZone(
|
||||
XCDemandZone *&zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsBreaked() &&
|
||||
breakDirection == X_DIRECTION_BULLISH;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Implment Zone Finding ...
|
||||
int index = breakerBar.Index();
|
||||
int llIDX = iLowest(
|
||||
symbol,
|
||||
period,
|
||||
MODE_LOW,
|
||||
loopback,
|
||||
index //
|
||||
);
|
||||
result = IsValidIndex(llIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL llBar;
|
||||
result = llBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
llIDX //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
zone = new XCDemandZone();
|
||||
result = zone.Init(
|
||||
llBar,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Extensions ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user