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);
+97 -134
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 ...
@@ -287,12 +287,16 @@ public:
// //
if (hasSupport) if (hasSupport)
{
//
if (drawImportantAreas)
{ {
// //
DrawSupport( DrawSupport(
support, support,
ChartID() // ChartID() //
); );
}
// //
supportTime = cBar.time; supportTime = cBar.time;
@@ -313,12 +317,16 @@ public:
// //
if (hasResistance) if (hasResistance)
{
//
if (drawImportantAreas)
{ {
// //
DrawResistance( DrawResistance(
resistance, resistance,
ChartID() // ChartID() //
); );
}
// //
resistanceTime = cBar.time; resistanceTime = cBar.time;
@@ -341,12 +349,16 @@ public:
// //
if (hasBullishOB) if (hasBullishOB)
{
//
if (drawImportantAreas)
{ {
// //
DrawBullishOrderBlock( DrawBullishOrderBlock(
bullishOB, bullishOB,
ChartID() // ChartID() //
); );
}
// //
bullishOBTime = cBar.time; bullishOBTime = cBar.time;
@@ -366,12 +378,16 @@ public:
// //
if (hasBearishOB) if (hasBearishOB)
{
//
if (drawImportantAreas)
{ {
// //
DrawBearishOrderBlock( DrawBearishOrderBlock(
bearishOB, bearishOB,
ChartID() // ChartID() //
); );
}
// //
bearishOBTime = cBar.time; bearishOBTime = cBar.time;
@@ -397,12 +413,18 @@ public:
{ {
// //
bullishFVG = cBar; bullishFVG = cBar;
//
if (drawImportantAreas)
{
//
DrawBullishFVG( DrawBullishFVG(
bullishFVG, bullishFVG,
bullishFVGUpper, bullishFVGUpper,
bullishFVGLower, bullishFVGLower,
ChartID() // ChartID() //
); );
}
// //
bullishFVGTime = cBar.time; bullishFVGTime = cBar.time;
@@ -425,12 +447,18 @@ public:
{ {
// //
bearishFVG = cBar; bearishFVG = cBar;
//
if (drawImportantAreas)
{
//
DrawBearishFVG( DrawBearishFVG(
bearishFVG, bearishFVG,
bearishFVGUpper, bearishFVGUpper,
bearishFVGLower, bearishFVGLower,
ChartID() // ChartID() //
); );
}
// //
bearishFVGTime = cBar.time; bearishFVGTime = cBar.time;
@@ -1406,90 +1434,69 @@ 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 ... // Checking Long Conditions ...
bool allowCHMSignals = false; if (isPriceOveralSwitchedToBullish)
bool allowCHHKSignals = false;
bool allowCHSTRSignals = false;
//
// Check Signals based on:
// XCHMA ...
if (allowCHMSignals)
{
//
double pressureDistance = 200;
//
if (isCHMBullish)
{ {
// //
hasLong = hasLong =
// //
isCHMBullish && hasBullishPower &&
hasBullishPattern && hasBullishPressure &&
chmDistanceDiffInPoint <= pressureDistance chstrConditions.isHBullish &&
// cheConditions.isStrongBullish &&
; cBar.low > pvConditions.fib2s[cIndex]
//
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
// //
; ;
@@ -1498,25 +1505,22 @@ public:
{ {
// //
type = POSITION_TYPE_BUY; type = POSITION_TYPE_BUY;
sl = chhkLowMin; sl = pvConditions.fib3s[cIndex];
} }
} }
// //
if (isCHHKSwitchedToBearish) // Checking Short Conditions ...
if (isPriceOveralSwitchedToBearish)
{ {
// //
hasShort = hasShort =
// //
false hasBearishPower &&
// hasBearishPressure &&
// isCHMBearish && chstrConditions.isHBearish &&
// isCHHKBearish && cheConditions.isStrongBearish &&
// isCHSTRBearish && cBar.high < pvConditions.fib4s[cIndex]
// hasBearishPower &&
// hasBearishPressure &&
// hasBearishPattern &&
// chhkDistanceDiffInPoint <= pressureDistance
// //
; ;
@@ -1525,52 +1529,7 @@ public:
{ {
// //
type = POSITION_TYPE_SELL; type = POSITION_TYPE_SELL;
sl = chhkHighMax; sl = pvConditions.fib3s[cIndex];
}
}
}
//
// Check Signals based on:
// XCHSTR ...
if (allowCHSTRSignals)
{
}
//
// Checking Long Conditions ...
//
// forceCloseLongs = isCHHKBullishBreaked;
// forceCloseShorts = isCHHKBearishBreaked;
//
// Check Exist Conditions ...
if (forceCloseLongs || forceCloseShorts)
{
//
string comment = "Exit Condition ...";
//
ENUM_X_POSITION_TYPES mType =
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 ...";
Alert(msg);
} }
} }
@@ -1661,6 +1620,9 @@ public:
// //
// Calculate TP and SL ... // Calculate TP and SL ...
// based on Strategy ... // based on Strategy ...
// only when on of TP or SL Provides, using provided R2R ...
if ((tp <= 0 && sl > 0) || (tp > 0 && sl <= 0))
{
CalculateTPSLByPrice( CalculateTPSLByPrice(
sl, sl,
tp, tp,
@@ -1668,6 +1630,7 @@ public:
entry, entry,
r2r // r2r //
); );
}
// //
// Preparing Signal ... // Preparing Signal ...