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
+16 -12
View File
@@ -36,31 +36,35 @@ long eaMagicNumber = 78692110; // Magic Number
int eaSlippage = 10; // Slippgae int eaSlippage = 10; // Slippgae
// //
double eaVolume = 0.01; double eaVolume = 0.01; // Static Volume
double eaAllowLong = true; double eaAllowLong = true; // Allow Long Positions
double eaAllowShort = true; double eaAllowShort = true; // Allow Short Positions
// //
int eaMaxAllowedLongs = 0; int eaMaxAllowedLongs = 0; // Max Allowed Long Positions
int eaMaxAllowedShorts = 0; int eaMaxAllowedShorts = 0; // Max Allowed Short Positions
// //
double eaTPPoint = 200; double eaTPPoint = 200; // Static TP Point
double eaSLPoint = 100; double eaSLPoint = 100; // Static SL Point
// //
bool eaIgnoreTP = false; bool eaIgnoreTP = false; // Ignore TP
bool eaIgnoreSL = false; bool eaIgnoreSL = false; // Ignore SL
// //
double eaR2R = 2; double eaR2R = 2; // Risk to Reward Ratio
// //
// Variables ... // Variables ...
//
// Bar Style nad Time Instances ...
XSCXCTHelper *mCTHelper; XSCXCTHelper *mCTHelper;
XSCXCCHelper *mCCHelper; XSCXCCHelper *mCCHelper;
// //
// Registred Strategies ...
XSCBaseStrategy *strategies[]; XSCBaseStrategy *strategies[];
// //
@@ -237,9 +241,9 @@ bool InitialEA()
eaR2R, // R2R ... eaR2R, // R2R ...
eaSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
100, // eaTPPoint, // TP 50, // eaTPPoint, // TP
eaSLPoint, // SL eaSLPoint, // SL
eaIgnoreTP, eaIgnoreTP,
true, // eaIgnoreSL, true, // eaIgnoreSL,
+96 -55
View File
@@ -21,6 +21,9 @@
// //
// Imports ... // Imports ...
//
// Import(s) Helper(s) ...
#include "../Helpers/x-saherelm.xhk.helper.mq5" #include "../Helpers/x-saherelm.xhk.helper.mq5"
#include "../Helpers/x-saherelm.xmc.helper.mq5" #include "../Helpers/x-saherelm.xmc.helper.mq5"
#include "../Helpers/x-saherelm.xtd.helper.mq5" #include "../Helpers/x-saherelm.xtd.helper.mq5"
@@ -29,12 +32,17 @@
#include "../Helpers/x-saherelm.xvlm.helper.mq5" #include "../Helpers/x-saherelm.xvlm.helper.mq5"
#include "../Helpers/x-saherelm.xosc.helper.mq5" #include "../Helpers/x-saherelm.xosc.helper.mq5"
#include "../Helpers/x-saherelm.xchma.helper.mq5" #include "../Helpers/x-saherelm.xchma.helper.mq5"
//
// Base Classes ...
#include "../Classes/x-saherelm.xstrategy.class.mq5" #include "../Classes/x-saherelm.xstrategy.class.mq5"
// //
// Specific Identifier(s) of XStrategy ...
string XTestStartegyToken = "XTest"; string XTestStartegyToken = "XTest";
// //
// XStrategy Class Implementation(s) ...
class XSCXTestStrategy : public XSCBaseStrategy class XSCXTestStrategy : public XSCBaseStrategy
{ {
// //
@@ -140,6 +148,9 @@ public:
bool hasLong = false; bool hasLong = false;
bool hasShort = false; bool hasShort = false;
//
// Retrieve Conditions ...
// //
// XMC ... // XMC ...
XMCConditions mcConditions; XMCConditions mcConditions;
@@ -215,6 +226,9 @@ public:
rsis // rsis //
); );
//
// Start Calculations ...
// //
double points = GetPoints(mSymbol); double points = GetPoints(mSymbol);
@@ -225,15 +239,10 @@ public:
int ppIndex = pIndex + 1; int ppIndex = pIndex + 1;
// //
// For Trend ... // Retrieve Bars ...
XOHCL tmpHSW[];
XOHCL tmpLSW[];
// //
// For Verifications ... // Last Bar ...
//
// Bar On Trading Period ...
XOHCL cBar; XOHCL cBar;
result = cBar.Init( result = cBar.Init(
mSymbol, mSymbol,
@@ -246,6 +255,7 @@ public:
} }
// //
// Previous Bar of Last Bar ...
XOHCL pBar; XOHCL pBar;
result = cBar.GetPreviousBar(pBar); result = cBar.GetPreviousBar(pBar);
if (!result) if (!result)
@@ -254,6 +264,7 @@ public:
} }
// //
// Last Swing Low Bar ...
XOHCL lastSwingLow; XOHCL lastSwingLow;
result = cBar.FindLastSwingLow(lastSwingLow); result = cBar.FindLastSwingLow(lastSwingLow);
if (!result) if (!result)
@@ -262,6 +273,7 @@ public:
} }
// //
// Last Swing High Bar ...
XOHCL lastSwingHigh; XOHCL lastSwingHigh;
result = cBar.FindLastSwingHigh(lastSwingHigh); result = cBar.FindLastSwingHigh(lastSwingHigh);
if (!result) if (!result)
@@ -270,10 +282,17 @@ public:
} }
// //
// Retrieve Highest High(s) and Lowest Low(s) ...
//
// Highest High ...
double hh5 = cBar.FindHighest( double hh5 = cBar.FindHighest(
5, 5,
MODE_HIGH // MODE_HIGH //
); );
//
// Lowest Low ...
double ll5 = cBar.FindLowest( double ll5 = cBar.FindLowest(
5, 5,
MODE_LOW // 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 hasBullishPattern = HasBullishPattern(cBar);
bool isBullishTrend = cBar.HasBullishTrend( bool isBullishTrend = cBar.HasBullishTrend(
tmpHSW, tmpHSW,
@@ -340,6 +368,7 @@ public:
); );
// //
// Bearish ...
bool hasBearishPattern = HasBearishPattern(cBar); bool hasBearishPattern = HasBearishPattern(cBar);
bool isBearishTrend = cBar.HasBearishTrend( bool isBearishTrend = cBar.HasBearishTrend(
tmpHSW, tmpHSW,
@@ -347,6 +376,12 @@ public:
false // false //
); );
//
// Detect XCHMA based Conditions ...
//
// Bullish ...
// //
bool isHCrossedOver = bool isHCrossedOver =
// //
@@ -404,6 +439,7 @@ public:
; ;
// //
// Bullish XCHMA Conditions ...
bool isCrossedOver = bool isCrossedOver =
// //
isHCrossedOver isHCrossedOver
@@ -422,6 +458,9 @@ public:
// //
; ;
//
// Bearish ...
// //
bool isHCrossedUnder = bool isHCrossedUnder =
// //
@@ -479,6 +518,7 @@ public:
; ;
// //
// Bullish XCHMA Conditions ...
bool isCrossedUnder = bool isCrossedUnder =
// //
isHCrossedUnder isHCrossedUnder
@@ -497,6 +537,9 @@ public:
// //
; ;
//
// XCHE Conditions ...
// //
bool isCHESwitchedToStrongBullish = cheConditions.isStrongSwitchedToBullish; bool isCHESwitchedToStrongBullish = cheConditions.isStrongSwitchedToBullish;
@@ -504,11 +547,13 @@ public:
bool isCHESwitchedToStrongBearish = cheConditions.isStrongSwitchedToBearish; bool isCHESwitchedToStrongBearish = cheConditions.isStrongSwitchedToBearish;
// //
// Signalling ...
// Looking for Signals Based on Conditions ...
//
// Long ...
if (isCrossedOver) if (isCrossedOver)
{ {
//
// Print("isCrossedOver");
// //
hasLong = hasLong =
// //
@@ -528,10 +573,6 @@ public:
// //
if (hasLong) if (hasLong)
{ {
//
// DrawSwingLow(lastSwingLow, ChartID());
// DrawSwingHigh(lastSwingHigh, ChartID());
// //
type = POSITION_TYPE_BUY; type = POSITION_TYPE_BUY;
sl = cheConditions.long2[1]; sl = cheConditions.long2[1];
@@ -539,41 +580,7 @@ public:
} }
// //
if (isCrossedUnder) // Long ...
{
//
// 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];
}
}
//
if (isCHESwitchedToStrongBullish) 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) if (isCHESwitchedToStrongBearish)
{ {
// //
@@ -619,6 +656,9 @@ public:
} }
} }
//
// Preparing Signals for Execution ...
// //
result = hasLong || hasShort; result = hasLong || hasShort;
if (!result) if (!result)
@@ -650,7 +690,12 @@ public:
} }
// //
// Retrieve Entry Price based on Position Type ...
entry = GetEntry(mSymbol, type); entry = GetEntry(mSymbol, type);
//
// Calculate TP and SL ...
// based on Strategy ...
CalculateTPSLByPrice( CalculateTPSLByPrice(
sl, sl,
tp, tp,
@@ -660,6 +705,7 @@ public:
); );
// //
// Preparing Signal ...
result = signal.Prepare( result = signal.Prepare(
mSymbol, mSymbol,
GetTag(), GetTag(),
@@ -672,12 +718,6 @@ public:
tp // tp //
); );
//
if (result)
{
// signal.sl = 0;
}
// //
return result; return result;
} }
@@ -698,6 +738,7 @@ protected:
XSCXMCHelper *mcHelper; XSCXMCHelper *mcHelper;
// //
// XTD ...
XTDInputs tdInputs; XTDInputs tdInputs;
XSCXTDHelper *tdHelper; XSCXTDHelper *tdHelper;