last ...
This commit is contained in:
@@ -4134,5 +4134,416 @@ struct X121SMCStrategyConditionParser
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XHKMA ...
|
||||
bool HasSenario4Conditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
ENUM_X_DIRECTION trend,
|
||||
XBoxZone &box,
|
||||
XBoxZone &holderBox,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XSignalBox &waitingBoxes[],
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
holderBox.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Trend Exists ...
|
||||
result = HasDirection(trend);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extrand Trend Direction ...
|
||||
bool hasBullishTrend = IsBullish(trend);
|
||||
bool hasBearishTrend = IsBearish(trend);
|
||||
|
||||
//
|
||||
// Checking Waiting Baoxes Exists ...
|
||||
result = HasChild(waitingBoxes);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Current Waiting Box is Directional To Trend ...
|
||||
XSignalBox iSignalBox;
|
||||
idx = GetYoungest(waitingBoxes);
|
||||
result = IsValidIndex(idx);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iSignalBox.Clean();
|
||||
return result;
|
||||
}
|
||||
iSignalBox = waitingBoxes[idx];
|
||||
result = iSignalBox.IsValid() &&
|
||||
iSignalBox.ob.dir == trend;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iSignalBox.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasBullishSignalBox = iSignalBox.IsValid() &&
|
||||
iSignalBox.ob.IsBullish();
|
||||
|
||||
//
|
||||
bool hasBearishSignalBox = iSignalBox.IsValid() &&
|
||||
iSignalBox.ob.IsBearish();
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
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;
|
||||
XOHCL pPBar;
|
||||
|
||||
//
|
||||
// Initial Bars ...
|
||||
result = zBar.Init(
|
||||
cState.symbol,
|
||||
cState.period,
|
||||
barIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
zBar.GetPreviousBar(cBar);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
result =
|
||||
result &&
|
||||
pBar.GetPreviousBar(pPBar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
pPBar.Clean();
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION iBarPosDir;
|
||||
bool isBarValidForDir = cHelper
|
||||
.mBarAnalyser
|
||||
.IsValidForPosition(
|
||||
cBar,
|
||||
iBarPosDir //
|
||||
);
|
||||
bool isBarValidForBullish =
|
||||
isBarValidForDir &&
|
||||
IsBullish(iBarPosDir);
|
||||
bool isBarValidForBearish =
|
||||
isBarValidForDir &&
|
||||
IsBearish(iBarPosDir);
|
||||
|
||||
//
|
||||
// Check Bar Validation for Trend Based Directions ...
|
||||
result =
|
||||
isBarValidForDir &&
|
||||
iBarPosDir == trend &&
|
||||
HasDirection(iBarPosDir);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
pPBar.Clean();
|
||||
cState.Clean();
|
||||
iSignalBox.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Here we Have to Check Other Consitions Based On Current
|
||||
// Stuffs ...
|
||||
XBoxZone zoneBox;
|
||||
|
||||
//
|
||||
// Select Boxes for Zones ...
|
||||
XBoxZone tmpBoxes[];
|
||||
if (hasBullishTrend)
|
||||
{
|
||||
//
|
||||
XBoxZone tmp[];
|
||||
|
||||
//
|
||||
// Order Blocks ...
|
||||
// ToBox(
|
||||
// cState.bullishOrderBlocks,
|
||||
// tmp //
|
||||
// );
|
||||
// Copy(
|
||||
// tmp,
|
||||
// tmpBoxes //
|
||||
// );
|
||||
// Clean(tmp);
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
ToBox(
|
||||
cState.bullishFairValueGaps,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false // Ignore Clean ...
|
||||
);
|
||||
Clean(tmp);
|
||||
}
|
||||
else if (hasBearishTrend)
|
||||
{
|
||||
//
|
||||
XBoxZone tmp[];
|
||||
|
||||
//
|
||||
// Order Blocks ...
|
||||
// ToBox(
|
||||
// cState.bearishOrderBlocks,
|
||||
// tmp //
|
||||
// );
|
||||
// Copy(
|
||||
// tmp,
|
||||
// tmpBoxes //
|
||||
// );
|
||||
// Clean(tmp);
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
ToBox(
|
||||
cState.bearishFairValueGaps,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false // Ignore Clean ...
|
||||
);
|
||||
Clean(tmp);
|
||||
}
|
||||
has = HasChild(tmpBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
while (HasChild(tmpBoxes))
|
||||
{
|
||||
//
|
||||
// Select Box based on Trend ...
|
||||
idx = hasBullishTrend
|
||||
? GetLowest(tmpBoxes)
|
||||
: hasBearishTrend
|
||||
? GetHighest(tmpBoxes)
|
||||
: -1;
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[idx];
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Selected Box ...
|
||||
bool isDirPassed = iBox.dir == trend;
|
||||
bool isFromPassed =
|
||||
iSignalBox.fvg.IsValid()
|
||||
? iBox.from > iSignalBox.fvg.from
|
||||
: iBox.from > iSignalBox.ob.from;
|
||||
bool isPriceInsidePassed =
|
||||
hasBullishTrend
|
||||
? cBar.low < iBox.upper &&
|
||||
cBar.low > iBox.lower
|
||||
: hasBearishTrend
|
||||
? cBar.high > iBox.lower &&
|
||||
cBar.high < iBox.upper
|
||||
: false;
|
||||
has = isDirPassed &&
|
||||
isFromPassed &&
|
||||
isPriceInsidePassed;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
zoneBox = iBox;
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Clean(tmpBoxes);
|
||||
|
||||
//
|
||||
bool hasBullishZoneBox = zoneBox.IsValid() &&
|
||||
zoneBox.IsBullish();
|
||||
|
||||
//
|
||||
bool hasBearishZoneBox = zoneBox.IsValid() &&
|
||||
zoneBox.IsBearish();
|
||||
|
||||
//
|
||||
// Summarize Conditions ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Bullish Conditions ...
|
||||
hasBullishTrend &&
|
||||
hasBullishZoneBox &&
|
||||
hasBullishSignalBox &&
|
||||
isBarValidForBullish &&
|
||||
//
|
||||
// Other Additional Conditions ...
|
||||
true
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Bearish Conditions ...
|
||||
hasBearishTrend &&
|
||||
hasBearishZoneBox &&
|
||||
hasBearishSignalBox &&
|
||||
isBarValidForBearish &&
|
||||
//
|
||||
// Other Additional Conditions ...
|
||||
true
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Filling Requirements ...
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
box = zoneBox;
|
||||
|
||||
//
|
||||
box.to = TimeCurrent();
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
Print("Found ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
pPBar.Clean();
|
||||
cState.Clean();
|
||||
iSignalBox.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user