This commit is contained in:
2025-03-19 01:38:07 +03:30
parent 9f0ebd1afe
commit 012499cc73
7 changed files with 1242 additions and 387 deletions
+830
View File
@@ -0,0 +1,830 @@
//
bool HasSenario1Conditions(
ENUM_X_CYCLES cycle,
XBoxZone &box,
XBoxZone &holderBox,
ENUM_X_DIRECTION &dir,
XBoxZone &waitingBoxes[],
X121SMCStrategySignalProviderData &provider,
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Fil Selected Data ...
XPOIState cState;
X121Conditions cXConditions;
XPOIStateEvents cStateEvents;
XC121SMCCycleHelper *cHelper;
X121SMCCycleConditions cConditions;
result = provider.SelectCycle(
cycle,
cState,
cStateEvents,
cXConditions,
cHelper,
cConditions //
);
if (!result)
{
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
cStateEvents.Clean();
//
return result;
}
Parse(cXConditions);
//
// Fil Selected Data ...
XPOIState chState;
X121Conditions chXConditions;
XPOIStateEvents chStateEvents;
XC121SMCCycleHelper *chHelper;
X121SMCCycleConditions chConditions;
if (holderCycle != X_CYCLE_NONE)
{
//
result = provider.SelectCycle(
holderCycle,
chState,
chStateEvents,
chXConditions,
chHelper,
chConditions //
);
if (!result)
{
//
chState.Clean();
ZeroMemory(chHelper);
chConditions.Clean();
chXConditions.Clean();
chStateEvents.Clean();
//
return result;
}
//
Parse(chXConditions);
}
//
// Checking Waiting Baoxes Exists ...
result = HasChild(waitingBoxes);
if (!result)
{
return result;
}
//
XCPOIDrawer *drawer = provider
.visionCycleHelper
.mPOIDrawer;
//
// Normalize Args ...
//
box.Clean();
holderBox.Clean();
dir = X_DIRECTION_NONE;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int idx = -1;
int count = 0;
bool has = false;
//
int zIDX = barIndex;
int cIDX = zIDX + 1;
int pIDX = cIDX + 1;
int ppIDX = pIDX + 1;
//
bool isBullish = false;
bool isBearish = false;
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
//
// Initial Bars ...
result = zBar.Init(
cState.symbol,
cState.period,
barIndex //
);
result =
result &&
zBar.GetPreviousBar(cBar);
result =
result &&
cBar.GetPreviousBar(pBar);
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
cState.Clean();
chState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
ZeroMemory(chHelper);
chConditions.Clean();
chXConditions.Clean();
//
return result;
}
//
// Detect Inside Box ...
XBoxZone insideBox;
count = ArraySize(waitingBoxes);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = waitingBoxes[i];
bool isBullish = iBox.IsBullish();
double iMid = iBox.lower + ((iBox.upper - iBox.lower) / 2);
//
has =
//
isBullish
? cBar.low < iMid &&
cBar.low > iBox.lower
: cBar.high > iMid &&
cBar.high < iBox.upper
//
;
if (has)
{
//
insideBox = iBox;
break;
}
}
}
has = insideBox.IsValid();
//
ENUM_X_DIRECTION iBarPosDir;
bool isBarValidForDir = cHelper
.mBarAnalyser
.IsValidForPosition(
cBar,
iBarPosDir //
);
bool isBarValidForBullish =
isBarValidForDir &&
IsBullish(iBarPosDir);
bool isBarValidForBearish =
isBarValidForDir &&
IsBearish(iBarPosDir);
//
if (has)
{
//
XCBoxObject *iObj;
has = drawer.DrawBox(
insideBox,
iObj //
);
if (has)
{
//
Print("Dec Scores:");
Print("-------------");
Print("Bull: ", provider.decisionBullishScore);
Print("Bear: ", provider.decisionBearishScore);
Print("-------------");
Print("Anal Scores:");
Print("-------------");
Print("Bull: ", provider.analyseBullishScore);
Print("Bear: ", provider.analyseBearishScore);
Print("-------------");
Print("Bar Valid For: " + ToString(iBarPosDir));
Print("-------------");
Print(ToString(insideBox.dir), " Inside ...");
Print("-------------");
}
}
//
result = has;
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
cState.Clean();
chState.Clean();
insideBox.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
ZeroMemory(chHelper);
chConditions.Clean();
chXConditions.Clean();
//
return result;
}
//
// Detecting Signal Conditions ...
//
// Bullish Conditions ...
isBullish =
//
// Base Condition ...
(
//
insideBox.IsBullish() &&
isBarValidForBullish
//
)
//
;
//
// Bearish Conditions ...
isBearish =
//
// Base Condition ...
(
//
insideBox.IsBearish() &&
isBarValidForBearish
//
)
//
;
//
// Filling Requirements ...
result =
isBullish ||
isBearish;
if (result)
{
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
box.dir = dir;
box.to = TimeCurrent();
box.from = insideBox.from;
box.upper = insideBox.upper;
box.lower = insideBox.lower;
box.symbol = cXConditions.symbol;
box.period = cXConditions.period;
}
//
// Check All Conditions ...
result =
box.IsValid() &&
HasDirection(dir) &&
(isBullish ||
isBearish);
//
// Cleanup Resources ...
zBar.Clean();
cBar.Clean();
pBar.Clean();
cState.Clean();
chState.Clean();
insideBox.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cStateEvents.Clean();
cXConditions.Clean();
ZeroMemory(chHelper);
chConditions.Clean();
chStateEvents.Clean();
chXConditions.Clean();
//
return result;
}
/////////////////////////////////////////////////////
/**
* Checking a Box Exists in Collections or not ...
*
* @param box: XBoxZone instance reference ...
*
* @return ( bool )
*/
bool IsExists(XBoxZone &box)
{
//
bool result = false;
//
// Check Validation ...
result = box.IsValid() &&
(HasWaitingBoxes() ||
HasBreakedBoxes() ||
HasUnavailableBoxes());
if (!result)
{
return result;
}
//
int idx = -1;
bool has = false;
//
// Check Index in Waiting Boxes ...
has = HasWaitingBoxes();
if (has)
{
//
idx = FindIndex(
box,
waitingBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
}
}
//
// Check Index in Breaked Boxes ...
has = HasBreakedBoxes();
if (has)
{
//
idx = FindIndex(
box,
breakedBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
}
}
//
// Check Index in Unavailable Boxes ...
has = HasUnavailableBoxes();
if (has)
{
//
idx = FindIndex(
box,
unavailableBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
}
}
//
return result;
}
/**
* Detect Signal Boxes ...
*
* @param cycle: ENUM_X_CYCLES member ...
* @param provider: X121SMCStrategySignalProviderData instance reference ...
* @param barIndex: int ...
*
* @return ( bool )
*/
bool DetectSignalBoxes(
ENUM_X_CYCLES cycle,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
//
bool result = false;
//
int idx = -1;
int count = 0;
bool has = false;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
// Select Cycle ...
XPOIState cState;
XPOIStateEvents cStateEvents;
X121Conditions cXConditions;
XC121SMCCycleHelper *cHelper;
X121SMCCycleConditions cConditions;
result = provider.SelectCycle(
cycle,
cState,
cStateEvents,
cXConditions,
cHelper,
cConditions //
);
if (!result)
{
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cStateEvents.Clean();
cXConditions.Clean();
//
return result;
}
//
// Select Rejection Boxes ...
// //
// // Select Validate Rejection Boxes ...
// XBoxZone rejections[];
// int count = cHelper
// .DetectRejections(
// rejections,
// barIndex //
// );
// //
// result = IsValidSize(count);
// if (result)
// {
// //
// for (int i = 0; i < count; i++)
// {
// //
// has = IsExists(rejections[i]);
// if (!has)
// {
// //
// AddRef(
// rejections[i],
// waitingBoxes //
// );
// }
// }
// }
// //
// // Select Order Blocks ...
// if (cStateEvents.hasNewOrderBlock)
// {
// //
// idx = GetYoungest(cState.orderBlocks);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCOrderBlock *iOB = cState.orderBlocks[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iOB //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
//
// Select Fair Value Gaps ...
// if (cStateEvents.hasNewFairValueGap)
// {
// //
// idx = GetYoungest(cState.fairValueGaps);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCFVG *iOB = cState.fairValueGaps[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iOB //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
//
// Select Supply/Demand Zones ...
// if (cStateEvents.hasNewSupplyZone)
// {
// //
// idx = GetYoungest(cState.supplyZones);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCSupplyZone *iSupply = cState.supplyZones[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iSupply //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
// if (cStateEvents.hasNewDemandZone)
// {
// //
// idx = GetYoungest(cState.demandZones);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCDemandZone *iDemand = cState.demandZones[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iDemand //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
//
// Select Support/Resistance Zones ...
// if (cStateEvents.hasNewSupportZone)
// {
// //
// idx = GetYoungest(cState.supportZones);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCSupportZone *iSupport = cState.supportZones[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iSupport //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
// if (cStateEvents.hasNewResistanceZone)
// {
// //
// idx = GetYoungest(cState.resistanceZones);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCResistanceZone *iResistance = cState.resistanceZones[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iResistance //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
//
count = CountWaitingBoxes();
result = IsValidSize(count);
//
// Cleanup Resources ...
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
cStateEvents.Clean();
//
return result;
}
/**
* Validating Waiting Boxes and Detect Breaked Boxes ...
*
* @param barIndex: int ...
*
* @return ( int )
*/
int ValidateWaitingBoxes(
int barIndex = 0 //
)
{
//
int result = 0;
//
bool has = false;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (barIndex == 0)
{
barIndex = 1;
}
//
has = HasWaitingBoxes();
if (!has)
{
return result;
}
//
int removeIDX[];
result = CountWaitingBoxes();
for (int i = 0; i < result; i++)
{
//
XOHCL iBar;
XBoxZone iBox = waitingBoxes[i];
bool isInite = iBar
.Init(
iBox.symbol,
iBox.period,
iBox.from //
);
//
has = isInite &&
IsBoxBreaked(
iBox,
iBar.Index() - 1,
barIndex,
period //
);
if (has)
{
//
Add(
i,
removeIDX //
);
//
AddRef(
iBox,
breakedBoxes //
);
}
//
iBox.Clean();
iBar.Clean();
}
//
has = HasChild(removeIDX);
if (has)
{
//
CleanupArray(
removeIDX,
waitingBoxes //
);
}
Clean(removeIDX);
//
result = CountWaitingBoxes();
//
return result;
}
@@ -339,7 +339,7 @@ bool IsSame(
}
//
result = sourceBox.IsSame(destBox);
result = sourceBox.IsSameAs(destBox);
//
return result;
@@ -894,7 +894,7 @@ bool FindBoxIndex(
XBoxZone iBox = boxes[i];
//
bool isSame = box.IsSame(iBox);
bool isSame = box.IsSameAs(iBox);
if (isSame)
{
//
@@ -931,7 +931,7 @@ bool IsBoxBelow(
//
result = source.IsValid() &&
dest.IsValid() &&
!source.IsSame(dest);
!source.IsSameAs(dest);
if (!result)
{
return result;
@@ -974,7 +974,7 @@ bool IsBoxAbove(
//
result = source.IsValid() &&
dest.IsValid() &&
!source.IsSame(dest);
!source.IsSameAs(dest);
if (!result)
{
return result;
@@ -1019,7 +1019,7 @@ bool IsBoxInside(
//
result = source.IsValid() &&
dest.IsValid() &&
!source.IsSame(dest);
!source.IsSameAs(dest);
if (!result)
{
return result;
@@ -1083,7 +1083,7 @@ bool IsBoxInsideOr(
//
result = source.IsValid() &&
dest.IsValid() &&
!source.IsSame(dest);
!source.IsSameAs(dest);
if (!result)
{
return result;
+34 -33
View File
@@ -5317,6 +5317,7 @@ struct XBoxZone
{
//
return IsValid() &&
item.IsValid() &&
dir == item.dir &&
from == item.from &&
type == item.type &&
@@ -5326,42 +5327,42 @@ struct XBoxZone
period == item.period;
}
/**
* Check Box is Same as another ...
*
* @param box: XBoxZone instance Reference ...
*
* @return ( bool )
*/
bool IsSame(XBoxZone &box)
{
//
bool result = false;
// /**
// * Check Box is Same as another ...
// *
// * @param box: XBoxZone instance Reference ...
// *
// * @return ( bool )
// */
// bool IsSame(XBoxZone &box)
// {
// //
// bool result = false;
//
result = IsValid() &&
box.IsValid();
if (!result)
{
return result;
}
// //
// result = IsValid() &&
// box.IsValid();
// if (!result)
// {
// return result;
// }
//
result =
//
dir == box.dir &&
from == box.from &&
type == box.type &&
upper == box.upper &&
lower == box.lower &&
symbol == box.symbol &&
period == box.period
//
;
// //
// result =
// //
// dir == box.dir &&
// from == box.from &&
// type == box.type &&
// upper == box.upper &&
// lower == box.lower &&
// symbol == box.symbol &&
// period == box.period
// //
// ;
//
return result;
}
// //
// return result;
// }
/**
* Retrieve Box Age ...
+207
View File
@@ -642,6 +642,54 @@ struct XOBFVG
}
};
//
struct XSignalBox
{
//
XBoxZone ob;
XBoxZone fvg;
//
// Constructor ...
XSignalBox()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
ob.Clean();
fvg.Clean();
}
/**
* Validate Model ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
ob.IsValid();
//
return result;
}
//
};
//
// Model State Parsing ...
struct XPOIStateEvents
@@ -4869,6 +4917,165 @@ int AddIfNotExists(
return result;
}
//
//
//
/**
* Find Index of a Signal Box on another ...
*
* @param index: int, index of exists ...
* @param item: XSignal Box ...
* @param items: XSignal Box Collection ...
*
* @return ( bool )
*/
bool FindIndex(
int &index,
XSignalBox &item,
XSignalBox &items[] //
)
{
//
bool result = false;
//
index = -1;
int count = ArraySize(items);
//
result = item.IsValid() &&
HasChild(items);
if (!result)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
bool isSame = item.ob
.IsSameAs(items[i].ob);
if (isSame)
{
//
index = i;
break;
}
}
//
result = IsValidIndex(index);
//
return result;
}
/**
* Find Index of a Signal Box on another ...
*
* @param index: int, index of exists ...
* @param item: XSignal Box ...
* @param items: XSignal Box Collection ...
*
* @return ( bool )
*/
bool FindIndex(
int &index,
XBoxZone &item,
XSignalBox &items[] //
)
{
//
bool result = false;
//
index = -1;
int count = ArraySize(items);
//
result = item.IsValid() &&
HasChild(items);
if (!result)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
bool isSame = item.IsSameAs(items[i].ob);
if (isSame)
{
//
index = i;
break;
}
//
isSame = item.IsSameAs(items[i].fvg);
if (isSame)
{
//
index = i;
break;
}
}
//
result = IsValidIndex(index);
//
return result;
}
/**
* Add a Signal Box in a Collection if not Exists ...
*
* @param item: XSignal Box ...
* @param items: XSignal Box Collection ...
*
* @return ( bool )
*/
bool AddIfNotExists(
XSignalBox &item,
XSignalBox &items[] //
)
{
//
bool result = false;
//
result = item.IsValid();
if (!result)
{
return result;
}
//
int idx = -1;
result = !FindIndex(
idx,
item,
items //
);
if (!result)
{
return result;
}
//
AddRef(
item,
items //
);
//
return result;
}
//
// XPOI State Event Parsers ...
@@ -2631,7 +2631,7 @@ struct X121SMCStrategyConditionParser
XBoxZone &box,
XBoxZone &holderBox,
ENUM_X_DIRECTION &dir,
XBoxZone &waitingBoxes[],
XSignalBox &waitingBoxes[],
X121SMCStrategySignalProviderData &provider,
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
int barIndex = 0 //
@@ -2783,41 +2783,6 @@ struct X121SMCStrategyConditionParser
return result;
}
//
// Detect Inside Box ...
XBoxZone insideBox;
count = ArraySize(waitingBoxes);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = waitingBoxes[i];
bool isBullish = iBox.IsBullish();
double iMid = iBox.lower + ((iBox.upper - iBox.lower) / 2);
//
has =
//
isBullish
? cBar.low < iMid &&
cBar.low > iBox.lower
: cBar.high > iMid &&
cBar.high < iBox.upper
//
;
if (has)
{
//
insideBox = iBox;
break;
}
}
}
has = insideBox.IsValid();
//
ENUM_X_DIRECTION iBarPosDir;
bool isBarValidForDir = cHelper
@@ -2834,55 +2799,27 @@ struct X121SMCStrategyConditionParser
IsBearish(iBarPosDir);
//
if (has)
{
//
XCBoxObject *iObj;
has = drawer.DrawBox(
insideBox,
iObj //
);
if (has)
{
//
Print("Dec Scores:");
Print("-------------");
Print("Bull: ", provider.decisionBullishScore);
Print("Bear: ", provider.decisionBearishScore);
Print("-------------");
Print("Anal Scores:");
Print("-------------");
Print("Bull: ", provider.analyseBullishScore);
Print("Bear: ", provider.analyseBearishScore);
Print("-------------");
Print("Bar Valid For: " + ToString(iBarPosDir));
Print("-------------");
Print(ToString(insideBox.dir), " Inside ...");
Print("-------------");
}
}
// result = isBarValidForBullish ||
// isBarValidForBearish;
// if (!result)
// {
// //
// zBar.Clean();
// cBar.Clean();
// pBar.Clean();
// cState.Clean();
// chState.Clean();
// insideBox.Clean();
// ZeroMemory(cHelper);
// cConditions.Clean();
// cXConditions.Clean();
// ZeroMemory(chHelper);
// chConditions.Clean();
// chXConditions.Clean();
//
result = has;
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
cState.Clean();
chState.Clean();
insideBox.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
ZeroMemory(chHelper);
chConditions.Clean();
chXConditions.Clean();
//
return result;
}
// //
// return result;
// }
//
// Detecting Signal Conditions ...
@@ -2894,8 +2831,11 @@ struct X121SMCStrategyConditionParser
// Base Condition ...
(
//
insideBox.IsBullish() &&
isBarValidForBullish
false
// cBar.IsBullish() &&
// isBarValidForBullish &&
// cBar.close > cXConditions.x3maFastBuffer[cIDX] &&
// cXConditions.x3maFastBuffer[cIDX] < cXConditions.x3maSlowBuffer[cIDX]
//
)
//
@@ -2908,8 +2848,11 @@ struct X121SMCStrategyConditionParser
// Base Condition ...
(
//
insideBox.IsBearish() &&
isBarValidForBearish
false
// cBar.IsBearish() &&
// isBarValidForBearish &&
// cBar.close < cXConditions.x3maFastBuffer[cIDX] &&
// cXConditions.x3maFastBuffer[cIDX] > cXConditions.x3maSlowBuffer[cIDX]
//
)
//
@@ -2931,9 +2874,9 @@ struct X121SMCStrategyConditionParser
//
box.dir = dir;
box.to = TimeCurrent();
box.from = insideBox.from;
box.upper = insideBox.upper;
box.lower = insideBox.lower;
// box.from = insideBox.from;
// box.upper = insideBox.upper;
// box.lower = insideBox.lower;
box.symbol = cXConditions.symbol;
box.period = cXConditions.period;
}
@@ -2953,7 +2896,7 @@ struct X121SMCStrategyConditionParser
pBar.Clean();
cState.Clean();
chState.Clean();
insideBox.Clean();
// insideBox.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cStateEvents.Clean();
@@ -119,11 +119,11 @@ class XCX121SMCXWZSignalDetector : public XCBase
zIndex,
loopback,
false, // Trigger ...
true, // Decision ...
true, // Analyse ...
true, // Verification ...
true, // Consolidation ...
true // Vision ...
true, // Decision ...
true, // Analyse ...
true, // Verification ...
true, // Consolidation ...
true // Vision ...
);
if (!result)
{
@@ -224,7 +224,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
// Detectiong Signal Boxes ...
hasWaitingBoxes = workingZone
.DetectSignalBoxes(
X_CYCLE_DECISION,
X_CYCLE_ANALYSE,
provider,
zIndex //
);
@@ -311,11 +311,12 @@ class XCX121SMCXWZSignalDetector : public XCBase
if (hasBreakedBoxes)
{
//
int idx = FindIndex(
int idx = -1;
bool has = FindIndex(
idx,
signalBox,
workingZone.breakedBoxes //
);
bool has = IsValidIndex(idx);
if (has)
{
//
@@ -333,11 +334,12 @@ class XCX121SMCXWZSignalDetector : public XCBase
if (hasWaitingBoxes)
{
//
int idx = FindIndex(
int idx = -1;
bool has = FindIndex(
idx,
signalBox,
workingZone.waitingBoxes //
);
bool has = IsValidIndex(idx);
if (has)
{
//
@@ -470,7 +472,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 0;
}
// else
// else
// if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_BOX)
// {
// //
@@ -838,8 +840,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
// Summarize Results ...
result = hasPriority &&
hasSignalBox &&
hasRewardAmount;
hasSignalBox &&
hasRewardAmount;
//
if (result)
+115 -243
View File
@@ -71,9 +71,9 @@ struct X121SMCStrategyXWZWorkingZone
XCDemandZone *demandZone;
//
XBoxZone waitingBoxes[];
XBoxZone breakedBoxes[];
XBoxZone unavailableBoxes[];
XSignalBox waitingBoxes[];
XSignalBox breakedBoxes[];
XSignalBox unavailableBoxes[];
//
CArrayObj mDrawnObjects;
@@ -236,7 +236,7 @@ struct X121SMCStrategyXWZWorkingZone
*
* @return ( bool )
*/
bool IsExists(XBoxZone &box)
bool IsExists(XSignalBox &box)
{
//
bool result = false;
@@ -262,11 +262,11 @@ struct X121SMCStrategyXWZWorkingZone
if (has)
{
//
idx = FindIndex(
result = FindIndex(
idx,
box,
waitingBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
@@ -279,11 +279,11 @@ struct X121SMCStrategyXWZWorkingZone
if (has)
{
//
idx = FindIndex(
result = FindIndex(
idx,
box,
breakedBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
@@ -296,11 +296,11 @@ struct X121SMCStrategyXWZWorkingZone
if (has)
{
//
idx = FindIndex(
result = FindIndex(
idx,
box,
unavailableBoxes //
);
result = IsValidIndex(idx);
if (result)
{
return result;
@@ -514,233 +514,78 @@ struct X121SMCStrategyXWZWorkingZone
return result;
}
//
// Select Rejection Boxes ...
// //
// // Select Validate Rejection Boxes ...
// XBoxZone rejections[];
// int count = cHelper
// .DetectRejections(
// rejections,
// barIndex //
// );
// //
// result = IsValidSize(count);
// if (result)
// {
// //
// for (int i = 0; i < count; i++)
// {
// //
// has = IsExists(rejections[i]);
// if (!has)
// {
// //
// AddRef(
// rejections[i],
// waitingBoxes //
// );
// }
// }
// }
//
// Select Order Blocks ...
// if (cStateEvents.hasNewOrderBlock)
// {
// //
// idx = GetYoungest(cState.orderBlocks);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCOrderBlock *iOB = cState.orderBlocks[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iOB //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
//
// Select Fair Value Gaps ...
// if (cStateEvents.hasNewFairValueGap)
// {
// //
// idx = GetYoungest(cState.fairValueGaps);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCFVG *iOB = cState.fairValueGaps[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iOB //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
//
// Select Supply/Demand Zones ...
// if (cStateEvents.hasNewSupplyZone)
// {
// //
// idx = GetYoungest(cState.supplyZones);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCSupplyZone *iSupply = cState.supplyZones[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iSupply //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
// if (cStateEvents.hasNewDemandZone)
// {
// //
// idx = GetYoungest(cState.demandZones);
// has = IsValidIndex(idx);
// if (has)
// {
// //
// XCDemandZone *iDemand = cState.demandZones[idx];
// //
// XBoxZone iBox;
// has = ToBox(
// iBox,
// iDemand //
// );
// if (has)
// {
// //
// has = IsExists(iBox);
// if (!has)
// {
// //
// AddRef(
// iBox,
// waitingBoxes //
// );
// }
// }
// }
// }
//
// Select Support/Resistance Zones ...
if (cStateEvents.hasNewSupportZone)
if (cStateEvents.hasNewOrderBlock)
{
//
idx = GetYoungest(cState.supportZones);
idx = GetYoungest(cState.orderBlocks);
has = IsValidIndex(idx);
if (has)
{
//
XCSupportZone *iSupport = cState.supportZones[idx];
XCOrderBlock *iOB = cState.orderBlocks[idx];
bool isBullish = iOB.IsBullish();
//
XBoxZone iBox;
XBoxZone iOBBox;
XBoxZone iFVGBox;
has = ToBox(
iBox,
iSupport //
iOBBox,
iOB //
);
if (has)
{
//
has = IsExists(iBox);
if (!has)
// Detect FVGs ...
if (cStateEvents.hasNewFairValueGap)
{
//
AddRef(
iBox,
waitingBoxes //
);
int idx =
isBullish
? GetLowest(cState.bullishFairValueGaps)
: GetHighest(cState.bearishFairValueGaps);
XCFVG *iFVG =
isBullish
? cState.bullishFairValueGaps[idx]
: cState.bearishFairValueGaps[idx];
has = IsValidIndex(idx);
if (has)
{
//
ToBox(
iFVGBox,
iFVG //
);
}
}
}
}
}
if (cStateEvents.hasNewResistanceZone)
{
//
idx = GetYoungest(cState.resistanceZones);
has = IsValidIndex(idx);
if (has)
{
//
XCResistanceZone *iResistance = cState.resistanceZones[idx];
//
XBoxZone iBox;
has = ToBox(
iBox,
iResistance //
);
has = iOBBox.IsValid() &&
iFVGBox.IsValid();
if (has)
{
//
has = IsExists(iBox);
if (!has)
{
//
AddRef(
iBox,
waitingBoxes //
);
}
XSignalBox iSignalBox;
//
iSignalBox.ob = iOBBox;
iSignalBox.fvg = iFVGBox;
//
AddRef(
iSignalBox,
waitingBoxes //
);
//
iSignalBox.Clean();
}
//
iOBBox.Clean();
iFVGBox.Clean();
}
}
@@ -805,21 +650,33 @@ struct X121SMCStrategyXWZWorkingZone
{
//
XOHCL iBar;
XBoxZone iBox = waitingBoxes[i];
bool isInite = iBar
.Init(
iBox.symbol,
iBox.period,
iBox.from //
);
XSignalBox iBox = waitingBoxes[i];
bool isInite = iBar.Init(
iBox.ob.symbol,
iBox.ob.period,
iBox.ob.from //
);
//
has = isInite &&
IsBoxBreaked(
iBox,
iBar.Index() - 1,
barIndex,
period //
(
//
IsBoxBreaked(
iBox.fvg,
iBar.Index() - 1,
barIndex,
period //
)
//
||
//
IsBoxBreaked(
iBox.ob,
iBar.Index() - 1,
barIndex,
period //
)
//
);
if (has)
{
@@ -837,7 +694,7 @@ struct X121SMCStrategyXWZWorkingZone
}
//
iBox.Clean();
// iBox.Clean();
iBar.Clean();
}
@@ -996,18 +853,6 @@ struct X121SMCStrategyXWZWorkingZone
//
// Waiting Boxes ...
ENUM_X_DIRECTION boxDir = X_DIRECTION_NONE;
XBoxZone tmpBoxes[];
Copy(
waitingBoxes,
tmpBoxes //
);
int count = ArraySize(tmpBoxes);
bool has = IsValidSize(count);
if (has)
{
//
}
//
@@ -1051,7 +896,14 @@ struct X121SMCStrategyXWZWorkingZone
count = CountWaitingBoxes();
for (int i = 0; i < count; i++)
{
waitingBoxes[i].to = value;
//
waitingBoxes[i].ob.to = value;
//
if (waitingBoxes[i].fvg.IsValid())
{
waitingBoxes[i].fvg.to = value;
}
}
}
@@ -1786,18 +1638,38 @@ struct X121SMCStrategyXWZWorkingZone
for (int i = 0; i < count; i++)
{
//
XCBoxObject *iBoxObj;
// OB ...
XCBoxObject *iOBBoxObj;
has = drawer.DrawBox(
waitingBoxes[i],
iBoxObj //
waitingBoxes[i].ob,
iOBBoxObj //
);
if (has)
{
mDrawnObjects.Add(iBoxObj);
mDrawnObjects.Add(iOBBoxObj);
}
//
ZeroMemory(iBoxObj);
// FVG ...
if (waitingBoxes[i].fvg.IsValid())
{
//
XCBoxObject *iFVGBoxObj;
has = drawer.DrawBox(
waitingBoxes[i].fvg,
iFVGBoxObj //
);
if (has)
{
mDrawnObjects.Add(iFVGBoxObj);
}
//
ZeroMemory(iFVGBoxObj);
}
//
ZeroMemory(iOBBoxObj);
}
}
}