last works ...

This commit is contained in:
2024-12-08 14:13:30 +03:30
parent 7cef619800
commit 317e8b8ba3
3 changed files with 353 additions and 0 deletions
+26
View File
@@ -307,6 +307,32 @@ struct XTick
return result; return result;
} }
/**
* Init XTick for Specified Time ...
*
* @param _symbol: String, Symbol Representation ...
* @param _time: Datetime, Specified Time ...
*
* @return ( bool )
*/
bool Init(
string _symbol,
datetime _time //
)
{
//
bool result = false;
//
// TODO: Complete this ...
//
result = IsValid();
//
return result;
}
/** /**
* Cleanup ... * Cleanup ...
*/ */
@@ -330,6 +330,285 @@ class XC121SMCCycleHelper : public XCBase
return result; return result;
} }
//
// 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);
//
// 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();
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();
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;
}
// //
// Virtuals ... // Virtuals ...
@@ -425,6 +425,54 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
} }
conditions.visionConditions.state = mVisionState; conditions.visionConditions.state = mVisionState;
//
// Detect Valid Supply and Demand Zones ...
XCSupplyZone *supplyZone;
XCDemandZone *demandZone;
result = mTriggerCycleHelper
.DetectValisSupplyZone(
cBar,
supplyZone,
demandZone //
);
if (!result)
{
//
conditions.Clean();
return result;
}
//
supplyZone.To(cTime);
XCSupplyZoneObject *iSupplyZoneObj;
result = mPOIDrawer.CreateSupplyZone(
supplyZone,
iSupplyZoneObj //
);
if (!result)
{
//
conditions.Clean();
return result;
}
//
demandZone.To(cTime);
XCDemandZoneObject *iDemandZoneObj;
result = mPOIDrawer.CreateDemandZone(
demandZone,
iDemandZoneObj //
);
if (!result)
{
//
conditions.Clean();
return result;
}
//
Print("Supply and Demand Zone Created ...");
// //
if (!result) if (!result)
{ {