last ...
This commit is contained in:
@@ -122,8 +122,52 @@ struct XOBFVG
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
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)
|
||||
{
|
||||
@@ -313,8 +410,11 @@ struct XOBFVG
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
has = fvg != NULL &&
|
||||
fvg.IsValid();
|
||||
has =
|
||||
HasOB() &&
|
||||
fvg != NULL &&
|
||||
fvg.IsValid() &&
|
||||
ob.GetDirection() == fvg.GetDirection();
|
||||
if (!has)
|
||||
{
|
||||
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 ...
|
||||
*
|
||||
|
||||
@@ -339,6 +339,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
double targets[];
|
||||
double reward = 0;
|
||||
XBoxZone signalBox;
|
||||
XOBFVG activatedZone;
|
||||
double amountPercent = 0;
|
||||
bool hasPriority = false;
|
||||
bool hasSignalBox = false;
|
||||
@@ -420,6 +421,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
result = false;
|
||||
workingZone.Clean();
|
||||
activatedZone.Clean();
|
||||
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.BoxColor(clrYellow);
|
||||
iObj.BoxStyle(STYLE_SOLID);
|
||||
|
||||
//
|
||||
workingZone.mDrawnObjects.Add(iObj);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -535,20 +584,24 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
|
||||
//
|
||||
double iSL = 0;
|
||||
double signalBoxRange = (signalBox.upper - signalBox.lower);
|
||||
if (signalBoxRange < points * 100)
|
||||
{
|
||||
iSL = pivot;
|
||||
}
|
||||
else
|
||||
{
|
||||
iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2;
|
||||
}
|
||||
|
||||
// double signalBoxRange = (signalBox.upper - signalBox.lower);
|
||||
// if (signalBoxRange < points * 100)
|
||||
// {
|
||||
// iSL = pivot;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// 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(
|
||||
@@ -904,15 +957,10 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
true, // Draw Supply 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 ...
|
||||
|
||||
//
|
||||
Clean(sls);
|
||||
Clean(targets);
|
||||
|
||||
//
|
||||
Clean(visionPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
@@ -953,6 +1005,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
consolidationXConditions.Clean();
|
||||
|
||||
//
|
||||
signalBox.Clean();
|
||||
activatedZone.Clean();
|
||||
consolidationZBar.Clean();
|
||||
|
||||
//
|
||||
|
||||
@@ -71,6 +71,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
XOBFVG waitingZones[];
|
||||
XOBFVG unavailableZones[];
|
||||
|
||||
//
|
||||
CArrayObj mDrawnObjects;
|
||||
@@ -449,7 +450,8 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
// Detect OB FVG ...
|
||||
result =
|
||||
hasNewOrderBlock &&
|
||||
hasNewFairValueGap;
|
||||
hasNewFairValueGap &&
|
||||
ob.GetDirection() == fvg.GetDirection();
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
@@ -461,13 +463,8 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Check Item Is not Exists ...
|
||||
idx = FindIndex(
|
||||
obFVG,
|
||||
waitingZones //
|
||||
);
|
||||
has = !IsValidIndex(idx);
|
||||
if (has)
|
||||
has = IsExists(obFVG);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
// New Waiting Zone ...
|
||||
@@ -479,8 +476,18 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
else
|
||||
{
|
||||
//
|
||||
// Update Exists Waiting Zone ...
|
||||
waitingZones[idx].AddFVG(fvg);
|
||||
// Check Item Is not Exists ...
|
||||
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(fvg);
|
||||
ZeroMemory(supplyZone);
|
||||
ZeroMemory(demandZone);
|
||||
ZeroMemory(supply);
|
||||
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;
|
||||
@@ -957,7 +1133,8 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
XCPOIDrawer *drawer,
|
||||
bool drawSupplyZone = false,
|
||||
bool drawDemandZone = false,
|
||||
bool drawWaitingZones = false //
|
||||
bool drawWaitingZones = false,
|
||||
bool drawWaitingZonesBoxArea = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1220,6 +1397,32 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
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);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasUnavailableZones()
|
||||
{
|
||||
return HasChild(unavailableZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CounUnavailableZones()
|
||||
{
|
||||
return ArraySize(unavailableZones);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user