Complete Fair Value Gaps Detetion ...
This commit is contained in:
@@ -407,6 +407,36 @@ class XCPOIDetector : public XCBaseAlert
|
||||
mOrderBlocksSameBars = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
|
||||
/**
|
||||
* Get Fair Value Gaps Detection Same Bars ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FairValueGapsSameBars()
|
||||
{
|
||||
return mFairValueGapsSameBars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fair Value Gaps Detection Same Bars ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void FairValueGapsSameBars(int value)
|
||||
{
|
||||
//
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
//
|
||||
mFairValueGapsSameBars = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
@@ -860,6 +890,68 @@ class XCPOIDetector : public XCBaseAlert
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
int fvgSameBars = FairValueGapsSameBars();
|
||||
if (fvgSameBars > 0)
|
||||
{
|
||||
//
|
||||
// Bullish Fair Value Gap ...
|
||||
isDetected = DetectBullishFairValueGap(cBar);
|
||||
if (isDetected)
|
||||
{
|
||||
//
|
||||
ENUM_XPOI_EVENTS event = X_BULLISH_FVG_DETECTED;
|
||||
XCFVG *param;
|
||||
bool hasItem = GetLastItem(
|
||||
param,
|
||||
mBullishFairValueGaps //
|
||||
);
|
||||
if (hasItem)
|
||||
{
|
||||
//
|
||||
NotifyEventListeners(
|
||||
event,
|
||||
param //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
event,
|
||||
state //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish Fair Value Gap ...
|
||||
isDetected = DetectBearishFairValueGap(cBar);
|
||||
if (isDetected)
|
||||
{
|
||||
//
|
||||
ENUM_XPOI_EVENTS event = X_BEARISH_FVG_DETECTED;
|
||||
XCFVG *param;
|
||||
bool hasItem = GetLastItem(
|
||||
param,
|
||||
mBearishFairValueGaps //
|
||||
);
|
||||
if (hasItem)
|
||||
{
|
||||
//
|
||||
NotifyEventListeners(
|
||||
event,
|
||||
param //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
event,
|
||||
state //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
ValidatePOIs(cBar);
|
||||
|
||||
@@ -959,6 +1051,10 @@ class XCPOIDetector : public XCBaseAlert
|
||||
//
|
||||
Clean(mBullishOrderBlocks);
|
||||
Clean(mBearishOrderBlocks);
|
||||
|
||||
//
|
||||
Clean(mBullishFairValueGaps);
|
||||
Clean(mBearishFairValueGaps);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1010,6 +1106,9 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
OrderBlocksSameBars(3);
|
||||
|
||||
//
|
||||
FairValueGapsSameBars(3);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1086,6 +1185,10 @@ class XCPOIDetector : public XCBaseAlert
|
||||
int bullishOrderBlocksCount = 0;
|
||||
int bearishOrderBlocksCount = 0;
|
||||
|
||||
//
|
||||
int bullishFairValueGapsCount = 0;
|
||||
int bearishFairValueGapsCount = 0;
|
||||
|
||||
//
|
||||
bool canContinue = true;
|
||||
|
||||
@@ -1192,6 +1295,28 @@ class XCPOIDetector : public XCBaseAlert
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
int fvgSameBars = FairValueGapsSameBars();
|
||||
if (fvgSameBars > 0)
|
||||
{
|
||||
//
|
||||
// Bullish Fair Value Gaps ...
|
||||
bullishFairValueGapsCount = DetectRequiredBullishFairValueGaps(barIndex);
|
||||
if (bullishFairValueGapsCount == requiredPOIs)
|
||||
{
|
||||
ArrayReverse(mBullishFairValueGaps);
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish Fair Value Gaps ...
|
||||
bearishFairValueGapsCount = DetectRequiredBearishFairValueGaps(barIndex);
|
||||
if (bearishFairValueGapsCount == requiredPOIs)
|
||||
{
|
||||
ArrayReverse(mBearishFairValueGaps);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
canContinue =
|
||||
//
|
||||
@@ -1253,6 +1378,16 @@ class XCPOIDetector : public XCBaseAlert
|
||||
// Bearish Order Blocks ...
|
||||
bearishOrderBlocksCount < requiredPOIs
|
||||
//
|
||||
||
|
||||
//
|
||||
// Bullish Fair Value Gaps ...
|
||||
bullishFairValueGapsCount < requiredPOIs
|
||||
//
|
||||
||
|
||||
//
|
||||
// Bearish Fair Value Gaps ...
|
||||
bearishFairValueGapsCount < requiredPOIs
|
||||
//
|
||||
;
|
||||
if (canContinue)
|
||||
{
|
||||
@@ -3439,12 +3574,327 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
int mFairValueGapsSameBars; // Fair Value Gaps Detection Same Bars ...
|
||||
|
||||
//
|
||||
// Bullish FVG ...
|
||||
XCFVG *mBullishFairValueGaps[];
|
||||
|
||||
/**
|
||||
* Detect Bullish Fair Value Gap ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectBullishFairValueGap(XOHCL &bar)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int sameBars = FairValueGapsSameBars();
|
||||
if (sameBars < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL prevBar;
|
||||
XOHCL nextBar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = mBarAnalyser
|
||||
.HasFairValueGap(
|
||||
bar,
|
||||
prevBar,
|
||||
nextBar,
|
||||
dir,
|
||||
sameBars //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
dir == X_DIRECTION_BULLISH;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
XCFVG *fvg;
|
||||
fvg = new XCFVG();
|
||||
result = fvg.Init(
|
||||
prevBar,
|
||||
nextBar,
|
||||
dir //
|
||||
);
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
fvg.To(cTime);
|
||||
|
||||
//
|
||||
Add(
|
||||
fvg,
|
||||
mBullishFairValueGaps //
|
||||
);
|
||||
|
||||
// //
|
||||
// XCBullishFairValueGapObject *iObj;
|
||||
// bool isCreated = mDrawer.CreateBullishFairValueGap(
|
||||
// fvg,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Required Bullish Fair Value Gaps ...
|
||||
*
|
||||
* @param barIndex: Integer Start bar index ...
|
||||
* 0 is Default ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int DetectRequiredBullishFairValueGaps(int barIndex)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
int required = MaxNumberOfRequiredPOIs();
|
||||
if (required <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(mBullishFairValueGaps);
|
||||
if (count >= required)
|
||||
{
|
||||
//
|
||||
result = count;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int sameBars = FairValueGapsSameBars();
|
||||
if (sameBars < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
bool isInited = bar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
DetectBullishFairValueGap(bar);
|
||||
|
||||
//
|
||||
result = ArraySize(mBullishFairValueGaps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish FVG ...
|
||||
XCFVG *mBearishFairValueGaps[];
|
||||
|
||||
/**
|
||||
* Detect Bearish Fair Value Gap ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectBearishFairValueGap(XOHCL &bar)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int sameBars = FairValueGapsSameBars();
|
||||
if (sameBars < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL prevBar;
|
||||
XOHCL nextBar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = mBarAnalyser
|
||||
.HasFairValueGap(
|
||||
bar,
|
||||
prevBar,
|
||||
nextBar,
|
||||
dir,
|
||||
sameBars //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
dir == X_DIRECTION_BEARISH;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
XCFVG *fvg;
|
||||
fvg = new XCFVG();
|
||||
result = fvg.Init(
|
||||
prevBar,
|
||||
nextBar,
|
||||
dir //
|
||||
);
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
fvg.To(cTime);
|
||||
|
||||
//
|
||||
Add(
|
||||
fvg,
|
||||
mBearishFairValueGaps //
|
||||
);
|
||||
|
||||
// //
|
||||
// XCBearishFairValueGapObject *iObj;
|
||||
// bool isCreated = mDrawer.CreateBearishFairValueGap(
|
||||
// fvg,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Required Bearish Fair Value Gaps ...
|
||||
*
|
||||
* @param barIndex: Integer Start bar index ...
|
||||
* 0 is Default ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int DetectRequiredBearishFairValueGaps(int barIndex)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
int required = MaxNumberOfRequiredPOIs();
|
||||
if (required <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(mBearishFairValueGaps);
|
||||
if (count >= required)
|
||||
{
|
||||
//
|
||||
result = count;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int sameBars = FairValueGapsSameBars();
|
||||
if (sameBars < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
bool isInited = bar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
DetectBearishFairValueGap(bar);
|
||||
|
||||
//
|
||||
result = ArraySize(mBearishFairValueGaps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Liquidity Zones ...
|
||||
|
||||
Reference in New Issue
Block a user