last ...
This commit is contained in:
@@ -1763,6 +1763,90 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar Has Support or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param supportBar: XOHCL instance Specified Support Bar ...
|
||||
* @param rage: int,
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasSupport(
|
||||
XOHCL &bar,
|
||||
XOHCL &supportBar,
|
||||
int range = 21 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int barIndex = bar.Index() + range;
|
||||
result = IsValidIndex(barIndex);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
supportBar.Clean();
|
||||
return result;
|
||||
}
|
||||
result = supportBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
result = supportBar.low < supportBar.GetDown();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
supportBar.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double selectedValue = supportBar.GetDown();
|
||||
|
||||
//
|
||||
int llIDX = bar.FindLowestIndex(range - 1, MODE_LOW);
|
||||
result = IsValidIndex(llIDX);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
supportBar.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double llValue = iLow(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
llIDX //
|
||||
);
|
||||
|
||||
//
|
||||
result = llValue >= selectedValue;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
supportBar.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = supportBar.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Resistance Bar or not ...
|
||||
*
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3612,7 +3612,8 @@ class XCSupportZone : public XCBarZone
|
||||
*/
|
||||
bool Init(
|
||||
XOHCL &bar,
|
||||
int range = 0 //
|
||||
int range = 0,
|
||||
bool useRangeAsStart = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -3647,7 +3648,10 @@ class XCSupportZone : public XCBarZone
|
||||
int periodSeconds = PeriodSeconds(bar.period);
|
||||
|
||||
//
|
||||
datetime from = (datetime)((int)time - (range * periodSeconds));
|
||||
datetime from =
|
||||
!useRangeAsStart
|
||||
? (datetime)((int)time - (range * periodSeconds))
|
||||
: time;
|
||||
datetime to = (datetime)((int)time + (range * periodSeconds));
|
||||
|
||||
//
|
||||
@@ -6323,588 +6327,3 @@ struct XBoxZone
|
||||
};
|
||||
|
||||
//
|
||||
struct XOBFVGPivot
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
double value;
|
||||
datetime at;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XOBFVGPivot()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
value = 0;
|
||||
at = NULL;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
value > 0 &&
|
||||
IsValid(at);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
struct XOBFVG
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
XCFVG *fvg;
|
||||
XCOrderBlock *ob;
|
||||
|
||||
//
|
||||
XCSupplyZone *supplyZones[];
|
||||
XCDemandZone *demandZones[];
|
||||
|
||||
//
|
||||
XCSupportZone *supportZones[];
|
||||
XCResistanceZone *resistanceZones[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XOBFVG()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
ZeroMemory(ob);
|
||||
ZeroMemory(fvg);
|
||||
|
||||
//
|
||||
Clean(supplyZones);
|
||||
Clean(demandZones);
|
||||
Clean(supportZones);
|
||||
Clean(resistanceZones);
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsValid()
|
||||
{
|
||||
return HasOB() &&
|
||||
HasFVG();
|
||||
}
|
||||
|
||||
//
|
||||
bool HasOB()
|
||||
{
|
||||
return ob != NULL &&
|
||||
ob.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
bool HasFVG()
|
||||
{
|
||||
return fvg != NULL &&
|
||||
fvg.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupplyZones()
|
||||
{
|
||||
return HasChild(supplyZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupplyZones()
|
||||
{
|
||||
return ArraySize(supplyZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasDemandZones()
|
||||
{
|
||||
return HasChild(demandZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountDemandZones()
|
||||
{
|
||||
return ArraySize(demandZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupportZones()
|
||||
{
|
||||
return HasChild(supportZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupportZones()
|
||||
{
|
||||
return ArraySize(supportZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasResistanceZones()
|
||||
{
|
||||
return HasChild(resistanceZones);
|
||||
}
|
||||
|
||||
//
|
||||
int CountResistanceZones()
|
||||
{
|
||||
return ArraySize(resistanceZones);
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION GetDirection()
|
||||
{
|
||||
//
|
||||
ENUM_X_DIRECTION result = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
bool isValid = IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ob.GetDirection();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBullish()
|
||||
{
|
||||
return IsBullish(GetDirection());
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBearish()
|
||||
{
|
||||
return IsBearish(GetDirection());
|
||||
}
|
||||
|
||||
//
|
||||
int GetSwings(
|
||||
XOBFVGPivot &pivots[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(pivots);
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION forDir = GetDirection();
|
||||
bool isBullish = IsBullish(forDir);
|
||||
|
||||
//
|
||||
XOHCL passedBar;
|
||||
XOBFVGPivot iPivot;
|
||||
bool isPassed = false;
|
||||
double appliedPrice = 0;
|
||||
bool isBodyState = false;
|
||||
|
||||
//
|
||||
// Start ...
|
||||
isPassed = ob.IsStarted(
|
||||
forDir,
|
||||
passedBar,
|
||||
isBodyState //
|
||||
);
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
appliedPrice =
|
||||
isBullish
|
||||
? passedBar.low
|
||||
: passedBar.high;
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
iPivot.value = appliedPrice;
|
||||
iPivot.at = passedBar.time;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
pivots //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Activation ...
|
||||
isPassed = ob.IsActivated(
|
||||
forDir,
|
||||
passedBar,
|
||||
isBodyState //
|
||||
);
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
appliedPrice =
|
||||
isBullish
|
||||
? passedBar.low
|
||||
: passedBar.high;
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
iPivot.value = appliedPrice;
|
||||
iPivot.at = passedBar.time;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
pivots //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Worked ...
|
||||
isPassed = ob.IsWorked(
|
||||
forDir,
|
||||
passedBar,
|
||||
isBodyState //
|
||||
);
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
appliedPrice =
|
||||
isBullish
|
||||
? passedBar.low
|
||||
: passedBar.high;
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
iPivot.value = appliedPrice;
|
||||
iPivot.at = passedBar.time;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
pivots //
|
||||
);
|
||||
|
||||
//
|
||||
iPivot.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
passedBar.Clean();
|
||||
|
||||
//
|
||||
result = ArraySize(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void UpdateZones(
|
||||
XPOIState &state //
|
||||
)
|
||||
{
|
||||
//
|
||||
Clean(supplyZones);
|
||||
Clean(demandZones);
|
||||
Clean(supportZones);
|
||||
Clean(resistanceZones);
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
IsValid() &&
|
||||
state.HasChild();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
bool isPassed = false;
|
||||
|
||||
//
|
||||
// Supply Zones ...
|
||||
has = state.HasSupplyZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountSupplyZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupplyZone *iZone = state.supplyZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
supplyZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Demand Zones ...
|
||||
has = state.HasDemandZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountDemandZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCDemandZone *iZone = state.demandZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
demandZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Support Zones ...
|
||||
has = state.HasSupportZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountSupportZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZone *iZone = state.supportZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
supportZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance Zones ...
|
||||
has = state.HasResistanceZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = state.CountResistanceZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCResistanceZone *iZone = state.resistanceZones[i];
|
||||
|
||||
//
|
||||
isPassed = iZone.From() > ob.From();
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isPassed = IsInsideDiff(
|
||||
iZone,
|
||||
ob //
|
||||
);
|
||||
if (!isPassed)
|
||||
{
|
||||
//
|
||||
ZeroMemory(iZone);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
iZone,
|
||||
resistanceZones //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void UpdateTo(datetime value = NULL)
|
||||
{
|
||||
//
|
||||
value = NormalizeTime(value);
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
has = HasOB();
|
||||
if (has)
|
||||
{
|
||||
ob.To(value);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasFVG();
|
||||
if (has)
|
||||
{
|
||||
fvg.To(value);
|
||||
}
|
||||
|
||||
//
|
||||
// Supply Zones ...
|
||||
has = HasSupplyZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountSupplyZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
supplyZones[i].To(value);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Demand Zones ...
|
||||
has = HasDemandZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountDemandZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
demandZones[i].To(value);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Support Zones ...
|
||||
has = HasSupportZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountSupportZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
supportZones[i].To(value);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance Zones ...
|
||||
has = HasResistanceZones();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountResistanceZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
resistanceZones[i].To(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user