last ...
This commit is contained in:
@@ -6124,12 +6124,231 @@ struct XMarketStructure
|
||||
//
|
||||
};
|
||||
|
||||
struct XStateZones
|
||||
{
|
||||
//
|
||||
XCSupportZone *supportZones[]; // Holds Founded Support Zones ...
|
||||
XCResistanceZone *resistanceZones[]; // Holds Founded Resistance Zones ...
|
||||
XCSupplyZone *supplyZones[]; // Holds Founded Supply Zones ...
|
||||
XCDemandZone *demandZones[]; // Holds Founded Demand Zones ...
|
||||
XCOrderBlock *bullishOrderBlocks[]; // Holds Founded Bullish Order Blocks ...
|
||||
XCOrderBlock *bearishOrderBlocks[]; // Holds Founded Bearish Order Blocks ...
|
||||
XCFVG *bullishFairValueGaps[]; // Holds Founded Bullish Fair Value Gaps ...
|
||||
XCFVG *bearishFairValueGaps[]; // Holds Founded Bearish Fair Value Gaps ...
|
||||
|
||||
//
|
||||
XStateZones()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleaning Model ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
Clean(supportZones);
|
||||
Clean(resistanceZones);
|
||||
Clean(supplyZones);
|
||||
Clean(demandZones);
|
||||
Clean(bullishOrderBlocks);
|
||||
Clean(bearishOrderBlocks);
|
||||
Clean(bullishFairValueGaps);
|
||||
Clean(bearishFairValueGaps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValidSize(CountSupportZones()) ||
|
||||
IsValidSize(CountResistanceZones()) ||
|
||||
IsValidSize(CountSupplyZones()) ||
|
||||
IsValidSize(CountDemandZones()) ||
|
||||
IsValidSize(CountBullishOrderBlocks()) ||
|
||||
IsValidSize(CountBearishOrderBlocks()) ||
|
||||
IsValidSize(CountBullishFairValueGaps()) ||
|
||||
IsValidSize(CountBearishFairValueGaps())
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
int CountSupportZones()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(supportZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountResistanceZones()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(resistanceZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupplyZones()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(supplyZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountDemandZones()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(demandZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountBullishOrderBlocks()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bullishOrderBlocks);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountBearishOrderBlocks()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bearishOrderBlocks);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountBullishFairValueGaps()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bullishFairValueGaps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountBearishFairValueGaps()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bearishFairValueGaps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
struct XFVGOrderBlock
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
XCOrderBlock *orderBlock;
|
||||
XCFVG *fairValueGap;
|
||||
// XStateZones stateZones;
|
||||
|
||||
//
|
||||
XFVGOrderBlock()
|
||||
@@ -6149,7 +6368,7 @@ struct XFVGOrderBlock
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
@@ -6162,6 +6381,7 @@ struct XFVGOrderBlock
|
||||
//
|
||||
orderBlock != NULL &&
|
||||
fairValueGap != NULL &&
|
||||
// stateZones.IsValid() &&
|
||||
((orderBlock.IsBullish() &&
|
||||
fairValueGap.IsBullish()) ||
|
||||
((orderBlock.IsBearish() &&
|
||||
@@ -6175,9 +6395,9 @@ struct XFVGOrderBlock
|
||||
|
||||
/**
|
||||
* Get Model Direction ...
|
||||
*
|
||||
*
|
||||
* @param dir: ENUM_X_DIRECTION member ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetDirection(
|
||||
@@ -8172,6 +8392,441 @@ bool CalculatePriceInsideZones(
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CalculateStateZones(
|
||||
XStateZones &zones,
|
||||
XPOIState &source,
|
||||
double upper,
|
||||
double lower,
|
||||
datetime from //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
zones.Clean();
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
upper > 0 &&
|
||||
lower > 0 &&
|
||||
upper > lower &&
|
||||
IsValid(from) &&
|
||||
source.IsValid() &&
|
||||
source.HasChild()
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
|
||||
//
|
||||
// Support ...
|
||||
count = source.CountSupportZones();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZone *iZone = source.supportZones[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.supportZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
count = source.CountResistanceZones();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCResistanceZone *iZone = source.resistanceZones[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.resistanceZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Supply ...
|
||||
count = source.CountSupplyZones();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupplyZone *iZone = source.supplyZones[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.supplyZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Demand ...
|
||||
count = source.CountDemandZones();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCDemandZone *iZone = source.demandZones[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.demandZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bullish OrderBlocks ...
|
||||
count = source.CountBullishOrderBlocks();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iZone = source.bullishOrderBlocks[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.bullishOrderBlocks //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish OrderBlocks ...
|
||||
count = source.CountBearishOrderBlocks();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iZone = source.bearishOrderBlocks[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.bearishOrderBlocks //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bullish FairValueGaps ...
|
||||
count = source.CountBullishFairValueGaps();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCFVG *iZone = source.bullishFairValueGaps[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.bullishFairValueGaps //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish FairValueGaps ...
|
||||
count = source.CountBearishFairValueGaps();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCFVG *iZone = source.bearishFairValueGaps[i];
|
||||
|
||||
//
|
||||
double iUpper = iZone.Upper();
|
||||
double iLower = iZone.Lower();
|
||||
datetime iFrom = iZone.From();
|
||||
|
||||
//
|
||||
bool isAbove = iUpper > upper &&
|
||||
iLower <= upper;
|
||||
|
||||
//
|
||||
bool isInside = iUpper <= upper &&
|
||||
iLower >= lower;
|
||||
|
||||
//
|
||||
bool isBelow = iUpper >= lower &&
|
||||
iLower < lower;
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
iFrom > from &&
|
||||
(isAbove ||
|
||||
isBelow ||
|
||||
isInside)
|
||||
//
|
||||
;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
iZone.To(cTime);
|
||||
Add(
|
||||
iZone,
|
||||
zones.bearishFairValueGaps //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = zones.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Value Change instance to Exists Collection if it's not Exists ...
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user