This commit is contained in:
2024-07-25 20:12:08 +03:30
parent 8525704eb1
commit 0ad2770634
2 changed files with 156 additions and 193 deletions
+3 -3
View File
@@ -359,7 +359,7 @@ bool InitialEA()
eurusdSymbol, eurusdSymbol,
PERIOD_M5, PERIOD_M5,
eaVolume, eaVolume,
eaR2R, // R2R ... 1, // eaR2R, // R2R ...
eaSlippage, eaSlippage,
magicNumber, magicNumber,
true, // Ignore Signal Execution true, // Ignore Signal Execution
@@ -371,8 +371,8 @@ bool InitialEA()
eaIgnoreSL, eaIgnoreSL,
eaAllowLong, eaAllowLong,
eaAllowShort, eaAllowShort,
1, // eaMaxAllowedLongs, // Max Longs eaMaxAllowedLongs, // Max Longs
1 // eaMaxAllowedShorts // Max Shorts eaMaxAllowedShorts // Max Shorts
); );
eurusdXCHKMStrategy.SetAlertLogAlerts(true); eurusdXCHKMStrategy.SetAlertLogAlerts(true);
eurusdXCHKMStrategy.SetAlertEnableAlerts(true); eurusdXCHKMStrategy.SetAlertEnableAlerts(true);
+153 -190
View File
@@ -147,8 +147,8 @@ public:
bool hasShort = false; bool hasShort = false;
// //
bool forceCloseLongs = false; // Draw Support/Resistance/OB(s)/FVG(s) ...
bool forceCloseShorts = false; bool drawImportantAreas = false;
// //
// Retrieve Conditions ... // Retrieve Conditions ...
@@ -289,10 +289,14 @@ public:
if (hasSupport) if (hasSupport)
{ {
// //
DrawSupport( if (drawImportantAreas)
support, {
ChartID() // //
); DrawSupport(
support,
ChartID() //
);
}
// //
supportTime = cBar.time; supportTime = cBar.time;
@@ -315,10 +319,14 @@ public:
if (hasResistance) if (hasResistance)
{ {
// //
DrawResistance( if (drawImportantAreas)
resistance, {
ChartID() // //
); DrawResistance(
resistance,
ChartID() //
);
}
// //
resistanceTime = cBar.time; resistanceTime = cBar.time;
@@ -343,10 +351,14 @@ public:
if (hasBullishOB) if (hasBullishOB)
{ {
// //
DrawBullishOrderBlock( if (drawImportantAreas)
bullishOB, {
ChartID() // //
); DrawBullishOrderBlock(
bullishOB,
ChartID() //
);
}
// //
bullishOBTime = cBar.time; bullishOBTime = cBar.time;
@@ -368,10 +380,14 @@ public:
if (hasBearishOB) if (hasBearishOB)
{ {
// //
DrawBearishOrderBlock( if (drawImportantAreas)
bearishOB, {
ChartID() // //
); DrawBearishOrderBlock(
bearishOB,
ChartID() //
);
}
// //
bearishOBTime = cBar.time; bearishOBTime = cBar.time;
@@ -397,12 +413,18 @@ public:
{ {
// //
bullishFVG = cBar; bullishFVG = cBar;
DrawBullishFVG(
bullishFVG, //
bullishFVGUpper, if (drawImportantAreas)
bullishFVGLower, {
ChartID() // //
); DrawBullishFVG(
bullishFVG,
bullishFVGUpper,
bullishFVGLower,
ChartID() //
);
}
// //
bullishFVGTime = cBar.time; bullishFVGTime = cBar.time;
@@ -425,12 +447,18 @@ public:
{ {
// //
bearishFVG = cBar; bearishFVG = cBar;
DrawBearishFVG(
bearishFVG, //
bearishFVGUpper, if (drawImportantAreas)
bearishFVGLower, {
ChartID() // //
); DrawBearishFVG(
bearishFVG,
bearishFVGUpper,
bearishFVGLower,
ChartID() //
);
}
// //
bearishFVGTime = cBar.time; bearishFVGTime = cBar.time;
@@ -1406,171 +1434,102 @@ public:
// //
; ;
//
// Other Conditions ...
//
bool isPriceOveralBullish =
//
cBar.low > chhkConditions.hBars[cIndex].high
//
;
//
bool isPriceOveralBullishPrev =
//
pBar.low > chhkConditions.hBars[pIndex].high
//
;
//
bool isPriceOveralSwitchedToBullish =
//
isPriceOveralBullish &&
!isPriceOveralBullishPrev
//
;
//
bool isPriceOveralBearish =
//
cBar.high < chhkConditions.hBars[cIndex].low
//
;
//
bool isPriceOveralBearishPrev =
//
pBar.high < chhkConditions.hBars[pIndex].low
//
;
//
bool isPriceOveralSwitchedToBearish =
//
isPriceOveralBearish &&
!isPriceOveralBearishPrev
//
;
// //
// Signalling ... // Signalling ...
// Looking for Signals Based on Conditions ... // Looking for Signals Based on Conditions ...
//
// Preparing Signals for Execution ...
bool allowCHMSignals = false;
bool allowCHHKSignals = false;
bool allowCHSTRSignals = false;
//
// Check Signals based on:
// XCHMA ...
if (allowCHMSignals)
{
//
double pressureDistance = 200;
//
if (isCHMBullish)
{
//
hasLong =
//
isCHMBullish &&
hasBullishPattern &&
chmDistanceDiffInPoint <= pressureDistance
//
;
//
if (hasLong)
{
//
type = POSITION_TYPE_SELL;
sl = chmMin;
}
}
//
if (isCHMBearish)
{
//
hasShort =
//
isCHMBearish &&
hasBearishPattern &&
chmDistanceDiffInPoint <= pressureDistance
//
;
//
if (hasShort)
{
//
type = POSITION_TYPE_SELL;
sl = chmMin;
}
}
}
//
// Check Signals based on:
// XCHHK ...
if (allowCHHKSignals)
{
//
double pressureDistance = 200;
//
if (isCHHKSwitchedBullish)
{
//
hasLong =
//
false
//
// isCHMBullish &&
// isCHHKBullish &&
// isCHSTRBullish &&
// hasBullishPower &&
// hasBullishPressure &&
// hasBullishPattern &&
// chhkDistanceDiffInPoint <= pressureDistance
//
;
//
if (hasLong)
{
//
type = POSITION_TYPE_BUY;
sl = chhkLowMin;
}
}
//
if (isCHHKSwitchedToBearish)
{
//
hasShort =
//
false
//
// isCHMBearish &&
// isCHHKBearish &&
// isCHSTRBearish &&
// hasBearishPower &&
// hasBearishPressure &&
// hasBearishPattern &&
// chhkDistanceDiffInPoint <= pressureDistance
//
;
//
if (hasShort)
{
//
type = POSITION_TYPE_SELL;
sl = chhkHighMax;
}
}
}
//
// Check Signals based on:
// XCHSTR ...
if (allowCHSTRSignals)
{
}
// //
// Checking Long Conditions ... // Checking Long Conditions ...
if (isPriceOveralSwitchedToBullish)
//
// forceCloseLongs = isCHHKBullishBreaked;
// forceCloseShorts = isCHHKBearishBreaked;
//
// Check Exist Conditions ...
if (forceCloseLongs || forceCloseShorts)
{ {
// //
string comment = "Exit Condition ..."; hasLong =
//
hasBullishPower &&
hasBullishPressure &&
chstrConditions.isHBullish &&
cheConditions.isStrongBullish &&
cBar.low > pvConditions.fib2s[cIndex]
//
;
// //
ENUM_X_POSITION_TYPES mType = if (hasLong)
forceCloseLongs
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
int count = trader.Close(
comment,
mSymbol,
GetTag(),
mPeriod,
mType,
false // Filter By Magic ...
);
if (IsValidSize(count))
{ {
// //
string msg = "Close (" + ToString(count) + ") " + (forceCloseLongs ? "Long" : "Short") + " Positions due Exit Conditions ..."; type = POSITION_TYPE_BUY;
Alert(msg); sl = pvConditions.fib3s[cIndex];
}
}
//
// Checking Short Conditions ...
if (isPriceOveralSwitchedToBearish)
{
//
hasShort =
//
hasBearishPower &&
hasBearishPressure &&
chstrConditions.isHBearish &&
cheConditions.isStrongBearish &&
cBar.high < pvConditions.fib4s[cIndex]
//
;
//
if (hasShort)
{
//
type = POSITION_TYPE_SELL;
sl = pvConditions.fib3s[cIndex];
} }
} }
@@ -1661,13 +1620,17 @@ public:
// //
// Calculate TP and SL ... // Calculate TP and SL ...
// based on Strategy ... // based on Strategy ...
CalculateTPSLByPrice( // only when on of TP or SL Provides, using provided R2R ...
sl, if ((tp <= 0 && sl > 0) || (tp > 0 && sl <= 0))
tp, {
type, CalculateTPSLByPrice(
entry, sl,
r2r // tp,
); type,
entry,
r2r //
);
}
// //
// Preparing Signal ... // Preparing Signal ...