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
@@ -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