last ...
This commit is contained in:
@@ -95,7 +95,7 @@ struct XOBFVG
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
XCFVG *fvg;
|
||||
XCFVG *fvgs[];
|
||||
XCOrderBlock *ob;
|
||||
|
||||
//
|
||||
@@ -112,8 +112,8 @@ struct XOBFVG
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
Clean(fvgs);
|
||||
ZeroMemory(ob);
|
||||
ZeroMemory(fvg);
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
@@ -123,7 +123,7 @@ struct XOBFVG
|
||||
bool IsValid()
|
||||
{
|
||||
return HasOB() &&
|
||||
HasFVG();
|
||||
HasFVGs();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -134,10 +134,15 @@ struct XOBFVG
|
||||
}
|
||||
|
||||
//
|
||||
bool HasFVG()
|
||||
bool HasFVGs()
|
||||
{
|
||||
return fvg != NULL &&
|
||||
fvg.IsValid();
|
||||
return HasChild(fvgs);
|
||||
}
|
||||
|
||||
//
|
||||
int CountFVGs()
|
||||
{
|
||||
return ArraySize(fvgs);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -300,6 +305,39 @@ struct XOBFVG
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void AddFVG(XCFVG *fvg)
|
||||
{
|
||||
//
|
||||
int idx = -1;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
has = fvg != NULL &&
|
||||
fvg.IsValid();
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
idx = FindIndex(
|
||||
fvg,
|
||||
fvgs //
|
||||
);
|
||||
has = !IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
fvg,
|
||||
fvgs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameAs(XOBFVG &item)
|
||||
{
|
||||
@@ -308,8 +346,7 @@ struct XOBFVG
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
IsSame(ob, item.ob) &&
|
||||
IsSame(fvg, item.fvg);
|
||||
IsSame(ob, item.ob);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -333,10 +370,15 @@ struct XOBFVG
|
||||
}
|
||||
|
||||
//
|
||||
has = HasFVG();
|
||||
has = HasFVGs();
|
||||
if (has)
|
||||
{
|
||||
fvg.To(value);
|
||||
//
|
||||
count = CountFVGs();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
fvgs[i].To(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3639,224 +3681,6 @@ struct XPOIState
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
int ExtractOBFVGs(
|
||||
XOBFVG &dest[],
|
||||
XPOIState &obState,
|
||||
XPOIState &fvgState,
|
||||
//
|
||||
ENUM_X_OBFVG_FVG_FILTERS filterFVGs = X_OBFVG_FVG_FILTER_INSIDE_OR,
|
||||
ENUM_X_OBFVG_FVG_SELECTION selectFVG = X_OBFVG_FVG_SELECT_OLDEST,
|
||||
//
|
||||
ENUM_TIMEFRAMES forPeriod = NULL,
|
||||
//
|
||||
// Start ...
|
||||
ENUM_XZONE_STATE startState = XZONE_STATE_PASSED,
|
||||
bool forceStartedBodyOut = false,
|
||||
//
|
||||
// Activation ...
|
||||
ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED,
|
||||
bool forceActivatedBodyIn = false,
|
||||
//
|
||||
// Breaktion ...
|
||||
ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED,
|
||||
bool forceBreakedBodyOut = false,
|
||||
//
|
||||
// Works ...
|
||||
ENUM_XZONE_STATE workState = XZONE_STATE_IGNORED,
|
||||
bool forceWorkedBodyOut = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
Clean(dest);
|
||||
|
||||
//
|
||||
has = obState.IsValid() &&
|
||||
fvgState.IsValid() &&
|
||||
obState.HasChild() &&
|
||||
fvgState.HasChild() &&
|
||||
selectFVG != X_OBFVG_FVG_SELECT_NONE &&
|
||||
filterFVGs != X_OBFVG_FVG_FILTER_NONE;
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCOrderBlock *obs[];
|
||||
int obsCount = obState.FilterOrderBlocks(
|
||||
obs,
|
||||
forPeriod,
|
||||
startState,
|
||||
forceStartedBodyOut,
|
||||
activeState,
|
||||
forceActivatedBodyIn,
|
||||
breakState,
|
||||
forceBreakedBodyOut,
|
||||
workState,
|
||||
forceWorkedBodyOut //
|
||||
);
|
||||
has = IsValidSize(obsCount);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCFVG *fvgs[];
|
||||
int fvgsCount = fvgState.FilterFairValueGaps(
|
||||
fvgs,
|
||||
forPeriod,
|
||||
startState,
|
||||
forceStartedBodyOut,
|
||||
activeState,
|
||||
forceActivatedBodyIn,
|
||||
breakState,
|
||||
forceBreakedBodyOut,
|
||||
workState,
|
||||
forceWorkedBodyOut //
|
||||
);
|
||||
has = IsValidSize(fvgsCount);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < obsCount; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOB = obs[i];
|
||||
XCFVG *iFVG = NULL;
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION iOBDir = iOB.GetDirection();
|
||||
bool isIOBBullish = IsBullish(iOBDir);
|
||||
|
||||
//
|
||||
XCFVG *iFVGs[];
|
||||
for (int j = 0; j < fvgsCount; j++)
|
||||
{
|
||||
//
|
||||
XCFVG *jFVG = fvgs[j];
|
||||
ENUM_X_DIRECTION jFVGDir = jFVG.GetDirection();
|
||||
|
||||
//
|
||||
bool isSameDir = iOBDir == jFVGDir;
|
||||
bool isFromPassed = jFVG.From() >= iOB.From();
|
||||
bool isInsideOr = IsInsideOrDiff(
|
||||
jFVG,
|
||||
iOB //
|
||||
);
|
||||
bool isAbove = IsAboveDiff(
|
||||
jFVG,
|
||||
iOB,
|
||||
true //
|
||||
);
|
||||
bool isBelow = IsBelowDiff(
|
||||
jFVG,
|
||||
iOB,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
bool isFilterPassed =
|
||||
filterFVGs == X_OBFVG_FVG_FILTER_ABOVE_BELOW
|
||||
? isIOBBullish
|
||||
? isAbove
|
||||
: isBelow
|
||||
: filterFVGs == X_OBFVG_FVG_FILTER_INSIDE_OR
|
||||
? isInsideOr
|
||||
: false;
|
||||
|
||||
//
|
||||
has =
|
||||
isSameDir &&
|
||||
isFromPassed &&
|
||||
isFilterPassed;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
jFVG,
|
||||
iFVGs //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(iFVGs);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
idx = selectFVG == X_OBFVG_FVG_SELECT_OLDEST
|
||||
? GetOldest(iFVGs)
|
||||
: selectFVG == X_OBFVG_FVG_SELECT_YOUNGEST
|
||||
? GetYoungest(iFVGs)
|
||||
: selectFVG == X_OBFVG_FVG_SELECT_HIGHEST_LOWEST
|
||||
? isIOBBullish
|
||||
? GetHighest(iFVGs)
|
||||
: GetLowest(iFVGs)
|
||||
: selectFVG == X_OBFVG_FVG_SELECT_LOWEST_HIGHEST
|
||||
? isIOBBullish
|
||||
? GetLowest(iFVGs)
|
||||
: GetHighest(iFVGs)
|
||||
: selectFVG == X_OBFVG_FVG_SELECT_LOWEST
|
||||
? GetLowest(iFVGs)
|
||||
: selectFVG == X_OBFVG_FVG_SELECT_HIGHEST
|
||||
? GetHighest(iFVGs)
|
||||
: -1;
|
||||
|
||||
//
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
iFVG = iFVGs[idx];
|
||||
Clean(iFVGs);
|
||||
|
||||
//
|
||||
XOBFVG iOBFVG;
|
||||
iOBFVG.ob = iOB;
|
||||
iOBFVG.fvg = iFVG;
|
||||
|
||||
//
|
||||
has = iOBFVG.IsValid();
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iOBFVG.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iOBFVG,
|
||||
dest //
|
||||
);
|
||||
|
||||
//
|
||||
iOBFVG.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(dest);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extensions Functions ...
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user