start implementing XCHICHWAP Strategy ...

This commit is contained in:
2024-09-29 21:55:25 +03:30
parent cc300c1fef
commit 09edc32c96
4 changed files with 1894 additions and 145 deletions
+120 -141
View File
@@ -36,7 +36,7 @@ class XSCXCHICHWAPStrategy : public XSCBaseStrategy
{
//
// Public ...
public:
public:
//
// Constructor(s) ...
void XSCXCHICHWAPStrategy(
@@ -60,25 +60,26 @@ public:
bool _allowShort = true,
int _maxAllowedLongs = 0,
int _maxAllowedShorts = 0 //
) : XSCBaseStrategy(_symbol,
_period,
_analizePeriod,
_volume,
_r2r,
_slippage,
_magicNumber,
_ignoreSignalExecution,
_useTPSLAsPoint,
_forceMaxTPSLAsPoint,
_tpPoint,
_slPoint,
_ignoreTP,
_ignoreSL,
_allowLong,
_allowShort,
_maxAllowedLongs,
_maxAllowedShorts //
)
)
: XSCBaseStrategy(_symbol,
_period,
_analizePeriod,
_volume,
_r2r,
_slippage,
_magicNumber,
_ignoreSignalExecution,
_useTPSLAsPoint,
_forceMaxTPSLAsPoint,
_tpPoint,
_slPoint,
_ignoreTP,
_ignoreSL,
_allowLong,
_allowShort,
_maxAllowedLongs,
_maxAllowedShorts //
)
{
//
SetAlertPrefix(GetTag());
@@ -347,6 +348,20 @@ public:
tmpLSW,
true //
);
bool isBullishTrend1 = cBar.HasBullishTrend(
tmpHSW,
tmpLSW,
false //
);
bool hasBullishTrend =
//
isBullishTrend
//
||
//
isBullishTrend1
//
;
//
// Bearish ...
@@ -354,10 +369,71 @@ public:
bool hasBearishPattern = HasBearishPattern(cBar);
bool hasBearishPressure = cBar.HasBearishPressure();
bool isBearishTrend = cBar.HasBearishTrend(
tmpHSW,
tmpLSW,
true //
);
bool isBearishTrend1 = cBar.HasBearishTrend(
tmpHSW,
tmpLSW,
false //
);
bool hasBearishTrend =
//
isBearishTrend
//
||
//
isBearishTrend1
//
;
//
// Define Conditions ...
MqlTick ticks[];
int ticksCount = CopyTicks(
mSymbol,
ticks,
COPY_TICKS_ALL,
0,
5 //
);
//
bool isTicksBullishForLong =
//
GetTickEntry(ticks[0], POSITION_TYPE_BUY, mSymbol) > GetTickEntry(ticks[1], POSITION_TYPE_BUY, mSymbol) &&
GetTickEntry(ticks[1], POSITION_TYPE_BUY, mSymbol) > GetTickEntry(ticks[2], POSITION_TYPE_BUY, mSymbol) &&
GetTickEntry(ticks[2], POSITION_TYPE_BUY, mSymbol) > GetTickEntry(ticks[3], POSITION_TYPE_BUY, mSymbol)
//
;
//
bool isTicksBearishForLong =
//
GetTickEntry(ticks[0], POSITION_TYPE_BUY, mSymbol) < GetTickEntry(ticks[1], POSITION_TYPE_BUY, mSymbol) &&
GetTickEntry(ticks[1], POSITION_TYPE_BUY, mSymbol) < GetTickEntry(ticks[2], POSITION_TYPE_BUY, mSymbol) &&
GetTickEntry(ticks[2], POSITION_TYPE_BUY, mSymbol) < GetTickEntry(ticks[3], POSITION_TYPE_BUY, mSymbol)
//
;
//
bool isTicksBullishForShort =
//
GetTickEntry(ticks[0], POSITION_TYPE_SELL, mSymbol) > GetTickEntry(ticks[1], POSITION_TYPE_SELL, mSymbol) &&
GetTickEntry(ticks[1], POSITION_TYPE_SELL, mSymbol) > GetTickEntry(ticks[2], POSITION_TYPE_SELL, mSymbol) &&
GetTickEntry(ticks[2], POSITION_TYPE_SELL, mSymbol) > GetTickEntry(ticks[3], POSITION_TYPE_SELL, mSymbol)
//
;
//
bool isTicksBearishForShort =
//
GetTickEntry(ticks[0], POSITION_TYPE_SELL, mSymbol) < GetTickEntry(ticks[1], POSITION_TYPE_SELL, mSymbol) &&
GetTickEntry(ticks[1], POSITION_TYPE_SELL, mSymbol) < GetTickEntry(ticks[2], POSITION_TYPE_SELL, mSymbol) &&
GetTickEntry(ticks[2], POSITION_TYPE_SELL, mSymbol) < GetTickEntry(ticks[3], POSITION_TYPE_SELL, mSymbol)
//
;
//
bool notHaveBearishPower = (!chmConditions.hasBearishPower &&
@@ -378,58 +454,20 @@ public:
!chvwapConditions.hasBullishPower);
//
bool isCHHKFullSwitchedToBullish =
chhkHelper.IsSwitchedToBullish(cIndex);
bool isVWapBullishOrder =
chvwapHelper.IsBullishOrder(cIndex);
//
bool isCHHKFullBullishAndSorted =
chhkHelper.IsBullishSorted(cIndex);
bool isVWapSwitchedToBullishOrder =
chvwapHelper.IsSwitchedToBullishOrder(cIndex);
//
bool isCHHKFullSwitchedToBearish =
chhkHelper.IsSwitchedToBearish(cIndex);
bool isVWapBearishOrder =
chvwapHelper.IsBearishOrder(cIndex);
//
bool isCHHKFullBearishAndSorted =
chhkHelper.IsBearishSorted(cIndex);
//
bool isBearishPowerDecreasing =
//
conditions.chhkConditions.isBearishPowerDecreasing &&
conditions.chcheConditions.isBearishPowerDecreasing
//
;
//
bool isBullishPowerDecreasing =
//
conditions.chhkConditions.isBullishPowerDecreasing &&
conditions.chcheConditions.isBullishPowerDecreasing
//
;
//
bool hasBearishDecision =
//
cBar.IsBearishDecision()
//
||
//
pBar.IsBearishDecision()
//
;
//
bool hasBullishDecision =
//
cBar.IsBullishDecision()
//
||
//
pBar.IsBullishDecision()
//
;
bool isVWapSwitchedToBearishOrder =
chvwapHelper.IsSwitchedToBearishOrder(cIndex);
//
double long1SL =
@@ -454,13 +492,15 @@ public:
//
bool hasLong1 =
//
isBullishTrend &&
hasBullishTrend &&
(hasBullishPower ||
hasBullishPattern ||
hasBullishPressure) &&
hasBullishDecision &&
notHaveBearishPower &&
isCHHKFullSwitchedToBullish
isTicksBullishForLong &&
(isVWapBullishOrder ||
isVWapSwitchedToBullishOrder) &&
chvwapConditions.hasBullishPower
//
;
if (hasLong1)
@@ -480,13 +520,15 @@ public:
//
bool hasShort1 =
//
isBearishTrend &&
hasBearishTrend &&
(hasBearishPower ||
hasBearishPattern ||
hasBearishPressure) &&
hasBearishDecision &&
notHaveBullishPower &&
isCHHKFullSwitchedToBearish
isTicksBullishForShort &&
(isVWapBearishOrder ||
isVWapSwitchedToBearishOrder) &&
chvwapConditions.hasBearishPower
//
;
if (hasShort1)
@@ -503,70 +545,11 @@ public:
type = POSITION_TYPE_SELL;
}
//
// Second Condition ...
//
bool hasLong2 =
//
isBullishTrend &&
(hasBullishPower ||
hasBullishPattern ||
hasBullishPressure) &&
hasBullishDecision &&
notHaveBearishPower &&
isCHHKFullBullishAndSorted
//
;
if (hasLong2)
{
//
pushers++;
Add(
"XCHHKE2",
signallers //
);
//
sl = long1SL;
type = POSITION_TYPE_BUY;
}
//
bool hasShort2 =
//
isBearishTrend &&
(hasBearishPower ||
hasBearishPattern ||
hasBearishPressure) &&
hasBearishDecision &&
notHaveBullishPower &&
isCHHKFullBearishAndSorted
//
;
if (hasShort2)
{
//
pushers++;
Add(
"XCHHKE2",
signallers //
);
//
sl = short1SL;
type = POSITION_TYPE_SELL;
}
//
hasLong =
//
hasLong1
//
||
//
hasLong2
//
;
//
@@ -574,10 +557,6 @@ public:
//
hasShort1
//
||
//
hasShort2
//
;
//
@@ -665,7 +644,7 @@ public:
//
// Protected ...
protected:
protected:
//
// Props ...
@@ -718,7 +697,7 @@ protected:
//
// Private ...
private:
private:
//
// Props ...
@@ -1084,10 +1063,10 @@ private:
chvwapInputs.hcPeriod = hcPeriod;
//
chvwapInputs.showShort = false;
chvwapInputs.showMedium = false;
chvwapInputs.showLong = false;
chvwapInputs.showHind = false;
chvwapInputs.showShort = true;
chvwapInputs.showMedium = true;
chvwapInputs.showLong = true;
chvwapInputs.showHind = true;
//
chvwapHelper = new XSCXCHVWAPHelper();