CleanUp Workspace after Backup all Contents Even X121 Setup ...
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
//
|
||||
// Import(s) Helper(s) ...
|
||||
#include "../Helpers/x-saherelm.xpv.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xche.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xchm.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xchhk.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xchche.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xchstr.helper.mq5"
|
||||
|
||||
//
|
||||
@@ -103,12 +103,12 @@ public:
|
||||
{
|
||||
//
|
||||
delete pvHelper;
|
||||
delete cheHelper;
|
||||
|
||||
//
|
||||
delete chmHelper;
|
||||
delete chhkHelper;
|
||||
delete chstrHelper;
|
||||
delete chcheHelper;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -139,15 +139,15 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
bool EnableXCHE()
|
||||
bool EnableXCHCHE()
|
||||
{
|
||||
return mEnableXCHE;
|
||||
return mEnableXCHCHE;
|
||||
}
|
||||
|
||||
//
|
||||
void EnableXCHE(bool value)
|
||||
void EnableXCHCHE(bool value)
|
||||
{
|
||||
mEnableXCHE = value;
|
||||
mEnableXCHCHE = value;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -457,15 +457,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
XCHEConditions cheConditions;
|
||||
result = cheHelper.GetConditions(cheConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XCHM ...
|
||||
XCHMConditions chmConditions;
|
||||
@@ -493,6 +484,15 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XCHCHE ...
|
||||
XCHCHEConditions chcheConditions;
|
||||
result = chcheHelper.GetConditions(chcheConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Start Calculations ...
|
||||
|
||||
@@ -885,47 +885,7 @@ public:
|
||||
);
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
|
||||
//
|
||||
if (cheConditions.long1[pIndex] > 0 &&
|
||||
cheConditions.long2[pIndex] > 0 &&
|
||||
cheConditions.long1[pIndex] != EMPTY_VALUE &&
|
||||
cheConditions.long2[pIndex] != EMPTY_VALUE &&
|
||||
!cheConditions.isStrongBullish)
|
||||
{
|
||||
//
|
||||
cheLastLongExitTime = pBar.time;
|
||||
cheLastLongExit1 = cheConditions.long1[pIndex];
|
||||
cheLastLongExit2 = cheConditions.long2[pIndex];
|
||||
}
|
||||
|
||||
//
|
||||
if (cheConditions.short1[pIndex] > 0 &&
|
||||
cheConditions.short2[pIndex] > 0 &&
|
||||
cheConditions.short1[pIndex] != EMPTY_VALUE &&
|
||||
cheConditions.short2[pIndex] != EMPTY_VALUE &&
|
||||
!cheConditions.isStrongBearish)
|
||||
{
|
||||
//
|
||||
cheLastShortExitTime = pBar.time;
|
||||
cheLastShortExit1 = cheConditions.short1[pIndex];
|
||||
cheLastShortExit2 = cheConditions.short2[pIndex];
|
||||
}
|
||||
|
||||
//
|
||||
double chhkBullishPower = chhkHelper.GetBullishPower(cIndex);
|
||||
double chhkBearishPower = chhkHelper.GetBearishPower(cIndex);
|
||||
|
||||
//
|
||||
double chhkMinBearishHigh = chhkHelper.GetMinBearishHigh(cIndex);
|
||||
double chhkMaxBearishHigh = chhkHelper.GetMaxBearishHigh(cIndex);
|
||||
double chhkMinBearishLow = chhkHelper.GetMinBearishLow(cIndex);
|
||||
double chhkMaxBearishLow = chhkHelper.GetMaxBearishLow(cIndex);
|
||||
double chhkMaxBullishHigh = chhkHelper.GetMaxBullishHigh(cIndex);
|
||||
double chhkMinBullishHigh = chhkHelper.GetMinBullishHigh(cIndex);
|
||||
double chhkMaxBullishLow = chhkHelper.GetMaxBullishLow(cIndex);
|
||||
double chhkMinBullishLow = chhkHelper.GetMinBullishLow(cIndex);
|
||||
// XCHM ...
|
||||
|
||||
//
|
||||
double chmBullishPower = chmHelper.GetBullishPower(cIndex);
|
||||
@@ -941,6 +901,26 @@ public:
|
||||
double chmMaxBearishSlow = chmHelper.GetMaxBearishSlow(cIndex);
|
||||
double chmMinBearishSlow = chmHelper.GetMinBearishSlow(cIndex);
|
||||
|
||||
//
|
||||
// XCHHK ...
|
||||
|
||||
//
|
||||
double chhkBullishPower = chhkHelper.GetBullishPower(cIndex);
|
||||
double chhkBearishPower = chhkHelper.GetBearishPower(cIndex);
|
||||
|
||||
//
|
||||
double chhkMinBearishHigh = chhkHelper.GetMinBearishHigh(cIndex);
|
||||
double chhkMaxBearishHigh = chhkHelper.GetMaxBearishHigh(cIndex);
|
||||
double chhkMinBearishLow = chhkHelper.GetMinBearishLow(cIndex);
|
||||
double chhkMaxBearishLow = chhkHelper.GetMaxBearishLow(cIndex);
|
||||
double chhkMaxBullishHigh = chhkHelper.GetMaxBullishHigh(cIndex);
|
||||
double chhkMinBullishHigh = chhkHelper.GetMinBullishHigh(cIndex);
|
||||
double chhkMaxBullishLow = chhkHelper.GetMaxBullishLow(cIndex);
|
||||
double chhkMinBullishLow = chhkHelper.GetMinBullishLow(cIndex);
|
||||
|
||||
//
|
||||
// XCHSTR ...
|
||||
|
||||
//
|
||||
double chstrBullishPower = chstrHelper.GetBullishPower(cIndex);
|
||||
double chstrBearishPower = chstrHelper.GetBearishPower(cIndex);
|
||||
@@ -952,94 +932,22 @@ public:
|
||||
double chstrMaxBearish = chstrHelper.GetMaxBearish(cIndex);
|
||||
|
||||
//
|
||||
double cheMaxLE = cheHelper.GetMaxLongExit(cIndex);
|
||||
double cheMinLE = cheHelper.GetMinLongExit(cIndex);
|
||||
double cheMaxSE = cheHelper.GetMaxShortExit(cIndex);
|
||||
double cheMinSE = cheHelper.GetMinShortExit(cIndex);
|
||||
// XCHCHE ...
|
||||
|
||||
//
|
||||
double chcheBullishPower = chcheHelper.GetBullishPower(cIndex);
|
||||
double chcheBearishPower = chcheHelper.GetBearishPower(cIndex);
|
||||
|
||||
//
|
||||
double chcheMaxBullish = chcheHelper.GetBullishMax(cIndex);
|
||||
double chcheMinBullish = chcheHelper.GetBullishMin(cIndex);
|
||||
double chcheMaxBearish = chcheHelper.GetBearishMax(cIndex);
|
||||
double chcheMinBearish = chcheHelper.GetBearishMin(cIndex);
|
||||
|
||||
//
|
||||
int pushers = 0;
|
||||
string signallers[];
|
||||
|
||||
//
|
||||
// XCHHK ...
|
||||
if (mEnableXCHHK)
|
||||
{
|
||||
//
|
||||
if (chhkConditions.isBullishPowerUp)
|
||||
{
|
||||
//
|
||||
bool chhkHasLong =
|
||||
//
|
||||
hasBullishPower &&
|
||||
cBar.IsBullish() &&
|
||||
hasBullishPattern &&
|
||||
hasBullishPressure &&
|
||||
cheConditions.isStrongBullish &&
|
||||
cBar.low > chhkMinBullishHigh &&
|
||||
chhkConditions.isBullishPowerUp
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (chhkHasLong)
|
||||
{
|
||||
//
|
||||
hasLong = chhkHasLong;
|
||||
if (hasLong)
|
||||
{
|
||||
//
|
||||
pushers++;
|
||||
Add(
|
||||
"XCHHK",
|
||||
signallers //
|
||||
);
|
||||
|
||||
//
|
||||
sl = chhkMaxBullishLow;
|
||||
type = POSITION_TYPE_BUY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (chhkConditions.isBearishPowerUp)
|
||||
{
|
||||
//
|
||||
bool chhkHasShort =
|
||||
//
|
||||
hasBearishPower &&
|
||||
cBar.IsBearish() &&
|
||||
hasBearishPattern &&
|
||||
hasBearishPressure &&
|
||||
cheConditions.isStrongBearish &&
|
||||
cBar.high < chhkMaxBearishLow &&
|
||||
chhkConditions.isBearishPowerUp
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (chhkHasShort)
|
||||
{
|
||||
//
|
||||
hasShort = chhkHasShort;
|
||||
if (hasShort)
|
||||
{
|
||||
//
|
||||
pushers++;
|
||||
Add(
|
||||
"XCHHK",
|
||||
signallers //
|
||||
);
|
||||
|
||||
//
|
||||
sl = chhkMinBearishHigh;
|
||||
type = POSITION_TYPE_SELL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XCHM ...
|
||||
if (mEnableXCHM)
|
||||
@@ -1055,8 +963,8 @@ public:
|
||||
hasBullishPattern &&
|
||||
hasBullishPressure &&
|
||||
cBar.low > chmMinBullishFast &&
|
||||
cheConditions.isStrongBullish &&
|
||||
chmConditions.isBullishPowerUp
|
||||
chmConditions.isBullishPowerUp &&
|
||||
chcheConditions.isCStrongBullish
|
||||
//
|
||||
;
|
||||
|
||||
@@ -1092,8 +1000,8 @@ public:
|
||||
hasBearishPattern &&
|
||||
hasBearishPressure &&
|
||||
cBar.high < chmMaxBearishFast &&
|
||||
cheConditions.isStrongBearish &&
|
||||
chmConditions.isBearishPowerUp
|
||||
chmConditions.isBearishPowerUp &&
|
||||
chcheConditions.isCStrongBearish
|
||||
//
|
||||
;
|
||||
|
||||
@@ -1119,6 +1027,85 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XCHHK ...
|
||||
if (mEnableXCHHK)
|
||||
{
|
||||
//
|
||||
if (chhkConditions.isBullishPowerUp)
|
||||
{
|
||||
//
|
||||
bool chhkHasLong =
|
||||
//
|
||||
hasBullishPower &&
|
||||
cBar.IsBullish() &&
|
||||
hasBullishPattern &&
|
||||
hasBullishPressure &&
|
||||
cBar.low > chhkMinBullishHigh &&
|
||||
chhkConditions.isBullishPowerUp &&
|
||||
chcheConditions.isCStrongBullish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (chhkHasLong)
|
||||
{
|
||||
//
|
||||
hasLong = chhkHasLong;
|
||||
if (hasLong)
|
||||
{
|
||||
//
|
||||
pushers++;
|
||||
Add(
|
||||
"XCHHK",
|
||||
signallers //
|
||||
);
|
||||
|
||||
//
|
||||
sl = chhkMaxBullishLow;
|
||||
type = POSITION_TYPE_BUY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (chhkConditions.isBearishPowerUp)
|
||||
{
|
||||
//
|
||||
bool chhkHasShort =
|
||||
//
|
||||
hasBearishPower &&
|
||||
cBar.IsBearish() &&
|
||||
hasBearishPattern &&
|
||||
hasBearishPressure &&
|
||||
cBar.high < chhkMaxBearishLow &&
|
||||
chhkConditions.isBearishPowerUp &&
|
||||
chcheConditions.isCStrongBearish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (chhkHasShort)
|
||||
{
|
||||
//
|
||||
hasShort = chhkHasShort;
|
||||
if (hasShort)
|
||||
{
|
||||
//
|
||||
pushers++;
|
||||
Add(
|
||||
"XCHHK",
|
||||
signallers //
|
||||
);
|
||||
|
||||
//
|
||||
sl = chhkMinBearishHigh;
|
||||
type = POSITION_TYPE_SELL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XCHSTR ...
|
||||
if (mEnableXCHSTR)
|
||||
@@ -1134,8 +1121,8 @@ public:
|
||||
hasBullishPattern &&
|
||||
hasBullishPressure &&
|
||||
cBar.low > chstrMinBullish &&
|
||||
cheConditions.isStrongBullish &&
|
||||
chstrConditions.isBullishPowerUp
|
||||
chstrConditions.isBullishPowerUp &&
|
||||
chcheConditions.isCStrongBullish
|
||||
//
|
||||
;
|
||||
|
||||
@@ -1171,8 +1158,8 @@ public:
|
||||
hasBearishPattern &&
|
||||
hasBearishPressure &&
|
||||
cBar.high < chstrMaxBearish &&
|
||||
cheConditions.isStrongBearish &&
|
||||
chstrConditions.isBearishPowerUp
|
||||
chstrConditions.isBearishPowerUp &&
|
||||
chcheConditions.isCStrongBearish
|
||||
//
|
||||
;
|
||||
|
||||
@@ -1199,80 +1186,78 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
if (mEnableXCHE)
|
||||
// XCHCHE ...
|
||||
if (mEnableXCHCHE)
|
||||
{
|
||||
//
|
||||
if (cheConditions.isStrongBullish)
|
||||
if (chcheConditions.isBullishPowerUp)
|
||||
{
|
||||
//
|
||||
bool cheHasLong =
|
||||
bool chcheHasLong =
|
||||
//
|
||||
HasCheLast() &&
|
||||
cheMinLE > 0 &&
|
||||
hasBullishPower &&
|
||||
cBar.IsBullish() &&
|
||||
hasBullishPattern &&
|
||||
hasBullishPressure &&
|
||||
cheMinLE > GetMaxCHELast() &&
|
||||
cheConditions.isStrongBullish
|
||||
cBar.low > chcheMinBullish &&
|
||||
chcheConditions.isBullishPowerUp &&
|
||||
chcheConditions.isCStrongBullish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (cheHasLong)
|
||||
if (chcheHasLong)
|
||||
{
|
||||
//
|
||||
hasLong = cheHasLong;
|
||||
hasLong = chcheHasLong;
|
||||
if (hasLong)
|
||||
{
|
||||
//
|
||||
pushers++;
|
||||
Add(
|
||||
"XCHE",
|
||||
"XCHCHE",
|
||||
signallers //
|
||||
);
|
||||
|
||||
//
|
||||
sl = cheMinLE;
|
||||
sl = chcheMinBullish;
|
||||
type = POSITION_TYPE_BUY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (cheConditions.isStrongBearish)
|
||||
if (chcheConditions.isBearishPowerUp)
|
||||
{
|
||||
//
|
||||
bool cheHasShort =
|
||||
bool chcheHasShort =
|
||||
//
|
||||
HasCheLast() &&
|
||||
cheMaxSE > 0 &&
|
||||
hasBearishPower &&
|
||||
cBar.IsBearish() &&
|
||||
hasBearishPattern &&
|
||||
hasBearishPressure &&
|
||||
cheMaxSE < GetMinCHELast() &&
|
||||
cheConditions.isStrongBearish
|
||||
cBar.high < chcheMaxBearish &&
|
||||
chcheConditions.isBearishPowerUp &&
|
||||
chcheConditions.isCStrongBearish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (cheHasShort)
|
||||
if (chcheHasShort)
|
||||
{
|
||||
//
|
||||
hasShort = cheHasShort;
|
||||
hasShort = chcheHasShort;
|
||||
if (hasShort)
|
||||
{
|
||||
//
|
||||
pushers++;
|
||||
Add(
|
||||
"XCHE",
|
||||
"XCHCHE",
|
||||
signallers //
|
||||
);
|
||||
|
||||
//
|
||||
sl = cheMaxSE;
|
||||
sl = chcheMaxBearish;
|
||||
type = POSITION_TYPE_SELL;
|
||||
}
|
||||
}
|
||||
@@ -1433,10 +1418,10 @@ protected:
|
||||
bool mDrawImportantAreas; // Draw Important Areas where Founded in Analyzing Time Frame
|
||||
|
||||
//
|
||||
bool mEnableXCHE; // Enable XCHE Signaller
|
||||
bool mEnableXCHM; // Enable XCHM Signaller
|
||||
bool mEnableXCHHK; // Enable XCHHK Signaller
|
||||
bool mEnableXCHSTR; // Enable XCHSTR Signaller
|
||||
bool mEnableXCHCHE; // Enable XCHCHE Signaller
|
||||
|
||||
//
|
||||
XOHCL support;
|
||||
@@ -1469,16 +1454,6 @@ protected:
|
||||
XPVInputs pvInputs;
|
||||
XSCXPVHelper *pvHelper;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
XCHSTRInputs chstrInputs;
|
||||
XSCXCHSTRHelper *chstrHelper;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
XCHEInputs cheInputs;
|
||||
XSCXCHEHelper *cheHelper;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XCHHKInputs chhkInputs;
|
||||
@@ -1489,6 +1464,16 @@ protected:
|
||||
XCHMInputs chmInputs;
|
||||
XSCXCHMHelper *chmHelper;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
XCHSTRInputs chstrInputs;
|
||||
XSCXCHSTRHelper *chstrHelper;
|
||||
|
||||
//
|
||||
// XCHCHE ...
|
||||
XCHCHEInputs chcheInputs;
|
||||
XSCXCHCHEHelper *chcheHelper;
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
@@ -1504,10 +1489,10 @@ private:
|
||||
mDrawImportantAreas = false;
|
||||
|
||||
//
|
||||
mEnableXCHE = true;
|
||||
mEnableXCHM = true;
|
||||
mEnableXCHHK = true;
|
||||
mEnableXCHSTR = true;
|
||||
mEnableXCHCHE = true;
|
||||
|
||||
//
|
||||
support.Clean();
|
||||
@@ -1573,26 +1558,6 @@ private:
|
||||
pvInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
|
||||
//
|
||||
cheInputs.Default();
|
||||
|
||||
//
|
||||
cheInputs.showLongExit1Line = false;
|
||||
cheInputs.showShortExit1Line = false;
|
||||
cheInputs.showLongExit2Line = false;
|
||||
cheInputs.showShortExit2Line = false;
|
||||
|
||||
//
|
||||
cheHelper = new XSCXCHEHelper();
|
||||
cheHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
cheInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// XCHM ...
|
||||
|
||||
@@ -1695,6 +1660,42 @@ private:
|
||||
mPeriod,
|
||||
chstrInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// XCHCHE ...
|
||||
|
||||
//
|
||||
chcheInputs.Default();
|
||||
|
||||
//
|
||||
chcheInputs.showCurrentLE1 = true;
|
||||
chcheInputs.showCurrentLE2 = true;
|
||||
chcheInputs.showCurrentSE1 = true;
|
||||
chcheInputs.showCurrentSE2 = true;
|
||||
chcheInputs.showShortLE1 = true;
|
||||
chcheInputs.showShortLE2 = true;
|
||||
chcheInputs.showShortSE1 = true;
|
||||
chcheInputs.showShortSE2 = true;
|
||||
chcheInputs.showMediumLE1 = true;
|
||||
chcheInputs.showMediumLE2 = true;
|
||||
chcheInputs.showMediumSE1 = true;
|
||||
chcheInputs.showMediumSE2 = true;
|
||||
chcheInputs.showLongLE1 = true;
|
||||
chcheInputs.showLongLE2 = true;
|
||||
chcheInputs.showLongSE1 = true;
|
||||
chcheInputs.showLongSE2 = true;
|
||||
chcheInputs.showHindLE1 = true;
|
||||
chcheInputs.showHindLE2 = true;
|
||||
chcheInputs.showHindSE1 = true;
|
||||
chcheInputs.showHindSE2 = true;
|
||||
|
||||
//
|
||||
chcheHelper = new XSCXCHCHEHelper();
|
||||
chcheHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
chcheInputs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -1,882 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XSCXDTDStrategy
|
||||
// Description: provides all based classes for use ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
|
||||
//
|
||||
// Import(s) Helper(s) ...
|
||||
#include "../Helpers/x-saherelm.xhk.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xpv.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xtd.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xdon.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xvlm.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xosc.helper.mq5"
|
||||
|
||||
//
|
||||
// Base Classes ...
|
||||
#include "../Classes/x-saherelm.xstrategy.class.mq5"
|
||||
|
||||
//
|
||||
// Specific Identifier(s) of XStrategy ...
|
||||
string XDTDStartegyToken = "XDTD";
|
||||
|
||||
//
|
||||
// XStrategy Class Implementation(s) ...
|
||||
class XSCXDTDStrategy : public XSCBaseStrategy
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XSCXDTDStrategy(
|
||||
//
|
||||
// Base ...
|
||||
string _symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES _period, // Trading TimeFrame
|
||||
double _volume, // Voluem
|
||||
double _r2r, // Risk/Reward Ratio
|
||||
int _slippage, // Trader Slippage
|
||||
long _magicNumber, // Trader Magic Number
|
||||
bool _ignoreSignalExecution = false, // Ignore Signal Execution
|
||||
bool _useTPSLAsPoint = false, // Converts TP and SL by Provided Points
|
||||
bool _forceMaxTPSLAsPoint = false, // Force Max TP and SL by Provided Points
|
||||
double _tpPoint = 0, // TP As Point
|
||||
double _slPoint = 0, // SL As Point
|
||||
bool _ignoreTP = false, // TP set to 0
|
||||
bool _ignoreSL = false, // SL set to 0
|
||||
bool _allowLong = true,
|
||||
bool _allowShort = true,
|
||||
int _maxAllowedLongs = 0,
|
||||
int _maxAllowedShorts = 0 //
|
||||
) : XSCBaseStrategy(_symbol,
|
||||
_period,
|
||||
_volume,
|
||||
_r2r,
|
||||
_slippage,
|
||||
_magicNumber,
|
||||
_ignoreSignalExecution,
|
||||
_useTPSLAsPoint,
|
||||
_forceMaxTPSLAsPoint,
|
||||
_tpPoint,
|
||||
_slPoint,
|
||||
_ignoreTP,
|
||||
_ignoreSL,
|
||||
_allowLong,
|
||||
_allowShort,
|
||||
_maxAllowedLongs,
|
||||
_maxAllowedShorts //
|
||||
)
|
||||
{
|
||||
//
|
||||
SetAlertPrefix(GetTag());
|
||||
|
||||
//
|
||||
PrepareRequirements();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCXDTDStrategy()
|
||||
{
|
||||
//
|
||||
delete pvHelper;
|
||||
delete tdHelper;
|
||||
delete hkHelper;
|
||||
delete oscHelper;
|
||||
delete vlmHelper;
|
||||
delete donHelper;
|
||||
}
|
||||
|
||||
//
|
||||
// Getter / Setter (s) ...
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
//
|
||||
// Customize Strategy Identifier ...
|
||||
string GetTag() override
|
||||
{
|
||||
return XDTDStartegyToken;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Conditions For Signal ...
|
||||
bool HasSignal(
|
||||
XSignal &signal //
|
||||
) override
|
||||
{
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
bool hasLong = false;
|
||||
bool hasShort = false;
|
||||
|
||||
//
|
||||
// Retrieve Conditions ...
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XPVConditions pvConditions;
|
||||
result = pvHelper.GetConditions(pvConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XTD ...
|
||||
XTDConditions tdConditions;
|
||||
result = tdHelper.GetConditions(tdConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XHKConditions hkConditions;
|
||||
result = hkHelper.GetConditions(hkConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XVLM ...
|
||||
XVLMConditions vlmConditions;
|
||||
result = vlmHelper.GetConditions(vlmConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
|
||||
//
|
||||
// Open ...
|
||||
double upperOs[];
|
||||
double lowerOs[];
|
||||
ArraySetAsSeries(upperOs, true);
|
||||
ArraySetAsSeries(lowerOs, true);
|
||||
donHelper.CopyUpperO(
|
||||
0,
|
||||
5,
|
||||
upperOs //
|
||||
);
|
||||
donHelper.CopyLowerO(
|
||||
0,
|
||||
5,
|
||||
lowerOs //
|
||||
);
|
||||
|
||||
//
|
||||
// Close ...
|
||||
double upperCs[];
|
||||
double lowerCs[];
|
||||
ArraySetAsSeries(upperCs, true);
|
||||
ArraySetAsSeries(lowerCs, true);
|
||||
donHelper.CopyUpperC(
|
||||
0,
|
||||
5,
|
||||
upperCs //
|
||||
);
|
||||
donHelper.CopyLowerC(
|
||||
0,
|
||||
5,
|
||||
lowerCs //
|
||||
);
|
||||
|
||||
//
|
||||
// High ...
|
||||
double upperHs[];
|
||||
double lowerHs[];
|
||||
ArraySetAsSeries(upperHs, true);
|
||||
ArraySetAsSeries(lowerHs, true);
|
||||
donHelper.CopyUpperH(
|
||||
0,
|
||||
5,
|
||||
upperHs //
|
||||
);
|
||||
donHelper.CopyLowerH(
|
||||
0,
|
||||
5,
|
||||
lowerHs //
|
||||
);
|
||||
|
||||
//
|
||||
// Low ...
|
||||
double upperLs[];
|
||||
double lowerLs[];
|
||||
ArraySetAsSeries(upperLs, true);
|
||||
ArraySetAsSeries(lowerLs, true);
|
||||
donHelper.CopyUpperL(
|
||||
0,
|
||||
5,
|
||||
upperLs //
|
||||
);
|
||||
donHelper.CopyLowerL(
|
||||
0,
|
||||
5,
|
||||
lowerLs //
|
||||
);
|
||||
|
||||
//
|
||||
double atr = oscHelper.GetATR(1);
|
||||
|
||||
//
|
||||
double rsis[];
|
||||
ArraySetAsSeries(rsis, true);
|
||||
oscHelper.CopyRSI(
|
||||
0,
|
||||
3,
|
||||
rsis //
|
||||
);
|
||||
|
||||
//
|
||||
// Start Calculations ...
|
||||
|
||||
//
|
||||
double points = GetPoints(mSymbol);
|
||||
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
// Retrieve Bars ...
|
||||
|
||||
//
|
||||
// Last Bar ...
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous Bar of Last Bar ...
|
||||
XOHCL pBar;
|
||||
result = cBar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Last Swing Low Bar ...
|
||||
XOHCL lastSwingLow;
|
||||
result = cBar.FindLastSwingLow(lastSwingLow);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Last Swing High Bar ...
|
||||
XOHCL lastSwingHigh;
|
||||
result = cBar.FindLastSwingHigh(lastSwingHigh);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Highest High(s) and Lowest Low(s) ...
|
||||
|
||||
//
|
||||
// Highest High ...
|
||||
double hh3 = cBar.FindHighest(
|
||||
3,
|
||||
MODE_HIGH //
|
||||
);
|
||||
|
||||
//
|
||||
// Lowest Low ...
|
||||
double ll3 = cBar.FindLowest(
|
||||
3,
|
||||
MODE_LOW //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Support Exists or Find ...
|
||||
bool hasSupport = support.IsValid();
|
||||
if (!hasSupport)
|
||||
{
|
||||
//
|
||||
hasSupport =
|
||||
//
|
||||
cBar.HasSupport(support)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
DrawSupport(
|
||||
support,
|
||||
ChartID() //
|
||||
);
|
||||
|
||||
//
|
||||
supportTime = cBar.time;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Resistance Exists or Find ...
|
||||
bool hasResistance = resistance.IsValid();
|
||||
if (!hasResistance)
|
||||
{
|
||||
//
|
||||
hasResistance =
|
||||
//
|
||||
cBar.HasResistance(resistance)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasResistance)
|
||||
{
|
||||
//
|
||||
DrawResistance(
|
||||
resistance,
|
||||
ChartID() //
|
||||
);
|
||||
|
||||
//
|
||||
resistanceTime = cBar.time;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// For Trend ...
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
// Detect Bullish/Bearish Patterns and Trends ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool hasBullishPattern = HasBullishPattern(cBar);
|
||||
bool isBullishTrend = cBar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool hasBearishPattern = HasBearishPattern(cBar);
|
||||
bool isBearishTrend = cBar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
// Detect Conditions ...
|
||||
// Prepare Required Conditions ...
|
||||
|
||||
//
|
||||
// High Upper => tpp top
|
||||
// Low Upper => top bottom
|
||||
|
||||
//
|
||||
// High Lower => bottom top
|
||||
// Low Lower => bottom bottom
|
||||
|
||||
//
|
||||
bool isUpperBandToched = IsValid(upperTouchTime);
|
||||
if (!isUpperBandToched)
|
||||
{
|
||||
//
|
||||
isUpperBandToched =
|
||||
//
|
||||
(cBar.high > upperLs[cIndex])
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
bool isLowerBandToched = IsValid(lowerTouchTime);
|
||||
if (!isLowerBandToched)
|
||||
{
|
||||
//
|
||||
isLowerBandToched =
|
||||
//
|
||||
(cBar.low < lowerHs[cIndex])
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
// Looking for Signals Based on Conditions ...
|
||||
|
||||
//
|
||||
if (isLowerBandToched)
|
||||
{
|
||||
//
|
||||
hasLong =
|
||||
//
|
||||
hasBullishPattern
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasLong)
|
||||
{
|
||||
//
|
||||
type = POSITION_TYPE_BUY;
|
||||
Print("");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (isUpperBandToched)
|
||||
{
|
||||
//
|
||||
hasShort =
|
||||
//
|
||||
hasBearishPattern
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasShort)
|
||||
{
|
||||
//
|
||||
type = POSITION_TYPE_SELL;
|
||||
Print("");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Preparing Signals for Execution ...
|
||||
|
||||
//
|
||||
result = hasLong || hasShort;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
CheckSupportValidation();
|
||||
CheckResistanceValidation();
|
||||
|
||||
//
|
||||
CheckUpperTouchTimeValidation();
|
||||
CheckLowerTouchTimeValidation();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
supportTime = NULL;
|
||||
isSupportTested = false;
|
||||
RemoveSupport(support);
|
||||
support.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (hasResistance)
|
||||
{
|
||||
//
|
||||
resistanceTime = NULL;
|
||||
isResistanceTested = false;
|
||||
RemoveResistance(resistance);
|
||||
resistance.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Entry Price based on Position Type ...
|
||||
entry = GetEntry(mSymbol, type);
|
||||
|
||||
//
|
||||
// Calculate TP and SL ...
|
||||
// based on Strategy ...
|
||||
CalculateTPSLByPrice(
|
||||
sl,
|
||||
tp,
|
||||
type,
|
||||
entry,
|
||||
r2r //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing Signal ...
|
||||
result = signal.Prepare(
|
||||
mSymbol,
|
||||
GetTag(),
|
||||
mPeriod,
|
||||
type,
|
||||
mode,
|
||||
entry,
|
||||
mVolume,
|
||||
sl,
|
||||
tp //
|
||||
);
|
||||
|
||||
//
|
||||
if (result) {
|
||||
//
|
||||
upperTouchTime = NULL;
|
||||
lowerTouchTime = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
XOHCL support;
|
||||
XOHCL resistance;
|
||||
|
||||
//
|
||||
// XTD ...
|
||||
XTDInputs tdInputs;
|
||||
XSCXTDHelper *tdHelper;
|
||||
|
||||
//
|
||||
// XOSC ...
|
||||
XOSCInputs oscInputs;
|
||||
XSCXOSCHelper *oscHelper;
|
||||
|
||||
//
|
||||
// XVLM ...
|
||||
XVLMInputs vlmInputs;
|
||||
XSCXVLMHelper *vlmHelper;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XHKInputs hkInputs;
|
||||
XSCXHKHelper *hkHelper;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XPVInputs pvInputs;
|
||||
XSCXPVHelper *pvHelper;
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
XDONInputs donInputs;
|
||||
XSCXDONHelper *donHelper;
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
void PrepareRequirements()
|
||||
{
|
||||
//
|
||||
support.Clean();
|
||||
supportTime = NULL;
|
||||
isSupportTested = false;
|
||||
|
||||
//
|
||||
resistance.Clean();
|
||||
resistanceTime = NULL;
|
||||
isResistanceTested = false;
|
||||
|
||||
//
|
||||
// Prepare XTD ...
|
||||
tdInputs.Default();
|
||||
|
||||
//
|
||||
tdHelper = new XSCXTDHelper();
|
||||
tdHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
tdInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XHK ...
|
||||
hkInputs.Default();
|
||||
hkInputs.smoothingLength = 14;
|
||||
|
||||
//
|
||||
hkInputs.drawHikenAshi = false;
|
||||
hkInputs.drawSmoothedHikenAshi = true;
|
||||
|
||||
//
|
||||
hkHelper = new XSCXHKHelper();
|
||||
hkHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
hkInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XPV ...
|
||||
pvInputs.Default();
|
||||
|
||||
//
|
||||
pvInputs.showPeaksAndVales = true;
|
||||
pvInputs.showLevels = false;
|
||||
pvInputs.showConsolidations = false;
|
||||
pvInputs.showFibo1Levels = false;
|
||||
pvInputs.showFibo2Levels = false;
|
||||
pvInputs.showFibo3Levels = true;
|
||||
pvInputs.showFibo4Levels = false;
|
||||
pvInputs.showFibo5Levels = false;
|
||||
|
||||
//
|
||||
pvHelper = new XSCXPVHelper();
|
||||
pvHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
pvInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XOSC ...
|
||||
oscInputs.Default();
|
||||
oscHelper = new XSCXOSCHelper();
|
||||
oscHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
oscInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XVLM ...
|
||||
vlmInputs.Default();
|
||||
vlmHelper = new XSCXVLMHelper();
|
||||
vlmHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
vlmInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
|
||||
//
|
||||
donInputs.Default();
|
||||
|
||||
//
|
||||
donInputs.showLow = true;
|
||||
donInputs.showHigh = true;
|
||||
donInputs.showOpen = false;
|
||||
donInputs.showClose = false;
|
||||
|
||||
//
|
||||
donHelper = new XSCXDONHelper();
|
||||
donHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
donInputs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool isSupportTested;
|
||||
datetime supportTime;
|
||||
void CheckSupportValidation()
|
||||
{
|
||||
//
|
||||
if (!isSupportTested)
|
||||
{
|
||||
//
|
||||
if (support.IsValid() && IsValid(supportTime))
|
||||
{
|
||||
//
|
||||
int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(supportTime))) / PeriodSeconds(mPeriod));
|
||||
if (age >= 50)
|
||||
{
|
||||
//
|
||||
isSupportTested = false;
|
||||
supportTime = NULL;
|
||||
RemoveSupport(support);
|
||||
support.Clean();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double points = GetPoints(mSymbol);
|
||||
|
||||
//
|
||||
// Find Price Distance ...
|
||||
double highDiff = MathAbs(cBar.high - support.high);
|
||||
double lowDiff = MathAbs(cBar.low - support.high);
|
||||
|
||||
//
|
||||
bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points;
|
||||
if (!isBreaked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
isSupportTested = false;
|
||||
RemoveSupport(support);
|
||||
supportTime = NULL;
|
||||
support.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
bool isResistanceTested;
|
||||
datetime resistanceTime;
|
||||
void CheckResistanceValidation()
|
||||
{
|
||||
//
|
||||
if (!isResistanceTested)
|
||||
{
|
||||
//
|
||||
if (resistance.IsValid() && IsValid(resistanceTime))
|
||||
{
|
||||
//
|
||||
int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(resistanceTime))) / PeriodSeconds(mPeriod));
|
||||
if (age >= 50)
|
||||
{
|
||||
//
|
||||
isResistanceTested = false;
|
||||
resistanceTime = NULL;
|
||||
RemoveResistance(resistance);
|
||||
resistance.Clean();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double points = GetPoints(mSymbol);
|
||||
|
||||
//
|
||||
// Find Price Distance ...
|
||||
double highDiff = MathAbs(cBar.high - resistance.low);
|
||||
double lowDiff = MathAbs(cBar.low - resistance.low);
|
||||
|
||||
//
|
||||
bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points;
|
||||
if (!isBreaked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
isResistanceTested = false;
|
||||
RemoveResistance(resistance);
|
||||
resistanceTime = NULL;
|
||||
resistance.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
datetime lowerTouchTime;
|
||||
void CheckLowerTouchTimeValidation() {
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
datetime upperTouchTime;
|
||||
void CheckUpperTouchTimeValidation() {
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user