last ...
This commit is contained in:
@@ -36,6 +36,7 @@ const string X121SMCStrategyToken = "X121SMC";
|
||||
|
||||
//
|
||||
const string X121SMCXToken = "X121X";
|
||||
const string X121SMCXHKPVToken = "X121XHKPV";
|
||||
const string X121SMCXOBPVToken = "X121XOBPV";
|
||||
|
||||
//
|
||||
@@ -45,6 +46,7 @@ enum ENUM_X_121_SMC_PROVIDERS
|
||||
//
|
||||
X_121_SMC_PROVIDER_NONE,
|
||||
X_121_SMC_PROVIDER_X,
|
||||
X_121_SMC_PROVIDER_XHKPV,
|
||||
X_121_SMC_PROVIDER_XOBPV,
|
||||
};
|
||||
|
||||
@@ -612,6 +614,365 @@ struct X121SMCGuard
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Model Cycle State ...
|
||||
struct X121SMCCycleState
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
XCFVG *bullishFVGs[];
|
||||
XCOrderBlock *bullishOBs[];
|
||||
XCDemandZone *demandZones[];
|
||||
XCSupportZone *supportZones[];
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
XCFVG *bearishFVGs[];
|
||||
XCOrderBlock *bearishOBs[];
|
||||
XCSupplyZone *supplyZones[];
|
||||
XCResistanceZone *resistanceZones[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
X121SMCCycleState()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup Model ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
|
||||
//
|
||||
Clean(bullishFVGs);
|
||||
Clean(bullishOBs);
|
||||
Clean(demandZones);
|
||||
Clean(supportZones);
|
||||
|
||||
//
|
||||
Clean(bearishFVGs);
|
||||
Clean(bearishOBs);
|
||||
Clean(supplyZones);
|
||||
Clean(resistanceZones);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
(
|
||||
//
|
||||
(HasBullishOBs() &&
|
||||
(HasBullishFVGs() ||
|
||||
HasSupportZones() ||
|
||||
HasDemandZones()))
|
||||
//
|
||||
||
|
||||
(HasBearishOBs() &&
|
||||
(HasSupplyZones() ||
|
||||
HasBearishFVGs() ||
|
||||
HasResistanceZones()))
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountBullishOBs()
|
||||
{
|
||||
return ArraySize(bullishOBs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBullishOBs()
|
||||
{
|
||||
return IsValidSize(CountBullishOBs());
|
||||
}
|
||||
|
||||
//
|
||||
int CountBearishOBs()
|
||||
{
|
||||
return ArraySize(bearishOBs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBearishOBs()
|
||||
{
|
||||
return IsValidSize(CountBearishOBs());
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupportZones()
|
||||
{
|
||||
return ArraySize(supportZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupportZones()
|
||||
{
|
||||
return IsValidSize(CountSupportZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountResistanceZones()
|
||||
{
|
||||
return ArraySize(resistanceZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasResistanceZones()
|
||||
{
|
||||
return IsValidSize(CountResistanceZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountDemandZones()
|
||||
{
|
||||
return ArraySize(demandZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasDemandZones()
|
||||
{
|
||||
return IsValidSize(CountDemandZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupplyZones()
|
||||
{
|
||||
return ArraySize(supplyZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupplyZones()
|
||||
{
|
||||
return IsValidSize(CountSupplyZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountBullishFVGs()
|
||||
{
|
||||
return ArraySize(bullishFVGs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBullishFVGs()
|
||||
{
|
||||
return IsValidSize(CountBullishFVGs());
|
||||
}
|
||||
|
||||
//
|
||||
int CountBearishFVGs()
|
||||
{
|
||||
return ArraySize(bearishFVGs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBearishFVGs()
|
||||
{
|
||||
return IsValidSize(CountBearishFVGs());
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
bool DetectPriceInsideBox(
|
||||
XBoxZone &box,
|
||||
X121Conditions &xConditions,
|
||||
X121SMCCycleState &state //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
string symbol = state.symbol;
|
||||
ENUM_TIMEFRAMES period = state.period;
|
||||
|
||||
//
|
||||
box.symbol = symbol;
|
||||
box.period = period;
|
||||
|
||||
//
|
||||
result = state.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Price Inside Order Block ...
|
||||
|
||||
//
|
||||
bool hasBullishOBs = state.HasBullishOBs();
|
||||
int bullishOBsCount = state.CountBullishOBs();
|
||||
|
||||
//
|
||||
bool hasBearishOBs = state.HasBearishOBs();
|
||||
int bearishOBsCount = state.CountBearishOBs();
|
||||
|
||||
//
|
||||
bool hasOBs =
|
||||
//
|
||||
hasBullishOBs ||
|
||||
hasBearishOBs
|
||||
//
|
||||
;
|
||||
result = hasOBs;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasPriceInsideOB = false;
|
||||
XCOrderBlock *priceInsideOB = NULL;
|
||||
ENUM_X_DIRECTION boxDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (hasBullishOBs &&
|
||||
!hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bullishOBsCount; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOb = state.bullishOBs[i];
|
||||
|
||||
//
|
||||
bool isInside = IsPriceInsideZone(
|
||||
xConditions.valesBuffer[1],
|
||||
(XCZone *)iOb //
|
||||
);
|
||||
if (isInside)
|
||||
{
|
||||
//
|
||||
priceInsideOB = iOb;
|
||||
hasPriceInsideOB = true;
|
||||
boxDir = X_DIRECTION_BULLISH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (hasBearishOBs &&
|
||||
!hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bearishOBsCount; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOb = state.bearishOBs[i];
|
||||
|
||||
//
|
||||
bool isInside = IsPriceInsideZone(
|
||||
xConditions.peaksBuffer[1],
|
||||
(XCZone *)iOb //
|
||||
);
|
||||
if (isInside)
|
||||
{
|
||||
//
|
||||
priceInsideOB = iOb;
|
||||
hasPriceInsideOB = true;
|
||||
boxDir = X_DIRECTION_BEARISH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
bool hasBullishFVG = state.HasBullishFVGs();
|
||||
bool hasBearishFVG = state.HasBearishFVGs();
|
||||
bool hasDemandZones = state.HasDemandZones();
|
||||
bool hasSupplyZones = state.HasSupplyZones();
|
||||
bool hasSupportZones = state.HasSupportZones();
|
||||
bool hasResistanceZones = state.HasResistanceZones();
|
||||
|
||||
//
|
||||
bool hasBullishZones =
|
||||
//
|
||||
hasBullishFVG ||
|
||||
hasDemandZones ||
|
||||
hasSupportZones
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasBearishZones =
|
||||
//
|
||||
hasBearishFVG ||
|
||||
hasSupplyZones ||
|
||||
hasResistanceZones
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasPropperZones =
|
||||
//
|
||||
IsBullish(boxDir)
|
||||
? hasBullishZones
|
||||
: IsBearish(boxDir)
|
||||
? hasBearishZones
|
||||
: false
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (!hasPropperZones &&
|
||||
hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
box.to = priceInsideOB.To();
|
||||
box.from = priceInsideOB.From();
|
||||
box.upper = priceInsideOB.Upper();
|
||||
box.lower = priceInsideOB.Lower();
|
||||
}
|
||||
else if (hasPropperZones &&
|
||||
hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
// Detect Validate Zones ...
|
||||
}
|
||||
|
||||
//
|
||||
result = box.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Guard to Collection ...
|
||||
*
|
||||
@@ -704,6 +1065,11 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
|
||||
result = X121SMCXToken;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_121_SMC_PROVIDER_XHKPV:
|
||||
result = X121SMCXHKPVToken;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_121_SMC_PROVIDER_XOBPV:
|
||||
result = X121SMCXOBPVToken;
|
||||
@@ -737,6 +1103,10 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_X;
|
||||
}
|
||||
else if (Contains(X121SMCXHKPVToken, value))
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_XHKPV;
|
||||
}
|
||||
else if (Contains(X121SMCXOBPVToken, value))
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_XOBPV;
|
||||
|
||||
Reference in New Issue
Block a user