Complete Support and Resistance POI ...

This commit is contained in:
2024-11-12 21:51:07 +03:30
parent 43ee49b32f
commit 797917e30a
5 changed files with 998 additions and 56 deletions
+444 -19
View File
@@ -317,6 +317,36 @@ class XCPOIDetector : public XCBaseAlert
mRejectionBarShadowPercent = value;
}
//
// Support and Resistance Zone(s) ...
/**
* Get Support and Resistance Range for Verification ...
*
* @return ( int )
*/
int SupportAndResistanceRange()
{
return mSupportAndResistanceRange;
}
/**
* Set Support and Resistance Range for Verification ...
*
* @param value: Integer ...
*/
void SupportAndResistanceRange(int value)
{
//
if (value < 2)
{
value = 2;
}
//
mSupportAndResistanceRange = value;
}
//
// Actions ...
@@ -574,6 +604,78 @@ class XCPOIDetector : public XCBaseAlert
);
}
//
// Support and Resistance Zones ...
int supResRange = SupportAndResistanceRange();
if (supResRange > 0)
{
//
XOHCL supResBar;
isInited = supResBar.Init(
symbol,
period,
zIndex + supResRange //
);
if (isInited)
{
//
// Support Zones ...
isDetected = DetectSupportZone(supResBar);
if (isDetected)
{
//
ENUM_XPOI_EVENTS event = X_SUPPORT_ZONE_DETECTED;
XCSupportZone *param;
bool hasItem = GetLastItem(
param,
mSupportZones //
);
if (hasItem)
{
//
NotifyEventListeners(
event,
param //
);
}
//
Add(
event,
state //
);
}
//
// Resistance Zones ...
isDetected = DetectResistanceZone(supResBar);
if (isDetected)
{
//
ENUM_XPOI_EVENTS event = X_RESISTANCE_ZONE_DETECTED;
XCResistanceZone *param;
bool hasItem = GetLastItem(
param,
mResistanceZones //
);
if (hasItem)
{
//
NotifyEventListeners(
event,
param //
);
}
//
Add(
event,
state //
);
}
}
}
//
CleanupUnusedPOIs();
@@ -658,6 +760,10 @@ class XCPOIDetector : public XCBaseAlert
//
Clean(mBullishRejectionBars);
Clean(mBearishRejectionBars);
//
Clean(mSupportZones);
Clean(mResistanceZones);
}
/**
@@ -700,6 +806,9 @@ class XCPOIDetector : public XCBaseAlert
//
RejectionBarExtendRange(0);
RejectionBarShadowPercent(55);
//
SupportAndResistanceRange(7);
}
//
@@ -764,6 +873,10 @@ class XCPOIDetector : public XCBaseAlert
int bullishRejectionBarsCount = 0;
int bearishRejectionBarsCount = 0;
//
int supportZonesCount = 0;
int resistanceZonesCount = 0;
//
bool canContinue = true;
@@ -818,6 +931,22 @@ class XCPOIDetector : public XCBaseAlert
ArrayReverse(mBearishRejectionBars);
}
//
// Support Zone(s) ...
supportZonesCount = DetectRequiredSupportZones(barIndex);
if (supportZonesCount == requiredPOIs)
{
ArrayReverse(mSupportZones);
}
//
// Resistance Zone(s) ...
resistanceZonesCount = DetectRequiredResistanceZones(barIndex);
if (resistanceZonesCount == requiredPOIs)
{
ArrayReverse(mResistanceZones);
}
//
canContinue =
//
@@ -849,6 +978,16 @@ class XCPOIDetector : public XCBaseAlert
// Bearish Rejection Bars ...
bearishRejectionBarsCount < requiredPOIs
//
||
//
// Support Zones ...
supportZonesCount < requiredPOIs
//
||
//
// Resistance Zones ...
resistanceZonesCount < requiredPOIs
//
;
if (canContinue)
{
@@ -1863,16 +2002,16 @@ class XCPOIDetector : public XCBaseAlert
mBullishRejectionBars //
);
//
XCBullishRejectionObject *iObj;
bool isCreated = mDrawer.CreateBullishRejectionBar(
rejectionBar,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
// //
// XCBullishRejectionObject *iObj;
// bool isCreated = mDrawer.CreateBullishRejectionBar(
// rejectionBar,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
}
}
@@ -1995,15 +2134,15 @@ class XCPOIDetector : public XCBaseAlert
);
//
XCBearishRejectionObject *iObj;
bool isCreated = mDrawer.CreateBearishRejectionBar(
rejectionBar,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
// XCBearishRejectionObject *iObj;
// bool isCreated = mDrawer.CreateBearishRejectionBar(
// rejectionBar,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
}
}
@@ -2072,11 +2211,297 @@ class XCPOIDetector : public XCBaseAlert
return result;
}
//
// Support and Resistance Zone ...
int mSupportAndResistanceRange; // Support and Resistance Range for Verification ...
//
// Support Zone(s) ...
XCSupportZone *mSupportZones[]; // Holds Founded Support Zones ...
/**
* Detect Support Zone ...
*
* @param bar: XOHCL instance ...
*
* @return ( bool )
*/
bool DetectSupportZone(XOHCL &bar)
{
//
bool result = false;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
int range = SupportAndResistanceRange();
int barIndex = bar.Index();
result = range > 0 &&
barIndex >= range;
if (!result)
{
return result;
}
//
result = mBarAnalyser.IsSupport(
bar,
range //
);
if (result)
{
//
XCSupportZone *support;
support = new XCSupportZone();
result = support.Init(
bar,
range //
);
//
if (result)
{
//
datetime cTime = TimeCurrent();
support.To(cTime);
//
Add(
support,
mSupportZones //
);
// //
// XCSupportZoneObject *iObj;
// bool isCreated = mDrawer.CreateSupportZone(
// support,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
}
}
//
return result;
}
/**
* Detect Required Support Zones ...
*
* @param barIndex: Integer Start bar index ...
* 0 is Default ...
*
* @return ( int )
*/
int DetectRequiredSupportZones(int barIndex = 0)
{
//
int result = 0;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int required = MaxNumberOfRequiredPOIs();
if (required <= 0)
{
return result;
}
//
int count = ArraySize(mSupportZones);
if (count >= required)
{
//
result = count;
return result;
}
//
int range = SupportAndResistanceRange();
if (range < 0 || barIndex < range)
{
return result;
}
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL bar;
bool isInited = bar.Init(
symbol,
period,
barIndex //
);
if (!isInited)
{
return result;
}
//
DetectSupportZone(bar);
//
result = ArraySize(mSupportZones);
//
return result;
}
//
// Resistance Zone(s) ...
XCResistanceZone *mResistanceZones[]; // Holds Founded Resistance Zones ...
/**
* Detect Resistance Zone ...
*
* @param bar: XOHCL instance ...
*
* @return ( bool )
*/
bool DetectResistanceZone(XOHCL &bar)
{
//
bool result = false;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
int range = SupportAndResistanceRange();
int barIndex = bar.Index();
result = range > 0 &&
barIndex >= range;
if (!result)
{
return result;
}
//
result = mBarAnalyser.IsResistance(
bar,
range //
);
if (result)
{
//
XCResistanceZone *resistance;
resistance = new XCResistanceZone();
result = resistance.Init(
bar,
range //
);
//
if (result)
{
//
Add(
resistance,
mResistanceZones //
);
// //
// XCResistanceZoneObject *iObj;
// bool isCreated = mDrawer.CreateResistanceZone(
// resistance,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
}
}
//
return result;
}
/**
* Detect Required Resistance Zones ...
*
* @param barIndex: Integer Start bar index ...
* 0 is Default ...
*
* @return ( int )
*/
int DetectRequiredResistanceZones(int barIndex = 0)
{
//
int result = 0;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int required = MaxNumberOfRequiredPOIs();
if (required <= 0)
{
return result;
}
//
int count = ArraySize(mResistanceZones);
if (count >= required)
{
//
result = count;
return result;
}
//
int range = SupportAndResistanceRange();
if (range < 0 || barIndex < range)
{
return result;
}
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL bar;
bool isInited = bar.Init(
symbol,
period,
barIndex //
);
if (!isInited)
{
return result;
}
//
DetectResistanceZone(bar);
//
result = ArraySize(mResistanceZones);
//
return result;
}
//
// Supply Zone(s) ...