last ...
This commit is contained in:
+536
-112
@@ -88,6 +88,18 @@ input bool showDownTrend = true; // Show Down Trend
|
||||
input bool showLongReject = true; // Show Long Reject
|
||||
input bool showShortReject = true; // Show Short Reject
|
||||
|
||||
//
|
||||
input bool showPOIs = false; // Draw POI(s) ...
|
||||
input bool showActivatedPOIs = false; // Draw Activated POI(s) ...
|
||||
input bool showBullishOrderBlocks = true; // Draw Bullish Order Blocks ...
|
||||
input bool showBearishOrderBlocks = true; // Draw Bearish Order Blocks ...
|
||||
input bool showBullishFairValueGaps = true; // Draw Bullish Fair Value Gaps ...
|
||||
input bool showBearishFairValueGaps = true; // Draw Bearish Fair Value Gaps ...
|
||||
input bool showSupplyZones = true; // Draw Supply Zones ...
|
||||
input bool showDemandZones = true; // Draw Demand Zones ...
|
||||
input bool showSupportZones = true; // Draw Support Zones ...
|
||||
input bool showResistanceZones = true; // Draw Resistance Zones ...
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
@@ -246,6 +258,9 @@ XCResistanceZone *mXWZActivatedResistanceZones[];
|
||||
*/
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
mXWZDrawnObjects.Clear();
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
@@ -487,20 +502,6 @@ int OnCalculate(
|
||||
// Main Loop ...
|
||||
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
|
||||
{
|
||||
//
|
||||
CalculatedPOIs(
|
||||
//
|
||||
i,
|
||||
prev_calculated,
|
||||
rates_total,
|
||||
//
|
||||
open,
|
||||
high,
|
||||
close,
|
||||
low,
|
||||
tick_volume //
|
||||
);
|
||||
|
||||
//
|
||||
CalculateBuffers(
|
||||
//
|
||||
@@ -756,6 +757,20 @@ void CalculateBuffers(
|
||||
bar_index <= barsLimit;
|
||||
if (canCalculate)
|
||||
{
|
||||
//
|
||||
CalculatedPOIs(
|
||||
//
|
||||
bar_index,
|
||||
prevCalculated,
|
||||
ratesTotal,
|
||||
//
|
||||
open,
|
||||
high,
|
||||
close,
|
||||
low,
|
||||
tickVolume //
|
||||
);
|
||||
|
||||
//
|
||||
CalculateValues(
|
||||
bar_index,
|
||||
@@ -1264,6 +1279,10 @@ void CalculatedPOIs(
|
||||
DetectPOIs(iBar);
|
||||
UpdatePOIs(iBar);
|
||||
DrawPOIs();
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
pBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1272,37 +1291,8 @@ void DetectPOIs(
|
||||
)
|
||||
{
|
||||
//
|
||||
// Detect PullBack ...
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION pullbackDir;
|
||||
bool hasPullBack = mXWZBarAnalyser.HasPullBack(
|
||||
pullbackDir,
|
||||
bar //
|
||||
);
|
||||
bool hasBullishPullBack =
|
||||
hasPullBack &&
|
||||
IsBullish(pullbackDir);
|
||||
bool hasBearishPullBack =
|
||||
hasPullBack &&
|
||||
IsBearish(pullbackDir);
|
||||
|
||||
//
|
||||
// Detect PinBar ...
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION pinBarDir;
|
||||
bool hasPinBar = mXWZBarAnalyser.IsPinBar(
|
||||
bar,
|
||||
pinBarDir,
|
||||
0 //
|
||||
);
|
||||
bool hasBullishPinBar =
|
||||
hasPinBar &&
|
||||
IsBullish(pinBarDir);
|
||||
bool hasBearishPinBar =
|
||||
hasPinBar &&
|
||||
IsBearish(pinBarDir);
|
||||
int idx = -1;
|
||||
int range = 21;
|
||||
|
||||
//
|
||||
// Detect Order Block ...
|
||||
@@ -1348,17 +1338,233 @@ void DetectPOIs(
|
||||
if (!isActivated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
idx = FindIndex(
|
||||
ob,
|
||||
mXWZUnActivatedOBs //
|
||||
);
|
||||
if (!IsValidIndex(idx))
|
||||
{
|
||||
//
|
||||
Add(
|
||||
ob,
|
||||
mXWZUnActivatedOBs //
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
ob,
|
||||
mXWZActivatedOBs //
|
||||
);
|
||||
if (!IsValidIndex(idx))
|
||||
{
|
||||
//
|
||||
ob.To(activationBar.time);
|
||||
|
||||
//
|
||||
Add(
|
||||
ob,
|
||||
mXWZActivatedOBs //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
obBar.Clean();
|
||||
activationBar.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
obBar.Clean();
|
||||
|
||||
//
|
||||
// Detect Fair Value Gap ...
|
||||
|
||||
//
|
||||
XOHCL fvgStartBar;
|
||||
XOHCL fvgEndBar;
|
||||
XCFVG *fvg;
|
||||
ENUM_X_DIRECTION fvgDir;
|
||||
bool hasFVG = mXWZBarAnalyser.HasFairValueGap(
|
||||
bar,
|
||||
fvgStartBar,
|
||||
fvgEndBar,
|
||||
fvgDir //
|
||||
);
|
||||
bool hasBullishFVG =
|
||||
hasFVG &&
|
||||
IsBullish(fvgDir);
|
||||
bool hasBearishFVG =
|
||||
hasFVG &&
|
||||
IsBearish(fvgDir);
|
||||
if (hasFVG)
|
||||
{
|
||||
//
|
||||
fvg = new XCFVG();
|
||||
bool isInited = fvg.Init(
|
||||
fvgStartBar,
|
||||
fvgEndBar,
|
||||
fvgDir //
|
||||
);
|
||||
if (isInited)
|
||||
{
|
||||
//
|
||||
ENUM_X_DIRECTION forDir = fvg.GetDirection();
|
||||
|
||||
//
|
||||
// Check OB Not Activated ...
|
||||
XOHCL activationBar;
|
||||
bool isActivationBarBodyIn = false;
|
||||
bool isActivated = fvg.IsActivated(
|
||||
forDir,
|
||||
activationBar,
|
||||
isActivationBarBodyIn,
|
||||
false,
|
||||
_Period //
|
||||
);
|
||||
|
||||
//
|
||||
if (!isActivated)
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
fvg,
|
||||
mXWZUnActivatedFVGs //
|
||||
);
|
||||
if (!IsValidIndex(idx))
|
||||
{
|
||||
//
|
||||
Add(
|
||||
fvg,
|
||||
mXWZUnActivatedFVGs //
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
fvg,
|
||||
mXWZActivatedFVGs //
|
||||
);
|
||||
if (!IsValidIndex(idx))
|
||||
{
|
||||
//
|
||||
fvg.To(activationBar.time);
|
||||
|
||||
//
|
||||
Add(
|
||||
fvg,
|
||||
mXWZActivatedFVGs //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
activationBar.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
fvgEndBar.Clean();
|
||||
fvgStartBar.Clean();
|
||||
|
||||
//
|
||||
// Detect Supply Zone ...
|
||||
|
||||
//
|
||||
// Detect Deman Zone ...
|
||||
|
||||
//
|
||||
// Detect Support Zone ...
|
||||
|
||||
//
|
||||
XOHCL supportBar;
|
||||
XCSupportZone *supportZone;
|
||||
bool hasSupport = mXWZBarAnalyser
|
||||
.HasSupport(
|
||||
bar,
|
||||
supportBar,
|
||||
range //
|
||||
);
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
supportZone = new XCSupportZone();
|
||||
hasSupport = supportZone.Init(
|
||||
supportBar,
|
||||
range,
|
||||
true // Use Range As Start ...
|
||||
);
|
||||
|
||||
//
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
// Check OB Not Activated ...
|
||||
XOHCL activationBar;
|
||||
bool isActivationBarBodyIn = false;
|
||||
bool isActivated = supportZone.IsActivated(
|
||||
X_DIRECTION_BULLISH,
|
||||
activationBar,
|
||||
isActivationBarBodyIn,
|
||||
false,
|
||||
_Period //
|
||||
);
|
||||
|
||||
//
|
||||
if (!isActivated)
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
supportZone,
|
||||
mXWZUnActivatedSupportZones //
|
||||
);
|
||||
hasSupport = !IsValidIndex(idx);
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
supportZone,
|
||||
mXWZUnActivatedSupportZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
supportZone,
|
||||
mXWZActivatedSupportZones //
|
||||
);
|
||||
hasSupport = !IsValidIndex(idx);
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
supportZone.To(activationBar.time);
|
||||
|
||||
//
|
||||
Add(
|
||||
supportZone,
|
||||
mXWZActivatedSupportZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
activationBar.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
supportBar.Clean();
|
||||
|
||||
//
|
||||
// Detect Resistance Zone ...
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1459,7 +1665,7 @@ void UpdatePOIs(
|
||||
// Check OB Not Activated ...
|
||||
XOHCL activationBar;
|
||||
bool isActivationBarBodyIn = false;
|
||||
bool isActivated = mXWZUnActivatedOBs[i]
|
||||
bool isActivated = mXWZUnActivatedFVGs[i]
|
||||
.IsActivated(
|
||||
mXWZUnActivatedFVGs[i].GetDirection(),
|
||||
activationBar,
|
||||
@@ -1480,6 +1686,14 @@ void UpdatePOIs(
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
Add(
|
||||
mXWZUnActivatedFVGs[i],
|
||||
mXWZActivatedFVGs //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1489,6 +1703,68 @@ void UpdatePOIs(
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Support Zones ...
|
||||
count = ArraySize(mXWZUnActivatedSupportZones);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCSupportZone *tmps[];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Update To ...
|
||||
mXWZUnActivatedSupportZones[i].To(to);
|
||||
|
||||
//
|
||||
// Check Activation ...
|
||||
|
||||
//
|
||||
// Check OB Not Activated ...
|
||||
XOHCL activationBar;
|
||||
bool isActivationBarBodyIn = false;
|
||||
bool isActivated = mXWZUnActivatedSupportZones[i]
|
||||
.IsActivated(
|
||||
X_DIRECTION_BULLISH,
|
||||
activationBar,
|
||||
isActivationBarBodyIn,
|
||||
false,
|
||||
_Period //
|
||||
);
|
||||
|
||||
//
|
||||
if (!isActivated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
mXWZUnActivatedSupportZones[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
mXWZUnActivatedSupportZones[i].To(activationBar.time);
|
||||
|
||||
//
|
||||
Add(
|
||||
mXWZUnActivatedSupportZones[i],
|
||||
mXWZActivatedSupportZones //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
activationBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
tmps,
|
||||
mXWZUnActivatedSupportZones //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
@@ -1501,96 +1777,244 @@ void DrawPOIs()
|
||||
bool isCreated = false;
|
||||
|
||||
//
|
||||
mXWZDrawnObjects.Clear();
|
||||
|
||||
//
|
||||
// Order Blocks ...
|
||||
|
||||
//
|
||||
// UnActivated ...
|
||||
count = ArraySize(mXWZUnActivatedOBs);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
if (!showPOIs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateOrderBlock(
|
||||
mXWZUnActivatedOBs[i],
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Activated ...
|
||||
count = ArraySize(mXWZActivatedOBs);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
// Order Blocks ...
|
||||
bool showOrderBlocks =
|
||||
showBullishOrderBlocks ||
|
||||
showBearishOrderBlocks;
|
||||
if (showOrderBlocks)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
// UnActivated ...
|
||||
count = ArraySize(mXWZUnActivatedOBs);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOB = mXWZActivatedOBs[i];
|
||||
|
||||
//
|
||||
bool isBullish = iOB.IsBullish();
|
||||
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateOrderBlock(
|
||||
iOB,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
((XCBullishOrderBlockObject *)iObj).ZoneFill(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
((XCBearishOrderBlockObject *)iObj).ZoneFill(true);
|
||||
}
|
||||
bool isBullish = mXWZUnActivatedOBs[i].IsBullish();
|
||||
|
||||
//
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
if ((isBullish &&
|
||||
showBullishOrderBlocks) ||
|
||||
(!isBullish &&
|
||||
showBearishOrderBlocks))
|
||||
{
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateOrderBlock(
|
||||
mXWZUnActivatedOBs[i],
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Activated ...
|
||||
count = ArraySize(mXWZActivatedOBs);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOB = mXWZActivatedOBs[i];
|
||||
|
||||
//
|
||||
bool isBullish = iOB.IsBullish();
|
||||
|
||||
//
|
||||
if (showActivatedPOIs &&
|
||||
((isBullish &&
|
||||
showBullishOrderBlocks) ||
|
||||
(!isBullish &&
|
||||
showBearishOrderBlocks)))
|
||||
{
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateOrderBlock(
|
||||
iOB,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
// if (isBullish)
|
||||
// {
|
||||
// ((XCBullishOrderBlockObject *)iObj).ZoneFill(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ((XCBearishOrderBlockObject *)iObj).ZoneFill(true);
|
||||
// }
|
||||
|
||||
//
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
count = ArraySize(mXWZUnActivatedFVGs);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
bool showOrderFairValueGaps =
|
||||
showBullishFairValueGaps ||
|
||||
showBearishFairValueGaps;
|
||||
if (showOrderFairValueGaps)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
// UnActivated ...
|
||||
count = ArraySize(mXWZUnActivatedFVGs);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateFairValueGap(
|
||||
mXWZUnActivatedFVGs[i],
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
//
|
||||
bool isBullish = mXWZUnActivatedFVGs[i].IsBullish();
|
||||
|
||||
//
|
||||
if ((isBullish &&
|
||||
showBullishFairValueGaps) ||
|
||||
(!isBullish &&
|
||||
showBearishFairValueGaps))
|
||||
{
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateFairValueGap(
|
||||
mXWZUnActivatedFVGs[i],
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Activated ...
|
||||
count = ArraySize(mXWZActivatedFVGs);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCFVG *iFVG = mXWZActivatedFVGs[i];
|
||||
|
||||
//
|
||||
bool isBullish = iFVG.IsBullish();
|
||||
|
||||
//
|
||||
if (showActivatedPOIs &&
|
||||
((isBullish &&
|
||||
showBullishFairValueGaps) ||
|
||||
(!isBullish &&
|
||||
showBearishFairValueGaps)))
|
||||
{
|
||||
XCBaseObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateFairValueGap(
|
||||
iFVG,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
// if (isBullish)
|
||||
// {
|
||||
// ((XCBullishOrderBlockObject *)iObj).ZoneFill(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ((XCBearishOrderBlockObject *)iObj).ZoneFill(true);
|
||||
// }
|
||||
|
||||
//
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Support Zones ...
|
||||
if (showSupportZones)
|
||||
{
|
||||
//
|
||||
// UnActivated ...
|
||||
count = ArraySize(mXWZUnActivatedSupportZones);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZoneObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateSupportZone(
|
||||
mXWZUnActivatedSupportZones[i],
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Activated ...
|
||||
if (showActivatedPOIs)
|
||||
{
|
||||
//
|
||||
count = ArraySize(mXWZActivatedSupportZones);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZoneObject *iObj;
|
||||
isCreated = mXWZPOIDrawer
|
||||
.CreateSupportZone(
|
||||
mXWZActivatedSupportZones[i],
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
mXWZDrawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user