last worsk ...
This commit is contained in:
@@ -0,0 +1,297 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Find a Support or Resistance Zone ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Support Zone ...
|
||||||
|
// bool hasSupportZone = conditions.HasSupportZone();
|
||||||
|
// if (isLowEqualsToVale && !hasSupportZone)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// int count = state.CountSupportZones();
|
||||||
|
// if (IsValidSize(count))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// for (int i = count - 1; i >= 0; i--)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCSupportZone *iZone = state.supportZones[i];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isValid =
|
||||||
|
// vale >= iZone.Lower() &&
|
||||||
|
// vale <= iZone.Upper();
|
||||||
|
// if (isValid)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.supportZone = iZone;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// hasSupportZone = conditions.HasSupportZone();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Resistance Zone ...
|
||||||
|
// bool hasResistanceZone = conditions.HasResistanceZone();
|
||||||
|
// if (isHighEqualsToPeak && !hasResistanceZone)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// int count = state.CountResistanceZones();
|
||||||
|
// if (IsValidSize(count))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// for (int i = count - 1; i >= 0; i--)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCResistanceZone *iZone = state.resistanceZones[i];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isValid =
|
||||||
|
// peak >= iZone.Lower() &&
|
||||||
|
// peak <= iZone.Upper();
|
||||||
|
// if (isValid)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// conditions.resistanceZone = iZone;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// hasResistanceZone = conditions.HasResistanceZone();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isLowEqualsToVale &&
|
||||||
|
// hasSupportZone;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isHighEqualsToPeak &&
|
||||||
|
// hasResistanceZone;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// result = isBullish ||
|
||||||
|
// isBearish;
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Retrieve Active Zone ...
|
||||||
|
// XCBarZone *activeZone;
|
||||||
|
// result = conditions.HasActiveZone(activeZone);
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Draw ...
|
||||||
|
// if (hasSupportZone)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCSupportZoneObject *iObj;
|
||||||
|
// bool isCreated = drawer.CreateSupportZone(
|
||||||
|
// conditions.supportZone,
|
||||||
|
// iObj //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// if (hasResistanceZone)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCResistanceZoneObject *iObj;
|
||||||
|
// bool isCreated = drawer.CreateResistanceZone(
|
||||||
|
// conditions.resistanceZone,
|
||||||
|
// iObj //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSupportZone *supportZone;
|
||||||
|
XCResistanceZone *resistanceZone;
|
||||||
|
datetime activeZoneFoundedAt;
|
||||||
|
|
||||||
|
//
|
||||||
|
supportZone = NULL;
|
||||||
|
resistanceZone = NULL;
|
||||||
|
activeZoneFoundedAt = NULL;
|
||||||
|
|
||||||
|
bool HasSupportZone()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
supportZone != NULL &&
|
||||||
|
supportZone.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasResistanceZone()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
resistanceZone != NULL &&
|
||||||
|
resistanceZone.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasActiveZone(XCBarZone *&zone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
zone = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool hasSupportZone = HasSupportZone();
|
||||||
|
bool hasResistanceZone = HasResistanceZone();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = hasSupportZone ||
|
||||||
|
hasResistanceZone;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hasSupportZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
supportZone.To(TimeCurrent());
|
||||||
|
zone = supportZone;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hasResistanceZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
resistanceZone.To(TimeCurrent());
|
||||||
|
zone = resistanceZone;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Cycle Trend Based On Pivots ...
|
||||||
|
*
|
||||||
|
* @param dir: ENUM_X_DIRECTION member Reference ...
|
||||||
|
* @param numberOfPivots: Integer ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectTrend(
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
int numberOfPivots = 3 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (numberOfPivots < 2)
|
||||||
|
{
|
||||||
|
numberOfPivots = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int verifications = 0;
|
||||||
|
XValueChange changes[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish Trend ...
|
||||||
|
int peaksChangesCount = CountPeaksChanges();
|
||||||
|
if (!result &&
|
||||||
|
peaksChangesCount > numberOfPivots)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Clean(changes);
|
||||||
|
FillPeaksChanges(changes);
|
||||||
|
|
||||||
|
//
|
||||||
|
verifications = 0;
|
||||||
|
for (int i = peaksChangesCount - 1 - numberOfPivots; i < peaksChangesCount - 2; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XValueChange cChange = changes[i];
|
||||||
|
XValueChange nChange = changes[i + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
if (cChange.after > nChange.after)
|
||||||
|
{
|
||||||
|
verifications++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = verifications == numberOfPivots - 1;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
dir = X_DIRECTION_BEARISH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish Trend ...
|
||||||
|
int valesChangesCount = CountValesChanges();
|
||||||
|
if (!result &&
|
||||||
|
valesChangesCount > numberOfPivots)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Clean(changes);
|
||||||
|
FillValesChanges(changes);
|
||||||
|
|
||||||
|
//
|
||||||
|
verifications = 0;
|
||||||
|
for (int i = valesChangesCount - 1 - numberOfPivots; i < valesChangesCount - 2; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XValueChange cChange = changes[i];
|
||||||
|
XValueChange nChange = changes[i + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
if (cChange.after < nChange.after)
|
||||||
|
{
|
||||||
|
verifications++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = verifications == numberOfPivots - 1;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
dir = X_DIRECTION_BULLISH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -59,7 +59,7 @@ input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Ver
|
|||||||
input group "Risk Management";
|
input group "Risk Management";
|
||||||
input double eaR2R = 6; // Signallers Risk to Reward Ratio
|
input double eaR2R = 6; // Signallers Risk to Reward Ratio
|
||||||
input double eaVolume = 0.05; // Static Volume
|
input double eaVolume = 0.05; // Static Volume
|
||||||
input double eaRiskPercentPerBalance = 0.5; // Risk Percent Per Balance in Each Trade
|
input double eaRiskPercentPerBalance = 0.1; // Risk Percent Per Balance in Each Trade
|
||||||
input bool eaDynamicRiskManagement = false; // Dynamic Risk Management
|
input bool eaDynamicRiskManagement = false; // Dynamic Risk Management
|
||||||
input bool eaUseDynamicVolume = false; // Use Dynamic Volume
|
input bool eaUseDynamicVolume = false; // Use Dynamic Volume
|
||||||
input double eaDynamicVolumeStep = 0.01; // Increase Volume Step
|
input double eaDynamicVolumeStep = 0.01; // Increase Volume Step
|
||||||
@@ -71,10 +71,10 @@ input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 14400; // Pause
|
|||||||
//
|
//
|
||||||
// Protection ...
|
// Protection ...
|
||||||
input group "Protection";
|
input group "Protection";
|
||||||
input bool eaAllowHedging = false; // Allow Hedge Positions
|
input bool eaAllowHedging = true; // Allow Hedge Positions
|
||||||
input int eaMinOpenTradesFroHedging = 3; // Minimum Open Positions for Hedging
|
input int eaMinOpenTradesFroHedging = 3; // Minimum Open Positions for Hedging
|
||||||
input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging
|
input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging
|
||||||
input double eaHedgeingMinRequiredProfitPerVolumeStep = 0.5; // Minimum Required Profit Per Volume Step for Hedging
|
input double eaHedgeingMinRequiredProfitPerVolumeStep = 0.3; // Minimum Required Profit Per Volume Step for Hedging
|
||||||
|
|
||||||
//
|
//
|
||||||
// Alert ...
|
// Alert ...
|
||||||
|
|||||||
@@ -881,6 +881,183 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Cycle Trend Based On Pivots ...
|
||||||
|
*
|
||||||
|
* @param dir: ENUM_X_DIRECTION member Reference ...
|
||||||
|
* @param numberOfPivots: Integer ...
|
||||||
|
* @param maxAllowedLoopback: Integer ...
|
||||||
|
* @param minRequiredPivotVerification: Integer ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectTrend(
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
int numberOfPivots = 3,
|
||||||
|
int maxAllowedLoopback = 576,
|
||||||
|
int minRequiredPivotVerification = 5 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (numberOfPivots < 3)
|
||||||
|
{
|
||||||
|
numberOfPivots = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int index = 0;
|
||||||
|
double peaks[];
|
||||||
|
double vales[];
|
||||||
|
double peak = 0;
|
||||||
|
double vale = 0;
|
||||||
|
int peaksVerified = 0;
|
||||||
|
int valesVerified = 0;
|
||||||
|
bool canContinue = true;
|
||||||
|
while (canContinue)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Peak ...
|
||||||
|
bool lookupPeak = ArraySize(peaks) < numberOfPivots;
|
||||||
|
if (lookupPeak)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPeak = mX121Helper.GetPeak(index);
|
||||||
|
if (iPeak == peak)
|
||||||
|
{
|
||||||
|
peaksVerified++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (peaksVerified >= minRequiredPivotVerification)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iPeak,
|
||||||
|
peaks //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
peaksVerified = 0;
|
||||||
|
lookupPeak = ArraySize(peaks) < numberOfPivots;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
peak = iPeak;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vale ...
|
||||||
|
bool lookupVale = ArraySize(vales) < numberOfPivots;
|
||||||
|
if (lookupVale)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iVale = mX121Helper.GetVale(index);
|
||||||
|
if (iVale == vale)
|
||||||
|
{
|
||||||
|
valesVerified++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (valesVerified >= minRequiredPivotVerification)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iVale,
|
||||||
|
vales //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
valesVerified = 0;
|
||||||
|
lookupVale = ArraySize(vales) < numberOfPivots;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vale = iVale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
canContinue = index < maxAllowedLoopback &&
|
||||||
|
(lookupPeak ||
|
||||||
|
lookupVale);
|
||||||
|
if (canContinue)
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int verifications = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Peaks ...
|
||||||
|
int peaksCount = ArraySize(peaks);
|
||||||
|
if (!result &&
|
||||||
|
peaksCount == numberOfPivots)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
verifications = 0;
|
||||||
|
for (int i = 0; i < peaksCount - 1; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iValue = peaks[i];
|
||||||
|
double nValue = peaks[i + 1];
|
||||||
|
if (iValue < nValue)
|
||||||
|
{
|
||||||
|
verifications++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = verifications == numberOfPivots - 1;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
dir = X_DIRECTION_BEARISH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vales ...
|
||||||
|
int valesCount = ArraySize(vales);
|
||||||
|
if (!result &&
|
||||||
|
valesCount == numberOfPivots)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
verifications = 0;
|
||||||
|
for (int i = 0; i < valesCount - 1; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iValue = vales[i];
|
||||||
|
double nValue = vales[i + 1];
|
||||||
|
if (iValue > nValue)
|
||||||
|
{
|
||||||
|
verifications++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = verifications == numberOfPivots - 1;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
dir = X_DIRECTION_BULLISH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Change Values Actions ...
|
// Change Values Actions ...
|
||||||
|
|
||||||
@@ -1332,9 +1509,9 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Last Peaks Pivot Point ...
|
* Get Last Peaks Pivot Point ...
|
||||||
*
|
*
|
||||||
* @param pivot: XPVPivotPoint instance Reference ...
|
* @param pivot: XPVPivotPoint instance Reference ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool GetLastPeakPivotPoint(XPVPivotPoint &pivot)
|
bool GetLastPeakPivotPoint(XPVPivotPoint &pivot)
|
||||||
@@ -1410,9 +1587,9 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Last Vale Pivot Point ...
|
* Get Last Vale Pivot Point ...
|
||||||
*
|
*
|
||||||
* @param pivot: XPVPivotPoint instance Reference ...
|
* @param pivot: XPVPivotPoint instance Reference ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool GetLastValePivotPoint(XPVPivotPoint &pivot)
|
bool GetLastValePivotPoint(XPVPivotPoint &pivot)
|
||||||
|
|||||||
@@ -372,13 +372,15 @@ struct X121SMCTradeData
|
|||||||
//
|
//
|
||||||
double pVolume = _position.volume;
|
double pVolume = _position.volume;
|
||||||
double pSL = NormalizePrice(_position.sl, _position.symbol);
|
double pSL = NormalizePrice(_position.sl, _position.symbol);
|
||||||
|
double pTP = NormalizePrice(_position.tp, _position.symbol);
|
||||||
double pEntry = NormalizePrice(_position.entry, _position.symbol);
|
double pEntry = NormalizePrice(_position.entry, _position.symbol);
|
||||||
|
|
||||||
//
|
//
|
||||||
result =
|
result =
|
||||||
//
|
//
|
||||||
IsValid() &&
|
IsValid() &&
|
||||||
sl == pSL &&
|
(sl == pSL ||
|
||||||
|
tp == pTP) &&
|
||||||
entry == pEntry &&
|
entry == pEntry &&
|
||||||
pVolume == volume &&
|
pVolume == volume &&
|
||||||
_position.IsValid() &&
|
_position.IsValid() &&
|
||||||
@@ -389,6 +391,17 @@ struct X121SMCTradeData
|
|||||||
//
|
//
|
||||||
;
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
IsValid() &&
|
||||||
|
_position.IsValid() &&
|
||||||
|
_position.ticket == signal.positionId;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -3324,6 +3337,21 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
" PC (" + ToString(closeVolume) + ") On TP Level: " +
|
" PC (" + ToString(closeVolume) + ") On TP Level: " +
|
||||||
ToString(partialCloseOnTP) + " Successfully ...";
|
ToString(partialCloseOnTP) + " Successfully ...";
|
||||||
Alert(message);
|
Alert(message);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Finish Position ...
|
||||||
|
if (closeVolume == mainVolume)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Finish(
|
||||||
|
iPosition.ticket,
|
||||||
|
iPosition,
|
||||||
|
comment //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3419,6 +3447,19 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
);
|
);
|
||||||
if (IsValidSize(closedPositionsCount))
|
if (IsValidSize(closedPositionsCount))
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Finish Positions and Clear Data ...
|
||||||
|
for (int i = 0; i < ArraySize(positions); i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPosition iPosition = positions[i];
|
||||||
|
Finish(
|
||||||
|
iPosition.ticket,
|
||||||
|
iPosition,
|
||||||
|
comment //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
string message = "Hedge (" + ToString(count) + ") Positions By: " +
|
string message = "Hedge (" + ToString(count) + ") Positions By: " +
|
||||||
ToString(profitSummary) + " Successfully ...";
|
ToString(profitSummary) + " Successfully ...";
|
||||||
|
|||||||
@@ -1283,9 +1283,8 @@ class XC121SMCExpert : public XCBaseExpert
|
|||||||
void ReConfigure() override
|
void ReConfigure() override
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// TODO: Enable this on Production ...
|
ReConfigureTradeHandler();
|
||||||
// ReConfigureTradeHandler();
|
ReConfigureAllStrategies();
|
||||||
// ReConfigureAllStrategies();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1507,6 +1506,12 @@ class XC121SMCExpert : public XCBaseExpert
|
|||||||
*/
|
*/
|
||||||
void ReConfigureTradeHandler()
|
void ReConfigureTradeHandler()
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
if (mTradeHandler == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Alerts ...
|
// Configure Alerts ...
|
||||||
mTradeHandler.SetAlertPrefix(GetTag());
|
mTradeHandler.SetAlertPrefix(GetTag());
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ const string X121SMCStrategyToken = "X121SMC";
|
|||||||
//
|
//
|
||||||
const string X121SMCXTestToken = "X121XTest";
|
const string X121SMCXTestToken = "X121XTest";
|
||||||
const string X121SMCXPVOBToken = "X121XPVOB";
|
const string X121SMCXPVOBToken = "X121XPVOB";
|
||||||
|
const string X121SMCXPVDPToken = "X121XPVDP";
|
||||||
const string X121SMCXPVSupDemToken = "X121XPVSUPDEM";
|
const string X121SMCXPVSupDemToken = "X121XPVSUPDEM";
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -46,6 +47,7 @@ enum ENUM_X_121_SMC_PROVIDERS
|
|||||||
X_121_SMC_PROVIDER_NONE,
|
X_121_SMC_PROVIDER_NONE,
|
||||||
X_121_SMC_PROVIDER_XTEST,
|
X_121_SMC_PROVIDER_XTEST,
|
||||||
X_121_SMC_PROVIDER_XPVOB,
|
X_121_SMC_PROVIDER_XPVOB,
|
||||||
|
X_121_SMC_PROVIDER_XPVDP,
|
||||||
X_121_SMC_PROVIDER_XPVSUPDEM,
|
X_121_SMC_PROVIDER_XPVSUPDEM,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1960,6 +1962,11 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
|
|||||||
result = X121SMCXPVOBToken;
|
result = X121SMCXPVOBToken;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_121_SMC_PROVIDER_XPVDP:
|
||||||
|
result = X121SMCXPVDPToken;
|
||||||
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
case X_121_SMC_PROVIDER_XPVSUPDEM:
|
case X_121_SMC_PROVIDER_XPVSUPDEM:
|
||||||
result = X121SMCXPVSupDemToken;
|
result = X121SMCXPVSupDemToken;
|
||||||
@@ -1997,6 +2004,10 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
|
|||||||
{
|
{
|
||||||
result = X_121_SMC_PROVIDER_XPVOB;
|
result = X_121_SMC_PROVIDER_XPVOB;
|
||||||
}
|
}
|
||||||
|
else if (Contains(X121SMCXPVDPToken, value))
|
||||||
|
{
|
||||||
|
result = X_121_SMC_PROVIDER_XPVDP;
|
||||||
|
}
|
||||||
else if (Contains(X121SMCXPVSupDemToken, value))
|
else if (Contains(X121SMCXPVSupDemToken, value))
|
||||||
{
|
{
|
||||||
result = X_121_SMC_PROVIDER_XPVSUPDEM;
|
result = X_121_SMC_PROVIDER_XPVSUPDEM;
|
||||||
|
|||||||
+1
-1
@@ -652,4 +652,4 @@ bool DetectX121SMCTestSiganlTrigger(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -0,0 +1,986 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 X121 SMC Signal Lib
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Name:
|
||||||
|
// Description: provide all Signalling functions ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property library
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://www.saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
||||||
|
#include "../Libraries/x-121.smc.lib.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
struct X121SMCStrategyXPVDPSignalConditions
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol;
|
||||||
|
ENUM_TIMEFRAMES period;
|
||||||
|
|
||||||
|
//
|
||||||
|
double sl;
|
||||||
|
ENUM_X_DIRECTION dir;
|
||||||
|
ENUM_X_POSITION_TYPES type;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Setup Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime setupTime;
|
||||||
|
datetime triggerTime;
|
||||||
|
|
||||||
|
//
|
||||||
|
double peak;
|
||||||
|
double vale;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
X121SMCStrategyXPVDPSignalConditions()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleaning Up ...
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
sl = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
type = X_POSITION_TYPE_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
symbol = NULL;
|
||||||
|
period = NULL;
|
||||||
|
setupTime = NULL;
|
||||||
|
triggerTime = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
ExtensionClean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Setup Age ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetSetupAge()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsSetuped())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period);
|
||||||
|
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extensions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean Additional Properties ...
|
||||||
|
*/
|
||||||
|
void ExtensionClean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
peak = 0;
|
||||||
|
vale = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extension Functions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Setup Conditions ...
|
||||||
|
bool DetectX121SMCXPVDPSiganlSetup(
|
||||||
|
string _symbol,
|
||||||
|
ENUM_TIMEFRAMES _period,
|
||||||
|
//
|
||||||
|
X121SMCStrategyXPVDPSignalConditions &conditions,
|
||||||
|
//
|
||||||
|
XC121SMCCycleHelper *triggerCycleHelper,
|
||||||
|
XC121SMCCycleHelper *decisionCycleHelper,
|
||||||
|
XC121SMCCycleHelper *analyseCycleHelper,
|
||||||
|
XC121SMCCycleHelper *verificationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *consolidationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *visionCycleHelper
|
||||||
|
//
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int zIndex = 0;
|
||||||
|
int cIndex = zIndex + 1;
|
||||||
|
int pIndex = cIndex + 1;
|
||||||
|
int ppIndex = pIndex + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int loopback = 10;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = _symbol;
|
||||||
|
ENUM_TIMEFRAMES period = _period;
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.symbol = symbol;
|
||||||
|
conditions.period = period;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL zBar;
|
||||||
|
result = zBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
zIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
result = cBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
cIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
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);
|
||||||
|
|
||||||
|
//
|
||||||
|
int zoneValidationDivider = 10;
|
||||||
|
int validPivotRepetition = triggerCycleHelper.mX121Helper
|
||||||
|
.GetDonChainLength();
|
||||||
|
|
||||||
|
//
|
||||||
|
double selectedSL = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger ...
|
||||||
|
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
||||||
|
X121SMCCycleConditions triggerConditions;
|
||||||
|
result = triggerCycleHelper.GetConditions(
|
||||||
|
triggerCycleEvents,
|
||||||
|
triggerPoiEvents,
|
||||||
|
triggerConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decision ...
|
||||||
|
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
||||||
|
X121SMCCycleConditions decisionConditions;
|
||||||
|
result = decisionCycleHelper.GetConditions(
|
||||||
|
decisionCycleEvents,
|
||||||
|
decisionPoiEvents,
|
||||||
|
decisionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Analyse ...
|
||||||
|
ENUM_XPOI_EVENTS analysePoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
||||||
|
X121SMCCycleConditions analyseConditions;
|
||||||
|
result = analyseCycleHelper.GetConditions(
|
||||||
|
analyseCycleEvents,
|
||||||
|
analysePoiEvents,
|
||||||
|
analyseConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Verification ...
|
||||||
|
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
||||||
|
X121SMCCycleConditions verificationConditions;
|
||||||
|
result = verificationCycleHelper.GetConditions(
|
||||||
|
verificationCycleEvents,
|
||||||
|
verificationPoiEvents,
|
||||||
|
verificationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Consolidation ...
|
||||||
|
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
||||||
|
X121SMCCycleConditions consolidationConditions;
|
||||||
|
result = consolidationCycleHelper.GetConditions(
|
||||||
|
consolidationCycleEvents,
|
||||||
|
consolidationPoiEvents,
|
||||||
|
consolidationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vision ...
|
||||||
|
ENUM_XPOI_EVENTS visionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
||||||
|
X121SMCCycleConditions visionConditions;
|
||||||
|
result = visionCycleHelper.GetConditions(
|
||||||
|
visionCycleEvents,
|
||||||
|
visionPoiEvents,
|
||||||
|
visionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles POI States ...
|
||||||
|
XPOIState triggerState = triggerConditions.state;
|
||||||
|
XPOIState decisionState = decisionConditions.state;
|
||||||
|
XPOIState analyseState = analyseConditions.state;
|
||||||
|
XPOIState verificationState = verificationConditions.state;
|
||||||
|
XPOIState consolidationState = consolidationConditions.state;
|
||||||
|
XPOIState visionState = visionConditions.state;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Setup Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Market Trend ...
|
||||||
|
ENUM_X_DIRECTION trend;
|
||||||
|
bool hasTrend = consolidationCycleHelper
|
||||||
|
.DetectTrend(trend);
|
||||||
|
bool hasBullishTrend = hasTrend &&
|
||||||
|
IsBullish(trend);
|
||||||
|
bool hasBearishTrend = hasTrend &&
|
||||||
|
IsBearish(trend);
|
||||||
|
result = hasBullishTrend ||
|
||||||
|
hasBearishTrend;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Select Source State ...
|
||||||
|
XPOIState state = decisionState;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect High Equals to Peaks or Low Equals to Vale ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Peak ...
|
||||||
|
double peak = triggerConditions.x121Conditions.peaksBuffer[1];
|
||||||
|
bool isNewPeak = triggerConditions.x121Conditions.isNewPeak;
|
||||||
|
bool isNewPeakOverLast = triggerConditions.x121Conditions.isNewPeakOverLast;
|
||||||
|
bool isNewPeakUnderLast = triggerConditions.x121Conditions.isNewPeakUnderLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vale ...
|
||||||
|
double vale = triggerConditions.x121Conditions.valesBuffer[1];
|
||||||
|
bool isNewVale = triggerConditions.x121Conditions.isNewVale;
|
||||||
|
bool isNewValeOverLast = triggerConditions.x121Conditions.isNewValeOverLast;
|
||||||
|
bool isNewValeUnderLast = triggerConditions.x121Conditions.isNewValeUnderLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isHighEqualsToPeak =
|
||||||
|
isNewPeak &&
|
||||||
|
peak == cBar.high;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isLowEqualsToVale =
|
||||||
|
isNewVale &&
|
||||||
|
vale == cBar.low;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isHighEqualsToPeak ||
|
||||||
|
isLowEqualsToVale;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now We Have To Check DONChain Status ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double donCUpper = triggerConditions.x121Conditions.donCloseUpperBuffer[1];
|
||||||
|
double donCUpperPrev = triggerConditions.x121Conditions.donCloseUpperBuffer[2];
|
||||||
|
|
||||||
|
//
|
||||||
|
double donCLower = triggerConditions.x121Conditions.donCloseLowerBuffer[1];
|
||||||
|
double donCLowerPrev = triggerConditions.x121Conditions.donCloseLowerBuffer[2];
|
||||||
|
|
||||||
|
//
|
||||||
|
double donOUpper = triggerConditions.x121Conditions.donOpenUpperBuffer[1];
|
||||||
|
double donOUpperPrev = triggerConditions.x121Conditions.donOpenUpperBuffer[2];
|
||||||
|
|
||||||
|
//
|
||||||
|
double donOLower = triggerConditions.x121Conditions.donOpenLowerBuffer[1];
|
||||||
|
double donOLowerPrev = triggerConditions.x121Conditions.donOpenLowerBuffer[2];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonUpperBullish = donCUpper > donOUpper;
|
||||||
|
bool isDonUpperBullishPrev = donCUpperPrev > donOUpperPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonUpperBearish = donCUpper < donOUpper;
|
||||||
|
bool isDonUpperBearishPrev = donCUpperPrev < donOUpperPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonUpperSwitchedToBullish = isDonUpperBullish &&
|
||||||
|
!isDonUpperBullishPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonUpperSwitchedToBearish = isDonUpperBearish &&
|
||||||
|
!isDonUpperBearishPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonLowerBullish = donCLower > donOLower;
|
||||||
|
bool isDonLowerBullishPrev = donCLowerPrev > donOLowerPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonLowerBearish = donCLower < donOLower;
|
||||||
|
bool isDonLowerBearishPrev = donCLowerPrev < donOLowerPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonLowerSwitchedToBullish = isDonLowerBullish &&
|
||||||
|
!isDonLowerBullishPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonLowerSwitchedToBearish = isDonLowerBearish &&
|
||||||
|
!isDonLowerBearishPrev;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate State ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonInBullishState =
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
(isDonUpperBullish ||
|
||||||
|
isDonUpperSwitchedToBullish)
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
(isDonLowerBullish ||
|
||||||
|
isDonLowerSwitchedToBullish)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDonInBearishState =
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
(isDonUpperBearish ||
|
||||||
|
isDonUpperSwitchedToBearish)
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
(isDonLowerBearish ||
|
||||||
|
isDonLowerSwitchedToBearish)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summary DonChain State ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
hasBullishTrend
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
//
|
||||||
|
isDonInBullishState
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
//
|
||||||
|
(isHighEqualsToPeak ||
|
||||||
|
isLowEqualsToVale)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
hasBearishTrend
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
//
|
||||||
|
isDonInBearishState
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
//
|
||||||
|
(isHighEqualsToPeak ||
|
||||||
|
isLowEqualsToVale)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check VWap Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double vwapFast = triggerConditions.x121Conditions.vwapFastBuffer[1];
|
||||||
|
double vwapMid = triggerConditions.x121Conditions.vwapMidBuffer[1];
|
||||||
|
double vwapSlow = triggerConditions.x121Conditions.vwapSlowBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
double vwaps[3] = {
|
||||||
|
vwapFast,
|
||||||
|
vwapMid,
|
||||||
|
vwapSlow,
|
||||||
|
};
|
||||||
|
double vwapMax = GetMax(vwaps);
|
||||||
|
double vwapMin = GetMin(vwaps);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCloseOverVwapMax =
|
||||||
|
//
|
||||||
|
ask > vwapMax &&
|
||||||
|
bid > vwapMax &&
|
||||||
|
(cBar.low > vwapMax ||
|
||||||
|
cBar.close > vwapMax)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCloseUnderVwapMin =
|
||||||
|
//
|
||||||
|
ask < vwapMin &&
|
||||||
|
bid < vwapMin &&
|
||||||
|
(cBar.high < vwapMin ||
|
||||||
|
cBar.close < vwapMin)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapFastBullish = triggerConditions.x121Conditions.isVWapFastBullish;
|
||||||
|
bool isVWapFastBearish = triggerConditions.x121Conditions.isVWapFastBearish;
|
||||||
|
bool isVWapMidBullish = triggerConditions.x121Conditions.isVWapMidBullish;
|
||||||
|
bool isVWapMidBearish = triggerConditions.x121Conditions.isVWapMidBearish;
|
||||||
|
bool isVWapSlowBullish = triggerConditions.x121Conditions.isVWapSlowBullish;
|
||||||
|
bool isVWapSlowBearish = triggerConditions.x121Conditions.isVWapSlowBearish;
|
||||||
|
bool isVWapFastOverMid = triggerConditions.x121Conditions.isVWapFastOverMid;
|
||||||
|
bool isVWapMidOverSlow = triggerConditions.x121Conditions.isVWapMidOverSlow;
|
||||||
|
bool isVWapFastUnderMid = triggerConditions.x121Conditions.isVWapFastUnderMid;
|
||||||
|
bool isVWapMidUnderSlow = triggerConditions.x121Conditions.isVWapMidUnderSlow;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVwapBullishFormed =
|
||||||
|
//
|
||||||
|
// Order ...
|
||||||
|
(isVWapFastOverMid ||
|
||||||
|
isVWapMidOverSlow ||
|
||||||
|
(isVWapFastOverMid &&
|
||||||
|
isVWapMidOverSlow))
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
// State ...
|
||||||
|
((isVWapFastBullish &&
|
||||||
|
isVWapMidBullish) ||
|
||||||
|
(isVWapMidBullish &&
|
||||||
|
isVWapSlowBullish) ||
|
||||||
|
(isVWapFastBullish &&
|
||||||
|
isVWapMidBullish &&
|
||||||
|
isVWapSlowBullish))
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVwapBearishFormed =
|
||||||
|
//
|
||||||
|
// Order ...
|
||||||
|
(isVWapFastUnderMid ||
|
||||||
|
isVWapMidUnderSlow ||
|
||||||
|
(isVWapFastUnderMid &&
|
||||||
|
isVWapMidUnderSlow))
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
// State ...
|
||||||
|
((isVWapFastBearish &&
|
||||||
|
isVWapMidBearish) ||
|
||||||
|
(isVWapMidBearish &&
|
||||||
|
isVWapSlowBearish) ||
|
||||||
|
(isVWapFastBearish &&
|
||||||
|
isVWapMidBearish &&
|
||||||
|
isVWapSlowBearish))
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summar VWap State ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
isCloseOverVwapMax &&
|
||||||
|
isVwapBullishFormed;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
isCloseUnderVwapMin &&
|
||||||
|
isVwapBearishFormed;
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Sar State ...
|
||||||
|
double sar = triggerConditions.x121Conditions.sarBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isSarBullish = triggerConditions.x121Conditions.isSarBullish;
|
||||||
|
bool isSarSwitchedToBullish = triggerConditions.x121Conditions.isSarSwitchedToBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isSarBearish = triggerConditions.x121Conditions.isSarBearish;
|
||||||
|
bool isSarSwitchedToBearish = triggerConditions.x121Conditions.isSarSwitchedToBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summary Sar ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isSarBullishFormed = isSarBullish ||
|
||||||
|
isSarSwitchedToBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isSarBearishFormed = isSarBearish ||
|
||||||
|
isSarSwitchedToBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
isSarBullishFormed;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
isSarBearishFormed;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.setupTime = cTime;
|
||||||
|
conditions.dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Trigger Conditions ...
|
||||||
|
bool DetectX121SMCXPVDPSiganlTrigger(
|
||||||
|
//
|
||||||
|
X121SMCStrategyXPVDPSignalConditions &conditions,
|
||||||
|
//
|
||||||
|
string _symbol,
|
||||||
|
ENUM_TIMEFRAMES _period,
|
||||||
|
//
|
||||||
|
XC121SMCCycleHelper *triggerCycleHelper,
|
||||||
|
XC121SMCCycleHelper *decisionCycleHelper,
|
||||||
|
XC121SMCCycleHelper *analyseCycleHelper,
|
||||||
|
XC121SMCCycleHelper *verificationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *consolidationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *visionCycleHelper,
|
||||||
|
//
|
||||||
|
int maxAllowedSetupAge = 60 //
|
||||||
|
//
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = conditions.IsSetuped();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime setupTime = conditions.setupTime;
|
||||||
|
ENUM_X_DIRECTION setupDir = conditions.dir;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int zIndex = 0;
|
||||||
|
int cIndex = zIndex + 1;
|
||||||
|
int pIndex = cIndex + 1;
|
||||||
|
int ppIndex = pIndex + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int loopback = 10;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = _symbol;
|
||||||
|
ENUM_TIMEFRAMES period = _period;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL zBar;
|
||||||
|
result = zBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
zIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
result = cBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
cIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
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);
|
||||||
|
|
||||||
|
//
|
||||||
|
int zoneValidationDivider = 10;
|
||||||
|
int validPivotRepetition = triggerCycleHelper.mX121Helper
|
||||||
|
.GetDonChainLength();
|
||||||
|
|
||||||
|
//
|
||||||
|
double selectedSL = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger ...
|
||||||
|
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
||||||
|
X121SMCCycleConditions triggerConditions;
|
||||||
|
result = triggerCycleHelper.GetConditions(
|
||||||
|
triggerCycleEvents,
|
||||||
|
triggerPoiEvents,
|
||||||
|
triggerConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decision ...
|
||||||
|
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
||||||
|
X121SMCCycleConditions decisionConditions;
|
||||||
|
result = decisionCycleHelper.GetConditions(
|
||||||
|
decisionCycleEvents,
|
||||||
|
decisionPoiEvents,
|
||||||
|
decisionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Analyse ...
|
||||||
|
ENUM_XPOI_EVENTS analysePoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
||||||
|
X121SMCCycleConditions analyseConditions;
|
||||||
|
result = analyseCycleHelper.GetConditions(
|
||||||
|
analyseCycleEvents,
|
||||||
|
analysePoiEvents,
|
||||||
|
analyseConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Verification ...
|
||||||
|
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
||||||
|
X121SMCCycleConditions verificationConditions;
|
||||||
|
result = verificationCycleHelper.GetConditions(
|
||||||
|
verificationCycleEvents,
|
||||||
|
verificationPoiEvents,
|
||||||
|
verificationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Consolidation ...
|
||||||
|
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
||||||
|
X121SMCCycleConditions consolidationConditions;
|
||||||
|
result = consolidationCycleHelper.GetConditions(
|
||||||
|
consolidationCycleEvents,
|
||||||
|
consolidationPoiEvents,
|
||||||
|
consolidationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vision ...
|
||||||
|
ENUM_XPOI_EVENTS visionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
||||||
|
X121SMCCycleConditions visionConditions;
|
||||||
|
result = visionCycleHelper.GetConditions(
|
||||||
|
visionCycleEvents,
|
||||||
|
visionPoiEvents,
|
||||||
|
visionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles POI States ...
|
||||||
|
XPOIState triggerState = triggerConditions.state;
|
||||||
|
XPOIState decisionState = decisionConditions.state;
|
||||||
|
XPOIState analyseState = analyseConditions.state;
|
||||||
|
XPOIState verificationState = verificationConditions.state;
|
||||||
|
XPOIState consolidationState = consolidationConditions.state;
|
||||||
|
XPOIState visionState = visionConditions.state;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double vwapFast = triggerConditions.x121Conditions.vwapFastBuffer[1];
|
||||||
|
double vwapMid = triggerConditions.x121Conditions.vwapMidBuffer[1];
|
||||||
|
double vwapSlow = triggerConditions.x121Conditions.vwapSlowBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
double vwaps[3] = {
|
||||||
|
vwapFast,
|
||||||
|
vwapMid,
|
||||||
|
vwapSlow,
|
||||||
|
};
|
||||||
|
double vwapMax = GetMax(vwaps);
|
||||||
|
double vwapMin = GetMin(vwaps);
|
||||||
|
|
||||||
|
//
|
||||||
|
double sar = triggerConditions.x121Conditions.sarBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
IsBullish(setupDir)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
IsBearish(setupDir)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Cleanup Setup Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.triggerTime = cTime;
|
||||||
|
conditions.sl = isBullish
|
||||||
|
? MathMin(sar, vwapMin)
|
||||||
|
: MathMin(sar, vwapMax);
|
||||||
|
conditions.type = isBullish
|
||||||
|
? X_POSITION_TYPE_LONG
|
||||||
|
: X_POSITION_TYPE_SHORT;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SaherElm IT Center MQL5 X121 SMC Signal Class
|
// SaherElm IT Center MQL5 X121 SMC Signal Lib
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// Name:
|
// Name:
|
||||||
// Description: provide all Signalling functions ...
|
// Description: provide all Signalling functions ...
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SaherElm IT Center MQL5 X121 SMC Signal Class
|
// SaherElm IT Center MQL5 X121 SMC Signal Lib
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// Name:
|
// Name:
|
||||||
// Description: provide all Signalling functions ...
|
// Description: provide all Signalling functions ...
|
||||||
@@ -27,9 +27,10 @@
|
|||||||
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
#include "../Signals/x-121.smc.test.signal.class.mq5"
|
#include "../Signals/x-121.smc.test.signal.lib.mq5"
|
||||||
#include "../Signals/x-121.smc.xpvob.signal.class.mq5"
|
#include "../Signals/x-121.smc.xpvdp.signal.lib.mq5"
|
||||||
#include "../Signals/x-121.smc.xpvsupdem.signal.class.mq5"
|
#include "../Signals/x-121.smc.xpvob.signal.lib.mq5"
|
||||||
|
#include "../Signals/x-121.smc.xpvsupdem.signal.lib.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
@@ -158,6 +159,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
//
|
//
|
||||||
bool hasTestSignal = false;
|
bool hasTestSignal = false;
|
||||||
bool hasXPVOBSignal = false;
|
bool hasXPVOBSignal = false;
|
||||||
|
bool hasXPVDPSignal = false;
|
||||||
bool hasXPVSUPDEMSignal = false;
|
bool hasXPVSUPDEMSignal = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -174,8 +176,17 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
if (!hasSignal)
|
if (!hasSignal)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// hasXPVOBSignal = DetectXPVOBSignal(conditions);
|
hasXPVOBSignal = DetectXPVOBSignal(conditions);
|
||||||
// hasSignal = hasXPVOBSignal;
|
hasSignal = hasXPVOBSignal;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XPVDP Signal ...
|
||||||
|
if (!hasSignal)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasXPVDPSignal = DetectXPVDPSignal(conditions);
|
||||||
|
hasSignal = hasXPVDPSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -275,6 +286,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
//
|
//
|
||||||
// Configure Signal Protecting ...
|
// Configure Signal Protecting ...
|
||||||
if (hasXPVOBSignal ||
|
if (hasXPVOBSignal ||
|
||||||
|
hasXPVDPSignal ||
|
||||||
hasXPVSUPDEMSignal)
|
hasXPVSUPDEMSignal)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -288,7 +300,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
|
|
||||||
//
|
//
|
||||||
signal.trailSL = true;
|
signal.trailSL = true;
|
||||||
signal.trailSLStartOnReachTPLevel = 4;
|
signal.trailSLStartOnReachTPLevel = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -828,6 +840,119 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XPVDP Signal ...
|
||||||
|
X121SMCStrategyXPVDPSignalConditions mXPVDPConditions;
|
||||||
|
bool DetectXPVDPSignal(
|
||||||
|
X121SMCStrategyConditions &conditions //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime cTime = TimeCurrent();
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XPVDP;
|
||||||
|
string providerStr = ToString(provider);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Setup Conditions ...
|
||||||
|
datetime setupTime = mXPVDPConditions.setupTime;
|
||||||
|
bool isSetuped = mXPVDPConditions.IsSetuped();
|
||||||
|
ENUM_X_DIRECTION setupDir = mXPVDPConditions.dir;
|
||||||
|
if (!isSetuped)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Signal Setup ...
|
||||||
|
isSetuped = DetectX121SMCXPVDPSiganlSetup(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
mXPVDPConditions,
|
||||||
|
mTriggerCycleHelper,
|
||||||
|
mDecisionCycleHelper,
|
||||||
|
mAnalyseCycleHelper,
|
||||||
|
mVerificationCycleHelper,
|
||||||
|
mConsolidationCycleHelper,
|
||||||
|
mVisionCycleHelper //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
setupDir = mXPVDPConditions.dir;
|
||||||
|
setupTime = mXPVDPConditions.setupTime;
|
||||||
|
}
|
||||||
|
result = isSetuped;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Trigger Conditions ...
|
||||||
|
bool canTrigger = mXPVDPConditions.CanTrigger();
|
||||||
|
datetime triggerTime = mXPVDPConditions.triggerTime;
|
||||||
|
if (!canTrigger)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Signal Trigger ...
|
||||||
|
canTrigger = DetectX121SMCXPVDPSiganlTrigger(
|
||||||
|
mXPVDPConditions,
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
mTriggerCycleHelper,
|
||||||
|
mDecisionCycleHelper,
|
||||||
|
mAnalyseCycleHelper,
|
||||||
|
mVerificationCycleHelper,
|
||||||
|
mConsolidationCycleHelper,
|
||||||
|
mVisionCycleHelper //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = canTrigger;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
triggerTime = mXPVDPConditions.triggerTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Signal Direction ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish = IsBullish(setupDir);
|
||||||
|
isBearish = IsBearish(setupDir);
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Issues Signal on Conditions ...
|
||||||
|
conditions.signalDir = setupDir;
|
||||||
|
conditions.provider = providerStr;
|
||||||
|
conditions.sl = mXPVDPConditions.sl;
|
||||||
|
|
||||||
|
//
|
||||||
|
mXPVDPConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// XPVSUPDEM Signal ...
|
// XPVSUPDEM Signal ...
|
||||||
X121SMCStrategyXPVSUPDEMSignalConditions mXPVSUPDEMConditions;
|
X121SMCStrategyXPVSUPDEMSignalConditions mXPVSUPDEMConditions;
|
||||||
|
|||||||
Reference in New Issue
Block a user