last ...
This commit is contained in:
@@ -5373,7 +5373,7 @@ struct XBoxZone
|
||||
{
|
||||
//
|
||||
string typeStr = IsValid(type)
|
||||
? type
|
||||
? type + "_"
|
||||
: "XBOX";
|
||||
string result =
|
||||
//
|
||||
|
||||
@@ -2626,7 +2626,7 @@ struct X121SMCStrategyConditionParser
|
||||
}
|
||||
|
||||
//
|
||||
// Rejected Box ...
|
||||
// Rejected Boxes ...
|
||||
bool HasRejectedBoxConditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XSignalBox &box,
|
||||
@@ -2917,7 +2917,7 @@ struct X121SMCStrategyConditionParser
|
||||
}
|
||||
|
||||
//
|
||||
// Activated Boxe ...
|
||||
// Activated Boxes ...
|
||||
bool HasActivatedBoxConditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XSignalBox &box,
|
||||
@@ -3197,13 +3197,13 @@ struct X121SMCStrategyConditionParser
|
||||
|
||||
//
|
||||
box.sl = isBullish
|
||||
? cXConditions.vwapMin
|
||||
: cXConditions.vwapMax;
|
||||
? cXConditions.vwapMin
|
||||
: cXConditions.vwapMax;
|
||||
|
||||
//
|
||||
box.tp = isBullish
|
||||
? box.sharp.upper
|
||||
: box.sharp.lower;
|
||||
? box.sharp.upper
|
||||
: box.sharp.lower;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -3231,5 +3231,575 @@ struct X121SMCStrategyConditionParser
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Breaked Boxes ...
|
||||
bool HasBreakedBoxConditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XSignalBox &box,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XSignalBox &breakedBoxes[],
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
int barIndex = 0 //
|
||||
) {
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Checking Waiting Baoxes Exists ...
|
||||
result = HasChild(breakedBoxes);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
|
||||
//
|
||||
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();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Bar Based on Positions State ...
|
||||
ENUM_X_DIRECTION iBarPosDir;
|
||||
bool isBarValidForDir = cHelper
|
||||
.mBarAnalyser
|
||||
.IsValidForPosition(
|
||||
cBar,
|
||||
iBarPosDir //
|
||||
);
|
||||
bool isBarValidForBullish =
|
||||
isBarValidForDir &&
|
||||
IsBullish(iBarPosDir);
|
||||
bool isBarValidForBearish =
|
||||
isBarValidForDir &&
|
||||
IsBearish(iBarPosDir);
|
||||
|
||||
//
|
||||
// Extract Selected Boxes ...
|
||||
XBoxZone selectedBox;
|
||||
XSignalBox iSignalBox;
|
||||
count = ArraySize(breakedBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XSignalBox iBox = breakedBoxes[i];
|
||||
|
||||
//
|
||||
bool isBullish = iBox.ob.IsBullish();
|
||||
|
||||
//
|
||||
has = cBar.low < iBox.sharp.upper &&
|
||||
cBar.low > iBox.sharp.lower &&
|
||||
cBar.high > iBox.sharp.lower &&
|
||||
cBar.high < iBox.sharp.upper;
|
||||
|
||||
//
|
||||
// Force Using OB ...
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iSignalBox = iBox;
|
||||
if (!selectedBox.IsValid())
|
||||
{
|
||||
selectedBox = iBox.ob;
|
||||
}
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
result =
|
||||
iSignalBox.IsValid() &&
|
||||
selectedBox.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
iSignalBox.Clean();
|
||||
selectedBox.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasSignalBox = iSignalBox.IsValid();
|
||||
bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir);
|
||||
|
||||
//
|
||||
// Checking Other Conditions ...
|
||||
|
||||
//
|
||||
// XVWAP ...
|
||||
|
||||
//
|
||||
bool isVWapSlopeBullish =
|
||||
cXConditions.isVwapFastSlopeBullish &&
|
||||
cXConditions.isVwapMidSlopeBullish &&
|
||||
cXConditions.isVwapSlowSlopeBullish;
|
||||
|
||||
//
|
||||
bool isVWapSlopeBearish =
|
||||
cXConditions.isVwapFastSlopeBearish &&
|
||||
cXConditions.isVwapMidSlopeBearish &&
|
||||
cXConditions.isVwapSlowSlopeBearish;
|
||||
|
||||
//
|
||||
bool isVWapBullishCondition =
|
||||
(cXConditions.isVWapBullishOrdered &&
|
||||
cXConditions.isVWapSwitchedToBullishState) ||
|
||||
(cXConditions.isVWapBullishState &&
|
||||
cXConditions.isVWapSwitchedToBullishOrdered);
|
||||
|
||||
//
|
||||
bool isVWapBearishCondition =
|
||||
(cXConditions.isVWapBearishOrdered &&
|
||||
cXConditions.isVWapSwitchedToBearishState) ||
|
||||
(cXConditions.isVWapBearishState &&
|
||||
cXConditions.isVWapSwitchedToBearishOrdered);
|
||||
|
||||
//
|
||||
// Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
hasSignalBox &&
|
||||
isSignalBoxBullish &&
|
||||
isVWapSlopeBullish &&
|
||||
isBarValidForBullish &&
|
||||
isVWapBullishCondition
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
hasSignalBox &&
|
||||
isVWapSlopeBearish &&
|
||||
!isSignalBoxBullish &&
|
||||
isBarValidForBearish &&
|
||||
isVWapBearishCondition
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Filling Requirements ...
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
box = iSignalBox;
|
||||
box.UpdateTo(TimeCurrent());
|
||||
|
||||
//
|
||||
// Provide TP/SL ...
|
||||
|
||||
//
|
||||
box.sl = isBullish
|
||||
? cXConditions.vwapMin
|
||||
: cXConditions.vwapMax;
|
||||
|
||||
//
|
||||
box.tp = isBullish
|
||||
? box.sharp.upper
|
||||
: box.sharp.lower;
|
||||
}
|
||||
|
||||
//
|
||||
// Check All Conditions ...
|
||||
result =
|
||||
box.IsValid() &&
|
||||
HasDirection(dir) &&
|
||||
(isBullish ||
|
||||
isBearish);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
iSignalBox.Clean();
|
||||
selectedBox.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XFVGMA ...
|
||||
bool HasXFVGMAConditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XSignalBox &box,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XSignalBox &waitingBoxes[],
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = HasChild(waitingBoxes);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
|
||||
//
|
||||
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();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select Waiting Box ...
|
||||
XBoxZone selectedBox;
|
||||
XSignalBox selectedSignalBox;
|
||||
count = ArraySize(waitingBoxes);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XSignalBox iSBox = waitingBoxes[i];
|
||||
bool isBullish = iSBox.ob.IsBullish();
|
||||
|
||||
//
|
||||
bool isInsidePassed =
|
||||
isBullish
|
||||
? cBar.low < iSBox.ob.upper &&
|
||||
cBar.low > iSBox.ob.lower
|
||||
: cBar.high > iSBox.ob.lower &&
|
||||
cBar.high < iSBox.ob.upper;
|
||||
|
||||
//
|
||||
bool isTypePassed = iSBox.sharp.type == "XSHPOBX";
|
||||
|
||||
//
|
||||
has = isTypePassed &&
|
||||
isInsidePassed;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
selectedBox = iSBox.ob;
|
||||
selectedSignalBox = iSBox;
|
||||
break;
|
||||
}
|
||||
}
|
||||
result = selectedBox.IsValid() &&
|
||||
selectedSignalBox.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
selectedBox.Clean();
|
||||
cXConditions.Clean();
|
||||
selectedSignalBox.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isSignalBoxBullish = selectedBox.IsBullish();
|
||||
|
||||
//
|
||||
// Checking Other Conditions ...
|
||||
|
||||
//
|
||||
// Checking Bar Based on Positions State ...
|
||||
ENUM_X_DIRECTION iBarPosDir;
|
||||
bool isBarValidForDir = cHelper
|
||||
.mBarAnalyser
|
||||
.IsValidForPosition(
|
||||
cBar,
|
||||
iBarPosDir //
|
||||
);
|
||||
bool isBarValidForBullish =
|
||||
isBarValidForDir &&
|
||||
IsBullish(iBarPosDir);
|
||||
bool isBarValidForBearish =
|
||||
isBarValidForDir &&
|
||||
IsBearish(iBarPosDir);
|
||||
|
||||
//
|
||||
// Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
isSignalBoxBullish &&
|
||||
isBarValidForBullish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
!isSignalBoxBullish &&
|
||||
isBarValidForBearish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Filling Requirements ...
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
box = selectedSignalBox;
|
||||
box.ob.to = TimeCurrent();
|
||||
}
|
||||
|
||||
//
|
||||
// Check All Conditions ...
|
||||
result =
|
||||
box.IsValid() &&
|
||||
HasDirection(dir) &&
|
||||
(isBullish ||
|
||||
isBearish);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
selectedBox.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
cXConditions.Clean();
|
||||
selectedSignalBox.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
enum ENUM_X121SMC_XWZ_PROVIDERS
|
||||
{
|
||||
X121SMC_XWZ_PROVIDER_NONE,
|
||||
X121SMC_XWZ_PROVIDER_XFVGMA,
|
||||
X121SMC_XWZ_PROVIDER_XBREAKED_BOX,
|
||||
X121SMC_XWZ_PROVIDER_XREJECTED_BOX,
|
||||
X121SMC_XWZ_PROVIDER_XACTIVATED_BOX,
|
||||
@@ -911,6 +912,474 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
sharpConsolidation.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Preparing Waiting Box based on FVG State ...
|
||||
if (fvgStateEvents.hasNewSharp)
|
||||
{
|
||||
//
|
||||
// Select Newest Sharp Change ...
|
||||
XBoxZone sharp;
|
||||
idx = GetYoungest(fvgState.sharps);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XOHCL endBar;
|
||||
XOHCL startBar;
|
||||
int totalBars = 0;
|
||||
int orderBlocksIDX[];
|
||||
int bullBarsCount = 0;
|
||||
int bearBarsCount = 0;
|
||||
int validPercent = 75;
|
||||
|
||||
//
|
||||
sharp = fvgState.sharps[idx];
|
||||
sharp.type = "XSHPOBX";
|
||||
bool isSharpBullish = sharp.IsBullish();
|
||||
|
||||
//
|
||||
// Validate End Bar ...
|
||||
if (sharp.IsValid())
|
||||
{
|
||||
//
|
||||
// Validate End Bar Direction ...
|
||||
int endBarIDX = GetBarIndex(
|
||||
sharp.symbol,
|
||||
sharp.period,
|
||||
sharp.to //
|
||||
);
|
||||
|
||||
//
|
||||
has = endBar.Init(
|
||||
sharp.symbol,
|
||||
sharp.period,
|
||||
endBarIDX + 1 //
|
||||
);
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = sharp.dir == endBar.GetDirection();
|
||||
if (!has)
|
||||
{
|
||||
sharp.Clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Start Bar ...
|
||||
if (sharp.IsValid())
|
||||
{
|
||||
//
|
||||
// Validate Start Bar Direction ...
|
||||
int startBarIDX = GetBarIndex(
|
||||
sharp.symbol,
|
||||
sharp.period,
|
||||
sharp.from //
|
||||
);
|
||||
|
||||
//
|
||||
has = startBar.Init(
|
||||
sharp.symbol,
|
||||
sharp.period,
|
||||
startBarIDX + 1 //
|
||||
);
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = sharp.dir == Opposit(startBar.GetDirection());
|
||||
if (!has)
|
||||
{
|
||||
sharp.Clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate OrderBlocks ...
|
||||
if (sharp.IsValid())
|
||||
{
|
||||
//
|
||||
int end = endBar.Index();
|
||||
int start = startBar.Index();
|
||||
for (int i = start; i >= end; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
has = iBar.Init(
|
||||
sharp.symbol,
|
||||
sharp.period,
|
||||
i //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
totalBars++;
|
||||
|
||||
//
|
||||
bool isBullish = iBar.IsBullish();
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
bullBarsCount++;
|
||||
|
||||
//
|
||||
if (!isSharpBullish)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
i,
|
||||
orderBlocksIDX //
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
bearBarsCount++;
|
||||
|
||||
//
|
||||
if (isSharpBullish)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
i,
|
||||
orderBlocksIDX //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Follow Order Blocks ...
|
||||
has = HasChild(orderBlocksIDX);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
int bullBarsPercent = (bullBarsCount * 100) / totalBars;
|
||||
int bearBarsPercent = (bearBarsCount * 100) / totalBars;
|
||||
|
||||
//
|
||||
has = isSharpBullish
|
||||
? bullBarsPercent >= validPercent
|
||||
: bearBarsPercent >= validPercent;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Prepare Waiting Boxes ...
|
||||
count = ArraySize(orderBlocksIDX);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
has = iBar.Init(
|
||||
sharp.symbol,
|
||||
sharp.period,
|
||||
orderBlocksIDX[i] //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iOB;
|
||||
XBoxZone iFVG;
|
||||
|
||||
//
|
||||
iOB.to = sharp.to;
|
||||
iOB.type = "XOBX";
|
||||
iOB.dir = sharp.dir;
|
||||
iOB.from = iBar.time;
|
||||
iOB.lower = iBar.low;
|
||||
iOB.upper = iBar.high;
|
||||
iOB.period = iBar.period;
|
||||
iOB.symbol = iBar.symbol;
|
||||
|
||||
//
|
||||
// Select FVG ...
|
||||
has = iOB.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Select FVG ...
|
||||
has = HasChild(fvgState.fairValueGaps);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XBoxZone tmpBoxes[];
|
||||
if (isSharpBullish)
|
||||
{
|
||||
//
|
||||
ToBox(
|
||||
fvgState.bullishFairValueGaps,
|
||||
tmpBoxes //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
ToBox(
|
||||
fvgState.bearishFairValueGaps,
|
||||
tmpBoxes //
|
||||
);
|
||||
}
|
||||
has = HasChild(tmpBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
while (HasChild(tmpBoxes))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(tmpBoxes);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[idx];
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate FVG ...
|
||||
bool isDirPassed = iBox.dir == sharp.dir;
|
||||
bool isFromPassed = iBox.from >= iOB.from;
|
||||
bool isPricePassed = IsBoxInsideOr(iBox, iOB);
|
||||
|
||||
//
|
||||
has = isDirPassed &&
|
||||
isFromPassed &&
|
||||
isPricePassed;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iFVG = iBox;
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
Clean(tmpBoxes);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
has =
|
||||
sharp.IsValid() &&
|
||||
iOB.IsValid() &&
|
||||
iFVG.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XSignalBox iSBox;
|
||||
|
||||
//
|
||||
iSBox.ob = iOB;
|
||||
iSBox.fvg = iFVG;
|
||||
iSBox.sharp = sharp;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iSBox,
|
||||
waitingBoxes //
|
||||
);
|
||||
|
||||
//
|
||||
iSBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
iOB.Clean();
|
||||
iFVG.Clean();
|
||||
iBar.Clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Follow Non Order Block ...
|
||||
// First Found FVGs ...
|
||||
XBoxZone iOB;
|
||||
XBoxZone iFVG;
|
||||
XBoxZone tmpBoxes[];
|
||||
if (isSharpBullish)
|
||||
{
|
||||
//
|
||||
ToBox(
|
||||
fvgState.bullishFairValueGaps,
|
||||
tmpBoxes //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
ToBox(
|
||||
fvgState.bearishFairValueGaps,
|
||||
tmpBoxes //
|
||||
);
|
||||
}
|
||||
has = HasChild(tmpBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
while (HasChild(tmpBoxes))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(tmpBoxes);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[idx];
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate FVG ...
|
||||
bool isDirPassed = iBox.dir == sharp.dir;
|
||||
bool isFromPassed = iBox.from >= sharp.from;
|
||||
bool isPricePassed = IsBoxInside(iBox, sharp);
|
||||
|
||||
//
|
||||
has = isDirPassed &&
|
||||
isFromPassed &&
|
||||
isPricePassed;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iFVG = iBox;
|
||||
|
||||
//
|
||||
// Now we Have to Create an Order Block ...
|
||||
|
||||
//
|
||||
XOHCL iToBar;
|
||||
XOHCL iFromBar;
|
||||
|
||||
//
|
||||
int fromIDX = GetBarIndex(
|
||||
iBox.symbol,
|
||||
iBox.period,
|
||||
iBox.from //
|
||||
);
|
||||
int toIDX = GetBarIndex(
|
||||
iBox.symbol,
|
||||
iBox.period,
|
||||
iBox.to //
|
||||
);
|
||||
has = iToBar.Init(
|
||||
iBox.symbol,
|
||||
iBox.period,
|
||||
toIDX //
|
||||
);
|
||||
has =
|
||||
has &&
|
||||
iFromBar.Init(
|
||||
iBox.symbol,
|
||||
iBox.period,
|
||||
fromIDX //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iBox.Clean();
|
||||
iToBar.Clean();
|
||||
iFromBar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iOB.to = iBox.to;
|
||||
iOB.type = "XOBX";
|
||||
iOB.dir = iBox.dir;
|
||||
iOB.from = iBox.from;
|
||||
iOB.symbol = iBox.symbol;
|
||||
iOB.period = iBox.period;
|
||||
iOB.lower = MathMin(iToBar.low, iFromBar.low);
|
||||
iOB.upper = MathMax(iToBar.high, iFromBar.high);
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
iToBar.Clean();
|
||||
iFromBar.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
Clean(tmpBoxes);
|
||||
|
||||
//
|
||||
has = iOB.IsValid() &&
|
||||
iFVG.IsValid() &&
|
||||
sharp.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XSignalBox iSBox;
|
||||
|
||||
//
|
||||
iSBox.ob = iOB;
|
||||
iSBox.fvg = iFVG;
|
||||
iSBox.sharp = sharp;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iSBox,
|
||||
waitingBoxes //
|
||||
);
|
||||
|
||||
//
|
||||
iSBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
iOB.Clean();
|
||||
iFVG.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
endBar.Clean();
|
||||
startBar.Clean();
|
||||
Clean(orderBlocksIDX);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
count = CountWaitingBoxes();
|
||||
result = IsValidSize(count);
|
||||
@@ -1498,7 +1967,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
// ---------------------------------------------------
|
||||
// Activated Box ...
|
||||
// ---------------------------------------------------
|
||||
bool useSenario2 = false;
|
||||
bool useSenario2 = true;
|
||||
bool isSenario2Happend = false;
|
||||
bool isSenario2Bullish = false;
|
||||
bool isSenario2Bearish = false;
|
||||
@@ -1537,7 +2006,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
// ---------------------------------------------------
|
||||
// Breaked Box ...
|
||||
// ---------------------------------------------------
|
||||
bool useSenario3 = false;
|
||||
bool useSenario3 = true;
|
||||
bool isSenario3Happend = false;
|
||||
bool isSenario3Bullish = false;
|
||||
bool isSenario3Bearish = false;
|
||||
@@ -1545,14 +2014,39 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
!isSenario2Happend &&
|
||||
useSenario3)
|
||||
{
|
||||
//
|
||||
isSenario3Happend = cParser.HasBreakedBoxConditions(
|
||||
X_CYCLE_DECISION,
|
||||
box,
|
||||
dir,
|
||||
breakedBoxes,
|
||||
provider,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
isSenario3Bullish =
|
||||
isSenario3Happend &&
|
||||
IsBullish(dir);
|
||||
|
||||
//
|
||||
isSenario3Bearish =
|
||||
isSenario3Happend &&
|
||||
IsBearish(dir);
|
||||
|
||||
//
|
||||
if (isSenario3Happend)
|
||||
{
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_XACTIVATED_BOX;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Senario 4:
|
||||
// -----------------------------------------------
|
||||
// Detect Signal Box Based On XHKMA Conditions ...
|
||||
// Detect Signal Box Based On FVG Conditions ...
|
||||
// -----------------------------------------------
|
||||
bool useSenario4 = false;
|
||||
bool useSenario4 = true;
|
||||
bool isSenario4Happend = false;
|
||||
bool isSenario4Bullish = false;
|
||||
bool isSenario4Bearish = false;
|
||||
@@ -1561,14 +2055,38 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
!isSenario3Happend &&
|
||||
useSenario4)
|
||||
{
|
||||
//
|
||||
isSenario4Happend = cParser.HasXFVGMAConditions(
|
||||
X_CYCLE_DECISION,
|
||||
box,
|
||||
dir,
|
||||
waitingBoxes,
|
||||
provider,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
isSenario4Bullish =
|
||||
isSenario4Happend &&
|
||||
IsBullish(dir);
|
||||
|
||||
//
|
||||
isSenario4Bearish =
|
||||
isSenario4Happend &&
|
||||
IsBearish(dir);
|
||||
|
||||
//
|
||||
if (isSenario4Happend)
|
||||
{
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_XFVGMA;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Senario 5:
|
||||
// ---------------------------------------------
|
||||
// XSHCNZ Signal Box Detection Conditions ...
|
||||
// ---------------------------------------------
|
||||
bool useSenario5 = true;
|
||||
bool useSenario5 = false;
|
||||
bool isSenario5Happend = false;
|
||||
bool isSenario5Bullish = false;
|
||||
bool isSenario5Bearish = false;
|
||||
|
||||
Reference in New Issue
Block a user