This commit is contained in:
2024-07-18 17:14:31 +03:30
parent 57affb201e
commit 70f2435c44
2 changed files with 399 additions and 120 deletions
+104 -98
View File
@@ -33,14 +33,25 @@
// //
// Inputs ... // Inputs ...
long mMagicNumber = 78692110; // Magic Number long eaMagicNumber = 78692110; // Magic Number
int mSlippage = 10; // Slippgae int eaSlippage = 10; // Slippgae
// //
double eaVolume = 0.01; double eaVolume = 0.01;
double eaAllowLong = true; double eaAllowLong = true;
double eaAllowShort = true; double eaAllowShort = true;
//
int eaMaxAllowedLongs = 0;
int eaMaxAllowedShorts = 0;
//
double eaTPPoint = 200;
double eaSLPoint = 100;
//
double eaR2R = 1.5;
// //
// Variables ... // Variables ...
XSCXCTHelper *mCTHelper; XSCXCTHelper *mCTHelper;
@@ -198,7 +209,7 @@ bool InitialEA()
{ {
// //
// MAGIC NUMBER ... // MAGIC NUMBER ...
long magicNumber = mMagicNumber + 1; long magicNumber = eaMagicNumber + 1;
// //
// XSRBR ... // XSRBR ...
@@ -212,13 +223,13 @@ bool InitialEA()
PERIOD_M5, PERIOD_M5,
PERIOD_H1, PERIOD_H1,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs 0, // Max Longs
@@ -237,17 +248,17 @@ bool InitialEA()
PERIOD_M15, PERIOD_M15,
PERIOD_M30, PERIOD_M30,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts, // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
eurusdM15SRBRStrategy.SetAlertLogAlerts(true); eurusdM15SRBRStrategy.SetAlertLogAlerts(true);
@@ -265,18 +276,17 @@ bool InitialEA()
eurusdSymbol, eurusdSymbol,
PERIOD_M5, PERIOD_M5,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
eurusdM5EMRNGStrategy.SetAlertLogAlerts(true); eurusdM5EMRNGStrategy.SetAlertLogAlerts(true);
eurusdM5EMRNGStrategy.SetAlertEnableAlerts(true); eurusdM5EMRNGStrategy.SetAlertEnableAlerts(true);
@@ -291,7 +301,7 @@ bool InitialEA()
{ {
// //
// MAGIC NUMBER ... // MAGIC NUMBER ...
long magicNumber = mMagicNumber + 2; long magicNumber = eaMagicNumber + 2;
// //
// XSRBR ... // XSRBR ...
@@ -305,17 +315,17 @@ bool InitialEA()
PERIOD_M5, PERIOD_M5,
PERIOD_H1, PERIOD_H1,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts, // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
usdchfM5SRBRStrategy.SetAlertLogAlerts(true); usdchfM5SRBRStrategy.SetAlertLogAlerts(true);
@@ -333,18 +343,17 @@ bool InitialEA()
usdchfSymbol, usdchfSymbol,
PERIOD_M5, PERIOD_M5,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
usdchfM5EMRNGStrategy.SetAlertLogAlerts(true); usdchfM5EMRNGStrategy.SetAlertLogAlerts(true);
usdchfM5EMRNGStrategy.SetAlertEnableAlerts(true); usdchfM5EMRNGStrategy.SetAlertEnableAlerts(true);
@@ -359,7 +368,7 @@ bool InitialEA()
{ {
// //
// MAGIC NUMBER ... // MAGIC NUMBER ...
long magicNumber = mMagicNumber + 3; long magicNumber = eaMagicNumber + 3;
// //
// XSRBR ... // XSRBR ...
@@ -373,17 +382,17 @@ bool InitialEA()
PERIOD_M5, PERIOD_M5,
PERIOD_M30, PERIOD_M30,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts, // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
usdjpyM5SRBRStrategy.SetAlertLogAlerts(true); usdjpyM5SRBRStrategy.SetAlertLogAlerts(true);
@@ -401,18 +410,17 @@ bool InitialEA()
usdjpySymbol, usdjpySymbol,
PERIOD_M5, PERIOD_M5,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
usdjpyM5EMRNGStrategy.SetAlertLogAlerts(true); usdjpyM5EMRNGStrategy.SetAlertLogAlerts(true);
usdjpyM5EMRNGStrategy.SetAlertEnableAlerts(true); usdjpyM5EMRNGStrategy.SetAlertEnableAlerts(true);
@@ -427,7 +435,7 @@ bool InitialEA()
{ {
// //
// MAGIC NUMBER ... // MAGIC NUMBER ...
long magicNumber = mMagicNumber + 4; long magicNumber = eaMagicNumber + 4;
// //
// XSRBR ... // XSRBR ...
@@ -441,17 +449,17 @@ bool InitialEA()
PERIOD_M5, PERIOD_M5,
PERIOD_H1, PERIOD_H1,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts, // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
gbpusdM5SRBRStrategy.SetAlertLogAlerts(true); gbpusdM5SRBRStrategy.SetAlertLogAlerts(true);
@@ -469,18 +477,17 @@ bool InitialEA()
gbpusdSymbol, gbpusdSymbol,
PERIOD_M5, PERIOD_M5,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
gbpusdM5EMRNGStrategy.SetAlertLogAlerts(true); gbpusdM5EMRNGStrategy.SetAlertLogAlerts(true);
gbpusdM5EMRNGStrategy.SetAlertEnableAlerts(true); gbpusdM5EMRNGStrategy.SetAlertEnableAlerts(true);
@@ -495,7 +502,7 @@ bool InitialEA()
{ {
// //
// MAGIC NUMBER ... // MAGIC NUMBER ...
long magicNumber = mMagicNumber + 5; long magicNumber = eaMagicNumber + 5;
// //
// XSRBR ... // XSRBR ...
@@ -509,17 +516,17 @@ bool InitialEA()
PERIOD_M15, PERIOD_M15,
PERIOD_M30, PERIOD_M30,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts, // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
xauusdM5SRBRStrategy.SetAlertLogAlerts(true); xauusdM5SRBRStrategy.SetAlertLogAlerts(true);
@@ -537,18 +544,17 @@ bool InitialEA()
xauusdSymbol, xauusdSymbol,
PERIOD_M5, PERIOD_M5,
eaVolume, eaVolume,
1.5, // R2R ... eaR2R, // R2R ...
mSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Use TP SL Point true, // Use TP SL Point
false, // Use Max false, // Use Max
200, // TP eaTPPoint, // TP
100, // SL eaSLPoint, // SL
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
0, // Max Longs eaMaxAllowedLongs, // Max Longs
0, // Max Shorts eaMaxAllowedShorts // Max Shorts
X_SIGNALLING_BOTH_DIRECTIONS // X_SIGNALIING_TREND_REVERSAL_DIRECTION // X_SIGNALLING_BOTH_DIRECTIONS //
); );
xauusdM5EMRNGStrategy.SetAlertLogAlerts(true); xauusdM5EMRNGStrategy.SetAlertLogAlerts(true);
xauusdM5EMRNGStrategy.SetAlertEnableAlerts(true); xauusdM5EMRNGStrategy.SetAlertEnableAlerts(true);
+295 -22
View File
@@ -22,6 +22,7 @@
// //
/// Imports ... /// Imports ...
#include "../Helpers/x-saherelm.xtm.helper.mq5" #include "../Helpers/x-saherelm.xtm.helper.mq5"
#include "../Helpers/x-saherelm.xstr.helper.mq5"
#include "../Classes/x-saherelm.xstrategy.class.mq5" #include "../Classes/x-saherelm.xstrategy.class.mq5"
// //
@@ -51,8 +52,7 @@ public:
bool _allowLong = true, bool _allowLong = true,
bool _allowShort = true, bool _allowShort = true,
int _maxAllowedLongs = 0, int _maxAllowedLongs = 0,
int _maxAllowedShorts = 0, int _maxAllowedShorts = 0 //
ENUM_X_SIGNALLING_DIRECTION _signallingDirection = X_SIGNALLING_TREND_DIRECTION // Signalling in Which Direction
) : XSCBaseStrategy(_symbol, ) : XSCBaseStrategy(_symbol,
_period, _period,
_volume, _volume,
@@ -70,10 +70,7 @@ public:
) )
{ {
// //
mSignallingDirection = _signallingDirection; ConfigureRequirements();
//
ConfigureTMInputs();
// //
SetAlertPrefix(GetTag()); SetAlertPrefix(GetTag());
@@ -89,18 +86,6 @@ public:
// //
// Getter / Setter (s) ... // Getter / Setter (s) ...
//
ENUM_X_SIGNALLING_DIRECTION SignallingDirection()
{
return mSignallingDirection;
}
//
void SignallingDirection(ENUM_X_SIGNALLING_DIRECTION value)
{
mSignallingDirection = value;
}
// //
// Overrides ... // Overrides ...
@@ -120,6 +105,276 @@ public:
// //
bool result = false; bool result = false;
//
signal.Clean();
//
double sl = 0;
double tp = 0;
double risk = 0;
double entry = 0;
double reward = 0;
double r2r = R2R();
ENUM_POSITION_TYPE type = POSITION_TYPE_BUY;
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
//
int start = 0;
int count = 5;
//
double tms[];
ArraySetAsSeries(tms, true);
mTMHelper.CopyMain(
start,
count,
tms //
);
//
XSTRConditions strConditions;
result = mSTRHelper.GetConditions(
strConditions,
start,
count //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
mSymbol,
mPeriod,
1 //
);
if (!result)
{
return result;
}
//
double hh5 = cBar.FindHighest(
5,
MODE_HIGH //
);
double ll5 = cBar.FindLowest(
5,
MODE_LOW //
);
//
XOHCL pBar;
result = cBar.GetPreviousBar(pBar);
if (!result)
{
return result;
}
//
bool hasLong = false;
bool hasShort = false;
//
XOHCL tmpHSW[];
XOHCL tmpLSW[];
//
bool useHammer = true;
bool useMorningStar = false;
bool useBullishEngulfing = true;
bool useBullishMaurubozu = true;
//
bool useShootingStar = true;
bool useEveningStar = false;
bool useBearishEngulfing = true;
bool useBearishMaurubozu = true;
//
// Long ...
//
bool isHammer = !useHammer
? false
: cBar.IsHammer();
bool isMorningStar = !useMorningStar
? false
: cBar.IsMorningStar();
bool isBullishMarubozu = !useBullishEngulfing
? false
: cBar.IsBullishMarubozu();
bool isBullishEngulfing = !useBullishMaurubozu
? false
: cBar.IsBullishEngulfing();
//
bool isBullishTrend = cBar.HasBullishTrend(
tmpHSW,
tmpLSW,
true //
);
//
// Find Swing Low Above of EMA ...
// Find Swing High Above of EMA ...
// Fins Swing Low Below of EMA ...
// Detect Bullish Pattern ...
hasLong =
//
cBar.IsBullish()
//
&&
//
isBullishTrend
//
&&
//
cBar.close > tms[1]
//
&&
//
ll5 < tms[1]
//
&&
//
strConditions.isTrendSwitchedToBullish
//
&&
//
(
//
isHammer
//
||
//
isMorningStar
//
||
//
isBullishMarubozu
//
||
//
isBullishEngulfing
//
)
//
;
if (hasLong)
{
//
type = POSITION_TYPE_BUY;
//
sl = tmpLSW[ArraySize(tmpLSW) - 1].low;
}
//
// Short ...
bool isShootingStar = !useShootingStar
? false
: cBar.IsShootingStar();
bool isEveningStar = !useEveningStar
? false
: cBar.IsEveningStar();
bool isBearishEngulfing = !useBearishEngulfing
? false
: cBar.IsBearishEngulfing();
bool isBearishMaurubozu = !useBearishMaurubozu
? false
: cBar.IsBearishMarubozu();
//
bool isBearishTrend = cBar.HasBearishTrend(
tmpHSW,
tmpLSW,
true //
);
//
hasShort =
//
cBar.IsBearish()
//
&&
//
isBearishTrend
//
&&
//
cBar.close < tms[1]
//
&&
//
hh5 > tms[1]
//
&&
//
strConditions.isTrendSwitchedToBearish
//
&&
//
(
//
isShootingStar
//
||
//
isEveningStar
//
||
//
isBearishEngulfing
//
||
//
isBearishMaurubozu
//
)
//
;
if (hasShort)
{
//
type = POSITION_TYPE_SELL;
//
sl = tmpHSW[ArraySize(tmpHSW) - 1].high;
}
//
result = hasLong || hasShort;
if (!result)
{
return result;
}
//
entry = GetEntry(mSymbol, type);
CalculateTPSLByPrice(
sl,
tp,
type,
entry,
r2r //
);
//
result = signal.Prepare(
mSymbol,
GetTag(),
mPeriod,
type,
mode,
entry,
mVolume,
sl,
tp //
);
// //
return result; return result;
} }
@@ -130,13 +385,14 @@ protected:
// //
// Props ... // Props ...
//
ENUM_X_SIGNALLING_DIRECTION mSignallingDirection; // Signalling Direction
// //
XTMInputs mTMInputs; // Tren Magic Inputs ... XTMInputs mTMInputs; // Tren Magic Inputs ...
XSCXTMHelper *mTMHelper; // Trend Magic Helper Class ... XSCXTMHelper *mTMHelper; // Trend Magic Helper Class ...
//
XSTRInputs mSTRInputs; // Super Trend Inputs ...
XSCXSTRHelper *mSTRHelper; // Super Trend Helper Class ...
// //
// Private ... // Private ...
private: private:
@@ -144,7 +400,7 @@ private:
// //
// Set Default TM Inputs ... // Set Default TM Inputs ...
void ConfigureTMInputs() void ConfigureRequirements()
{ {
// //
mTMInputs.maShift = 0; mTMInputs.maShift = 0;
@@ -164,6 +420,23 @@ private:
mPeriod, mPeriod,
mTMInputs // mTMInputs //
); );
//
mSTRInputs.length = 14;
mSTRInputs.multiplier = 3.5;
mSTRInputs.appliedTo = PRICE_CLOSE;
//
mSTRInputs.showTrends = true;
mSTRInputs.fillTrends = false;
//
mSTRHelper = new XSCXSTRHelper();
mSTRHelper.Init(
mSymbol,
mPeriod,
mSTRInputs //
);
} }
}; };