This commit is contained in:
2025-03-05 04:47:19 +03:30
parent 17c6704104
commit 8f9ad96b90
3 changed files with 507 additions and 36 deletions
+206 -4
View File
@@ -122,8 +122,52 @@ struct XOBFVG
// //
bool IsValid() bool IsValid()
{ {
return HasOB() && //
HasFVGs(); bool result = false;
//
result = HasOB() &&
HasFVGs();
if (!result)
{
return result;
}
//
XOHCL passedBar;
bool isBodyOut;
bool isOBStarted = ob.IsStarted(
ob.GetDirection(),
passedBar,
isBodyOut //
);
//
int idx = GetOldest(fvgs);
result = IsValidIndex(idx);
if (!result)
{
//
passedBar.Clean();
return result;
}
//
bool isFVGStarted = fvgs[idx].IsStarted(
ob.GetDirection(),
passedBar,
isBodyOut //
);
//
result = isOBStarted &&
isFVGStarted;
//
passedBar.Clean();
//
return result;
} }
// //
@@ -305,6 +349,59 @@ struct XOBFVG
return result; return result;
} }
//
bool GetMainFVG(
XCFVG *&fvg //
)
{
//
bool result = false;
//
fvg = NULL;
//
result = IsValid();
if (!result)
{
return result;
}
//
int idx = GetOldest(fvgs);
result = IsValidIndex(idx);
if (!result)
{
//
ZeroMemory(fvg);
return result;
}
//
fvg = fvgs[idx];
result = fvg != NULL &&
fvg.IsValid();
//
return result;
}
//
bool ToZone(XBoxZone &box)
{
//
bool result = false;
//
result = ToZoneBox(
box,
this //
);
//
return result;
}
// //
void AddFVG(XCFVG *fvg) void AddFVG(XCFVG *fvg)
{ {
@@ -313,8 +410,11 @@ struct XOBFVG
bool has = false; bool has = false;
// //
has = fvg != NULL && has =
fvg.IsValid(); HasOB() &&
fvg != NULL &&
fvg.IsValid() &&
ob.GetDirection() == fvg.GetDirection();
if (!has) if (!has)
{ {
return; return;
@@ -3714,6 +3814,108 @@ void SpecifiedUpdateTo(
} }
} }
/**
* Extract Box Zone's of Specified OBFVG ...
*
* @param box: XBoxZone instance, represent result ...
* @param obfvg: XOBFVG instance, specified Model ...
*
* @return ( bool )
*/
bool ToZoneBox(
XBoxZone &box,
XOBFVG &obfvg //
)
{
//
bool result = false;
//
box.Clean();
//
// Check Model Validation ...
result = obfvg.IsValid();
if (!result)
{
return result;
}
//
// Retrieve Model Main Fair Value Gap ...
XCFVG *fvg;
result = obfvg.GetMainFVG(fvg);
if (!result)
{
//
box.Clean();
ZeroMemory(fvg);
//
return result;
}
//
// Retrieve Main Fair Value Gap's Started Bar ...
XOHCL startedBar;
bool isBodyOut = false;
bool isStarted = fvg.IsStarted(
fvg.GetDirection(),
startedBar,
isBodyOut //
);
result = isStarted;
if (!result)
{
//
box.Clean();
ZeroMemory(fvg);
startedBar.Clean();
//
return result;
}
//
// Converts Main Fair Value Gaps to Box ...
result = ToBox(
box,
fvg //
);
if (!result)
{
//
box.Clean();
ZeroMemory(fvg);
startedBar.Clean();
//
return result;
}
//
// Update Box using Started Bar ...
box.lower = startedBar.low;
box.upper = startedBar.high;
box.from = startedBar.NextAt();
//
// Check Box Validation ...
result = box.IsValid();
if (!result)
{
box.Clean();
}
//
// Cleanup Resources ...
ZeroMemory(fvg);
startedBar.Clean();
//
return result;
}
/** /**
* Converts to XBoxZone ... * Converts to XBoxZone ...
* *
@@ -339,6 +339,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
double targets[]; double targets[];
double reward = 0; double reward = 0;
XBoxZone signalBox; XBoxZone signalBox;
XOBFVG activatedZone;
double amountPercent = 0; double amountPercent = 0;
bool hasPriority = false; bool hasPriority = false;
bool hasSignalBox = false; bool hasSignalBox = false;
@@ -420,6 +421,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
result = false; result = false;
workingZone.Clean(); workingZone.Clean();
activatedZone.Clean();
hasWorkingZone = false; hasWorkingZone = false;
// //
@@ -462,6 +464,50 @@ class XCX121SMCXWZSignalDetector : public XCBase
} }
} }
//
// Detect Signal Box ...
hasSignalBox = hasWorkingZone &&
hasWaitingZones &&
workingZone.IsZoneRejected(
activatedZone,
zIndex //
);
if (hasSignalBox)
{
//
signalBox.Clean();
hasSignalBox = activatedZone.ToZone(signalBox);
if (hasSignalBox)
{
//
signalBox.to = cTime;
signalBoxDir = signalBox.dir;
provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
//
int idx = FindIndex(
activatedZone,
workingZone.waitingZones //
);
bool has = IsValidIndex(idx);
if (has)
{
//
ArrayRemove(
workingZone.waitingZones,
idx,
1 //
);
//
AddRef(
activatedZone,
workingZone.unavailableZones //
);
}
}
}
// //
// //
// //
@@ -517,6 +563,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
iObj.BoxWidth(1); iObj.BoxWidth(1);
iObj.BoxColor(clrYellow); iObj.BoxColor(clrYellow);
iObj.BoxStyle(STYLE_SOLID); iObj.BoxStyle(STYLE_SOLID);
//
workingZone.mDrawnObjects.Add(iObj);
} }
// //
@@ -535,20 +584,24 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
double iSL = 0; double iSL = 0;
double signalBoxRange = (signalBox.upper - signalBox.lower);
if (signalBoxRange < points * 100) // double signalBoxRange = (signalBox.upper - signalBox.lower);
{ // if (signalBoxRange < points * 100)
iSL = pivot; // {
} // iSL = pivot;
else // }
{ // else
iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2; // {
} // iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2;
// }
// //
// if (provider == X121SMC_XWZ_PROVIDER_PV_ZONE)
// {
// }
// //
if (provider == X121SMC_XWZ_PROVIDER_PV_ZONE) iSL = pivot;
{
}
// //
Add( Add(
@@ -904,15 +957,10 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
true, // Draw Supply Zone ... true, // Draw Supply Zone ...
true, // Draw Demand Zone ... true, // Draw Demand Zone ...
true // Draw Waiting Zones ... true, // Draw Waiting Zones ...
true // Draw Waiting Zones Box Area ...
// //
); );
//
if (hasWaitingZones)
{
Print("Has Waiting Zones ...");
}
} }
// //
@@ -922,6 +970,10 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
// Cleanup Resources ... // Cleanup Resources ...
//
Clean(sls);
Clean(targets);
// //
Clean(visionPoiEvents); Clean(visionPoiEvents);
Clean(analysePoiEvents); Clean(analysePoiEvents);
@@ -953,6 +1005,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
consolidationXConditions.Clean(); consolidationXConditions.Clean();
// //
signalBox.Clean();
activatedZone.Clean();
consolidationZBar.Clean(); consolidationZBar.Clean();
// //
+228 -13
View File
@@ -71,6 +71,7 @@ struct X121SMCStrategyXWZWorkingZone
// //
XOBFVG waitingZones[]; XOBFVG waitingZones[];
XOBFVG unavailableZones[];
// //
CArrayObj mDrawnObjects; CArrayObj mDrawnObjects;
@@ -449,7 +450,8 @@ struct X121SMCStrategyXWZWorkingZone
// Detect OB FVG ... // Detect OB FVG ...
result = result =
hasNewOrderBlock && hasNewOrderBlock &&
hasNewFairValueGap; hasNewFairValueGap &&
ob.GetDirection() == fvg.GetDirection();
if (result) if (result)
{ {
// //
@@ -461,13 +463,8 @@ struct X121SMCStrategyXWZWorkingZone
if (has) if (has)
{ {
// //
// Check Item Is not Exists ... has = IsExists(obFVG);
idx = FindIndex( if (!has)
obFVG,
waitingZones //
);
has = !IsValidIndex(idx);
if (has)
{ {
// //
// New Waiting Zone ... // New Waiting Zone ...
@@ -479,8 +476,18 @@ struct X121SMCStrategyXWZWorkingZone
else else
{ {
// //
// Update Exists Waiting Zone ... // Check Item Is not Exists ...
waitingZones[idx].AddFVG(fvg); idx = FindIndex(
obFVG,
waitingZones //
);
has = !IsValidIndex(idx);
if (!has)
{
//
// Update Exists Waiting Zone ...
waitingZones[idx].AddFVG(fvg);
}
} }
} }
} }
@@ -591,8 +598,177 @@ struct X121SMCStrategyXWZWorkingZone
// //
ZeroMemory(ob); ZeroMemory(ob);
ZeroMemory(fvg); ZeroMemory(fvg);
ZeroMemory(supplyZone); ZeroMemory(supply);
ZeroMemory(demandZone); ZeroMemory(demand);
//
return result;
}
//
bool IsZoneRejected(
XOBFVG &zone,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Cleanup Result ...
zone.Clean();
//
// Normalize Bar Index ...
if (barIndex < 0)
{
barIndex = 0;
}
//
// Validate ...
result = IsValid() &&
HasWaitingZones();
if (!result)
{
return result;
}
//
// Detecting Rejected Waiting Zone ...
int count = CountWaitingZones();
for (int i = 0; i < count; i++)
{
//
// Detecting XBoxZone Area of Waiting Zone ...
XBoxZone iBox;
bool hasBox = waitingZones[i]
.ToZone(iBox);
if (hasBox)
{
//
// Check Zone Rejection ...
int fromIDX = iBarShift(
iBox.symbol,
period,
iBox.from //
);
bool has = IsValidIndex(fromIDX);
if (has)
{
//
// Looking for Rejection ...
bool isBullish = iBox.IsBullish();
for (int j = barIndex; j < fromIDX; j++)
{
//
XOHCL iBar;
has = iBar.Init(
iBox.symbol,
period,
j //
);
if (has)
{
//
// Checking Box Rejected ...
//
bool isLowerReject =
//
isBullish &&
(iBar.low < iBox.upper &&
iBar.GetDown() > iBox.upper)
//
;
//
bool isUpperReject =
//
!isBullish &&
(iBar.high > iBox.lower &&
iBar.GetUp() < iBox.lower)
//
;
//
bool isRejected =
isLowerReject ||
isUpperReject;
result = isRejected;
if (result)
{
//
iBar.Clean();
break;
}
}
//
iBar.Clean();
}
}
}
//
// Validate Result ...
if (result)
{
//
iBox.Clean();
zone = waitingZones[i];
break;
}
//
iBox.Clean();
}
//
return result;
}
//
bool IsExists(XOBFVG &zone)
{
//
bool result = false;
//
// Check Validation ...
result = HasWaitingZones() ||
HasUnavailableZones();
if (!result)
{
return result;
}
//
int idx = -1;
//
// Check Index in Waiting Zones ...
idx = FindIndex(
zone,
waitingZones //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
//
// Check Index in Unavailable Zones ...
idx = FindIndex(
zone,
unavailableZones //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
// //
return result; return result;
@@ -957,7 +1133,8 @@ struct X121SMCStrategyXWZWorkingZone
XCPOIDrawer *drawer, XCPOIDrawer *drawer,
bool drawSupplyZone = false, bool drawSupplyZone = false,
bool drawDemandZone = false, bool drawDemandZone = false,
bool drawWaitingZones = false // bool drawWaitingZones = false,
bool drawWaitingZonesBoxArea = false //
) )
{ {
// //
@@ -1220,6 +1397,32 @@ struct X121SMCStrategyXWZWorkingZone
mDrawnObjects.Add(iObjects[j]); mDrawnObjects.Add(iObjects[j]);
} }
} }
//
if (drawWaitingZonesBoxArea)
{
//
XBoxZone iBox;
has = waitingZones[i].ToZone(
iBox //
);
if (has)
{
//
XCBoxObject *iBoxObj;
has = drawer.DrawBox(
iBox,
iBoxObj //
);
if (has)
{
mDrawnObjects.Add(iBoxObj);
}
}
//
iBox.Clean();
}
} }
} }
} }
@@ -1257,6 +1460,18 @@ struct X121SMCStrategyXWZWorkingZone
return ArraySize(waitingZones); return ArraySize(waitingZones);
} }
//
bool HasUnavailableZones()
{
return HasChild(unavailableZones);
}
//
int CounUnavailableZones()
{
return ArraySize(unavailableZones);
}
// //
}; };