complete supply and demand zones ...
This commit is contained in:
@@ -1134,4 +1134,132 @@ class XCResistanceZoneObject : public XCZoneObject
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply Zone ...
|
||||||
|
class XCSupplyZoneObject : public XCZoneObject {
|
||||||
|
//
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creator ...
|
||||||
|
*
|
||||||
|
* @param chart_id: Long, Specified Chart ID ...
|
||||||
|
* @param window: Integer, Specified Chart Window ID ...
|
||||||
|
* @param zone: XCSupplyZone instance ...
|
||||||
|
* @param prefix: String ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool Create(
|
||||||
|
long chart_id,
|
||||||
|
int window,
|
||||||
|
XCSupplyZone &zone,
|
||||||
|
string prefix = NULL //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string name = zone.GetTag();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = CreateByZone(
|
||||||
|
chart_id,
|
||||||
|
name,
|
||||||
|
window,
|
||||||
|
zone,
|
||||||
|
prefix //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Object Type ...
|
||||||
|
*
|
||||||
|
* @return ( ENUM_XCHARTOBJECTS )
|
||||||
|
*/
|
||||||
|
virtual ENUM_XCHARTOBJECTS Type()
|
||||||
|
{
|
||||||
|
return X_SUPPLY_ZONE_OBJ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Demand Zone ...
|
||||||
|
class XCDemandZoneObject : public XCZoneObject {
|
||||||
|
//
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creator ...
|
||||||
|
*
|
||||||
|
* @param chart_id: Long, Specified Chart ID ...
|
||||||
|
* @param window: Integer, Specified Chart Window ID ...
|
||||||
|
* @param zone: XCDemandZone instance ...
|
||||||
|
* @param prefix: String ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool Create(
|
||||||
|
long chart_id,
|
||||||
|
int window,
|
||||||
|
XCDemandZone &zone,
|
||||||
|
string prefix = NULL //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string name = zone.GetTag();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = CreateByZone(
|
||||||
|
chart_id,
|
||||||
|
name,
|
||||||
|
window,
|
||||||
|
zone,
|
||||||
|
prefix //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Object Type ...
|
||||||
|
*
|
||||||
|
* @return ( ENUM_XCHARTOBJECTS )
|
||||||
|
*/
|
||||||
|
virtual ENUM_XCHARTOBJECTS Type()
|
||||||
|
{
|
||||||
|
return X_SUPPLY_ZONE_OBJ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -347,6 +347,36 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
mSupportAndResistanceRange = value;
|
mSupportAndResistanceRange = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply and Demand Zone(s) ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Supply and Demand Range Verifications ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int SupplyAndDemandRange()
|
||||||
|
{
|
||||||
|
return mSupplyAndDemandRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Supply and Demand Range Verifications ...
|
||||||
|
*
|
||||||
|
* @param value: Integer ...
|
||||||
|
*/
|
||||||
|
void SupplyAndDemandRange(int value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (value < 2)
|
||||||
|
{
|
||||||
|
value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mSupplyAndDemandRange = value;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Actions ...
|
// Actions ...
|
||||||
|
|
||||||
@@ -676,6 +706,71 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply And Demand Zones ...
|
||||||
|
int supDemRange = SupplyAndDemandRange();
|
||||||
|
if (supDemRange > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Supply Zone ...
|
||||||
|
isDetected = DetectSupplyZone(cBar);
|
||||||
|
if (isDetected)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ENUM_XPOI_EVENTS event = X_SUPPLY_ZONE_DETECTED;
|
||||||
|
XCSupplyZone *param;
|
||||||
|
bool hasItem = GetLastItem(
|
||||||
|
param,
|
||||||
|
mSupplyZones //
|
||||||
|
);
|
||||||
|
if (hasItem)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
NotifyEventListeners(
|
||||||
|
event,
|
||||||
|
param //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
event,
|
||||||
|
state //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Demand Zone ...
|
||||||
|
isDetected = DetectDemandZone(cBar);
|
||||||
|
if (isDetected)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ENUM_XPOI_EVENTS event = X_DEMAND_ZONE_DETECTED;
|
||||||
|
XCDemandZone *param;
|
||||||
|
bool hasItem = GetLastItem(
|
||||||
|
param,
|
||||||
|
mDemandZones //
|
||||||
|
);
|
||||||
|
if (hasItem)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
NotifyEventListeners(
|
||||||
|
event,
|
||||||
|
param //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
event,
|
||||||
|
state //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ValidatePOIs(cBar);
|
||||||
|
|
||||||
//
|
//
|
||||||
CleanupUnusedPOIs();
|
CleanupUnusedPOIs();
|
||||||
|
|
||||||
@@ -764,6 +859,10 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
//
|
//
|
||||||
Clean(mSupportZones);
|
Clean(mSupportZones);
|
||||||
Clean(mResistanceZones);
|
Clean(mResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(mSupplyZones);
|
||||||
|
Clean(mDemandZones);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -809,6 +908,9 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
|
|
||||||
//
|
//
|
||||||
SupportAndResistanceRange(7);
|
SupportAndResistanceRange(7);
|
||||||
|
|
||||||
|
//
|
||||||
|
SupplyAndDemandRange(144);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -877,6 +979,10 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
int supportZonesCount = 0;
|
int supportZonesCount = 0;
|
||||||
int resistanceZonesCount = 0;
|
int resistanceZonesCount = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
int supplyZonesCount = 0;
|
||||||
|
int demandZonesCount = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool canContinue = true;
|
bool canContinue = true;
|
||||||
|
|
||||||
@@ -947,6 +1053,20 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
ArrayReverse(mResistanceZones);
|
ArrayReverse(mResistanceZones);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
supplyZonesCount = DetectRequiredSupplyZones(barIndex);
|
||||||
|
if (supplyZonesCount == requiredPOIs)
|
||||||
|
{
|
||||||
|
ArrayReverse(mSupplyZones);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
demandZonesCount = DetectRequiredDemandZones(barIndex);
|
||||||
|
if (demandZonesCount == requiredPOIs)
|
||||||
|
{
|
||||||
|
ArrayReverse(mDemandZones);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
canContinue =
|
canContinue =
|
||||||
//
|
//
|
||||||
@@ -988,6 +1108,16 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
// Resistance Zones ...
|
// Resistance Zones ...
|
||||||
resistanceZonesCount < requiredPOIs
|
resistanceZonesCount < requiredPOIs
|
||||||
//
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
// Supply Zones ...
|
||||||
|
supplyZonesCount < requiredPOIs
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
// Demand Zones ...
|
||||||
|
demandZonesCount < requiredPOIs
|
||||||
|
//
|
||||||
;
|
;
|
||||||
if (canContinue)
|
if (canContinue)
|
||||||
{
|
{
|
||||||
@@ -1000,6 +1130,15 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate Founded POI(s) ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL instance ...
|
||||||
|
*/
|
||||||
|
void ValidatePOIs(XOHCL &bar)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup Unused Objects ...
|
* Cleanup Unused Objects ...
|
||||||
*/
|
*/
|
||||||
@@ -1037,29 +1176,29 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
//
|
//
|
||||||
// Swings ...
|
// Swings ...
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Swing Highs ...
|
// // Swing Highs ...
|
||||||
if (swingHighsCount >= maxAllowed)
|
// if (swingHighsCount >= maxAllowed)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
ArrayRemove(
|
// ArrayRemove(
|
||||||
mSwingHighs,
|
// mSwingHighs,
|
||||||
from,
|
// from,
|
||||||
count //
|
// count //
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Swing Lows ...
|
// // Swing Lows ...
|
||||||
if (swingLowsCount >= maxAllowed)
|
// if (swingLowsCount >= maxAllowed)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
ArrayRemove(
|
// ArrayRemove(
|
||||||
mSwingLows,
|
// mSwingLows,
|
||||||
from,
|
// from,
|
||||||
count //
|
// count //
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
// //
|
// //
|
||||||
// // Trading Days ...
|
// // Trading Days ...
|
||||||
@@ -2503,11 +2642,347 @@ class XCPOIDetector : public XCBaseAlert
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply and Demand Zones ...
|
||||||
|
int mSupplyAndDemandRange; // Supply and Demand Range Verifications ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Supply Zone(s) ...
|
// Supply Zone(s) ...
|
||||||
|
XCSupplyZone *mSupplyZones[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Supply Zone ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL instance ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectSupplyZone(XOHCL &bar)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = bar.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int range = SupplyAndDemandRange();
|
||||||
|
result = range > 0;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int hhIDX = -1;
|
||||||
|
double hh = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int llIDX = -1;
|
||||||
|
double ll = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = mBarAnalyser
|
||||||
|
.CalculateLoopbackHLData(
|
||||||
|
hhIDX,
|
||||||
|
hh,
|
||||||
|
llIDX,
|
||||||
|
ll,
|
||||||
|
bar,
|
||||||
|
range //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL supplyBar;
|
||||||
|
result = supplyBar.Init(
|
||||||
|
bar.symbol,
|
||||||
|
bar.period,
|
||||||
|
hhIDX //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupplyZone *supply;
|
||||||
|
supply = new XCSupplyZone();
|
||||||
|
result = supply.Init(
|
||||||
|
supplyBar,
|
||||||
|
range //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
datetime cTime = TimeCurrent();
|
||||||
|
supply.To(cTime);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
supply,
|
||||||
|
mSupplyZones //
|
||||||
|
);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XCSupplyZoneObject *iObj;
|
||||||
|
// bool isCreated = mDrawer.CreateSupplyZone(
|
||||||
|
// supply,
|
||||||
|
// iObj //
|
||||||
|
// );
|
||||||
|
// if (isCreated)
|
||||||
|
// {
|
||||||
|
// AddObjectIfNotExists(iObj);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Required Supply Zones ...
|
||||||
|
*
|
||||||
|
* @param barIndex: Integer Start bar index ...
|
||||||
|
* 0 is Default ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int DetectRequiredSupplyZones(int barIndex)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int required = MaxNumberOfRequiredPOIs();
|
||||||
|
if (required <= 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(mSupplyZones);
|
||||||
|
if (count >= required)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = count;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int range = SupplyAndDemandRange();
|
||||||
|
if (range < 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL bar;
|
||||||
|
bool isInited = bar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
DetectSupplyZone(bar);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(mSupplyZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Demand Zone(s) ...
|
// Demand Zone(s) ...
|
||||||
|
XCDemandZone *mDemandZones[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Demand Zone ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL instance ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectDemandZone(XOHCL &bar)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = bar.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int range = SupplyAndDemandRange();
|
||||||
|
result = range > 0;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int hhIDX = -1;
|
||||||
|
double hh = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int llIDX = -1;
|
||||||
|
double ll = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = mBarAnalyser
|
||||||
|
.CalculateLoopbackHLData(
|
||||||
|
hhIDX,
|
||||||
|
hh,
|
||||||
|
llIDX,
|
||||||
|
ll,
|
||||||
|
bar,
|
||||||
|
range //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL demandBar;
|
||||||
|
result = demandBar.Init(
|
||||||
|
bar.symbol,
|
||||||
|
bar.period,
|
||||||
|
llIDX //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCDemandZone *demand;
|
||||||
|
demand = new XCDemandZone();
|
||||||
|
result = demand.Init(
|
||||||
|
demandBar,
|
||||||
|
range //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
datetime cTime = TimeCurrent();
|
||||||
|
demand.To(cTime);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
demand,
|
||||||
|
mDemandZones //
|
||||||
|
);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XCDemandZoneObject *iObj;
|
||||||
|
// bool isCreated = mDrawer.CreateDemandZone(
|
||||||
|
// demand,
|
||||||
|
// iObj //
|
||||||
|
// );
|
||||||
|
// if (isCreated)
|
||||||
|
// {
|
||||||
|
// AddObjectIfNotExists(iObj);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Required Demand Zones ...
|
||||||
|
*
|
||||||
|
* @param barIndex: Integer Start bar index ...
|
||||||
|
* 0 is Default ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int DetectRequiredDemandZones(int barIndex)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int required = MaxNumberOfRequiredPOIs();
|
||||||
|
if (required <= 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(mDemandZones);
|
||||||
|
if (count >= required)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = count;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int range = SupplyAndDemandRange();
|
||||||
|
if (range < 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL bar;
|
||||||
|
bool isInited = bar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
DetectDemandZone(bar);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(mDemandZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Order Blocks ...
|
// Order Blocks ...
|
||||||
|
|||||||
@@ -1788,6 +1788,135 @@ class XCPOIDrawer : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply and Demand Zones ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Supply Object ...
|
||||||
|
*
|
||||||
|
* @param zone: XCSupplyZone instance ...
|
||||||
|
* @param object: XCSupplyZoneObject pointer ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool CreateSupplyZone(
|
||||||
|
XCSupplyZone &zone,
|
||||||
|
XCSupplyZoneObject *&object //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
object = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
zone.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string prefix = Prefix();
|
||||||
|
long chartID = ChartIdentification();
|
||||||
|
int window = SubWindowIdentification();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool fill = SupplyZoneFill();
|
||||||
|
int width = SupplyZoneWidth();
|
||||||
|
color crl = SupplyZoneColor();
|
||||||
|
ENUM_LINE_STYLE style = SupplyZoneStyle();
|
||||||
|
|
||||||
|
//
|
||||||
|
object = new XCSupplyZoneObject();
|
||||||
|
result = object.Create(
|
||||||
|
chartID,
|
||||||
|
window,
|
||||||
|
zone,
|
||||||
|
prefix //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
object.ZoneFill(fill);
|
||||||
|
object.ZoneColor(crl);
|
||||||
|
object.ZoneWidth(width);
|
||||||
|
object.ZoneStyle(style);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Demand Object ...
|
||||||
|
*
|
||||||
|
* @param zone: XCDemandZone instance ...
|
||||||
|
* @param object: XCDemandZoneObject pointer ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool CreateDemandZone(
|
||||||
|
XCDemandZone &zone,
|
||||||
|
XCDemandZoneObject *&object //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
object = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
zone.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string prefix = Prefix();
|
||||||
|
long chartID = ChartIdentification();
|
||||||
|
int window = SubWindowIdentification();
|
||||||
|
|
||||||
|
//
|
||||||
|
bool fill = DemandZoneFill();
|
||||||
|
int width = DemandZoneWidth();
|
||||||
|
color crl = DemandZoneColor();
|
||||||
|
ENUM_LINE_STYLE style = DemandZoneStyle();
|
||||||
|
|
||||||
|
//
|
||||||
|
object = new XCDemandZoneObject();
|
||||||
|
result = object.Create(
|
||||||
|
chartID,
|
||||||
|
window,
|
||||||
|
zone,
|
||||||
|
prefix //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
object.ZoneFill(fill);
|
||||||
|
object.ZoneColor(crl);
|
||||||
|
object.ZoneWidth(width);
|
||||||
|
object.ZoneStyle(style);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
protected:
|
protected:
|
||||||
//
|
//
|
||||||
@@ -1846,16 +1975,16 @@ class XCPOIDrawer : public XCBase
|
|||||||
ResistanceZoneColor(clrRed);
|
ResistanceZoneColor(clrRed);
|
||||||
|
|
||||||
//
|
//
|
||||||
SupplyZoneFill(true);
|
SupplyZoneFill(false);
|
||||||
SupplyZoneWidth(1);
|
SupplyZoneWidth(1);
|
||||||
SupplyZoneStyle(STYLE_DOT);
|
SupplyZoneStyle(STYLE_DOT);
|
||||||
SupplyZoneColor(clrMagenta);
|
SupplyZoneColor(clrRed);
|
||||||
|
|
||||||
//
|
//
|
||||||
DemandZoneFill(true);
|
DemandZoneFill(false);
|
||||||
DemandZoneWidth(1);
|
DemandZoneWidth(1);
|
||||||
DemandZoneStyle(STYLE_DOT);
|
DemandZoneStyle(STYLE_DOT);
|
||||||
DemandZoneColor(clrAqua);
|
DemandZoneColor(clrGreen);
|
||||||
|
|
||||||
//
|
//
|
||||||
BullishOrderBlockFill(true);
|
BullishOrderBlockFill(true);
|
||||||
|
|||||||
@@ -1286,11 +1286,13 @@ class XCSupplyZone : public XCBarZone
|
|||||||
* Initialize POI ...
|
* Initialize POI ...
|
||||||
*
|
*
|
||||||
* @param bar: XOHCL instance ...
|
* @param bar: XOHCL instance ...
|
||||||
|
* @param range: Integer, Detection Range ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool Init(
|
bool Init(
|
||||||
XOHCL &bar //
|
XOHCL &bar,
|
||||||
|
int range = 0 //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1317,6 +1319,21 @@ class XCSupplyZone : public XCBarZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
result = IsValid();
|
result = IsValid();
|
||||||
|
if (result &&
|
||||||
|
range > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
datetime time = bar.time;
|
||||||
|
int periodSeconds = PeriodSeconds(bar.period);
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime from = (datetime)((int)time - (range * periodSeconds));
|
||||||
|
datetime to = (datetime)((int)time + (range * periodSeconds));
|
||||||
|
|
||||||
|
//
|
||||||
|
From(from);
|
||||||
|
To(to);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -1379,11 +1396,13 @@ class XCDemandZone : public XCBarZone
|
|||||||
* Initialize POI ...
|
* Initialize POI ...
|
||||||
*
|
*
|
||||||
* @param bar: XOHCL instance ...
|
* @param bar: XOHCL instance ...
|
||||||
|
* @param range: Integer, Detection Range ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool Init(
|
bool Init(
|
||||||
XOHCL &bar //
|
XOHCL &bar,
|
||||||
|
int range = 0 //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1410,6 +1429,21 @@ class XCDemandZone : public XCBarZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
result = IsValid();
|
result = IsValid();
|
||||||
|
if (result &&
|
||||||
|
range > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
datetime time = bar.time;
|
||||||
|
int periodSeconds = PeriodSeconds(bar.period);
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime from = (datetime)((int)time - (range * periodSeconds));
|
||||||
|
datetime to = (datetime)((int)time + (range * periodSeconds));
|
||||||
|
|
||||||
|
//
|
||||||
|
From(from);
|
||||||
|
To(to);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user