last ...
This commit is contained in:
@@ -36,6 +36,10 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
||||
// Props ...
|
||||
bool useGuards;
|
||||
double rfRewar;
|
||||
XBoxZone mWaitingBoxes[];
|
||||
XBoxZone mInsideBoxes[];
|
||||
XBoxZone mBreakedBoxes[];
|
||||
XBoxZone mUnAvailableBoxes[];
|
||||
X121SMCStrategyXINDSignalConditions mConditions;
|
||||
X121SMCStrategyXINDSignalConditions mConditionsCollection[];
|
||||
|
||||
@@ -206,21 +210,39 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
||||
//
|
||||
|
||||
//
|
||||
hasSignalBox = HasXPVConditions(
|
||||
int waitingBoxesCount = UpdateWaitingBoxes(
|
||||
X_CYCLE_DECISION,
|
||||
signalBox,
|
||||
signalBoxDir,
|
||||
provider,
|
||||
zIndex //
|
||||
provider //
|
||||
);
|
||||
if (hasSignalBox)
|
||||
bool hasWaitingBoxes = IsValidSize(waitingBoxesCount);
|
||||
|
||||
//
|
||||
DrawBoxes(drawer);
|
||||
|
||||
//
|
||||
if (hasWaitingBoxes)
|
||||
{
|
||||
signalProvider = X121SMC_XIND_PROVIDER_XSTR;
|
||||
//
|
||||
hasSignalBox = HasXPVConditions(
|
||||
X_CYCLE_DECISION,
|
||||
signalBox,
|
||||
signalBoxDir,
|
||||
provider,
|
||||
zIndex //
|
||||
);
|
||||
if (hasSignalBox)
|
||||
{
|
||||
signalProvider = X121SMC_XIND_PROVIDER_XSTR;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Models To Time ...
|
||||
UpdateTo(cTime);
|
||||
//
|
||||
//
|
||||
|
||||
// //
|
||||
// // Update Models To Time ...
|
||||
// UpdateTo(cTime);
|
||||
|
||||
//
|
||||
// Cleanup Signal if UnApproved ...
|
||||
@@ -393,6 +415,7 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
||||
pBar.Clean();
|
||||
pPBar.Clean();
|
||||
signalBox.Clean();
|
||||
ZeroMemory(drawer);
|
||||
consolidationZBar.Clean();
|
||||
|
||||
//
|
||||
@@ -1046,6 +1069,399 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Waiting Boxes ...
|
||||
int UpdateWaitingBoxes(
|
||||
ENUM_X_CYCLES cycle,
|
||||
X121SMCStrategySignalProviderData &provider //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = ArraySize(mWaitingBoxes) + ArraySize(mInsideBoxes);
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
// Fil Selected Data ...
|
||||
XPOIState cState;
|
||||
X121Conditions cXConditions;
|
||||
XPOIStateEvents cStateEvents;
|
||||
XC121SMCCycleHelper *cHelper;
|
||||
X121SMCCycleConditions cConditions;
|
||||
has = provider.SelectCycle(
|
||||
cycle,
|
||||
cState,
|
||||
cStateEvents,
|
||||
cXConditions,
|
||||
cHelper,
|
||||
cConditions //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detecting New Boxes ...
|
||||
|
||||
//
|
||||
// Checking Bullish Fair Value Gaps ...
|
||||
has = cState.HasBullishFairValueGaps();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XBoxZone tmpBoxes[];
|
||||
ToBox(
|
||||
cState.bullishFairValueGaps,
|
||||
tmpBoxes //
|
||||
);
|
||||
|
||||
//
|
||||
count = ArraySize(tmpBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[i];
|
||||
bool isValid = IsBoxValid(
|
||||
iBox,
|
||||
0,
|
||||
iBox.period //
|
||||
);
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
has = IsBoxExists(iBox);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iBox,
|
||||
mWaitingBoxes //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Bearish Fair Value Gaps ...
|
||||
has = cState.HasBearishFairValueGaps();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XBoxZone tmpBoxes[];
|
||||
ToBox(
|
||||
cState.bearishFairValueGaps,
|
||||
tmpBoxes //
|
||||
);
|
||||
|
||||
//
|
||||
count = ArraySize(tmpBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[i];
|
||||
bool isValid = IsBoxValid(
|
||||
iBox,
|
||||
0,
|
||||
iBox.period //
|
||||
);
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
has = IsBoxExists(iBox);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iBox,
|
||||
mWaitingBoxes //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
}
|
||||
|
||||
//
|
||||
// Update Times ...
|
||||
|
||||
//
|
||||
count = ArraySize(mWaitingBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
mWaitingBoxes[i].to = TimeCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
count = ArraySize(mInsideBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
mInsideBoxes[i].to = TimeCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Exists Boxes ...
|
||||
|
||||
//
|
||||
// Waiting Boxes ...
|
||||
// count = ArraySize(mWaitingBoxes);
|
||||
// has = IsValidSize(count);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// int mustRemove[];
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// mWaitingBoxes[i].to = TimeCurrent();
|
||||
// XBoxZone iBox = mWaitingBoxes[i];
|
||||
|
||||
// //
|
||||
// bool isValid = IsBoxValid(
|
||||
// iBox,
|
||||
// 0,
|
||||
// iBox.period //
|
||||
// );
|
||||
// bool isBreaked = IsBoxBreaked(
|
||||
// iBox,
|
||||
// 0,
|
||||
// iBox.period //
|
||||
// );
|
||||
|
||||
// //
|
||||
// bool isInside = !isValid && !isBreaked;
|
||||
// if (isInside)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// i,
|
||||
// mustRemove //
|
||||
// );
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// mInsideBoxes //
|
||||
// );
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (!isInside && isBreaked)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// i,
|
||||
// mustRemove //
|
||||
// );
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// mBreakedBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// CleanupArray(
|
||||
// mustRemove,
|
||||
// mWaitingBoxes //
|
||||
// );
|
||||
// }
|
||||
|
||||
//
|
||||
// Inside Boxes ...
|
||||
// count = ArraySize(mInsideBoxes);
|
||||
// has = IsValidSize(count);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// int mustRemove[];
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// mInsideBoxes[i].to = TimeCurrent();
|
||||
// XBoxZone iBox = mInsideBoxes[i];
|
||||
|
||||
// //
|
||||
// bool isBreaked = IsBoxBreaked(
|
||||
// iBox,
|
||||
// 0,
|
||||
// iBox.period //
|
||||
// );
|
||||
// if (isBreaked)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// i,
|
||||
// mustRemove //
|
||||
// );
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// mBreakedBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// CleanupArray(
|
||||
// mustRemove,
|
||||
// mInsideBoxes //
|
||||
// );
|
||||
// }
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
|
||||
//
|
||||
result = ArraySize(mWaitingBoxes) + ArraySize(mInsideBoxes);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBoxExists(XBoxZone &box)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
// Witing Boxes ...
|
||||
count = ArraySize(mWaitingBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = FindBoxIndex(
|
||||
idx,
|
||||
box,
|
||||
mWaitingBoxes //
|
||||
);
|
||||
result = has;
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Inside Boxes ...
|
||||
count = ArraySize(mInsideBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = FindBoxIndex(
|
||||
idx,
|
||||
box,
|
||||
mInsideBoxes //
|
||||
);
|
||||
result = has;
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Breaked Boxes ...
|
||||
count = ArraySize(mBreakedBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = FindBoxIndex(
|
||||
idx,
|
||||
box,
|
||||
mBreakedBoxes //
|
||||
);
|
||||
result = has;
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// UnAvailable Boxes ...
|
||||
count = ArraySize(mUnAvailableBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = FindBoxIndex(
|
||||
idx,
|
||||
box,
|
||||
mUnAvailableBoxes //
|
||||
);
|
||||
result = has;
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Conditions to Conditions Collection ...
|
||||
int AddConditionsIfNotExists(
|
||||
@@ -1188,6 +1604,78 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void DrawBoxes(
|
||||
XCPOIDrawer *drawer,
|
||||
bool forceClean = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
mObjects.Clear();
|
||||
}
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
// Waiting Boxes ...
|
||||
count = ArraySize(mWaitingBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
has = drawer.DrawBox(
|
||||
mWaitingBoxes[i],
|
||||
iObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
mObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Inside Boxes ...
|
||||
count = ArraySize(mInsideBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
has = drawer.DrawBox(
|
||||
mInsideBoxes[i],
|
||||
iObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
if (mInsideBoxes[i].IsBullish())
|
||||
{
|
||||
iObj.BoxColor(clrYellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
iObj.BoxColor(clrOrange);
|
||||
}
|
||||
|
||||
//
|
||||
mObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
@@ -1225,18 +1713,18 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
||||
mBarObjects.Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update To Time of Exists Components ...
|
||||
*
|
||||
* @param value: updated time ...
|
||||
*/
|
||||
void UpdateTo(
|
||||
datetime value = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
value = NormalizeTime(value);
|
||||
}
|
||||
// /**
|
||||
// * Update To Time of Exists Components ...
|
||||
// *
|
||||
// * @param value: updated time ...
|
||||
// */
|
||||
// void UpdateTo(
|
||||
// datetime value = NULL //
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// value = NormalizeTime(value);
|
||||
// }
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
@@ -448,10 +448,6 @@ bool HasXPVConditions(
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// Check new Order Block ...
|
||||
|
||||
|
||||
//
|
||||
// Summarize Conditions ...
|
||||
|
||||
@@ -459,7 +455,7 @@ bool HasXPVConditions(
|
||||
isBullish =
|
||||
//
|
||||
false
|
||||
//
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user