This commit is contained in:
2024-12-29 17:46:35 +03:30
parent e831ce8a91
commit c92f2570c7
12 changed files with 944 additions and 864 deletions
+334
View File
@@ -6101,6 +6101,340 @@ void DetectPivotPOIs(
}
}
/**
* Detect Price Inside Zones ...
*
* @param state: XPOIState instance Reference ...
* @param bar: XOHCL instance Reference ...
* @param hasSupport: Boolean ...
* @param hasResistanceZone: Boolean ...
* @param hasSupplyZone: Boolean ...
* @param hasDemandZone: Boolean ...
* @param hasOrderBlock: Boolean ...
* @param hasFairValueGap: Boolean ...
* @return ( bool )
*/
bool DetectPriceInsideZones(
XPOIState &state,
XOHCL &bar,
int &zonesCount,
bool &hasSupportZone,
XCSupportZone *&supportZone,
bool &hasResistanceZone,
XCResistanceZone *&resistanceZone,
bool &hasSupplyZone,
XCSupplyZone *&supplyZone,
bool &hasDemandZone,
XCDemandZone *&demandZone,
bool &hasOrderBlock,
XCOrderBlock *&orderBlock,
bool &hasFairValueGap,
XCFVG *&fairValueGap //
)
{
//
bool result = false;
//
zonesCount = 0;
//
hasSupportZone = false;
hasResistanceZone = false;
hasSupplyZone = false;
hasDemandZone = false;
hasOrderBlock = false;
hasFairValueGap = false;
//
supportZone = NULL;
resistanceZone = NULL;
supplyZone = NULL;
demandZone = NULL;
orderBlock = NULL;
fairValueGap = NULL;
//
datetime cTime = TimeCurrent();
//
result = bar.IsValid() &&
state.IsValid() &&
state.HasChild();
if (!result)
{
return result;
}
//
int count = 0;
//
// Support Zone ...
count = state.CountSupportZones();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCSupportZone *iZone = state.supportZones[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
supportZone = iZone;
}
}
//
hasSupportZone = supportZone != NULL &&
supportZone.IsValid();
if (hasSupportZone)
{
//
zonesCount++;
supportZone.To(cTime);
}
}
//
// Resistance Zone ...
count = state.CountResistanceZones();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCResistanceZone *iZone = state.resistanceZones[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
resistanceZone = iZone;
}
}
//
hasResistanceZone = resistanceZone != NULL &&
resistanceZone.IsValid();
if (hasResistanceZone)
{
//
zonesCount++;
resistanceZone.To(cTime);
}
}
//
// Supply Zone ...
count = state.CountSupplyZones();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCSupplyZone *iZone = state.supplyZones[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
supplyZone = iZone;
}
}
//
hasSupplyZone = supplyZone != NULL &&
supplyZone.IsValid();
if (hasSupplyZone)
{
//
zonesCount++;
supplyZone.To(cTime);
}
}
//
// Demand Zone ...
count = state.CountDemandZones();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCDemandZone *iZone = state.demandZones[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
demandZone = iZone;
}
}
//
hasDemandZone = demandZone != NULL &&
demandZone.IsValid();
if (hasDemandZone)
{
//
zonesCount++;
demandZone.To(cTime);
}
}
//
// OrderBlock ...
count = state.CountBullishOrderBlocks();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCOrderBlock *iZone = state.bullishOrderBlocks[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
orderBlock = iZone;
}
}
//
hasOrderBlock = orderBlock != NULL &&
orderBlock.IsValid();
if (hasOrderBlock)
{
//
zonesCount++;
orderBlock.To(cTime);
}
}
if (!hasOrderBlock)
{
//
count = state.CountBearishOrderBlocks();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCOrderBlock *iZone = state.bearishOrderBlocks[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
orderBlock = iZone;
}
}
//
hasOrderBlock = orderBlock != NULL &&
orderBlock.IsValid();
if (hasOrderBlock)
{
//
zonesCount++;
orderBlock.To(cTime);
}
}
}
//
// Fair Value Gap ...
count = state.CountBullishFairValueGaps();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCFVG *iZone = state.bullishFairValueGaps[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
fairValueGap = iZone;
}
}
//
hasFairValueGap = fairValueGap != NULL &&
fairValueGap.IsValid();
if (hasFairValueGap)
{
//
zonesCount++;
fairValueGap.To(cTime);
}
}
if (!hasFairValueGap)
{
//
count = state.CountBearishFairValueGaps();
if (IsValidSize(count))
{
//
for (int i = count - 1; i >= 0; i--)
{
//
XCFVG *iZone = state.bearishFairValueGaps[i];
//
bool isValid = IsPriceInsideZone(bar, iZone);
if (isValid)
{
//
fairValueGap = iZone;
}
}
//
hasFairValueGap = fairValueGap != NULL &&
fairValueGap.IsValid();
if (hasFairValueGap)
{
//
zonesCount++;
fairValueGap.To(cTime);
}
}
}
//
result =
//
hasSupportZone ||
hasResistanceZone ||
hasSupplyZone ||
hasDemandZone ||
hasOrderBlock ||
hasFairValueGap
//
;
//
return result;
}
/**
* Add Value Change instance to Exists Collection if it's not Exists ...
*