last ...
This commit is contained in:
@@ -463,287 +463,6 @@ class XC121SMCCycleHelper : public XCBase
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Detect Nearest Supply/Demand Zones ...
|
||||
*
|
||||
* @param bar: XOHCL instance, Start Bar ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectValisSupplyZone(
|
||||
XOHCL &bar,
|
||||
XCSupplyZone *&supplyZone,
|
||||
XCDemandZone *&demandZone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int index = bar.Index();
|
||||
|
||||
//
|
||||
double bid = GetBid(bar.symbol);
|
||||
double ask = GetAsk(bar.symbol);
|
||||
|
||||
//
|
||||
// Retrieve X121 Cnditions ...
|
||||
int conditionsLoopback = 10;
|
||||
X121Conditions x121Conditions;
|
||||
result = mX121Helper.GetConditions(
|
||||
x121Conditions,
|
||||
index,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
int validPeaksCount = ArraySize(x121Conditions.validPeaksBuffer);
|
||||
int validValesCount = ArraySize(x121Conditions.validValesBuffer);
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
ENUM_XPOI_EVENTS events[];
|
||||
mPOIDetector.Update(events);
|
||||
mPOIDetector.GetState(state);
|
||||
result = state.IsValid() &&
|
||||
state.HasChild();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Supply Zones ...
|
||||
XCSupplyZone *supplies[];
|
||||
int suppliesCount = state.CountSupplyZones();
|
||||
|
||||
//
|
||||
// Select Bar Validated Supply Zones ...
|
||||
if (IsValidSize(suppliesCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < suppliesCount; i++)
|
||||
{
|
||||
//
|
||||
XCSupplyZone *iZone = state.supplyZones[i];
|
||||
|
||||
//
|
||||
// Check Zone is Valid For Bar ...
|
||||
bool isValid = bar.high < iZone.Lower() &&
|
||||
ask < iZone.Lower() &&
|
||||
bid < iZone.Lower();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
supplies //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
suppliesCount = ArraySize(supplies);
|
||||
|
||||
//
|
||||
// Select Valid Peaks Filtered Supplies ...
|
||||
if (IsValidSize(suppliesCount))
|
||||
{
|
||||
//
|
||||
// Check Valid Peaks ...
|
||||
XCSupplyZone *tmp[];
|
||||
if (IsValidSize(validPeaksCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < suppliesCount; i++)
|
||||
{
|
||||
//
|
||||
XCSupplyZone *iZone = supplies[i];
|
||||
|
||||
//
|
||||
for (int j = 0; j < validPeaksCount; j++)
|
||||
{
|
||||
//
|
||||
double value = x121Conditions.validPeaksBuffer[j];
|
||||
|
||||
//
|
||||
// Check Valid Peaks in Zone ...
|
||||
bool isZoneContainsValidValue =
|
||||
value >= iZone.Lower() &&
|
||||
value <= iZone.Upper();
|
||||
if (isZoneContainsValidValue)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
tmp //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(supplies);
|
||||
Copy(
|
||||
tmp,
|
||||
supplies //
|
||||
);
|
||||
}
|
||||
suppliesCount = ArraySize(supplies);
|
||||
|
||||
//
|
||||
// Select Nearest Supply Zone ...
|
||||
if (IsValidSize(suppliesCount))
|
||||
{
|
||||
//
|
||||
// Check Nearest Supplies ...
|
||||
for (int i = 0; i < suppliesCount; i++)
|
||||
{
|
||||
//
|
||||
XCSupplyZone *iZone = supplies[i];
|
||||
if (supplyZone == NULL)
|
||||
{
|
||||
supplyZone = iZone;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
bool canChange =
|
||||
iZone.Lower() < supplyZone.Lower();
|
||||
if (canChange)
|
||||
{
|
||||
supplyZone = iZone;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Demand Zones ...
|
||||
XCDemandZone *demands[];
|
||||
int demandsCount = state.CountDemandZones();
|
||||
|
||||
//
|
||||
// Select Bar Validated Demand Zones ...
|
||||
if (IsValidSize(demandsCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < demandsCount; i++)
|
||||
{
|
||||
//
|
||||
XCDemandZone *iZone = state.demandZones[i];
|
||||
|
||||
//
|
||||
// Check Zone is Valid For Bar ...
|
||||
bool isValid = bar.low > iZone.Upper() &&
|
||||
ask > iZone.Upper() &&
|
||||
bid > iZone.Upper();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
demands //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
demandsCount = ArraySize(demands);
|
||||
|
||||
//
|
||||
// Select Valid Vales Filtered Demands ...
|
||||
if (IsValidSize(demandsCount))
|
||||
{
|
||||
//
|
||||
// Check Valid Vales ...
|
||||
XCDemandZone *tmp[];
|
||||
if (IsValidSize(validValesCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < demandsCount; i++)
|
||||
{
|
||||
//
|
||||
XCDemandZone *iZone = demands[i];
|
||||
|
||||
//
|
||||
for (int j = 0; j < validValesCount; j++)
|
||||
{
|
||||
//
|
||||
double value = x121Conditions.validValesBuffer[j];
|
||||
|
||||
//
|
||||
// Check Valid Peaks in Zone ...
|
||||
bool isZoneContainsValidValue =
|
||||
value >= iZone.Lower() &&
|
||||
value <= iZone.Upper();
|
||||
if (isZoneContainsValidValue)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
tmp //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(demands);
|
||||
Copy(
|
||||
tmp,
|
||||
demands //
|
||||
);
|
||||
}
|
||||
demandsCount = ArraySize(demands);
|
||||
|
||||
//
|
||||
// Select Nearest Demand Zone ...
|
||||
if (IsValidSize(demandsCount))
|
||||
{
|
||||
//
|
||||
// Check Nearest Demands ...
|
||||
for (int i = 0; i < demandsCount; i++)
|
||||
{
|
||||
//
|
||||
XCDemandZone *iZone = demands[i];
|
||||
if (demandZone == NULL)
|
||||
{
|
||||
demandZone = iZone;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
bool canChange =
|
||||
iZone.Upper() > demandZone.Upper();
|
||||
if (canChange)
|
||||
{
|
||||
demandZone = iZone;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Founded Zones ...
|
||||
result = (supplyZone != NULL &&
|
||||
supplyZone.IsValid()) &&
|
||||
(demandZone != NULL &&
|
||||
demandZone.IsValid());
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect XPV Based POI(s) ...
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user