Last ...
This commit is contained in:
@@ -26,200 +26,6 @@
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// 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 DetectSupplyZone(
|
||||
XCSupplyZone *&zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsBreaked();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Implment Zone Finding ...
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Demand Zone if Exists ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectDemandZone(
|
||||
XCDemandZone *&zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsBreaked();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Implment Zone Finding ...
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Implementations ...
|
||||
class XCBarAnalyser : public XCBase
|
||||
|
||||
@@ -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 ...
|
||||
|
||||
|
||||
@@ -887,7 +887,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillConsolidations(
|
||||
int FillConsolidationZones(
|
||||
XConsolidationZone &consolidations[] //
|
||||
)
|
||||
{
|
||||
|
||||
@@ -468,6 +468,111 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
double bid = GetBid(symbol);
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
int consolidationsCount = mTriggerCycleHelper.CountConsolidationZones();
|
||||
result = IsValidSize(consolidationsCount);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
XConsolidationZone consolidations[];
|
||||
mTriggerCycleHelper.FillConsolidationZones(consolidations);
|
||||
|
||||
//
|
||||
// Detect Bid inside Of Zones ...
|
||||
bool hasSupply = false;
|
||||
bool hasDemand = false;
|
||||
XCSupplyZone *supplyZone;
|
||||
XCDemandZone *demandZone;
|
||||
bool isBidInsideZone = false;
|
||||
XConsolidationZone bidContainsConsolidationZone;
|
||||
for (int i = consolidationsCount - 1; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
XConsolidationZone iZone = consolidations[i];
|
||||
|
||||
//
|
||||
// Check Supply or Demand Zone ...
|
||||
hasSupply = iZone.HasSupplyZone(supplyZone);
|
||||
hasDemand = iZone.HasDemandZone(demandZone);
|
||||
|
||||
//
|
||||
result = hasSupply ||
|
||||
hasDemand;
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bid inside Zone ...
|
||||
if (hasSupply)
|
||||
{
|
||||
//
|
||||
result = bid < supplyZone.Upper() &&
|
||||
bid > supplyZone.Lower();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = bid < demandZone.Upper() &&
|
||||
bid > demandZone.Lower();
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (hasSupply)
|
||||
{
|
||||
//
|
||||
supplyZone.To(cTime);
|
||||
XCSupplyZoneObject *iSupplyZoneObj;
|
||||
result = mPOIDrawer.CreateSupplyZone(
|
||||
supplyZone,
|
||||
iSupplyZoneObj //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (hasDemand)
|
||||
{
|
||||
//
|
||||
demandZone.To(cTime);
|
||||
XCDemandZoneObject *iDemandZoneObj;
|
||||
result = mPOIDrawer.CreateDemandZone(
|
||||
demandZone,
|
||||
iDemandZoneObj //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Print("BID Inside Zone ...");
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user