This commit is contained in:
2024-12-16 08:29:07 +03:30
parent 2290e174d8
commit e45fee2729
8 changed files with 6153 additions and 2535 deletions
+134
View File
@@ -63,6 +63,7 @@ enum ENUM_XCHARTOBJECTS
X_BEARISH_FVG_OBJ = 9875,
X_TICK_ZONE_OBJ = 9876,
X_TICKS_ZONE_OBJ = 9877,
X_CONSOLIDATION_ZONE_OBJ = 9878,
};
enum ENUM_X_CHART_IDS
@@ -1469,6 +1470,139 @@ class XCBullishFairValueGapObject : public XCZoneObject
}
};
class XCConsolidationZoneObject : public XCBaseObject
{
//
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param zone: XConsolidationZone instance ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XConsolidationZone &zone,
string prefix = NULL //
)
{
//
bool result = false;
//
result = zone.IsValid();
if (!result)
{
return result;
}
//
string name = zone.GetTag();
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
//
result = mRect.Create(
chart_id,
name,
window,
zone.From(),
zone.upper,
TimeCurrent(),
zone.lower //
);
//
if (result)
{
ObjName(name);
}
//
return result;
}
//
// Virtual ...
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_CONSOLIDATION_ZONE_OBJ;
}
//
// Setter(s) ...
/**
* Set Zone Width ...
*
* @param value: Integer ...
*/
void ZoneWidth(int value)
{
//
if (value < 1)
{
value = 1;
}
//
mRect.Width(value);
}
/**
* Set Zone Color ...
*
* @param value: Color ...
*/
void ZoneColor(color value)
{
mRect.Color(value);
}
/**
* Set Zone Style ...
*
* @param value: ENUM_LINE_STYLE member ...
*/
void ZoneStyle(ENUM_LINE_STYLE value)
{
mRect.Style(value);
}
/**
* Set Zone Fill ...
*
* @param value: Boolean ...
*/
void ZoneFill(bool value)
{
mRect.Fill(value);
}
//
private:
//
CChartObjectRectangle mRect;
//
};
//
// Bearish Fair Value Gaps ...
class XCBearishFairValueGapObject : public XCZoneObject
File diff suppressed because it is too large Load Diff
+38 -8
View File
@@ -44,12 +44,38 @@ enum ENUM_X_PRICE
//
enum ENUM_X_DIRECTION
{
X_DIRECTION_ALL,
X_DIRECTION_NONE,
X_DIRECTION_BULLISH,
X_DIRECTION_BEARISH,
X_DIRECTION_ALL, // All
X_DIRECTION_NONE, // None
X_DIRECTION_BULLISH, // Bullish
X_DIRECTION_BEARISH, // Bearish
};
string ToString(ENUM_X_DIRECTION value)
{
//
string result = NULL;
//
switch (value)
{
case X_DIRECTION_ALL:
result = "ALL";
break;
case X_DIRECTION_NONE:
result = "NONE";
break;
case X_DIRECTION_BULLISH:
result = "BULLISH";
break;
case X_DIRECTION_BEARISH:
result = "BEARISH";
break;
}
//
return result;
}
//
// Swing Types Enum ...
enum ENUM_X_SWING_TYPE
@@ -8571,7 +8597,8 @@ int FillPrice(
_mLoopback,
open //
);
if (!IsValidSize(result)) {
if (!IsValidSize(result))
{
return result;
}
@@ -8584,7 +8611,8 @@ int FillPrice(
_mLoopback,
high //
);
if (!IsValidSize(result)) {
if (!IsValidSize(result))
{
return result;
}
@@ -8597,7 +8625,8 @@ int FillPrice(
_mLoopback,
low //
);
if (!IsValidSize(result)) {
if (!IsValidSize(result))
{
return result;
}
@@ -8610,7 +8639,8 @@ int FillPrice(
_mLoopback,
close //
);
if (!IsValidSize(result)) {
if (!IsValidSize(result))
{
return result;
}
+128 -2
View File
@@ -3725,6 +3725,7 @@ struct XConsolidationZone
double lower; // Lower ...
//
datetime initTime;
int loopback; // Loopback ...
//
@@ -3775,6 +3776,10 @@ struct XConsolidationZone
_loopback > 0
//
;
if (!result)
{
return result;
}
//
upper = _upper;
@@ -3785,22 +3790,87 @@ struct XConsolidationZone
//
result = IsValid();
if (result)
{
initTime = TimeCurrent();
}
//
return result;
}
/**
* Update Breaked State ...
*/
void Update()
{
//
if (!IsValid())
{
return;
}
//
if (IsBreaked())
{
return;
}
//
XOHCL cBar;
bool isInited = cBar.Init(
symbol,
period,
0 //
);
if (!isInited)
{
return;
}
//
XOHCL pBar;
isInited = cBar.GetPreviousBar(pBar);
if (!isInited)
{
return;
}
//
// Check Consolidation Breaks ...
// Update Zone ...
// Add it ...
bool isBOSTop = cBar.high > upper;
bool isBOSBottom = cBar.low < lower;
bool hasBOS = isBOSTop ||
isBOSBottom;
if (!hasBOS)
{
return;
}
//
// Calculate Break Direction ...
breakerBar = cBar;
breakDirection = isBOSTop
? X_DIRECTION_BULLISH
: isBOSBottom
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
/**
* Cleanup ...
*/
void Clean()
{
//
symbol = NULL;
period = NULL;
upper = 0;
lower = 0;
loopback = 0;
symbol = NULL;
period = NULL;
initTime = NULL;
breakerBar.Clean();
breakDirection = X_DIRECTION_NONE;
}
@@ -3966,6 +4036,62 @@ struct XConsolidationZone
return result;
}
/**
* Retrieve Start Time ...
*
* @return ( datetime )
*/
datetime From()
{
//
datetime result = NULL;
//
if (!IsValid())
{
return result;
}
//
int startIndex = iBarShift(
symbol,
period,
initTime //
);
//
result = iTime(
symbol,
period,
loopback + startIndex //
);
//
return result;
}
/**
* Retrieve Unique Identifier ...
*
* @return ( string )
*/
string GetTag()
{
//
string result =
//
GetTypeName(this) + "_" +
symbol + "_" +
ToString(period) + "_" +
ToString(upper) + "_" +
ToString(lower)
//
;
//
return result;
}
//
};
+2 -1
View File
@@ -11,7 +11,8 @@
],
"C_Cpp.clang_format_style": "{ BasedOnStyle: Microsoft, UseTab: Never, IndentWidth: 4, TabWidth: 4, ColumnLimit: 0}",
"files.associations": {
"*.mq5": "cpp"
"*.mq5": "cpp",
"*.mqh": "cpp"
}
}
}
@@ -997,6 +997,145 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Count Pivot Points Change ...
*
* @return ( int )
*/
int CountPivotPoints()
{
return ArraySize(mPivotPoints);
}
/**
* Retrieve All Pivot Point Changes as a Collection ...
*
* @param pivots: XPVPivotPoint instance Reference ...
*
* @return ( int )
*/
int FillPivotPointss(XPVPivotPoint &pivots[])
{
//
int result = 0;
//
Clean(pivots);
//
int count = CountPivotPoints();
if (!IsValidSize(pivots))
{
return result;
}
//
Copy(
mPivotPoints,
pivots //
);
//
result = ArraySize(pivots);
//
return result;
}
/**
* Retrieve All Peak Pivot Point Changes as a Collection ...
*
* @param pivots: XPVPivotPoint instance Reference ...
*
* @return ( int )
*/
int FillPeakPivotPoints(XPVPivotPoint &pivots[])
{
//
int result = 0;
//
Clean(pivots);
//
int count = CountPivotPoints();
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XPVPivotPoint iPivot = mPivotPoints[i];
//
bool isValid = iPivot.IsPeak();
if (isValid)
{
//
AddRef(
iPivot,
pivots //
);
}
}
//
result = ArraySize(pivots);
//
return result;
}
/**
* Retrieve All Vale Pivot Point Changes as a Collection ...
*
* @param pivots: XPVPivotPoint instance Reference ...
*
* @return ( int )
*/
int FillValePivotPoints(XPVPivotPoint &pivots[])
{
//
int result = 0;
//
Clean(pivots);
//
int count = CountPivotPoints();
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XPVPivotPoint iPivot = mPivotPoints[i];
//
bool isValid = iPivot.IsVale();
if (isValid)
{
//
AddRef(
iPivot,
pivots //
);
}
}
//
result = ArraySize(pivots);
//
return result;
}
//
// Virtuals ...
@@ -1456,9 +1595,9 @@ class XC121SMCCycleHelper : public XCBase
int count = 0;
double value = 0;
int repetition = 0;
int minRepetition = 40;
ENUM_TIMEFRAMES period = GetPeriod();
int periodSeconds = PeriodSeconds(period);
int minRepetition = mX121Helper.GetDonChainLength();
ENUM_XPV_PIVOTS type = isNewPeak
? XPV_PEAK
: XPV_VALE;
@@ -1486,31 +1625,37 @@ class XC121SMCCycleHelper : public XCBase
}
//
value = prevChange.after;
int delayTime = ((int)lastChange.time - (int)prevChange.time);
repetition = delayTime / periodSeconds;
//
bool isValidPivot = repetition >= minRepetition;
if (isValidPivot)
if (lastChange.IsValid() &&
prevChange.IsValid())
{
//
XPVPivotPoint pivotPoint;
pivotPoint.type = type;
pivotPoint.value = value;
pivotPoint.repetition = repetition;
value = prevChange.after;
int delayTime = ((int)lastChange.time - (int)prevChange.time);
repetition = delayTime / periodSeconds;
//
AddRef(
pivotPoint,
mPivotPoints //
);
bool isValidPivot = repetition >= minRepetition;
if (isValidPivot)
{
//
XPVPivotPoint pivotPoint;
pivotPoint.type = type;
pivotPoint.value = value;
pivotPoint.time = prevChange.time;
pivotPoint.repetition = repetition;
//
Add(
PIVOT_POINT_DETECTED,
events //
);
//
AddRef(
pivotPoint,
mPivotPoints //
);
//
Add(
PIVOT_POINT_DETECTED,
events //
);
}
}
}
}
+83 -92
View File
@@ -455,6 +455,7 @@ struct XPVPivotPoint
// Props ...
double value;
int repetition;
datetime time;
ENUM_XPV_PIVOTS type;
//
@@ -474,6 +475,7 @@ struct XPVPivotPoint
{
//
value = 0;
time = NULL;
repetition = 0;
type = XPV_NONE;
}
@@ -492,6 +494,7 @@ struct XPVPivotPoint
result =
//
value > 0 &&
IsValid(time) &&
repetition > 0 &&
type != XPV_NONE
//
@@ -500,6 +503,44 @@ struct XPVPivotPoint
//
return result;
}
/**
* Check current Pivot Point is Peak or not ...
*
* @return ( bool )
*/
bool IsPeak()
{
//
bool result = false;
//
result = IsValid() &&
type == XPV_PEAK;
//
return result;
}
/**
* Check current Pivot Point is Vale or not ...
*
* @return ( bool )
*/
bool IsVale()
{
//
bool result = false;
//
result = IsValid() &&
type == XPV_VALE;
//
return result;
}
//
};
//
@@ -1967,7 +2008,7 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
//
// Custom Providers Conditions ...
struct XTestProiderConditions
struct XSMCStrategySetupConditions
{
//
// Props ...
@@ -1978,49 +2019,29 @@ struct XTestProiderConditions
//
double sl;
ENUM_X_DIRECTION dir;
ENUM_X_POSITION_TYPES type;
//
// Setup Props ...
//
bool isNewPeak;
bool isNewVale;
//
bool hasVisionSupplyZone;
XCSupplyZone *visionSupplyZone;
//
bool hasVisionDemandZone;
XCDemandZone *visionDemandZone;
//
bool hasConsolidationSupportZone;
XCSupportZone *consolidationSupportZone;
//
bool hasConsolidationResistanceZone;
XCResistanceZone *consolidationResistanceZone;
datetime setupTime;
datetime triggerTime;
XConsolidationZone zone;
//
double peak;
double vale;
//
bool hasSamePeaks;
bool hasSameVales;
//
datetime setupTime;
datetime triggerTime;
XPVPivotPoint validPeak;
XPVPivotPoint validVale;
//
// Trigger Props ...
//
// Constructor ...
XTestProiderConditions()
XSMCStrategySetupConditions()
{
Clean();
}
@@ -2035,31 +2056,23 @@ struct XTestProiderConditions
{
//
sl = 0;
peak = 0;
vale = 0;
//
isNewPeak = false;
isNewVale = false;
hasSamePeaks = false;
hasSameVales = false;
hasVisionSupplyZone = false;
hasVisionDemandZone = false;
hasConsolidationSupportZone = false;
hasConsolidationResistanceZone = false;
//
zone.Clean();
dir = X_DIRECTION_NONE;
type = X_POSITION_TYPE_NONE;
//
symbol = NULL;
period = NULL;
triggerTime = NULL;
setupTime = NULL;
visionSupplyZone = NULL;
visionDemandZone = NULL;
consolidationSupportZone = NULL;
consolidationResistanceZone = NULL;
triggerTime = NULL;
//
peak = 0;
vale = 0;
validPeak.Clean();
validVale.Clean();
}
/**
@@ -2069,69 +2082,26 @@ struct XTestProiderConditions
*
* @return ( bool )
*/
bool IsSetuped(
ENUM_X_DIRECTION &dir //
)
bool IsSetuped()
{
//
bool result = false;
//
dir = X_DIRECTION_NONE;
//
result = IsValid(setupTime);
result = IsValid(setupTime) &&
HasDirection(dir);
if (!result)
{
return result;
}
//
bool isBullish =
//
isNewVale &&
hasSamePeaks &&
hasSameVales &&
hasVisionDemandZone &&
visionDemandZone != NULL &&
visionDemandZone.IsValid()
//
;
//
bool isBearish =
//
isNewPeak &&
hasSamePeaks &&
hasSameVales &&
hasVisionSupplyZone &&
visionSupplyZone != NULL &&
visionSupplyZone.IsValid()
//
;
//
result =
isBullish ||
isBearish;
if (!result)
{
return result;
}
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
return result;
}
/**
* Detect How we Can Trigger Signal ...
*
*
* @return ( bool )
*/
bool CanTrigger()
@@ -2155,6 +2125,27 @@ struct XTestProiderConditions
return result;
}
//
// Helpers ...
void UpdateZone()
{
//
if (!zone.IsValid() ||
!validPeak.IsValid() ||
!validVale.IsValid())
{
return;
}
//
zone.upper = validPeak.value;
zone.lower = validVale.value;
//
zone.Update();
}
//
};
File diff suppressed because it is too large Load Diff