This commit is contained in:
2024-07-21 18:25:54 +03:30
parent a996143dd3
commit d194d85082
2 changed files with 112 additions and 67 deletions
+96 -55
View File
@@ -21,6 +21,9 @@
//
// Imports ...
//
// Import(s) Helper(s) ...
#include "../Helpers/x-saherelm.xhk.helper.mq5"
#include "../Helpers/x-saherelm.xmc.helper.mq5"
#include "../Helpers/x-saherelm.xtd.helper.mq5"
@@ -29,12 +32,17 @@
#include "../Helpers/x-saherelm.xvlm.helper.mq5"
#include "../Helpers/x-saherelm.xosc.helper.mq5"
#include "../Helpers/x-saherelm.xchma.helper.mq5"
//
// Base Classes ...
#include "../Classes/x-saherelm.xstrategy.class.mq5"
//
// Specific Identifier(s) of XStrategy ...
string XTestStartegyToken = "XTest";
//
// XStrategy Class Implementation(s) ...
class XSCXTestStrategy : public XSCBaseStrategy
{
//
@@ -140,6 +148,9 @@ public:
bool hasLong = false;
bool hasShort = false;
//
// Retrieve Conditions ...
//
// XMC ...
XMCConditions mcConditions;
@@ -215,6 +226,9 @@ public:
rsis //
);
//
// Start Calculations ...
//
double points = GetPoints(mSymbol);
@@ -225,15 +239,10 @@ public:
int ppIndex = pIndex + 1;
//
// For Trend ...
XOHCL tmpHSW[];
XOHCL tmpLSW[];
// Retrieve Bars ...
//
// For Verifications ...
//
// Bar On Trading Period ...
// Last Bar ...
XOHCL cBar;
result = cBar.Init(
mSymbol,
@@ -246,6 +255,7 @@ public:
}
//
// Previous Bar of Last Bar ...
XOHCL pBar;
result = cBar.GetPreviousBar(pBar);
if (!result)
@@ -254,6 +264,7 @@ public:
}
//
// Last Swing Low Bar ...
XOHCL lastSwingLow;
result = cBar.FindLastSwingLow(lastSwingLow);
if (!result)
@@ -262,6 +273,7 @@ public:
}
//
// Last Swing High Bar ...
XOHCL lastSwingHigh;
result = cBar.FindLastSwingHigh(lastSwingHigh);
if (!result)
@@ -270,10 +282,17 @@ public:
}
//
// Retrieve Highest High(s) and Lowest Low(s) ...
//
// Highest High ...
double hh5 = cBar.FindHighest(
5,
MODE_HIGH //
);
//
// Lowest Low ...
double ll5 = cBar.FindLowest(
5,
MODE_LOW //
@@ -332,6 +351,15 @@ public:
}
//
// For Trend ...
XOHCL tmpHSW[];
XOHCL tmpLSW[];
//
// Detect Bullish/Bearish Patterns and Trends ...
//
// Bullish ...
bool hasBullishPattern = HasBullishPattern(cBar);
bool isBullishTrend = cBar.HasBullishTrend(
tmpHSW,
@@ -340,6 +368,7 @@ public:
);
//
// Bearish ...
bool hasBearishPattern = HasBearishPattern(cBar);
bool isBearishTrend = cBar.HasBearishTrend(
tmpHSW,
@@ -347,6 +376,12 @@ public:
false //
);
//
// Detect XCHMA based Conditions ...
//
// Bullish ...
//
bool isHCrossedOver =
//
@@ -404,6 +439,7 @@ public:
;
//
// Bullish XCHMA Conditions ...
bool isCrossedOver =
//
isHCrossedOver
@@ -422,6 +458,9 @@ public:
//
;
//
// Bearish ...
//
bool isHCrossedUnder =
//
@@ -479,6 +518,7 @@ public:
;
//
// Bullish XCHMA Conditions ...
bool isCrossedUnder =
//
isHCrossedUnder
@@ -497,6 +537,9 @@ public:
//
;
//
// XCHE Conditions ...
//
bool isCHESwitchedToStrongBullish = cheConditions.isStrongSwitchedToBullish;
@@ -504,11 +547,13 @@ public:
bool isCHESwitchedToStrongBearish = cheConditions.isStrongSwitchedToBearish;
//
// Signalling ...
// Looking for Signals Based on Conditions ...
//
// Long ...
if (isCrossedOver)
{
//
// Print("isCrossedOver");
//
hasLong =
//
@@ -528,10 +573,6 @@ public:
//
if (hasLong)
{
//
// DrawSwingLow(lastSwingLow, ChartID());
// DrawSwingHigh(lastSwingHigh, ChartID());
//
type = POSITION_TYPE_BUY;
sl = cheConditions.long2[1];
@@ -539,41 +580,7 @@ public:
}
//
if (isCrossedUnder)
{
//
// Print("isCrossedUnder");
//
hasShort =
//
(isBearishTrend ||
hasBearishPattern)
//
&&
//
chmaConditions.isFastUnderSlow &&
chmaConditions.isCloseUnderFast &&
chmaConditions.isFastResistance &&
chmaConditions.isSlowResistance &&
cheConditions.isStrongBearish
//
;
//
if (hasShort)
{
//
// DrawSwingLow(lastSwingLow, ChartID());
// DrawSwingHigh(lastSwingHigh, ChartID());
//
type = POSITION_TYPE_SELL;
sl = cheConditions.short2[1];
}
}
//
// Long ...
if (isCHESwitchedToStrongBullish)
{
//
@@ -597,6 +604,36 @@ public:
}
//
// Short ...
if (isCrossedUnder)
{
//
hasShort =
//
(isBearishTrend ||
hasBearishPattern)
//
&&
//
chmaConditions.isFastUnderSlow &&
chmaConditions.isCloseUnderFast &&
chmaConditions.isFastResistance &&
chmaConditions.isSlowResistance &&
cheConditions.isStrongBearish
//
;
//
if (hasShort)
{
//
type = POSITION_TYPE_SELL;
sl = cheConditions.short2[1];
}
}
//
// Short ...
if (isCHESwitchedToStrongBearish)
{
//
@@ -619,6 +656,9 @@ public:
}
}
//
// Preparing Signals for Execution ...
//
result = hasLong || hasShort;
if (!result)
@@ -650,7 +690,12 @@ public:
}
//
// Retrieve Entry Price based on Position Type ...
entry = GetEntry(mSymbol, type);
//
// Calculate TP and SL ...
// based on Strategy ...
CalculateTPSLByPrice(
sl,
tp,
@@ -660,6 +705,7 @@ public:
);
//
// Preparing Signal ...
result = signal.Prepare(
mSymbol,
GetTag(),
@@ -672,12 +718,6 @@ public:
tp //
);
//
if (result)
{
// signal.sl = 0;
}
//
return result;
}
@@ -698,6 +738,7 @@ protected:
XSCXMCHelper *mcHelper;
//
// XTD ...
XTDInputs tdInputs;
XSCXTDHelper *tdHelper;