add support for get verifications from other time frames ...

This commit is contained in:
2024-06-14 09:00:28 +03:30
parent e12f7f72c5
commit 487896a078
3 changed files with 819 additions and 99 deletions
+484
View File
@@ -2024,6 +2024,490 @@ struct X121SignalGenerator
return result;
}
//
// Retrieve Long Verifications ...
bool HasLongVerifications(
X121SetupConditions &conditions[] // Conditions Collection
)
{
//
bool result = false;
//
int count = ArraySize(conditions);
result = IsValidSize(count);
if (!result)
{
return result;
}
//
// Loop through Conditions to Get Verifications ...
for (int i = count - 1; i >= 0; i--)
{
//
X121SetupConditions iConditions = conditions[i];
//
result = IsConditionsValidForLong(iConditions);
if (result)
{
break;
}
}
//
return result;
}
//
bool IsConditionsValidForLong(
X121SetupConditions &conditions,
int verification = 4 //
)
{
//
bool result = false;
//
int signs = 0;
//
// XTD ...
bool isTDPassed =
//
conditions.tdConditions.isBullish ||
conditions.tdConditions.isSwitchedToBullish
//
;
if (isTDPassed)
{
signs++;
}
//
// XHK ...
bool isHKPassed =
//
(conditions.hkConditions.isHKBullish ||
conditions.hkConditions.isHKSwitchedToBullish)
//
||
//
(conditions.hkConditions.isSMHKBullish ||
conditions.hkConditions.isSMHKSwitchedToBullish)
//
;
if (isHKPassed)
{
signs++;
}
//
// XCHE ...
bool isCHEPassed =
//
conditions.cheConditions.isBullish ||
conditions.cheConditions.isStrongBullish ||
conditions.cheConditions.isSwitchedToBullish ||
conditions.cheConditions.isStrongSwitchedToBullish
//
;
if (isCHEPassed)
{
signs++;
}
//
// XICH ...
bool isICHPassed =
//
(conditions.ichConditions.isTenkanSenOverKijunSen ||
conditions.ichConditions.isTenkanSenCrossedOverKijunSen)
//
&&
//
(conditions.ichConditions.isSenkouSpanAOverB ||
conditions.ichConditions.isSenkouSpanAOverLast ||
conditions.ichConditions.isSenkouSpanACrossedOverB ||
conditions.ichConditions.isSenkouSpanACrossedOverLast)
//
&&
//
(conditions.ichConditions.isFutureSenkouSpanAOverB ||
conditions.ichConditions.isFutureSenkouSpanAOverLast ||
conditions.ichConditions.isFutureSenkouSpanACrossedOverB ||
conditions.ichConditions.isFutureSenkouSpanACrossedOverLast)
//
;
if (isICHPassed)
{
signs++;
}
//
// XSTR ...
bool isSTRPassed =
//
conditions.strConditions.isTrendBullish ||
conditions.strConditions.isTrendSwitchedToBullish
//
;
if (isSTRPassed)
{
signs++;
}
//
// XMRB ...
bool isMRBPassed =
//
conditions.mrbConditions.isFastOverSlow ||
conditions.mrbConditions.isFastCrossedOverSlow
//
;
if (isMRBPassed)
{
signs++;
}
//
// XVLM ...
bool isVLMPassed =
//
conditions.vlmConditions.isVolumeBullish ||
conditions.vlmConditions.isVolumeOverLast ||
conditions.vlmConditions.isVolumeChangedToBullish
//
;
if (isVLMPassed)
{
signs++;
}
//
// XSSLC ...
bool isSSLCPassed =
//
conditions.sslcConditions.isBullish ||
conditions.sslcConditions.isSwitchedToBullish
//
;
if (isSSLCPassed)
{
signs++;
}
//
// XHULL ...
bool isHULLPassed =
//
conditions.hullConditions.isBullish ||
conditions.hullConditions.isUpBullish ||
conditions.hullConditions.isDownBullish ||
conditions.hullConditions.isSwitchedToBullish
//
;
if (isHULLPassed)
{
signs++;
}
//
// XADX ...
bool isADXTDPassed =
//
conditions.adxtdConditions.isBullish ||
conditions.adxtdConditions.isSwitchedToBullish ||
conditions.adxtdConditions.isStrongSwitchedToBullish
//
;
if (isADXTDPassed)
{
signs++;
}
//
// XMATD ...
bool isMATDPassed =
//
((conditions.matdConditions.isBullish ||
conditions.matdConditions.isSwitchedToBullish)
//
||
//
((conditions.matdConditions.isFastOverSlow ||
conditions.matdConditions.isFastCrossedOverSlow)
//
&&
//
(conditions.matdConditions.isMidOverSlow ||
conditions.matdConditions.isMidCrossedOverSlow)))
//
||
//
(conditions.matdConditions.isSARBullish ||
conditions.matdConditions.isSARSwitchedToBullish)
//
;
if (isMATDPassed)
{
signs++;
}
//
result =
//
signs > verification
//
;
//
return result;
}
//
// Retrieve Short Verifications ...
bool HasShortVerifications(
X121SetupConditions &conditions[] // Conditions Collection
)
{
//
bool result = false;
//
int count = ArraySize(conditions);
result = IsValidSize(count);
if (!result)
{
return result;
}
//
// Loop through Conditions to Get Verifications ...
for (int i = count - 1; i >= 0; i--)
{
//
X121SetupConditions iConditions = conditions[i];
//
result = IsConditionsValidForShort(iConditions);
if (result)
{
break;
}
}
//
return result;
}
//
bool IsConditionsValidForShort(
X121SetupConditions &conditions,
int verification = 4 //
)
{
//
bool result = false;
//
int signs = 0;
//
// XTD ...
bool isTDPassed =
//
conditions.tdConditions.isBearish ||
conditions.tdConditions.isSwitchedToBearish
//
;
if (isTDPassed)
{
signs++;
}
//
// XHK ...
bool isHKPassed =
//
(conditions.hkConditions.isHKBearish ||
conditions.hkConditions.isHKSwitchedToBearish)
//
||
//
(conditions.hkConditions.isSMHKBearish ||
conditions.hkConditions.isSMHKSwitchedToBearish)
//
;
if (isHKPassed)
{
signs++;
}
//
// XCHE ...
bool isCHEPassed =
//
conditions.cheConditions.isBearish ||
conditions.cheConditions.isStrongBearish ||
conditions.cheConditions.isSwitchedToBearish ||
conditions.cheConditions.isStrongSwitchedToBearish
//
;
if (isCHEPassed)
{
signs++;
}
//
// XICH ...
bool isICHPassed =
//
(conditions.ichConditions.isTenkanSenUnderKijunSen ||
conditions.ichConditions.isTenkanSenCrossedUnderKijunSen)
//
&&
//
(conditions.ichConditions.isSenkouSpanAUnderB ||
conditions.ichConditions.isSenkouSpanAUnderLast ||
conditions.ichConditions.isSenkouSpanACrossedUnderB ||
conditions.ichConditions.isSenkouSpanACrossedUnderLast)
//
&&
//
(conditions.ichConditions.isFutureSenkouSpanAUnderB ||
conditions.ichConditions.isFutureSenkouSpanAUnderLast ||
conditions.ichConditions.isFutureSenkouSpanACrossedUnderB ||
conditions.ichConditions.isFutureSenkouSpanACrossedUnderLast)
//
;
if (isICHPassed)
{
signs++;
}
//
// XSTR ...
bool isSTRPassed =
//
conditions.strConditions.isTrendBearish ||
conditions.strConditions.isTrendSwitchedToBearish
//
;
if (isSTRPassed)
{
signs++;
}
//
// XMRB ...
bool isMRBPassed =
//
conditions.mrbConditions.isFastUnderSlow ||
conditions.mrbConditions.isFastCrossedUnderSlow
//
;
if (isMRBPassed)
{
signs++;
}
//
// XVLM ...
bool isVLMPassed =
//
conditions.vlmConditions.isVolumeBearish ||
conditions.vlmConditions.isVolumeUnderLast ||
conditions.vlmConditions.isVolumeChangedToBearish
//
;
if (isVLMPassed)
{
signs++;
}
//
// XSSLC ...
bool isSSLCPassed =
//
conditions.sslcConditions.isBearish ||
conditions.sslcConditions.isSwitchedToBearish
//
;
if (isSSLCPassed)
{
signs++;
}
//
// XHULL ...
bool isHULLPassed =
//
conditions.hullConditions.isBearish ||
conditions.hullConditions.isUpBearish ||
conditions.hullConditions.isDownBearish ||
conditions.hullConditions.isSwitchedToBearish
//
;
if (isHULLPassed)
{
signs++;
}
//
// XADX ...
bool isADXTDPassed =
//
conditions.adxtdConditions.isBearish ||
conditions.adxtdConditions.isSwitchedToBearish ||
conditions.adxtdConditions.isStrongSwitchedToBearish
//
;
if (isADXTDPassed)
{
signs++;
}
//
// XMATD ...
bool isMATDPassed =
//
((conditions.matdConditions.isBearish ||
conditions.matdConditions.isSwitchedToBearish)
//
||
//
((conditions.matdConditions.isFastUnderSlow ||
conditions.matdConditions.isFastCrossedUnderSlow)
//
&&
//
(conditions.matdConditions.isMidUnderSlow ||
conditions.matdConditions.isMidCrossedUnderSlow)))
//
||
//
(conditions.matdConditions.isSARBearish ||
conditions.matdConditions.isSARSwitchedToBearish)
//
;
if (isMATDPassed)
{
signs++;
}
//
result =
//
signs > verification
//
;
//
return result;
}
//
// Filter Long Conditions ...
bool FilterLongConditions(
+319 -85
View File
@@ -88,6 +88,9 @@ struct XSignalInfo
bearishScore = 0;
signal.Clean();
conditions.Clean();
//
ResetGrid();
}
//
@@ -320,6 +323,21 @@ struct XSignalInfo
return result;
}
//
// Grid ...
//
double gVolume; // Next Grid Volume
double gEntry; // Next Grid Entry
//
void ResetGrid()
{
//
gEntry = 0;
gVolume = 0;
}
//
};
@@ -730,6 +748,18 @@ public:
mReuiredSignalVerifications = value;
}
//
bool GetVerificationFromOtherTimeFrames()
{
return mGetVerificationFromOtherTimeFrames;
}
//
void GetVerificationFromOtherTimeFrames(bool value)
{
mGetVerificationFromOtherTimeFrames = value;
}
//
int MaxAllowedTrades()
{
@@ -851,6 +881,7 @@ public:
// Current ...
XSignal cSignal;
int cPusher = 0;
bool cHasSignal = false;
string cProvider = NULL;
X121SetupConditions cConditions;
@@ -858,6 +889,7 @@ public:
// Short ...
XSignal sSignal;
int sPusher = 0;
bool sHasSignal = false;
string sProvider = NULL;
X121SetupConditions sConditions;
@@ -865,6 +897,7 @@ public:
// Medium ...
XSignal mSignal;
int mPusher = 0;
bool mHasSignal = false;
string mProvider = NULL;
X121SetupConditions mConditions;
@@ -872,6 +905,7 @@ public:
// Long ...
XSignal lSignal;
int lPusher = 0;
bool lHasSignal = false;
string lProvider = NULL;
X121SetupConditions lConditions;
@@ -879,6 +913,7 @@ public:
// Hind ...
XSignal hSignal;
int hPusher = 0;
bool hHasSignal = false;
string hProvider = NULL;
X121SetupConditions hConditions;
@@ -909,6 +944,13 @@ public:
lSignal.Clean();
hSignal.Clean();
//
cHasSignal = false;
sHasSignal = false;
mHasSignal = false;
lHasSignal = false;
hHasSignal = false;
//
cConditions.Clean();
sConditions.Clean();
@@ -961,7 +1003,7 @@ public:
//
// Parse Conditions for Signal ...
bool hasSignal = signalGenerator.HasSignal(
bool cHasSignal = signalGenerator.HasSignal(
cConditions,
cSignal,
cPusher,
@@ -977,7 +1019,7 @@ public:
);
//
if (hasSignal)
if (cHasSignal)
{
//
mSetups[i].WaitsUntilNextBar(
@@ -1024,7 +1066,7 @@ public:
//
// Parse Conditions for Signal ...
bool hasSignal = signalGenerator.HasSignal(
bool sHasSignal = signalGenerator.HasSignal(
sConditions,
sSignal,
sPusher,
@@ -1039,7 +1081,7 @@ public:
);
//
if (hasSignal)
if (sHasSignal)
{
//
mSetups[i].WaitsUntilNextBar(
@@ -1086,7 +1128,7 @@ public:
//
// Parse Conditions for Signal ...
bool hasSignal = signalGenerator.HasSignal(
bool mHasSignal = signalGenerator.HasSignal(
mConditions,
mSignal,
mPusher,
@@ -1102,7 +1144,7 @@ public:
);
//
if (hasSignal)
if (mHasSignal)
{
//
mSetups[i].WaitsUntilNextBar(
@@ -1149,7 +1191,7 @@ public:
//
// Parse Conditions for Signal ...
bool hasSignal = signalGenerator.HasSignal(
bool lHasSignal = signalGenerator.HasSignal(
lConditions,
lSignal,
lPusher,
@@ -1165,7 +1207,7 @@ public:
);
//
if (hasSignal)
if (lHasSignal)
{
//
mSetups[i].WaitsUntilNextBar(
@@ -1212,7 +1254,7 @@ public:
//
// Parse Conditions for Signal ...
bool hasSignal = signalGenerator.HasSignal(
bool hHasSignal = signalGenerator.HasSignal(
hConditions,
hSignal,
hPusher,
@@ -1228,7 +1270,7 @@ public:
);
//
if (hasSignal)
if (hHasSignal)
{
//
mSetups[i].WaitsUntilNextBar(
@@ -1259,21 +1301,62 @@ public:
if (cPusher >= mReuiredSignalVerifications)
{
//
// Check Final Bullish and Bearish Score ...
bool isScorePassed =
X121SetupConditions otherConditions[];
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
//
// Check Final Validations ...
bool isValid =
//
true
// isLong
// ? mBearishScore > mBullishScore
// : mBullishScore > mBearishScore
// isLong
// ? mBullishScore > (mBearishScore * 2)
// : mBearishScore > (mBullishScore * 2)
(
//
sHasSignal
//
||
//
mHasSignal
//
||
//
lHasSignal
//
||
//
hHasSignal
//
)
//
||
//
(
//
!mGetVerificationFromOtherTimeFrames
? true
: isLong
? signalGenerator.HasLongVerifications(otherConditions)
: signalGenerator.HasShortVerifications(otherConditions)
//
)
//
;
//
if (isScorePassed)
if (isValid)
{
//
AddRef(
@@ -1312,21 +1395,62 @@ public:
if (sPusher >= mReuiredSignalVerifications)
{
//
// Check Final Bullish and Bearish Score ...
bool isScorePassed =
X121SetupConditions otherConditions[];
AddRef(
cConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
//
// Check Final Validations ...
bool isValid =
//
true
// isLong
// ? mBearishScore > mBullishScore
// : mBullishScore > mBearishScore
// isLong
// ? mBullishScore > (mBearishScore * 2)
// : mBearishScore > (mBullishScore * 2)
(
//
cHasSignal
//
||
//
mHasSignal
//
||
//
lHasSignal
//
||
//
hHasSignal
//
)
//
||
//
(
//
!mGetVerificationFromOtherTimeFrames
? true
: isLong
? signalGenerator.HasLongVerifications(otherConditions)
: signalGenerator.HasShortVerifications(otherConditions)
//
)
//
;
//
if (isScorePassed)
if (isValid)
{
//
AddRef(
@@ -1365,21 +1489,62 @@ public:
if (mPusher >= mReuiredSignalVerifications)
{
//
// Check Final Bullish and Bearish Score ...
bool isScorePassed =
X121SetupConditions otherConditions[];
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
//
// Check Final Validations ...
bool isValid =
//
true
// isLong
// ? mBearishScore > mBullishScore
// : mBullishScore > mBearishScore
// isLong
// ? mBullishScore > (mBearishScore * 2)
// : mBearishScore > (mBullishScore * 2)
(
//
cHasSignal
//
||
//
sHasSignal
//
||
//
lHasSignal
//
||
//
hHasSignal
//
)
//
||
//
(
//
!mGetVerificationFromOtherTimeFrames
? true
: isLong
? signalGenerator.HasLongVerifications(otherConditions)
: signalGenerator.HasShortVerifications(otherConditions)
//
)
//
;
//
if (isScorePassed)
if (isValid)
{
//
AddRef(
@@ -1418,21 +1583,62 @@ public:
if (lPusher >= mReuiredSignalVerifications)
{
//
// Check Final Bullish and Bearish Score ...
bool isScorePassed =
X121SetupConditions otherConditions[];
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
//
// Check Final Validations ...
bool isValid =
//
true
// isLong
// ? mBearishScore > mBullishScore
// : mBullishScore > mBearishScore
// isLong
// ? mBullishScore > (mBearishScore * 2)
// : mBearishScore > (mBullishScore * 2)
(
//
cHasSignal
//
||
//
sHasSignal
//
||
//
mHasSignal
//
||
//
hHasSignal
//
)
//
||
//
(
//
!mGetVerificationFromOtherTimeFrames
? true
: isLong
? signalGenerator.HasLongVerifications(otherConditions)
: signalGenerator.HasShortVerifications(otherConditions)
//
)
//
;
//
if (isScorePassed)
if (isValid)
{
//
AddRef(
@@ -1471,21 +1677,61 @@ public:
if (hPusher >= mReuiredSignalVerifications)
{
//
// Check Final Bullish and Bearish Score ...
bool isScorePassed =
X121SetupConditions otherConditions[];
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
//
// Check Final Validations ...
bool isValid =
//
true
// isLong
// ? mBearishScore > mBullishScore
// : mBullishScore > mBearishScore
// isLong
// ? mBullishScore > (mBearishScore * 2)
// : mBearishScore > (mBullishScore * 2)
(
//
cHasSignal
//
||
//
sHasSignal
//
||
//
mHasSignal
//
||
//
lHasSignal
//
) //
||
//
(
//
!mGetVerificationFromOtherTimeFrames
? true
: isLong
? signalGenerator.HasLongVerifications(otherConditions)
: signalGenerator.HasShortVerifications(otherConditions)
//
)
//
;
//
if (isScorePassed)
if (isValid)
{
//
AddRef(
@@ -1506,19 +1752,6 @@ public:
}
}
//
if (mBullishScore == mBearishScore ||
mBullishScore < 10 ||
mBullishScore == 0 ||
mBullishScore > 200 ||
mBearishScore < 10 ||
mBearishScore == 0 ||
mBearishScore > 200)
{
//
// Print("Custom Scores ...");
}
//
// Create Score Summary for Commenting on Chart ...
string scoreSummary =
@@ -1748,18 +1981,19 @@ private:
// Props ...
//
bool mAllowLong; // Allow Long
bool mAllowShort; // Allow Short
double mVolume; // Volume
double mTPPoint; // TP Point
double mSLPoint; // SL Point
bool mUseSupport; // Use Support Signals
bool mIgnoreTP; // Ignore Calculated TP
bool mIgnoreSL; // Ignore Calculated SL
int mMaxAllowedTrades; // Max Alloed Positions
bool mCloseOnOpposit; // Close all Positions on Opposit
int mCloseOnSpecificTime; // Close All Trades in Specific Time
int mReuiredSignalVerifications; // Required Verifications for Validate Signals
bool mAllowLong; // Allow Long
bool mAllowShort; // Allow Short
double mVolume; // Volume
double mTPPoint; // TP Point
double mSLPoint; // SL Point
bool mUseSupport; // Use Support Signals
bool mIgnoreTP; // Ignore Calculated TP
bool mIgnoreSL; // Ignore Calculated SL
int mMaxAllowedTrades; // Max Alloed Positions
bool mCloseOnOpposit; // Close all Positions on Opposit
int mCloseOnSpecificTime; // Close All Trades in Specific Time
int mReuiredSignalVerifications; // Required Verifications for Validate Signals
bool mGetVerificationFromOtherTimeFrames; // Get Verifications from Other Time Frames
//
XSignalInfo mSignalInfos[];
+16 -14
View File
@@ -41,24 +41,25 @@ string x121EASymbols = "EURUSDb"; // Symbols
//
// Signals ...
bool x121EAAllowLong = true; // Allow Long Trades
bool x121EAAllowShort = true; // Allow Short Trades
int x121EAReuiredSignalVerifications = 6; // Required Verifications for Signals
bool x121EAAllowLong = true; // Allow Long Trades
bool x121EAAllowShort = true; // Allow Short Trades
int x121EAReuiredSignalVerifications = 2; // Required Verifications for Signals
bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames
//
// Risk Management ...
double x121EAVolume = 0.01; // Static Volume
double x121EATPPoint = 50; // TP Point
double x121EASLPoint = 500; // SL Point
int x121EAMaxAllowedTrades = 0; // Max Allowed Positions
bool x121EAIgnoreSL = false; // Ignore Calculated SL
bool x121EAIgnoreTP = false; // Ignore Calculated TP
bool x121EAUseSupport = false; // Use Support Signals
double x121EAMinRequiredProfitPerTrade = 0; // Minimum Required Profit for Hedging
double x121EAVolume = 0.01; // Static Volume
double x121EATPPoint = 50; // TP Point
double x121EASLPoint = 100; // SL Point
int x121EAMaxAllowedTrades = 1; // Max Allowed Positions
bool x121EAIgnoreSL = false; // Ignore Calculated SL
bool x121EAIgnoreTP = false; // Ignore Calculated TP
bool x121EAUseSupport = false; // Use Support Signals
double x121EAMinRequiredProfitPerTrade = 0; // Minimum Required Profit for Hedging
double x121EAMinRequiredProfitPerVolumeFactor = 0; // Minimum Required Profit for Hedging Per Velume
int x121EARestingAfterHedge = 300; // Resting Seconds After Hedge
int x121EACloseOnSpecificTime = -1; // Close All Trades in Specific Time
bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
int x121EARestingAfterHedge = 0; // Resting Seconds After Hedge
int x121EACloseOnSpecificTime = -1; // Close All Trades in Specific Time
bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
//
// Alert ...
@@ -180,6 +181,7 @@ bool InitialEA()
x121EA.MinRequiredProfitPerTrade(x121EAMinRequiredProfitPerTrade);
x121EA.ReuiredSignalVerifications(x121EAReuiredSignalVerifications);
x121EA.MinRequiredProfitPerVolumeFactor(x121EAMinRequiredProfitPerVolumeFactor);
x121EA.GetVerificationFromOtherTimeFrames(x121EAGetVerificationFromOtherTimeFrames);
//
// Configure Alert ...