This commit is contained in:
2024-12-16 19:48:01 +03:30
parent e45fee2729
commit 2a3138402d
5 changed files with 1123 additions and 275 deletions
+675
View File
@@ -8726,3 +8726,678 @@ struct XSMCStrategySetupConditions
//////////////////////////////////////////////////////////////////////////////////
//
// TODO: Remove this ...
XSMCStrategySetupConditions mTestConditions;
bool DetectTestSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_SMPV;
string providerStr = ToString(provider);
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
bool isBullish = false;
bool isBearish = false;
//
double ask = GetAsk(symbol);
double bid = GetBid(symbol);
datetime cTime = TimeCurrent();
//
double ll = cBar.FindLowest(9, MODE_LOW);
double hh = cBar.FindHighest(9, MODE_HIGH);
//
double selectedSL = 0;
//
X121SMCCycleConditions triggerConditions = conditions.triggerConditions;
X121SMCCycleConditions decisionConditions = conditions.decisionConditions;
X121SMCCycleConditions analyseConditions = conditions.analyseConditions;
X121SMCCycleConditions verificationConditions = conditions.verificationConditions;
X121SMCCycleConditions consolidationConditions = conditions.consolidationConditions;
X121SMCCycleConditions visionConditions = conditions.visionConditions;
//
XPOIState triggerState = triggerConditions.state;
XPOIState decisionState = decisionConditions.state;
XPOIState analyseState = analyseConditions.state;
XPOIState verificationState = verificationConditions.state;
XPOIState consolidationState = consolidationConditions.state;
XPOIState visionState = visionConditions.state;
//
// Retrieve Peak and Vale ...
double triggerPeak = triggerConditions.x121Conditions.peaksBuffer[0];
double triggerVale = triggerConditions.x121Conditions.valesBuffer[0];
//
int zoneValidationDivider = 10;
int validPivotRepetition = mTriggerCycleHelper.mX121Helper
.GetDonChainLength();
//
bool hasZone = false;
XPVPivotPoint validPeak;
XPVPivotPoint validVale;
bool canTrigger = false;
bool hasValidPeak = false;
bool hasValidVale = false;
datetime setupTime = NULL;
bool isZoneBreaked = false;
bool hasConsolidation = false;
XConsolidationZone lastConsolidation;
//
setupTime = mTestConditions.setupTime;
bool isSetuped = mTestConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mTestConditions.dir;
if (!isSetuped)
{
//
// Detect Valid Peaks and Vales ...
//
// Peaks ...
validPeak = mTestConditions.validPeak;
hasValidPeak = validPeak.IsValid();
if (!hasValidPeak)
{
//
// Detecte Valid Peaks ...
//
XPVPivotPoint triggerValidPeaks[];
int triggerValidPeaksCount = mTriggerCycleHelper
.FillPeakPivotPoints(triggerValidPeaks);
//
bool isValid =
IsValidSize(triggerValidPeaksCount);
if (isValid)
{
//
// Try to Find ...
for (int i = triggerValidPeaksCount - 1; i >= 0; i--)
{
//
XPVPivotPoint iPivot = triggerValidPeaks[i];
double iValue = iPivot.value;
//
bool isValid = // iValue == triggerConditions.x121Conditions.peaksBuffer[0] &&
iValue == decisionConditions.x121Conditions.peaksBuffer[0] &&
iValue == analyseConditions.x121Conditions.peaksBuffer[0] &&
iValue == verificationConditions.x121Conditions.peaksBuffer[0];
if (isValid)
{
//
validPeak = iPivot;
break;
}
}
//
hasValidPeak = validPeak.IsValid();
if (hasValidPeak)
{
//
mTestConditions.validPeak = validPeak;
//
if (!mTestConditions.validVale.IsValid())
{
//
XValueChange valesChanges[];
int valeChangesCount = mTriggerCycleHelper.FillValesChanges(valesChanges);
if (IsValidSize(valeChangesCount))
{
//
XValueChange lastChange = valesChanges[valeChangesCount - 1];
if (lastChange.IsValid())
{
//
XPVPivotPoint iPivot;
iPivot.repetition = 1;
iPivot.type = XPV_VALE;
iPivot.time = lastChange.time;
iPivot.value = lastChange.after;
if (iPivot.IsValid())
{
mTestConditions.validVale = iPivot;
}
}
}
}
}
}
}
//
// Vales ...
validVale = mTestConditions.validVale;
hasValidVale = validVale.IsValid();
if (!hasValidVale)
{
//
// Detecte Valid Vale ...
//
XPVPivotPoint triggerValidVales[];
int triggerValidValesCount = mTriggerCycleHelper
.FillValePivotPoints(triggerValidVales);
//
bool isValid =
IsValidSize(triggerValidValesCount);
if (isValid)
{
//
// Try to Find ...
for (int i = triggerValidValesCount - 1; i >= 0; i--)
{
//
XPVPivotPoint iPivot = triggerValidVales[i];
double iValue = iPivot.value;
//
bool isValid = // iValue == triggerConditions.x121Conditions.valesBuffer[0] &&
iValue == decisionConditions.x121Conditions.valesBuffer[0] &&
iValue == analyseConditions.x121Conditions.valesBuffer[0] &&
iValue == verificationConditions.x121Conditions.valesBuffer[0];
if (isValid)
{
//
validVale = iPivot;
break;
}
}
//
hasValidVale = validVale.IsValid();
if (hasValidVale)
{
//
mTestConditions.validVale = validVale;
//
if (!mTestConditions.validPeak.IsValid())
{
//
XValueChange valesChanges[];
int valeChangesCount = mTriggerCycleHelper.FillPeaksChanges(valesChanges);
if (IsValidSize(valeChangesCount))
{
//
XValueChange lastChange = valesChanges[valeChangesCount - 1];
if (lastChange.IsValid())
{
//
XPVPivotPoint iPivot;
iPivot.repetition = 1;
iPivot.type = XPV_PEAK;
iPivot.time = lastChange.time;
iPivot.value = lastChange.after;
if (iPivot.IsValid())
{
mTestConditions.validPeak = iPivot;
}
}
}
}
}
}
}
bool hasValidPivot = hasValidPeak &&
hasValidVale;
result = hasValidPivot;
if (!result)
{
return result;
}
//
mTestConditions.peak = triggerPeak;
mTestConditions.vale = triggerVale;
//
// We Sure we Have Valid Peak and Valid Vale ...
// Create a Zone ...
hasZone = mTestConditions.zone.IsValid();
if (!hasZone)
{
//
double pvZoneUpper = validPeak.value;
double pvZoneLower = validVale.value;
datetime pvZoneFrom =
validPeak.time < validVale.time
? validPeak.time
: validVale.time;
int pvZoneLoopback = iBarShift(
symbol,
period,
pvZoneFrom //
);
//
XConsolidationZone pvZone;
result = pvZone.Init(
symbol,
period,
pvZoneUpper,
pvZoneLower,
pvZoneLoopback //
);
if (!result)
{
return result;
}
//
mTestConditions.zone = pvZone;
hasZone = mTestConditions.zone.IsValid();
}
if (hasZone)
{
//
// Update Zone ...
mTestConditions.UpdateZone();
//
XCConsolidationZoneObject *iPVZoneObj;
iPVZoneObj = new XCConsolidationZoneObject();
bool isCreated = iPVZoneObj.Create(
mPOIDrawer.ChartIdentification(),
mPOIDrawer.SubWindowIdentification(),
mTestConditions.zone //
);
if (isCreated)
{
//
iPVZoneObj.ZoneWidth(4);
iPVZoneObj.ZoneColor(clrGold);
//
AddObjectIfNotExists(iPVZoneObj);
}
}
//
// Here we Have to Check Price Go into Zone ...
isZoneBreaked = mTestConditions.zone.IsBreaked();
result = isZoneBreaked;
if (!result)
{
return result;
}
//
isSetuped = true;
setupTime = cTime;
mTestConditions.setupTime = setupTime;
setupDir = mTestConditions.zone.breakDirection;
mTestConditions.dir = setupDir;
}
//
// Detect Trigger Conditions ...
canTrigger = mTestConditions.CanTrigger();
datetime triggerTime = mTestConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Consolidations ...
lastConsolidation = mTestConditions.consolidation;
hasConsolidation = lastConsolidation.IsValid();
if (!hasConsolidation)
{
//
XConsolidationZone consolidations[];
int consolidationsCount = mTriggerCycleHelper
.FillConsolidationZones(consolidations);
if (IsValidSize(consolidationsCount))
{
lastConsolidation = consolidations[consolidationsCount - 1];
}
result = lastConsolidation.IsValid();
if (!result)
{
return result;
}
XCConsolidationZoneObject *iConsolidationObj;
iConsolidationObj = new XCConsolidationZoneObject();
bool isCreated = iConsolidationObj.Create(
mPOIDrawer.ChartIdentification(),
mPOIDrawer.SubWindowIdentification(),
lastConsolidation //
);
if (isCreated)
{
//
iConsolidationObj.ZoneWidth(2);
iConsolidationObj.ZoneColor(clrLightBlue);
//
AddObjectIfNotExists(iConsolidationObj);
}
//
mTestConditions.consolidation = lastConsolidation;
hasConsolidation = mTestConditions.consolidation.IsValid();
result = hasConsolidation;
if (!result)
{
return result;
}
}
//
result =
//
hasConsolidation &&
lastConsolidation.IsBreaked() &&
lastConsolidation.breakDirection == setupDir;
if (!result)
{
//
ClearDraws();
mTestConditions.consolidation.Clean();
//
return result;
}
//
result =
setupDir == mTestConditions.zone.breakDirection &&
setupDir == mTestConditions.consolidation.breakDirection;
if (!result)
{
//
// Check Trigger Consitions ...
if (cTime - setupTime > 2400)
{
//
ClearDraws();
//
mTestConditions.Clean();
}
return result;
}
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
//
// Check Trigger Consitions ...
if (cTime - setupTime > 2400)
{
//
ClearDraws();
//
mTestConditions.Clean();
}
return result;
}
//
mTestConditions.symbol = symbol;
mTestConditions.period = period;
mTestConditions.triggerTime = cTime;
mTestConditions.sl = lastConsolidation.upper;
mTestConditions.type = isBullish
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
canTrigger = mTestConditions.CanTrigger();
triggerTime = mTestConditions.triggerTime;
result = canTrigger;
if (!result)
{
//
// Check Trigger Consitions ...
if (cTime - setupTime > 2400)
{
//
ClearDraws();
//
mTestConditions.Clean();
}
//
return result;
}
}
//
if (cTime - setupTime > 2400)
{
//
ClearDraws();
//
mTestConditions.Clean();
}
//
Print("Trigger Time ...");
//
// Issues Signal on Conditions ...
// conditions.signalDir = mTestConditions.dir;
// conditions.provider = providerStr;
// conditions.sl = mTestConditions.sl;
//
// mTestConditions.Clean();
//
return result;
}
//
// Custom Providers Conditions ...
struct XSMCStrategySetupConditions
{
//
// Props ...
//
string symbol;
ENUM_TIMEFRAMES period;
//
double sl;
ENUM_X_DIRECTION dir;
ENUM_X_POSITION_TYPES type;
//
// Setup Props ...
//
datetime setupTime;
datetime triggerTime;
XConsolidationZone zone;
XConsolidationZone consolidation;
//
double peak;
double vale;
XPVPivotPoint validPeak;
XPVPivotPoint validVale;
//
// Trigger Props ...
//
// Constructor ...
XSMCStrategySetupConditions()
{
Clean();
}
//
// Tools ...
/**
* Cleaning Up ...
*/
void Clean()
{
//
sl = 0;
//
zone.Clean();
consolidation.Clean();
dir = X_DIRECTION_NONE;
type = X_POSITION_TYPE_NONE;
//
symbol = NULL;
period = NULL;
setupTime = NULL;
triggerTime = NULL;
//
peak = 0;
vale = 0;
validPeak.Clean();
validVale.Clean();
}
/**
* Check Condition is Setting Up ...
*
* @param dir: ENUM_X_DIRECTION member, Setting Up Direction ...
*
* @return ( bool )
*/
bool IsSetuped()
{
//
bool result = false;
//
result = IsValid(setupTime) &&
HasDirection(dir);
if (!result)
{
return result;
}
//
return result;
}
/**
* Detect How we Can Trigger Signal ...
*
* @return ( bool )
*/
bool CanTrigger()
{
//
bool result = false;
//
result =
//
sl > 0 &&
IsValid(symbol) &&
IsValid(period) &&
IsValid(triggerTime) &&
type != X_POSITION_TYPE_ALL &&
type != X_POSITION_TYPE_NONE
//
;
//
return result;
}
//
// Helpers ...
void UpdateZone()
{
//
if (!zone.IsValid() ||
!validPeak.IsValid() ||
!validVale.IsValid())
{
return;
}
//
zone.upper = validPeak.value;
zone.lower = validVale.value;
//
zone.Update();
//
if (consolidation.IsValid())
{
consolidation.Update();
}
}
//
};
///////////////////////////////////////////////////////////////////////////////////
+41 -9
View File
@@ -3836,15 +3836,47 @@ struct XConsolidationZone
return;
}
//
// Check Consolidation Hounts ...
bool isHountTop = cBar.high > upper &&
cBar.low < upper &&
cBar.GetUp() < upper;
bool isHountBottom = cBar.low < lower &&
cBar.high > lower &&
cBar.GetDown() > lower;
bool isHounted = isHountTop ||
isHountBottom;
if (isHounted)
{
//
if (isHountTop)
{
upper = cBar.high;
}
//
if (isHountBottom)
{
lower = cBar.low;
}
//
return;
}
//
// Check Consolidation Breaks ...
// Update Zone ...
// Add it ...
bool isBOSTop = cBar.high > upper;
bool isBOSBottom = cBar.low < lower;
bool hasBOS = isBOSTop ||
isBOSBottom;
if (!hasBOS)
bool isBreakTop = (cBar.GetUp() > upper &&
cBar.GetDown() < upper) ||
(cBar.low > upper &&
cBar.high > upper);
bool isBreakBottom = (cBar.GetDown() < lower &&
cBar.GetUp() > lower) ||
(cBar.high < lower &&
cBar.low < lower);
bool isBreaked = isBreakTop ||
isBreakBottom;
if (!isBreaked)
{
return;
}
@@ -3852,9 +3884,9 @@ struct XConsolidationZone
//
// Calculate Break Direction ...
breakerBar = cBar;
breakDirection = isBOSTop
breakDirection = isBreakTop
? X_DIRECTION_BULLISH
: isBOSBottom
: isBreakBottom
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
@@ -812,6 +812,28 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Retrieve Last Sar Changes ...
*
* @param change: XValueChange instance ...
*
* @return ( bool )
*/
bool GetLastSarChange(XValueChange &change)
{
//
bool result = false;
//
result = GetLastItem(
change,
mSarChanges //
);
//
return result;
}
/**
* Count Saved Peaks Changes ...
*
@@ -849,6 +871,28 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Retrieve Last Peak Changes ...
*
* @param change: XValueChange instance ...
*
* @return ( bool )
*/
bool GetLastPeakChange(XValueChange &change)
{
//
bool result = false;
//
result = GetLastItem(
change,
mPeaksChanges //
);
//
return result;
}
/**
* Count Saved Vales Changes ...
*
@@ -886,6 +930,28 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Retrieve Last Vale Changes ...
*
* @param change: XValueChange instance ...
*
* @return ( bool )
*/
bool GetLastValeChange(XValueChange &change)
{
//
bool result = false;
//
result = GetLastItem(
change,
mValesChanges //
);
//
return result;
}
/**
* Count Saved VWap Order Changes ...
*
@@ -923,6 +989,28 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Retrieve Last VWap Order Changes ...
*
* @param change: XValueChange instance ...
*
* @return ( bool )
*/
bool GetLastVWapOrderChange(XValueChange &change)
{
//
bool result = false;
//
result = GetLastItem(
change,
mVWapOrderChanges //
);
//
return result;
}
/**
* Count Saved VWap State Changes ...
*
@@ -960,6 +1048,28 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Retrieve Last VWap State Changes ...
*
* @param change: XValueChange instance ...
*
* @return ( bool )
*/
bool GetLastVWapStateChange(XValueChange &change)
{
//
bool result = false;
//
result = GetLastItem(
change,
mVWapStateChanges //
);
//
return result;
}
/**
* Count Founded Consolidation Zones ...
*
@@ -997,6 +1107,28 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Retrieve Last Consolidation Breaks ...
*
* @param change: XValueChange instance ...
*
* @return ( bool )
*/
bool GetLastConsolidationZone(XConsolidationZone &zone)
{
//
bool result = false;
//
result = GetLastItem(
zone,
mConsolidationZones //
);
//
return result;
}
/**
* Count Pivot Points Change ...
*
@@ -1145,7 +1277,7 @@ class XC121SMCCycleHelper : public XCBase
virtual void Default()
{
//
ConsolidationLoopback(15);
ConsolidationLoopback(10);
MaxAllowedSavedChanges(50);
}
@@ -1549,41 +1681,29 @@ class XC121SMCCycleHelper : public XCBase
mActioveConsolidationZone.IsValid())
{
//
// Check Consolidation Breaks ...
// Update Zone ...
// Add it ...
bool isBOSTop = changeBar.high > mActioveConsolidationZone.upper;
bool isBOSBottom = changeBar.low < mActioveConsolidationZone.lower;
mActioveConsolidationZone.Update();
bool isBreaked = mActioveConsolidationZone.IsBreaked();
//
// Calculate Break Direction ...
ENUM_X_DIRECTION bosDir = isBOSTop
? X_DIRECTION_BULLISH
: isBOSBottom
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
if (isBreaked)
{
//
// Add Active to List ...
AddRef(
mActioveConsolidationZone,
mConsolidationZones //
);
//
// Update Actiove Zone ...
mActioveConsolidationZone.breakerBar = changeBar;
mActioveConsolidationZone.breakDirection = bosDir;
//
// Clean Active Zone ...
mActioveConsolidationZone.Clean();
//
// Add Active to List ...
AddRef(
mActioveConsolidationZone,
mConsolidationZones //
);
//
// Clean Active Zone ...
mActioveConsolidationZone.Clean();
//
Add(
CONSOLIDATION_BREAKED_DETECTED,
events //
);
//
Add(
CONSOLIDATION_BREAKED_DETECTED,
events //
);
}
}
}
+8
View File
@@ -2029,6 +2029,7 @@ struct XSMCStrategySetupConditions
datetime setupTime;
datetime triggerTime;
XConsolidationZone zone;
XConsolidationZone consolidation;
//
double peak;
@@ -2059,6 +2060,7 @@ struct XSMCStrategySetupConditions
//
zone.Clean();
consolidation.Clean();
dir = X_DIRECTION_NONE;
type = X_POSITION_TYPE_NONE;
@@ -2144,6 +2146,12 @@ struct XSMCStrategySetupConditions
//
zone.Update();
//
if (consolidation.IsValid())
{
consolidation.Update();
}
}
//
@@ -572,168 +572,29 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
.GetDonChainLength();
//
bool hasZone = false;
XPVPivotPoint validPeak;
XPVPivotPoint validVale;
bool canTrigger = false;
bool hasValidPeak = false;
bool hasValidVale = false;
datetime setupTime = NULL;
bool isZoneBreaked = false;
bool hasConsolidation = false;
XConsolidationZone consolidation;
//
setupTime = mTestConditions.setupTime;
bool isSetuped = mTestConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mTestConditions.dir;
if (!isSetuped)
{
//
// Detect Valid Peaks and Vales ...
//
// Peaks ...
XPVPivotPoint validPeak = mTestConditions.validPeak;
bool hasValidPeak = validPeak.IsValid();
if (!hasValidPeak)
{
//
// Detecte Valid Peaks ...
//
XPVPivotPoint triggerValidPeaks[];
int triggerValidPeaksCount = mTriggerCycleHelper
.FillPeakPivotPoints(triggerValidPeaks);
//
bool isValid =
IsValidSize(triggerValidPeaksCount);
if (isValid)
{
//
// Try to Find ...
for (int i = triggerValidPeaksCount - 1; i >= 0; i--)
{
//
XPVPivotPoint iPivot = triggerValidPeaks[i];
double iValue = iPivot.value;
//
bool isValid = iValue == triggerConditions.x121Conditions.peaksBuffer[0] &&
iValue == decisionConditions.x121Conditions.peaksBuffer[0] &&
iValue == analyseConditions.x121Conditions.peaksBuffer[0] &&
iValue == verificationConditions.x121Conditions.peaksBuffer[0];
if (isValid)
{
//
validPeak = iPivot;
break;
}
}
//
hasValidPeak = validPeak.IsValid();
if (hasValidPeak)
{
//
mTestConditions.validPeak = validPeak;
//
if (!mTestConditions.validVale.IsValid())
{
//
XValueChange valesChanges[];
int valeChangesCount = mTriggerCycleHelper.FillValesChanges(valesChanges);
if (IsValidSize(valeChangesCount))
{
//
XValueChange lastChange = valesChanges[valeChangesCount - 1];
if (lastChange.IsValid())
{
//
XPVPivotPoint iPivot;
iPivot.repetition = 1;
iPivot.type = XPV_VALE;
iPivot.time = lastChange.time;
iPivot.value = lastChange.after;
if (iPivot.IsValid())
{
mTestConditions.validVale = iPivot;
}
}
}
}
}
}
}
//
// Vales ...
XPVPivotPoint validVale = mTestConditions.validVale;
bool hasValidVale = validVale.IsValid();
if (!hasValidVale)
{
//
// Detecte Valid Vale ...
//
XPVPivotPoint triggerValidVales[];
int triggerValidValesCount = mTriggerCycleHelper
.FillValePivotPoints(triggerValidVales);
//
bool isValid =
IsValidSize(triggerValidValesCount);
if (isValid)
{
//
// Try to Find ...
for (int i = triggerValidValesCount - 1; i >= 0; i--)
{
//
XPVPivotPoint iPivot = triggerValidVales[i];
double iValue = iPivot.value;
//
bool isValid = iValue == triggerConditions.x121Conditions.valesBuffer[0] &&
iValue == decisionConditions.x121Conditions.valesBuffer[0] &&
iValue == analyseConditions.x121Conditions.valesBuffer[0] &&
iValue == verificationConditions.x121Conditions.valesBuffer[0];
if (isValid)
{
//
validVale = iPivot;
break;
}
}
//
hasValidVale = validVale.IsValid();
if (hasValidVale)
{
//
mTestConditions.validVale = validVale;
//
if (!mTestConditions.validPeak.IsValid())
{
//
XValueChange valesChanges[];
int valeChangesCount = mTriggerCycleHelper.FillPeaksChanges(valesChanges);
if (IsValidSize(valeChangesCount))
{
//
XValueChange lastChange = valesChanges[valeChangesCount - 1];
if (lastChange.IsValid())
{
//
XPVPivotPoint iPivot;
iPivot.repetition = 1;
iPivot.type = XPV_PEAK;
iPivot.time = lastChange.time;
iPivot.value = lastChange.after;
if (iPivot.IsValid())
{
mTestConditions.validPeak = iPivot;
}
}
}
}
}
}
}
bool hasValidPivot = hasValidPeak &&
hasValidVale;
result = hasValidPivot;
bool isNewPeak = triggerConditions.x121Conditions.isNewPeak;
bool isNewVale = triggerConditions.x121Conditions.isNewVale;
bool isNewPivot = isNewPeak ||
isNewVale;
result = isNewPivot;
if (!result)
{
return result;
@@ -742,108 +603,260 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
//
mTestConditions.peak = triggerPeak;
mTestConditions.vale = triggerVale;
hasConsolidation = Contains(
CONSOLIDATION_BREAKED_DETECTED,
mTriggerCycleEvents //
);
//
// We Sure we Have Valid Peak and Valid Vale ...
// Create a Zone ...
bool hasZone = mTestConditions.zone.IsValid();
if (!hasZone)
{
//
double pvZoneUpper = validPeak.value;
double pvZoneLower = validVale.value;
datetime pvZoneFrom =
validPeak.time < validVale.time
? validPeak.time
: validVale.time;
int pvZoneLoopback = iBarShift(
symbol,
period,
pvZoneFrom //
);
//
XConsolidationZone pvZone;
result = pvZone.Init(
symbol,
period,
pvZoneUpper,
pvZoneLower,
pvZoneLoopback //
);
if (!result)
{
return result;
}
//
mTestConditions.zone = pvZone;
hasZone = mTestConditions.zone.IsValid();
}
if (hasZone)
{
//
// Update Zone ...
mTestConditions.UpdateZone();
//
XCConsolidationZoneObject *iPVZoneObj;
iPVZoneObj = new XCConsolidationZoneObject();
bool isCreated = iPVZoneObj.Create(
mPOIDrawer.ChartIdentification(),
mPOIDrawer.SubWindowIdentification(),
mTestConditions.zone //
);
if (isCreated)
{
//
iPVZoneObj.ZoneWidth(4);
iPVZoneObj.ZoneColor(clrGold);
//
AddObjectIfNotExists(iPVZoneObj);
}
}
//
// Here we Have to Check Price Go into Zone ...
bool isZoneBreaked = mTestConditions.zone.IsBreaked();
result = isZoneBreaked;
result = hasConsolidation;
if (!result)
{
return result;
}
//
result = mTriggerCycleHelper
.GetLastConsolidationZone(consolidation);
if (!result)
{
return result;
}
//
// Validate Breaker Bar ...
XOHCL breakerBar;
result = consolidation.breakerBar
.GetPreviousBar(breakerBar);
//
// Find Momentum, Engulf Bar ...
//
// Engulfing ...
ENUM_X_DIRECTION engulfDir;
bool isEngulf = mTriggerCycleHelper.mBarAnalyser.IsEngulfBar(
breakerBar,
engulfDir //
);
//
// Momentum ...
ENUM_X_DIRECTION momentumDir;
bool isMomentum = mTriggerCycleHelper.mBarAnalyser.IsMomentumBar(
breakerBar,
momentumDir //
);
//
// Rejection ...
ENUM_X_DIRECTION rejectionDir;
bool isRejection = mTriggerCycleHelper.mBarAnalyser.IsRejectionBar(
breakerBar,
rejectionDir //
);
//
// Fibo Pressure ...
ENUM_X_DIRECTION fiboPresureDir;
bool hasFiboPressure = mTriggerCycleHelper.mBarAnalyser.HasFiboPressure(
breakerBar,
fiboPresureDir //
);
//
// Check Bar is Bullished ...
bool isBarBullish =
//
// Fibo Pressure ...
(hasFiboPressure &&
IsBullish(fiboPresureDir))
//
||
//
(
//
// Engulfing ...
(isEngulf &&
IsBullish(engulfDir))
//
||
//
// Momentum ...
(isMomentum &&
IsBullish(momentumDir))
//
||
//
// Rejection ...
(isRejection &&
IsBullish(rejectionDir))
//
)
//
;
//
// Check Bar is Bearish ...
bool isBarBearish =
//
// Fibo Pressure ...
(hasFiboPressure &&
IsBearish(fiboPresureDir))
//
||
//
(
//
// Engulfing ...
(isEngulf &&
IsBearish(engulfDir))
//
||
//
// Momentum ...
(isMomentum &&
IsBearish(momentumDir))
//
||
//
// Rejection ...
(isRejection &&
IsBearish(rejectionDir))
//
)
//
;
//
bool isBarPassed = isBarBullish ||
isBarBearish;
result = isBarPassed;
if (!result)
{
return result;
}
//
isBullish =
//
isBarBullish &&
IsBullish(consolidation.breakDirection)
//
;
//
isBearish =
//
isBarBearish &&
IsBearish(consolidation.breakDirection)
//
;
//
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
XCConsolidationZoneObject *iConsolidationObj;
iConsolidationObj = new XCConsolidationZoneObject();
bool isCreated = iConsolidationObj.Create(
mPOIDrawer.ChartIdentification(),
mPOIDrawer.SubWindowIdentification(),
consolidation //
);
if (isCreated)
{
//
iConsolidationObj.ZoneWidth(2);
iConsolidationObj.ZoneColor(clrLightBlue);
//
AddObjectIfNotExists(iConsolidationObj);
}
//
isSetuped = true;
setupTime = cTime;
mTestConditions.setupTime = setupTime;
setupDir = mTestConditions.zone.breakDirection;
setupDir = consolidation.breakDirection;
mTestConditions.dir = setupDir;
}
//
// Setup Forms ...
bool canTrigger = mTestConditions.CanTrigger();
// Detect Trigger Conditions ...
canTrigger = mTestConditions.CanTrigger();
datetime triggerTime = mTestConditions.triggerTime;
if (!canTrigger)
{
//
// Check Trigger Consitions ...
if (cTime - setupTime > 2400)
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
//
ClearDraws();
// Check Trigger Consitions ...
if (cTime - setupTime > 2400)
{
//
ClearDraws();
//
mTestConditions.Clean();
return false;
//
mTestConditions.Clean();
}
return result;
}
// //
// canTrigger = true;
// mTestConditions.triggerTime = cTime;
//
mTestConditions.symbol = symbol;
mTestConditions.period = period;
mTestConditions.triggerTime = cTime;
mTestConditions.sl = consolidation.upper;
mTestConditions.type = isBullish
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
canTrigger = mTestConditions.CanTrigger();
triggerTime = mTestConditions.triggerTime;
result = canTrigger;
if (!result)
{
//
// Check Trigger Consitions ...
if (cTime - setupTime > 2400)
{
//
ClearDraws();
//
mTestConditions.Clean();
}
//
return result;
}
}
//
if (cTime - setupTime > 2400)
{
//
ClearDraws();
//
mTestConditions.Clean();
}
//
Print("Trigger Time ...");
//
// Issues Signal on Conditions ...
// conditions.signalDir = mTestConditions.dir;
@@ -851,7 +864,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// conditions.sl = mTestConditions.sl;
//
// mTestConditions.Clean();
mTestConditions.Clean();
//
return result;