This commit is contained in:
2025-03-23 03:46:13 +03:30
parent a84b0befe2
commit c49abe21db
10 changed files with 4204 additions and 2932 deletions
+584
View File
@@ -0,0 +1,584 @@
//
// Configurations ...
bool useSharpChange = false;
bool useOrderBlockFVG = false;
//
// Select Order Blocks ...
if (useOrderBlockFVG)
{
//
if (obStateEvents.hasNewOrderBlock)
{
//
idx = GetYoungest(obState.orderBlocks);
has = IsValidIndex(idx);
if (has)
{
//
XCFVG *iFVG = NULL;
XCOrderBlock *iOB = obState.orderBlocks[idx];
bool isBullish = iOB.IsBullish();
//
// Detecting Inside FVG ...
has = fvgState.HasFairValueGaps();
if (has)
{
//
XCFVG *tmpFVGs[];
count = fvgState.CountFairValueGaps();
for (int i = 0; i < count; i++)
{
//
XCFVG *jFVG = fvgState.fairValueGaps[i];
//
bool isDirPassed = jFVG.GetDirection() == iOB.GetDirection();
bool isFromPassed = jFVG.From() >= iOB.From();
bool isPlacePassed = IsInsideOrDiff(
jFVG,
iOB,
false //
);
//
has = isDirPassed &&
isFromPassed &&
isPlacePassed;
if (has)
{
//
Add(
jFVG,
tmpFVGs //
);
}
//
ZeroMemory(jFVG);
}
//
// Selecting iFVG Based on Direction of OB ...
has = HasChild(tmpFVGs);
if (has)
{
//
idx =
isBullish
? GetLowest(tmpFVGs)
: GetHighest(tmpFVGs);
has = IsValidIndex(idx);
if (has)
{
iFVG = tmpFVGs[idx];
}
}
//
Clean(tmpFVGs);
}
//
XBoxZone iOBBox;
XBoxZone iFVGBox;
if (iFVG != NULL)
{
//
has = ToBox(
iFVGBox,
iFVG //
);
}
//
has = ToBox(
iOBBox,
iOB //
);
//
has = iOBBox.IsValid() &&
iFVGBox.IsValid();
if (has)
{
//
XSignalBox iSignalBox;
//
iSignalBox.ob = iOBBox;
iSignalBox.fvg = iFVGBox;
//
// Here We Check Waiting Box Contains Other Zones ...
// Like Support/Resistances ...
bool forceVerification = false;
if (forceVerification)
{
//
XBoxZone iVerificationBox;
XBoxZone tmpBoxes[];
if (isBullish)
{
//
ToBox(
provider.decisionState.supportZones,
tmpBoxes //
);
}
else
{
//
ToBox(
provider.decisionState.resistanceZones,
tmpBoxes //
);
}
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
// Select Box ...
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate Box ...
bool isValidPassed = !IsBoxValid(
iBox,
barIndex //
);
bool isDirPassed = iBox.dir == iOBBox.dir;
bool isPlacePassed =
IsBoxInside(
iBox,
iOBBox //
)
//
&&
//
(!iFVGBox.IsValid()
? true
: IsBoxInsideOr(
iBox,
iFVGBox //
));
//
has =
isDirPassed &&
isValidPassed &&
isPlacePassed;
if (has)
{
//
iVerificationBox = iBox;
iBox.Clean();
break;
}
//
iBox.Clean();
}
}
has = iVerificationBox.IsValid();
Clean(tmpBoxes);
iVerificationBox.Clean();
}
//
if (has)
{
//
AddRef(
iSignalBox,
waitingBoxes //
);
}
//
iSignalBox.Clean();
}
//
iOBBox.Clean();
iFVGBox.Clean();
ZeroMemory(iOB);
ZeroMemory(iFVG);
}
}
}
//
// Checking Other Senario for Waiting Boxes ...
if (useSharpChange)
{
//
if (obStateEvents.hasNewSharp)
{
//
XBoxZone currSharp;
XBoxZone prevSharp;
XBoxZone sharpConsolidation;
//
// Retrieve Current Sharp ...
XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer;
XBoxZone tmpBoxes[];
Copy(
obState.sharps,
tmpBoxes //
);
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (has)
{
//
currSharp = tmpBoxes[idx];
bool isBullish = currSharp.IsBullish();
//
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
while (HasChild(tmpBoxes))
{
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
//
if (!has)
{
break;
}
//
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
if (iBox.dir == currSharp.dir)
{
//
prevSharp = iBox;
iBox.Clean();
break;
}
//
iBox.Clean();
}
//
Clean(tmpBoxes);
}
Clean(tmpBoxes);
//
// Preparing Sharp Consolidation Box ...
has = currSharp.IsValid() &&
prevSharp.IsValid() &&
prevSharp.lower < currSharp.upper;
if (has)
{
//
sharpConsolidation.type = "XSHCNZ";
sharpConsolidation.dir = currSharp.dir;
sharpConsolidation.symbol = currSharp.symbol;
sharpConsolidation.period = currSharp.period;
//
sharpConsolidation.from = prevSharp.to;
sharpConsolidation.to = currSharp.from;
//
int toIDX = GetBarIndex(
currSharp.symbol,
currSharp.period,
sharpConsolidation.to //
);
int fromIDX = GetBarIndex(
currSharp.symbol,
currSharp.period,
sharpConsolidation.from //
);
int length = fromIDX - toIDX;
//
XOHCL toBar;
has = toBar.Init(
sharpConsolidation.symbol,
sharpConsolidation.period,
toIDX //
);
//
if (has)
{
//
double upper = toBar.FindHighest(
length,
MODE_HIGH //
);
//
double lower = toBar.FindLowest(
length,
MODE_LOW //
);
//
sharpConsolidation.upper = upper;
sharpConsolidation.lower = lower;
}
//
has = sharpConsolidation.IsValid();
if (has)
{
//
XSignalBox iBox;
//
iBox.ob = sharpConsolidation;
//
AddRef(
iBox,
waitingBoxes //
);
//
iBox.Clean();
// //
// XCBoxObject *iCBoxObj;
// XCBoxObject *iPBoxObj;
// provider.visionCycleHelper.mPOIDrawer.DrawBox(
// currSharp,
// iCBoxObj //
// );
// provider.visionCycleHelper.mPOIDrawer.DrawBox(
// prevSharp,
// iPBoxObj //
// );
}
//
currSharp.Clean();
prevSharp.Clean();
sharpConsolidation.Clean();
}
}
//
// Update Exists Box ...
// XBoxZone fvgs[];
// count = ArraySize(waitingBoxes);
// has = IsValidSize(count);
// if (has)
// {
// //
// for (int i = 0; i < count; i++)
// {
// //
// bool isSharpBox = waitingBoxes[i].ob.type == "XSHCNZ";
// if (!isSharpBox)
// {
// continue;
// }
// //
// bool isBullish = waitingBoxes[i].ob.IsBullish();
// //
// // Extract Inside FVGS ...
// if (isBullish)
// {
// //
// ToBox(
// fvgState.bullishFairValueGaps,
// fvgs //
// );
// }
// else
// {
// //
// ToBox(
// fvgState.bearishFairValueGaps,
// fvgs //
// );
// }
// has = HasChild(fvgs);
// if (has)
// {
// //
// int removeds[];
// int iFVGsCount = ArraySize(fvgs);
// for (int j = 0; j < iFVGsCount; j++)
// {
// //
// XBoxZone iFVGBox = fvgs[j];
// bool isFromPassed = iFVGBox.from >= waitingBoxes[i].ob.from;
// bool isBoundaryPassed =
// isBullish
// ? iFVGBox.lower < waitingBoxes[i].ob.upper
// : iFVGBox.upper > waitingBoxes[i].ob.lower;
// //
// has = isFromPassed &&
// isBoundaryPassed;
// if (!has)
// {
// //
// Add(
// j,
// removeds //
// );
// }
// }
// //
// CleanupArray(
// removeds,
// fvgs //
// );
// Clean(removeds);
// }
// //
// // Select FVG ...
// has = HasChild(fvgs);
// if (has)
// {
// //
// idx = isBullish
// ? GetLowest(fvgs)
// : GetHighest(fvgs);
// has = IsValidIndex(idx);
// if (has)
// {
// waitingBoxes[i].fvg = fvgs[idx];
// }
// }
// else
// {
// waitingBoxes[i].fvg.Clean();
// }
// }
// }
//
// Clean(fvgs);
}
/////////////////////////////////////////////////////////////////////////////////////
if (signalProvider == X121SMC_XWZ_PROVIDER_XHKMA)
{
//
iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 0;
//
// Prepare Box fro SL ...
iSL = pivot;
Add(
iSL,
sls //
);
//
// Fix rf Reward ...
rfRewar = 2;
}
else if (signalProvider == X121SMC_XWZ_PROVIDER_XREJECTED_BOX)
{
//
iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 0;
//
Clean(sls);
//
// Prepare Box fro SL ...
iSL = signalBox.lower + ((signalBox.upper - signalBox.lower) / 2);
Add(
iSL,
sls //
);
//
// Fix rf Reward ...
rfRewar = 2;
}
else if (signalProvider == X121SMC_XWZ_PROVIDER_XACTIVATED_BOX)
{
//
iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 0;
//
Clean(sls);
//
// Prepare Box fro SL ...
iSL = pivot;
Add(
iSL,
sls //
);
//
// Fix rf Reward ...
rfRewar = 2;
}
else if (signalProvider == X121SMC_XWZ_PROVIDER_XBREAKED_BOX)
{
//
iAtr = provider.decisionXConditions.atrBuffer[1];
iAtr *= 0;
//
Clean(sls);
//
// Prepare Box fro SL ...
iSL = pivot;
Add(
iSL,
sls //
);
//
// Fix rf Reward ...
rfRewar = 2;
}
+520
View File
@@ -0,0 +1,520 @@
//
int DrawOrderBlock(
XCOrderBlock *zone,
XCBaseObject *&objects[],
//
bool drawStartedBar = true,
bool drawActivatedBar = true,
bool drawBreakedBar = true,
bool drawWorkedBar = true,
//
int widthStartedBar = 1,
color clrStartedBar = clrYellow,
ENUM_LINE_STYLE styleStartedBar = STYLE_SOLID,
//
int widthActivatedBar = 1,
color clrActivatedBar = clrLime,
ENUM_LINE_STYLE styleActivatedBar = STYLE_SOLID,
//
int widthBreakedBar = 1,
color clrBreakedBar = clrRed,
ENUM_LINE_STYLE styleBreakedBar = STYLE_SOLID,
//
int widthWorkedBar = 1,
color clrWorkedBar = clrAqua,
ENUM_LINE_STYLE styleWorkedBar = STYLE_SOLID
//
)
{
//
int result = 0;
//
Clean(objects);
//
if (zone == NULL ||
!zone.IsValid())
{
return result;
}
//
ENUM_X_DIRECTION zoneDir = zone.GetDirection();
//
// Started Bar ...
XOHCL startedBar;
bool isBodyOut = false;
bool isStarted = zone
.IsStarted(
zoneDir,
startedBar,
isBodyOut //
);
if (isStarted)
{
//
datetime iBarTo = startedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
startedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthStartedBar);
iBarObj.LowShadowWidth(widthStartedBar);
iBarObj.HighShadowWidth(widthStartedBar);
//
iBarObj.BodyStyle(styleStartedBar);
iBarObj.LowShadowStyle(styleStartedBar);
iBarObj.HighShadowStyle(styleStartedBar);
//
iBarObj.BodyColor(clrStartedBar);
iBarObj.LowShadowColor(clrStartedBar);
iBarObj.HighShadowColor(clrStartedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
// Activated Bar ...
XOHCL activatedBar;
bool isBodyIn = false;
bool isActivated = zone
.IsActivated(
zoneDir,
activatedBar,
isBodyIn,
false // Force Body Out Started ...
);
if (isActivated)
{
//
datetime iBarTo = activatedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
activatedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthActivatedBar);
iBarObj.LowShadowWidth(widthActivatedBar);
iBarObj.HighShadowWidth(widthActivatedBar);
//
iBarObj.BodyStyle(styleActivatedBar);
iBarObj.LowShadowStyle(styleActivatedBar);
iBarObj.HighShadowStyle(styleActivatedBar);
//
iBarObj.BodyColor(clrActivatedBar);
iBarObj.LowShadowColor(clrActivatedBar);
iBarObj.HighShadowColor(clrActivatedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
// Breaked Bar ...
XOHCL breakedBar;
isBodyOut = false;
bool isBreaked = zone
.IsBreaked(
zoneDir,
breakedBar,
isBodyOut,
false, // Ignore Start ...
false // Force Body Out Started ...
);
if (isBreaked)
{
//
datetime iBarTo = breakedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
breakedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthBreakedBar);
iBarObj.LowShadowWidth(widthBreakedBar);
iBarObj.HighShadowWidth(widthBreakedBar);
//
iBarObj.BodyStyle(styleBreakedBar);
iBarObj.LowShadowStyle(styleBreakedBar);
iBarObj.HighShadowStyle(styleBreakedBar);
//
iBarObj.BodyColor(clrBreakedBar);
iBarObj.LowShadowColor(clrBreakedBar);
iBarObj.HighShadowColor(clrBreakedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
// Worked Bar ...
XOHCL workedBar;
isBodyOut = false;
bool isWorked = zone
.IsWorked(
zoneDir,
workedBar,
isBodyOut,
false, // Ignore Activation ...
false, // Force Body Out Started ...
false // Force Body In Activated ...
);
if (isWorked)
{
//
datetime iBarTo = workedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
workedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthWorkedBar);
iBarObj.LowShadowWidth(widthWorkedBar);
iBarObj.HighShadowWidth(widthWorkedBar);
//
iBarObj.BodyStyle(styleWorkedBar);
iBarObj.LowShadowStyle(styleWorkedBar);
iBarObj.HighShadowStyle(styleWorkedBar);
//
iBarObj.BodyColor(clrWorkedBar);
iBarObj.LowShadowColor(clrWorkedBar);
iBarObj.HighShadowColor(clrWorkedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
XCBaseObject *iObj;
bool isCreated = CreateOrderBlock(
zone,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
objects //
);
}
//
result = ArraySize(objects);
//
return result;
}
//
int DrawFairValueGap(
XCFVG *zone,
XCBaseObject *&objects[],
//
bool drawStartedBar = true,
bool drawActivatedBar = true,
bool drawBreakedBar = true,
bool drawWorkedBar = true,
//
int widthStartedBar = 1,
color clrStartedBar = clrYellow,
ENUM_LINE_STYLE styleStartedBar = STYLE_SOLID,
//
int widthActivatedBar = 1,
color clrActivatedBar = clrLime,
ENUM_LINE_STYLE styleActivatedBar = STYLE_SOLID,
//
int widthBreakedBar = 1,
color clrBreakedBar = clrRed,
ENUM_LINE_STYLE styleBreakedBar = STYLE_SOLID,
//
int widthWorkedBar = 1,
color clrWorkedBar = clrAqua,
ENUM_LINE_STYLE styleWorkedBar = STYLE_SOLID
//
)
{
//
int result = 0;
//
Clean(objects);
//
if (zone == NULL ||
!zone.IsValid())
{
return result;
}
//
ENUM_X_DIRECTION zoneDir = zone.GetDirection();
//
// Started Bar ...
XOHCL startedBar;
bool isBodyOut = false;
bool isStarted = zone
.IsStarted(
zoneDir,
startedBar,
isBodyOut //
);
if (isStarted)
{
//
datetime iBarTo = startedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
startedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthStartedBar);
iBarObj.LowShadowWidth(widthStartedBar);
iBarObj.HighShadowWidth(widthStartedBar);
//
iBarObj.BodyStyle(styleStartedBar);
iBarObj.LowShadowStyle(styleStartedBar);
iBarObj.HighShadowStyle(styleStartedBar);
//
iBarObj.BodyColor(clrStartedBar);
iBarObj.LowShadowColor(clrStartedBar);
iBarObj.HighShadowColor(clrStartedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
// Activated Bar ...
XOHCL activatedBar;
bool isBodyIn = false;
bool isActivated = zone
.IsActivated(
zoneDir,
activatedBar,
isBodyIn,
false // Force Body Out Started ...
);
if (isActivated)
{
//
datetime iBarTo = activatedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
activatedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthActivatedBar);
iBarObj.LowShadowWidth(widthActivatedBar);
iBarObj.HighShadowWidth(widthActivatedBar);
//
iBarObj.BodyStyle(styleActivatedBar);
iBarObj.LowShadowStyle(styleActivatedBar);
iBarObj.HighShadowStyle(styleActivatedBar);
//
iBarObj.BodyColor(clrActivatedBar);
iBarObj.LowShadowColor(clrActivatedBar);
iBarObj.HighShadowColor(clrActivatedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
// Breaked Bar ...
XOHCL breakedBar;
isBodyOut = false;
bool isBreaked = zone
.IsBreaked(
zoneDir,
breakedBar,
isBodyOut,
false, // Ignore Start ...
false // Force Body Out Started ...
);
if (isBreaked)
{
//
datetime iBarTo = breakedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
breakedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthBreakedBar);
iBarObj.LowShadowWidth(widthBreakedBar);
iBarObj.HighShadowWidth(widthBreakedBar);
//
iBarObj.BodyStyle(styleBreakedBar);
iBarObj.LowShadowStyle(styleBreakedBar);
iBarObj.HighShadowStyle(styleBreakedBar);
//
iBarObj.BodyColor(clrBreakedBar);
iBarObj.LowShadowColor(clrBreakedBar);
iBarObj.HighShadowColor(clrBreakedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
// Worked Bar ...
XOHCL workedBar;
isBodyOut = false;
bool isWorked = zone
.IsWorked(
zoneDir,
workedBar,
isBodyOut,
false, // Ignore Activation ...
false, // Force Body Out Started ...
false // Force Body In Activated ...
);
if (isWorked)
{
//
datetime iBarTo = workedBar.NextAt();
//
XCOHCLObject *iBarObj;
bool isCreated = CreateBar(
workedBar,
iBarObj,
iBarTo //
);
if (isCreated)
{
//
iBarObj.BodyWidth(widthWorkedBar);
iBarObj.LowShadowWidth(widthWorkedBar);
iBarObj.HighShadowWidth(widthWorkedBar);
//
iBarObj.BodyStyle(styleWorkedBar);
iBarObj.LowShadowStyle(styleWorkedBar);
iBarObj.HighShadowStyle(styleWorkedBar);
//
iBarObj.BodyColor(clrWorkedBar);
iBarObj.LowShadowColor(clrWorkedBar);
iBarObj.HighShadowColor(clrWorkedBar);
//
Add(
(XCBaseObject *)iBarObj,
objects //
);
}
}
//
XCBaseObject *iObj;
bool isCreated = CreateFairValueGap(
zone,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
objects //
);
}
//
result = ArraySize(objects);
//
return result;
}
File diff suppressed because it is too large Load Diff