This commit is contained in:
2025-02-27 02:04:50 +03:30
parent af9c398338
commit c94bfb2678
7 changed files with 1375 additions and 371 deletions
@@ -312,6 +312,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
// Setup Conditions ...
XOBFVG selectedZone;
bool hasSelectedZone = false;
bool isSelectedZoneReversal = false;
//
// First We Have to Has Working Zone ...
@@ -358,7 +361,44 @@ class XCX121SMCXWZSignalDetector : public XCBase
workingZone.HasInsideZones();
if (hasInsideZones)
{
Print("Has Inside Zones");
//
int selectedIDX = -1;
int count = workingZone.CountInsideZones();
for (int i = 0; i < count; i++)
{
//
bool has = CheckOBFVGXWZConditions(
isSelectedZoneReversal,
workingZone.insideZones[i],
decisionState,
decisionXConditions //
);
//
if (has)
{
//
selectedIDX = i;
selectedZone = workingZone.insideZones[i];
//
break;
}
}
//
if (IsValidIndex(selectedIDX))
{
//
ArrayRemove(
workingZone.insideZones,
selectedIDX,
1 //
);
//
hasSelectedZone = selectedZone.IsValid();
}
}
//
@@ -366,7 +406,55 @@ class XCX121SMCXWZSignalDetector : public XCBase
workingZone.HasBreakedZones();
if (hasBreakedZones)
{
Print("Has Breaked Zones");
//
if (!hasSelectedZone)
{
//
int selectedIDX = -1;
int count = workingZone.CountBreakedZones();
for (int i = 0; i < count; i++)
{
//
bool has = CheckOBFVGXWZConditions(
isSelectedZoneReversal,
workingZone.breakedZones[i],
decisionState,
decisionXConditions //
);
//
if (has)
{
//
selectedIDX = i;
selectedZone = workingZone.breakedZones[i];
//
break;
}
}
//
if (IsValidIndex(selectedIDX))
{
//
ArrayRemove(
workingZone.breakedZones,
selectedIDX,
1 //
);
//
hasSelectedZone = selectedZone.IsValid();
}
}
}
//
if (hasSelectedZone)
{
//
Print("Has Selected Zone ...");
}
//
@@ -378,14 +466,15 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
workingZone.Draw(
drawer,
true, // Force Clean ...
true,
true,
true,
true,
true,
true,
true //
true, // Draw Waiting Zones ..
true, // Draw Inside Zones ..
true, // Draw Breaked Zones ..
false, // Draw Supply Zone ..
false, // Draw Demand Zone ..
false, // Draw Supply Zones ..
false, // Draw Demand Zones ..
false, // Draw Support Zones ..
false // Draw Resistance Zones ..
);
}
+327 -23
View File
@@ -79,7 +79,10 @@ struct X121SMCStrategyXWZWorkingZone
XOBFVG waitingZones[];
//
CArrayObj mObjects;
CArrayObj mInsideZoneObjects;
CArrayObj mBreakedZoneObjects;
CArrayObj mWaitingZoneObjects;
CArrayObj mWorkingZoneObjects;
//
// Constructor ...
@@ -121,7 +124,10 @@ struct X121SMCStrategyXWZWorkingZone
ZeroMemory(demandZone);
//
mObjects.Clear();
mInsideZoneObjects.Clear();
mBreakedZoneObjects.Clear();
mWaitingZoneObjects.Clear();
mWorkingZoneObjects.Clear();
}
//
@@ -352,6 +358,7 @@ struct X121SMCStrategyXWZWorkingZone
}
//
// Detect OBFVG(s) ...
ExtractOBFVGs(
waitingZones,
mtfState,
@@ -1088,14 +1095,39 @@ struct X121SMCStrategyXWZWorkingZone
}
}
//
has = HasInsideZones();
if (has)
{
//
count = CountInsideZones();
for (int i = 0; i < count; i++)
{
insideZones[i].UpdateTo(value);
}
}
//
has = HasBreakedZones();
if (has)
{
//
count = CountBreakedZones();
for (int i = 0; i < count; i++)
{
breakedZones[i].UpdateTo(value);
}
}
//
}
//
void Draw(
XCPOIDrawer *drawer,
bool forceClean = false,
bool drawWaitingZones = true,
bool drawInsideZones = false,
bool drawBreakedZones = false,
bool drawSupplyZone = false,
bool drawDemandZone = false,
bool drawSupplyZones = false,
@@ -1110,12 +1142,6 @@ struct X121SMCStrategyXWZWorkingZone
return;
}
//
if (forceClean)
{
mObjects.Clear();
}
//
int count = 0;
bool has = false;
@@ -1145,7 +1171,7 @@ struct X121SMCStrategyXWZWorkingZone
//
if (isCreated)
{
mObjects.Add(iObj);
mWorkingZoneObjects.Add(iObj);
}
}
}
@@ -1172,7 +1198,7 @@ struct X121SMCStrategyXWZWorkingZone
//
if (isCreated)
{
mObjects.Add(iObj);
mWorkingZoneObjects.Add(iObj);
}
}
}
@@ -1196,7 +1222,7 @@ struct X121SMCStrategyXWZWorkingZone
//
if (isCreated)
{
mObjects.Add(iObj);
mWorkingZoneObjects.Add(iObj);
}
}
}
@@ -1223,7 +1249,7 @@ struct X121SMCStrategyXWZWorkingZone
//
if (isCreated)
{
mObjects.Add(iObj);
mWorkingZoneObjects.Add(iObj);
}
}
}
@@ -1251,7 +1277,7 @@ struct X121SMCStrategyXWZWorkingZone
//
if (isCreated)
{
mObjects.Add(iObj);
mWorkingZoneObjects.Add(iObj);
}
}
}
@@ -1279,7 +1305,7 @@ struct X121SMCStrategyXWZWorkingZone
//
if (isCreated)
{
mObjects.Add(iObj);
mWorkingZoneObjects.Add(iObj);
}
}
}
@@ -1309,7 +1335,73 @@ struct X121SMCStrategyXWZWorkingZone
//
for (int j = 0; j < objectsCount; j++)
{
mObjects.Add(objects[j]);
mWaitingZoneObjects.Add(objects[j]);
}
}
}
}
}
//
// Inside Zones ...
if (drawInsideZones)
{
//
has = HasInsideZones();
if (has)
{
//
count = CountInsideZones();
for (int i = 0; i < count; i++)
{
//
XCBaseObject *objects[];
int objectsCount = drawer.DrawOBFVG(
insideZones[i],
objects //
);
//
has = IsValidSize(objectsCount);
if (has)
{
//
for (int i = 0; i < objectsCount; i++)
{
mInsideZoneObjects.Add(objects[i]);
}
}
}
}
}
//
// Breaked Zones ...
if (drawBreakedZones)
{
//
has = HasBreakedZones();
if (has)
{
//
count = CountBreakedZones();
for (int i = 0; i < count; i++)
{
//
XCBaseObject *objects[];
int objectsCount = drawer.DrawOBFVG(
breakedZones[i],
objects //
);
//
has = IsValidSize(objectsCount);
if (has)
{
//
for (int i = 0; i < objectsCount; i++)
{
mBreakedZoneObjects.Add(objects[i]);
}
}
}
@@ -1348,7 +1440,7 @@ struct X121SMCStrategyXWZWorkingZone
zoneUpperLine.Color(clrRed);
//
mObjects.Add(zoneUpperLine);
mWaitingZoneObjects.Add(zoneUpperLine);
}
//
@@ -1367,7 +1459,7 @@ struct X121SMCStrategyXWZWorkingZone
zoneLowerLine.Color(clrRed);
//
mObjects.Add(zoneLowerLine);
mWaitingZoneObjects.Add(zoneLowerLine);
}
//
@@ -1386,7 +1478,7 @@ struct X121SMCStrategyXWZWorkingZone
upperLine.Color(clrLime);
//
mObjects.Add(upperLine);
mWaitingZoneObjects.Add(upperLine);
}
//
@@ -1405,7 +1497,7 @@ struct X121SMCStrategyXWZWorkingZone
lowerLine.Color(clrLime);
//
mObjects.Add(lowerLine);
mWaitingZoneObjects.Add(lowerLine);
}
//
@@ -1427,7 +1519,7 @@ struct X121SMCStrategyXWZWorkingZone
q1Line.Color(clrYellow);
//
mObjects.Add(q1Line);
mWaitingZoneObjects.Add(q1Line);
}
//
@@ -1446,7 +1538,7 @@ struct X121SMCStrategyXWZWorkingZone
q2Line.Color(clrYellow);
//
mObjects.Add(q2Line);
mWaitingZoneObjects.Add(q2Line);
}
//
@@ -1465,7 +1557,7 @@ struct X121SMCStrategyXWZWorkingZone
q3Line.Color(clrYellow);
//
mObjects.Add(q3Line);
mWaitingZoneObjects.Add(q3Line);
}
}
}
@@ -1660,4 +1752,216 @@ struct X121SMCStrategyXWZSignalConditions
//
};
//
// Extension Functions ...
/**
* Check an XOBFVG instance has Required Conditions ...
*
* @param zone: XOBFVG instance ...
* @param state: XPOIState instance ...
* @param conditions: X121Conditions instance ...
*
* @return ( bool )
*/
bool CheckOBFVGXWZConditions(
bool &isReversal,
XOBFVG &zone,
XPOIState &state,
X121Conditions &conditions //
)
{
//
bool result = false;
//
isReversal = false;
//
result =
zone.IsValid() &&
state.IsValid() &&
state.HasChild();
if (!result)
{
return result;
}
//
bool isBullish = zone.IsBullish();
bool isBearish = zone.IsBearish();
//
bool isBullishTrend = conditions.isTrendBullish ||
conditions.isTrendSwitchedToBullish;
bool isBearishTrend = conditions.isTrendBearish ||
conditions.isTrendSwitchedToBearish;
//
double bullishScore = 0;
double bearishScore = 0;
conditions.GenerateScore(
bullishScore,
bearishScore //
);
//
// VWap ...
//
double vwapFast = conditions.vwapFastBuffer[0];
double vwapMid = conditions.vwapMidBuffer[0];
double vwapSlow = conditions.vwapSlowBuffer[0];
//
bool isVWapInside =
//
vwapFast > zone.ob.Lower() &&
vwapFast < zone.ob.Upper()
//
&&
vwapMid > zone.ob.Lower() &&
vwapMid < zone.ob.Upper()
//
;
//
bool isVWapBullish =
//
(conditions.isVWapBullishState &&
conditions.isVWapSwitchedToBullishOrdered)
//
||
//
(conditions.isVWapBullishOrdered &&
conditions.isVWapSwitchedToBullishState)
//
;
//
bool isVWapBearish =
//
(conditions.isVWapBearishState &&
conditions.isVWapSwitchedToBearishOrdered)
//
||
//
(conditions.isVWapBearishOrdered &&
conditions.isVWapSwitchedToBearishState)
//
;
//
// X3Ma ...
//
double x3maFast = conditions.x3maFastBuffer[0];
double x3maMid = conditions.x3maMidBuffer[0];
double x3maSlow = conditions.x3maSlowBuffer[0];
//
bool isX3MaInside =
//
x3maFast > zone.ob.Lower() &&
x3maFast < zone.ob.Upper()
//
&&
x3maMid > zone.ob.Lower() &&
x3maMid < zone.ob.Upper()
//
;
//
bool isX3MaBullish =
//
(conditions.isX3MaBullishState &&
conditions.isX3MaSwitchedToBullishOrdered)
//
||
//
(conditions.isX3MaBullishOrdered &&
conditions.isX3MaSwitchedToBullishState)
//
;
//
bool isX3MaBearish =
//
(conditions.isX3MaBearishState &&
conditions.isX3MaSwitchedToBearishOrdered)
//
||
//
(conditions.isX3MaBearishOrdered &&
conditions.isX3MaSwitchedToBearishState)
//
;
//
//
//
//
bool isInside =
//
isVWapInside ||
isX3MaInside
//
;
//
bool isVWap3MaBullish =
isVWapBullish ||
isX3MaBullish;
//
bool isVWap3MaBearish =
isVWapBearish ||
isX3MaBearish;
//
//
//
//
bool isDirectionalBullishPassed =
//
isInside &&
isBullish &&
isBullishTrend &&
isVWap3MaBullish &&
bullishScore > 0 &&
bearishScore >= 0 &&
bullishScore > bearishScore
//
;
//
bool isDirectionalBearishPassed =
//
isInside &&
isBearish &&
isBearishTrend &&
isVWap3MaBearish &&
bearishScore > 0 &&
bullishScore >= 0 &&
bearishScore > bullishScore
//
;
//
if (isInside)
{
//
Print("X3MA VWAP Inside ...");
}
//
result = isDirectionalBullishPassed ||
isDirectionalBearishPassed;
//
return result;
}
//