1803 lines
43 KiB
Plaintext
1803 lines
43 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// --------------------------------------
|
|
// Name: XSCXCHStrategy
|
|
// 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.xpv.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchm.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchhk.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchtd.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchche.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchstr.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xchvlm.helper.mq5"
|
|
|
|
//
|
|
// Base Classes ...
|
|
#include "../Classes/x-saherelm.xstrategy.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Specific Identifier(s) of XStrategy ...
|
|
string XCHStartegyToken = "XCH";
|
|
|
|
//
|
|
struct XCHStrategyConditions
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Common ...
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
datetime time;
|
|
|
|
//
|
|
// Important Ares attached ...
|
|
|
|
//
|
|
XOHCL support;
|
|
XOHCL resistance;
|
|
XOHCL bullishOB;
|
|
XOHCL bearishOB;
|
|
|
|
//
|
|
double bullishFVGUpper;
|
|
double bullishFVGLower;
|
|
XOHCL bullishFVG;
|
|
|
|
//
|
|
double bearishFVGUpper;
|
|
double bearishFVGLower;
|
|
XOHCL bearishFVG;
|
|
|
|
//
|
|
XOHCL bullishTrendSwingHighs[];
|
|
XOHCL bullishTrendSwingLows[];
|
|
XOHCL bullishTrend;
|
|
|
|
//
|
|
XOHCL bearishTrendSwingHighs[];
|
|
XOHCL bearishTrendSwingLows[];
|
|
XOHCL bearishTrend;
|
|
|
|
//
|
|
// Helper Conditions ...
|
|
XPVConditions pvConditions;
|
|
XCHMConditions chmConditions;
|
|
XCHHKConditions chhkConditions;
|
|
XCHTDConditions chtdConditions;
|
|
XCHCHEConditions chcheConditions;
|
|
XCHSTRConditions chstrConditions;
|
|
XCHVLMConditions chvlmConditions;
|
|
|
|
//
|
|
// Constructor ...
|
|
void XCHStrategyConditions()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean()
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
time = NULL;
|
|
|
|
//
|
|
pvConditions.Clean();
|
|
chmConditions.Clean();
|
|
chhkConditions.Clean();
|
|
chtdConditions.Clean();
|
|
chcheConditions.Clean();
|
|
chstrConditions.Clean();
|
|
chvlmConditions.Clean();
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsValid(time) &&
|
|
IsValid(symbol) &&
|
|
IsValid(period)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Generate Provided Scores ...
|
|
void GenerateScore(
|
|
double &bullishScore,
|
|
double &bearishScore //
|
|
)
|
|
{
|
|
//
|
|
bullishScore = 0;
|
|
bearishScore = 0;
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
double bullScore = 0;
|
|
double bearScore = 0;
|
|
|
|
//
|
|
// XPV ...
|
|
pvConditions.GenerateScore(
|
|
bullScore,
|
|
bearScore //
|
|
);
|
|
bullishScore += bullScore;
|
|
bearishScore += bearScore;
|
|
|
|
//
|
|
// XCHM ...
|
|
chmConditions.GenerateScore(
|
|
bullScore,
|
|
bearScore //
|
|
);
|
|
bullishScore += bullScore;
|
|
bearishScore += bearScore;
|
|
|
|
//
|
|
// XCHHK ...
|
|
chhkConditions.GenerateScore(
|
|
bullScore,
|
|
bearScore //
|
|
);
|
|
bullishScore += bullScore;
|
|
bearishScore += bearScore;
|
|
|
|
//
|
|
// XCHTD ...
|
|
chtdConditions.GenerateScore(
|
|
bullScore,
|
|
bearScore //
|
|
);
|
|
bullishScore += bullScore;
|
|
bearishScore += bearScore;
|
|
|
|
//
|
|
// XCHCHE ...
|
|
chcheConditions.GenerateScore(
|
|
bullScore,
|
|
bearScore //
|
|
);
|
|
bullishScore += bullScore;
|
|
bearishScore += bearScore;
|
|
|
|
//
|
|
// XCHSTR ...
|
|
chstrConditions.GenerateScore(
|
|
bullScore,
|
|
bearScore //
|
|
);
|
|
bullishScore += bullScore;
|
|
bearishScore += bearScore;
|
|
|
|
//
|
|
// XCHVLM ...
|
|
chvlmConditions.GenerateScore(
|
|
bullScore,
|
|
bearScore //
|
|
);
|
|
bullishScore += bullScore;
|
|
bearishScore += bearScore;
|
|
}
|
|
|
|
//
|
|
// Generate Summary ...
|
|
string GenerateSummary(
|
|
bool onlyCommons = false,
|
|
bool onlyConditions = false,
|
|
bool includeScores = true,
|
|
bool ignoreFalseConditions = true,
|
|
string separator = "\n" //
|
|
)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
double bullishScore = 0;
|
|
double bearishScore = 0;
|
|
GenerateScore(
|
|
bullishScore,
|
|
bearishScore //
|
|
);
|
|
|
|
//
|
|
string commonStr = GenerateSpecifiedCommonSummary(
|
|
this,
|
|
separator,
|
|
includeScores,
|
|
true //
|
|
);
|
|
|
|
//
|
|
// XPV ...
|
|
string pvStr = pvConditions.GenerateSummary(
|
|
false,
|
|
true,
|
|
false,
|
|
ignoreFalseConditions //
|
|
);
|
|
|
|
//
|
|
// XCHM ...
|
|
string chmStr = chmConditions.GenerateSummary(
|
|
false,
|
|
true,
|
|
false,
|
|
ignoreFalseConditions //
|
|
);
|
|
|
|
//
|
|
// XCHHK ...
|
|
string chhkStr = chhkConditions.GenerateSummary(
|
|
false,
|
|
true,
|
|
false,
|
|
ignoreFalseConditions //
|
|
);
|
|
|
|
//
|
|
// XCHTD ...
|
|
string chtdStr = chtdConditions.GenerateSummary(
|
|
false,
|
|
true,
|
|
false,
|
|
ignoreFalseConditions //
|
|
);
|
|
|
|
//
|
|
// XCHCHE ...
|
|
string chcheStr = chcheConditions.GenerateSummary(
|
|
false,
|
|
true,
|
|
false,
|
|
ignoreFalseConditions //
|
|
);
|
|
|
|
//
|
|
// XCHSTR ...
|
|
string chstrStr = chstrConditions.GenerateSummary(
|
|
false,
|
|
true,
|
|
false,
|
|
ignoreFalseConditions //
|
|
);
|
|
|
|
//
|
|
// XCHVLM ...
|
|
string chvlmStr = chvlmConditions.GenerateSummary(
|
|
false,
|
|
true,
|
|
false,
|
|
ignoreFalseConditions //
|
|
);
|
|
|
|
//
|
|
string conditionsStr =
|
|
//
|
|
pvStr + separator +
|
|
chmStr + separator +
|
|
chhkStr + separator +
|
|
chtdStr + separator +
|
|
chcheStr + separator +
|
|
chstrStr + separator +
|
|
chvlmStr + separator +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
"[" + GetTag() + "]" + separator +
|
|
"----------" + separator +
|
|
(onlyConditions
|
|
? ""
|
|
: commonStr) +
|
|
" " + separator +
|
|
(onlyCommons
|
|
? ""
|
|
: conditionsStr) +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
return XCHStartegyToken;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
typedef void (*TOnXCHSignal)(
|
|
XSignal &signal,
|
|
XCHStrategyConditions &conditions //
|
|
);
|
|
|
|
//
|
|
// XStrategy Class Implementation(s) ...
|
|
class XSCXCHStrategy : public XSCBaseStrategy
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Constructor(s) ...
|
|
void XSCXCHStrategy(
|
|
//
|
|
// Base ...
|
|
string _symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES _period, // Trading TimeFrame
|
|
ENUM_TIMEFRAMES _analizePeriod, // Important Area Detect Time Frame
|
|
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,
|
|
_analizePeriod,
|
|
_volume,
|
|
_r2r,
|
|
_slippage,
|
|
_magicNumber,
|
|
_ignoreSignalExecution,
|
|
_useTPSLAsPoint,
|
|
_forceMaxTPSLAsPoint,
|
|
_tpPoint,
|
|
_slPoint,
|
|
_ignoreTP,
|
|
_ignoreSL,
|
|
_allowLong,
|
|
_allowShort,
|
|
_maxAllowedLongs,
|
|
_maxAllowedShorts //
|
|
)
|
|
{
|
|
//
|
|
SetAlertPrefix(GetTag());
|
|
|
|
//
|
|
PrepareRequirements();
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
void ~XSCXCHStrategy()
|
|
{
|
|
//
|
|
delete pvHelper;
|
|
|
|
//
|
|
delete chmHelper;
|
|
delete chhkHelper;
|
|
delete chstrHelper;
|
|
delete chcheHelper;
|
|
}
|
|
|
|
//
|
|
// Getter / Setter (s) ...
|
|
|
|
//
|
|
bool EnableXCHCHE()
|
|
{
|
|
return mEnableXCHCHE;
|
|
}
|
|
|
|
//
|
|
void EnableXCHCHE(bool value)
|
|
{
|
|
mEnableXCHCHE = value;
|
|
}
|
|
|
|
//
|
|
bool EnableXCHM()
|
|
{
|
|
return mEnableXCHM;
|
|
}
|
|
|
|
//
|
|
void EnableXCHM(bool value)
|
|
{
|
|
mEnableXCHM = value;
|
|
}
|
|
|
|
//
|
|
bool EnableXCHHK()
|
|
{
|
|
return mEnableXCHHK;
|
|
}
|
|
|
|
//
|
|
void EnableXCHHK(bool value)
|
|
{
|
|
mEnableXCHHK = value;
|
|
}
|
|
|
|
//
|
|
bool EnableXCHSTR()
|
|
{
|
|
return mEnableXCHSTR;
|
|
}
|
|
|
|
//
|
|
void EnableXCHSTR(bool value)
|
|
{
|
|
mEnableXCHSTR = value;
|
|
}
|
|
|
|
//
|
|
// Event Handlers ...
|
|
|
|
//
|
|
// On Signal Handlers ...
|
|
void AddXCHSignalEventHandler(TOnXCHSignal handler)
|
|
{
|
|
//
|
|
Add(
|
|
handler,
|
|
mOnXCHSignalEventHandlers //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Overrides ...
|
|
|
|
//
|
|
// Customize Strategy Identifier ...
|
|
string GetTag() override
|
|
{
|
|
return XCHStartegyToken;
|
|
}
|
|
|
|
//
|
|
// 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;
|
|
}
|
|
|
|
//
|
|
// XCHM ...
|
|
XCHMConditions chmConditions;
|
|
result = chmHelper.GetConditions(chmConditions);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCHHK ...
|
|
XCHHKConditions chhkConditions;
|
|
result = chhkHelper.GetConditions(chhkConditions);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCHTD ...
|
|
XCHTDConditions chtdConditions;
|
|
result = chtdHelper.GetConditions(chtdConditions);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCHSTR ...
|
|
XCHSTRConditions chstrConditions;
|
|
result = chstrHelper.GetConditions(chstrConditions);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCHCHE ...
|
|
XCHCHEConditions chcheConditions;
|
|
result = chcheHelper.GetConditions(chcheConditions);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCHVLM ...
|
|
XCHVLMConditions chvlmConditions;
|
|
result = chvlmHelper.GetConditions(chvlmConditions);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// 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;
|
|
}
|
|
|
|
//
|
|
// Prepare Conditions ...
|
|
|
|
//
|
|
XCHStrategyConditions conditions;
|
|
|
|
//
|
|
conditions.symbol = mSymbol;
|
|
conditions.period = mPeriod;
|
|
conditions.time = cBar.time;
|
|
|
|
//
|
|
conditions.pvConditions = pvConditions;
|
|
conditions.chmConditions = chmConditions;
|
|
conditions.chhkConditions = chhkConditions;
|
|
conditions.chtdConditions = chtdConditions;
|
|
conditions.chstrConditions = chstrConditions;
|
|
conditions.chcheConditions = chcheConditions;
|
|
conditions.chvlmConditions = chvlmConditions;
|
|
|
|
//
|
|
result = conditions.IsValid();
|
|
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 hh5 = cBar.FindHighest(
|
|
5,
|
|
MODE_HIGH //
|
|
);
|
|
|
|
//
|
|
// Lowest Low ...
|
|
double ll5 = cBar.FindLowest(
|
|
5,
|
|
MODE_LOW //
|
|
);
|
|
|
|
//
|
|
// For Trend ...
|
|
XOHCL tmpHSW[];
|
|
XOHCL tmpLSW[];
|
|
|
|
//
|
|
// Detect Bullish/Bearish Patterns and Trends ...
|
|
|
|
//
|
|
// Bullish ...
|
|
bool hasBullishPower = cBar.HasBullishPower();
|
|
bool hasBullishPattern = HasBullishPattern(cBar);
|
|
bool hasBullishPressure = cBar.HasBullishPressure();
|
|
bool isBullishTrend = cBar.HasBullishTrend(
|
|
tmpHSW,
|
|
tmpLSW,
|
|
true //
|
|
);
|
|
|
|
//
|
|
// Bearish ...
|
|
bool hasBearishPower = cBar.HasBearishPower();
|
|
bool hasBearishPattern = HasBearishPattern(cBar);
|
|
bool hasBearishPressure = cBar.HasBearishPressure();
|
|
bool isBearishTrend = cBar.HasBearishTrend(
|
|
tmpHSW,
|
|
tmpLSW,
|
|
false //
|
|
);
|
|
|
|
//
|
|
// XCHM ...
|
|
|
|
//
|
|
double chmBullishPower = chmHelper.GetBullishPower(cIndex);
|
|
double chmBearishPower = chmHelper.GetBearishPower(cIndex);
|
|
|
|
//
|
|
double chmMaxBullishFast = chmHelper.GetMaxBullishFast(cIndex);
|
|
double chmMinBullishFast = chmHelper.GetMinBullishFast(cIndex);
|
|
double chmMaxBullishSlow = chmHelper.GetMaxBullishSlow(cIndex);
|
|
double chmMinBullishSlow = chmHelper.GetMinBullishSlow(cIndex);
|
|
double chmMaxBearishFast = chmHelper.GetMaxBearishFast(cIndex);
|
|
double chmMinBearishFast = chmHelper.GetMinBearishFast(cIndex);
|
|
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);
|
|
|
|
//
|
|
// XCHTD ...
|
|
|
|
//
|
|
double chtdBullishPower = chtdHelper.GetBullishPower(cIndex);
|
|
double chtdBearishPower = chtdHelper.GetBearishPower(cIndex);
|
|
|
|
//
|
|
// XCHSTR ...
|
|
|
|
//
|
|
double chstrBullishPower = chstrHelper.GetBullishPower(cIndex);
|
|
double chstrBearishPower = chstrHelper.GetBearishPower(cIndex);
|
|
|
|
//
|
|
double chstrMinBullish = chstrHelper.GetMinBullish(cIndex);
|
|
double chstrMaxBullish = chstrHelper.GetMaxBullish(cIndex);
|
|
double chstrMinBearish = chstrHelper.GetMinBearish(cIndex);
|
|
double chstrMaxBearish = chstrHelper.GetMaxBearish(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);
|
|
|
|
//
|
|
// Change XCHCHE Current State ...
|
|
if (chcheConditions.cLE1[pIndex] > 0 &&
|
|
chcheConditions.cLE2[pIndex] > 0 &&
|
|
chcheConditions.cLE1[pIndex] != EMPTY_VALUE &&
|
|
chcheConditions.cLE2[pIndex] != EMPTY_VALUE &&
|
|
!chcheConditions.isCStrongBullish)
|
|
{
|
|
//
|
|
chcheCLastLongExitTime = pBar.time;
|
|
chcheCLastLongExit1 = chcheConditions.cLE1[pIndex];
|
|
chcheCLastLongExit2 = chcheConditions.cLE2[pIndex];
|
|
}
|
|
|
|
//
|
|
if (chcheConditions.cSE1[pIndex] > 0 &&
|
|
chcheConditions.cSE2[pIndex] > 0 &&
|
|
chcheConditions.cSE1[pIndex] != EMPTY_VALUE &&
|
|
chcheConditions.cSE2[pIndex] != EMPTY_VALUE &&
|
|
!chcheConditions.isCStrongBearish)
|
|
{
|
|
//
|
|
chcheCLastShortExitTime = pBar.time;
|
|
chcheCLastShortExit1 = chcheConditions.cSE1[pIndex];
|
|
chcheCLastShortExit2 = chcheConditions.cSE2[pIndex];
|
|
}
|
|
|
|
//
|
|
double chcheMinCBullish = chcheHelper.GetCycleBullishMin(
|
|
cIndex,
|
|
X_MARKET_CYCLE_UNKNOWN // Current ...
|
|
);
|
|
double chcheMaxCBearish = chcheHelper.GetCycleBearishMax(
|
|
cIndex,
|
|
X_MARKET_CYCLE_UNKNOWN // Current ...
|
|
);
|
|
|
|
//
|
|
// XCHVLM ...
|
|
|
|
//
|
|
double chvlmBullishPower = chvlmHelper.GetBullishPower(cIndex);
|
|
double chvlmBearishPower = chvlmHelper.GetBearishPower(cIndex);
|
|
|
|
//
|
|
DetectImportantAreas();
|
|
|
|
//
|
|
// Attached Important Areas to Conditions ...
|
|
FillConditionsImportantAreas(conditions);
|
|
|
|
//
|
|
int pushers = 0;
|
|
string signallers[];
|
|
|
|
//
|
|
// XCHM ...
|
|
if (mEnableXCHM)
|
|
{
|
|
//
|
|
if (chmConditions.isBullishPowerUp)
|
|
{
|
|
//
|
|
bool chmHasLong =
|
|
//
|
|
hasBullishPower &&
|
|
cBar.IsBullish() &&
|
|
hasBullishPattern &&
|
|
hasBullishPressure &&
|
|
cBar.low > chmMinBullishFast &&
|
|
chmConditions.isBullishPowerUp &&
|
|
chcheConditions.isCStrongBullish
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chmHasLong)
|
|
{
|
|
//
|
|
hasLong = chmHasLong;
|
|
if (hasLong)
|
|
{
|
|
//
|
|
pushers++;
|
|
Add(
|
|
"XCHM",
|
|
signallers //
|
|
);
|
|
|
|
//
|
|
sl = chmMaxBullishFast;
|
|
type = POSITION_TYPE_BUY;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (chmConditions.isBearishPowerUp)
|
|
{
|
|
//
|
|
bool chmHasShort =
|
|
//
|
|
hasBearishPower &&
|
|
cBar.IsBearish() &&
|
|
hasBearishPattern &&
|
|
hasBearishPressure &&
|
|
cBar.high < chmMaxBearishFast &&
|
|
chmConditions.isBearishPowerUp &&
|
|
chcheConditions.isCStrongBearish
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chmHasShort)
|
|
{
|
|
//
|
|
hasShort = chmHasShort;
|
|
if (hasShort)
|
|
{
|
|
//
|
|
pushers++;
|
|
Add(
|
|
"XCHM",
|
|
signallers //
|
|
);
|
|
|
|
//
|
|
sl = chmMinBearishFast;
|
|
type = POSITION_TYPE_SELL;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// 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)
|
|
{
|
|
//
|
|
if (chstrConditions.isBullishPowerUp)
|
|
{
|
|
//
|
|
bool chstrHasLong =
|
|
//
|
|
hasBullishPower &&
|
|
cBar.IsBullish() &&
|
|
hasBullishPattern &&
|
|
hasBullishPressure &&
|
|
cBar.low > chstrMinBullish &&
|
|
chstrConditions.isBullishPowerUp &&
|
|
chcheConditions.isCStrongBullish
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chstrHasLong)
|
|
{
|
|
//
|
|
hasLong = chstrHasLong;
|
|
if (hasLong)
|
|
{
|
|
//
|
|
pushers++;
|
|
Add(
|
|
"XCHSTR",
|
|
signallers //
|
|
);
|
|
|
|
//
|
|
sl = chstrMinBullish;
|
|
type = POSITION_TYPE_BUY;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (chstrConditions.isBearishPowerUp)
|
|
{
|
|
//
|
|
bool chstrHasShort =
|
|
//
|
|
hasBearishPower &&
|
|
cBar.IsBearish() &&
|
|
hasBearishPattern &&
|
|
hasBearishPressure &&
|
|
cBar.high < chstrMaxBearish &&
|
|
chstrConditions.isBearishPowerUp &&
|
|
chcheConditions.isCStrongBearish
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chstrHasShort)
|
|
{
|
|
//
|
|
hasShort = chstrHasShort;
|
|
if (hasShort)
|
|
{
|
|
//
|
|
pushers++;
|
|
Add(
|
|
"XCHSTR",
|
|
signallers //
|
|
);
|
|
|
|
//
|
|
sl = chstrMaxBearish;
|
|
type = POSITION_TYPE_SELL;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// XCHCHE ...
|
|
if (mEnableXCHCHE)
|
|
{
|
|
//
|
|
if (chcheConditions.isCStrongBullish)
|
|
{
|
|
//
|
|
bool chcheHasLong =
|
|
//
|
|
hasBullishPower &&
|
|
HasCHCHECLast() &&
|
|
cBar.IsBullish() &&
|
|
chcheMinCBullish > 0 &&
|
|
hasBullishPattern &&
|
|
hasBullishPressure &&
|
|
chcheConditions.hasBullishPower &&
|
|
chcheConditions.isCStrongBullish &&
|
|
chcheMinCBullish > GetMaxCHCHECLast()
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chcheHasLong)
|
|
{
|
|
//
|
|
hasLong = chcheHasLong;
|
|
if (hasLong)
|
|
{
|
|
//
|
|
pushers++;
|
|
Add(
|
|
"XCHCHE",
|
|
signallers //
|
|
);
|
|
|
|
//
|
|
sl = chcheMinBullish;
|
|
type = POSITION_TYPE_BUY;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
if (chcheConditions.isCStrongBearish)
|
|
{
|
|
//
|
|
bool chcheHasShort =
|
|
//
|
|
hasBearishPower &&
|
|
HasCHCHECLast() &&
|
|
cBar.IsBearish() &&
|
|
chcheMaxCBearish > 0 &&
|
|
hasBearishPattern &&
|
|
hasBearishPressure &&
|
|
chcheConditions.hasBearishPower &&
|
|
chcheConditions.isCStrongBearish &&
|
|
chcheMaxCBearish > GetMaxCHCHECLast()
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chcheHasShort)
|
|
{
|
|
//
|
|
hasShort = chcheHasShort;
|
|
if (hasShort)
|
|
{
|
|
//
|
|
pushers++;
|
|
Add(
|
|
"XCHCHE",
|
|
signallers //
|
|
);
|
|
|
|
//
|
|
sl = chcheMaxBearish;
|
|
type = POSITION_TYPE_SELL;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
result = hasLong || hasShort;
|
|
if (!result)
|
|
{
|
|
//
|
|
CheckImportantAreasValidation();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
// //
|
|
// result =
|
|
// //
|
|
// (hasLong &&
|
|
// bullishTrend.IsValid())
|
|
// //
|
|
// ||
|
|
// //
|
|
// (!hasLong &&
|
|
// bearishTrend.IsValid())
|
|
// //
|
|
// ;
|
|
// if (!result)
|
|
// {
|
|
// return result;
|
|
// }
|
|
|
|
//
|
|
DestroyImportantAreas();
|
|
|
|
//
|
|
// Retrieve Entry Price based on Position Type ...
|
|
entry = GetEntry(mSymbol, type);
|
|
|
|
//
|
|
// Calculate TP and SL ...
|
|
// based on Strategy ...
|
|
// only when on of TP or SL Provides, using provided R2R ...
|
|
if ((tp <= 0 && sl > 0) || (tp > 0 && sl <= 0))
|
|
{
|
|
CalculateTPSLByPrice(
|
|
sl,
|
|
tp,
|
|
type,
|
|
entry,
|
|
r2r //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Prepare Signal ...
|
|
result = signal.Prepare(
|
|
mSymbol,
|
|
signallers[0],
|
|
mPeriod,
|
|
type,
|
|
mode,
|
|
entry,
|
|
mVolume,
|
|
sl,
|
|
tp //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
signal.pushers = pushers;
|
|
|
|
//
|
|
// Notify XCH Specified Signal Event Handlers ...
|
|
NotifyOnXCHSignalEventHandlers(
|
|
signal,
|
|
conditions //
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
bool mEnableXCHM; // Enable XCHM Signaller
|
|
bool mEnableXCHHK; // Enable XCHHK Signaller
|
|
bool mEnableXCHSTR; // Enable XCHSTR Signaller
|
|
bool mEnableXCHCHE; // Enable XCHCHE Signaller
|
|
|
|
//
|
|
// XPV ...
|
|
XPVInputs pvInputs;
|
|
XSCXPVHelper *pvHelper;
|
|
|
|
//
|
|
// XCHMA ...
|
|
XCHMInputs chmInputs;
|
|
XSCXCHMHelper *chmHelper;
|
|
|
|
//
|
|
// XCHHK ...
|
|
XCHHKInputs chhkInputs;
|
|
XSCXCHHKHelper *chhkHelper;
|
|
|
|
//
|
|
// XCHTD ...
|
|
XCHTDInputs chtdInputs;
|
|
XSCXCHTDHelper *chtdHelper;
|
|
|
|
//
|
|
// XSTR ...
|
|
XCHSTRInputs chstrInputs;
|
|
XSCXCHSTRHelper *chstrHelper;
|
|
|
|
//
|
|
// XCHCHE ...
|
|
XCHCHEInputs chcheInputs;
|
|
XSCXCHCHEHelper *chcheHelper;
|
|
|
|
//
|
|
// XCHVLM ...
|
|
XCHVLMInputs chvlmInputs;
|
|
XSCXCHVLMHelper *chvlmHelper;
|
|
|
|
//
|
|
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// On XCH Signal Recieved Event Handler(s) ...
|
|
TOnXCHSignal mOnXCHSignalEventHandlers[];
|
|
|
|
//
|
|
// Notified Signal Event Handler(s) ...
|
|
void NotifyOnXCHSignalEventHandlers(
|
|
XSignal &signal,
|
|
XCHStrategyConditions &conditions //
|
|
)
|
|
{
|
|
//
|
|
if (!signal.IsValid() || !conditions.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(mOnXCHSignalEventHandlers);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
mOnXCHSignalEventHandlers[i](
|
|
signal,
|
|
conditions //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Install all Helpers and Prepare all
|
|
// Configurations for required Indicators ...
|
|
void PrepareRequirements()
|
|
{
|
|
//
|
|
mEnableXCHM = true;
|
|
mEnableXCHHK = true;
|
|
mEnableXCHSTR = true;
|
|
mEnableXCHCHE = true;
|
|
|
|
//
|
|
support.Clean();
|
|
supportTime = NULL;
|
|
isSupportTested = false;
|
|
|
|
//
|
|
resistance.Clean();
|
|
resistanceTime = NULL;
|
|
isResistanceTested = false;
|
|
|
|
//
|
|
// Short ...
|
|
ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES scPeriod = NULL; // PERIOD_M20; // Time Period
|
|
|
|
//
|
|
// Medium ...
|
|
ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES mcPeriod = NULL; // PERIOD_M30; // Time Period
|
|
|
|
//
|
|
// Long ...
|
|
ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES lcPeriod = NULL; // PERIOD_H1; // Time Period
|
|
|
|
//
|
|
// Hind ...
|
|
ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // X_PERIOD_MANUALLY; // How to Find Period
|
|
ENUM_TIMEFRAMES hcPeriod = NULL; // PERIOD_H2; // Time Period
|
|
|
|
//
|
|
// XPV ...
|
|
|
|
//
|
|
pvInputs.Default();
|
|
|
|
//
|
|
pvInputs.scMethod = scMethod;
|
|
pvInputs.scPeriod = scPeriod;
|
|
pvInputs.mcMethod = mcMethod;
|
|
pvInputs.mcPeriod = mcPeriod;
|
|
pvInputs.lcMethod = lcMethod;
|
|
pvInputs.lcPeriod = lcPeriod;
|
|
pvInputs.hcMethod = hcMethod;
|
|
pvInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
pvInputs.showPeaksAndVales = false;
|
|
pvInputs.showLevels = false;
|
|
pvInputs.showConsolidations = false;
|
|
pvInputs.showFibo1Levels = false;
|
|
pvInputs.showFibo2Levels = false;
|
|
pvInputs.showFibo3Levels = false;
|
|
pvInputs.showFibo4Levels = false;
|
|
pvInputs.showFibo5Levels = false;
|
|
|
|
//
|
|
pvHelper = new XSCXPVHelper();
|
|
pvHelper.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
pvInputs //
|
|
);
|
|
|
|
//
|
|
// XCHM ...
|
|
|
|
//
|
|
chmInputs.Default();
|
|
|
|
//
|
|
chmInputs.scMethod = scMethod;
|
|
chmInputs.scPeriod = scPeriod;
|
|
chmInputs.mcMethod = mcMethod;
|
|
chmInputs.mcPeriod = mcPeriod;
|
|
chmInputs.lcMethod = lcMethod;
|
|
chmInputs.lcPeriod = lcPeriod;
|
|
chmInputs.hcMethod = hcMethod;
|
|
chmInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
chmInputs.showFast = false;
|
|
chmInputs.showSlow = false;
|
|
chmInputs.showCCFast = false;
|
|
chmInputs.showCCSlow = false;
|
|
chmInputs.showSCFast = false;
|
|
chmInputs.showSCSlow = false;
|
|
chmInputs.showMCFast = false;
|
|
chmInputs.showMCSlow = false;
|
|
chmInputs.showLCFast = false;
|
|
chmInputs.showLCSlow = false;
|
|
chmInputs.showHCFast = false;
|
|
chmInputs.showHCSlow = false;
|
|
|
|
//
|
|
chmHelper = new XSCXCHMHelper();
|
|
chmHelper.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
chmInputs //
|
|
);
|
|
|
|
//
|
|
// XCHHK ...
|
|
|
|
//
|
|
chhkInputs.Default();
|
|
|
|
//
|
|
chhkInputs.scMethod = scMethod;
|
|
chhkInputs.scPeriod = scPeriod;
|
|
chhkInputs.mcMethod = mcMethod;
|
|
chhkInputs.mcPeriod = mcPeriod;
|
|
chhkInputs.lcMethod = lcMethod;
|
|
chhkInputs.lcPeriod = lcPeriod;
|
|
chhkInputs.hcMethod = hcMethod;
|
|
chhkInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
chhkInputs.ignoreShadows = true;
|
|
|
|
//
|
|
chhkInputs.showCurrent = false;
|
|
chhkInputs.showShort = false;
|
|
chhkInputs.showMedium = false;
|
|
chhkInputs.showLong = false;
|
|
chhkInputs.showHind = false;
|
|
|
|
//
|
|
chhkHelper = new XSCXCHHKHelper();
|
|
chhkHelper.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
chhkInputs //
|
|
);
|
|
|
|
//
|
|
// XCHTD ...
|
|
|
|
//
|
|
chtdInputs.Default();
|
|
|
|
//
|
|
chtdInputs.scMethod = scMethod;
|
|
chtdInputs.scPeriod = scPeriod;
|
|
chtdInputs.mcMethod = mcMethod;
|
|
chtdInputs.mcPeriod = mcPeriod;
|
|
chtdInputs.lcMethod = lcMethod;
|
|
chtdInputs.lcPeriod = lcPeriod;
|
|
chtdInputs.hcMethod = hcMethod;
|
|
chtdInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
chtdInputs.showCurrent = false;
|
|
chtdInputs.showShort = false;
|
|
chtdInputs.showMedium = false;
|
|
chtdInputs.showLong = false;
|
|
chtdInputs.showHind = false;
|
|
|
|
//
|
|
chtdHelper = new XSCXCHTDHelper();
|
|
chtdHelper.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
chtdInputs //
|
|
);
|
|
|
|
//
|
|
// XCHSTR ...
|
|
|
|
//
|
|
chstrInputs.Default();
|
|
|
|
//
|
|
chstrInputs.scMethod = scMethod;
|
|
chstrInputs.scPeriod = scPeriod;
|
|
chstrInputs.mcMethod = mcMethod;
|
|
chstrInputs.mcPeriod = mcPeriod;
|
|
chstrInputs.lcMethod = lcMethod;
|
|
chstrInputs.lcPeriod = lcPeriod;
|
|
chstrInputs.hcMethod = hcMethod;
|
|
chstrInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
chstrInputs.showCurrent = false;
|
|
chstrInputs.showShort = false;
|
|
chstrInputs.showMedium = false;
|
|
chstrInputs.showLong = false;
|
|
chstrInputs.showHind = false;
|
|
|
|
//
|
|
chstrHelper = new XSCXCHSTRHelper();
|
|
chstrHelper.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
chstrInputs //
|
|
);
|
|
|
|
//
|
|
// XCHCHE ...
|
|
|
|
//
|
|
chcheInputs.Default();
|
|
|
|
//
|
|
chcheInputs.scMethod = scMethod;
|
|
chcheInputs.scPeriod = scPeriod;
|
|
chcheInputs.mcMethod = mcMethod;
|
|
chcheInputs.mcPeriod = mcPeriod;
|
|
chcheInputs.lcMethod = lcMethod;
|
|
chcheInputs.lcPeriod = lcPeriod;
|
|
chcheInputs.hcMethod = hcMethod;
|
|
chcheInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
chcheInputs.showCurrentLE1 = false;
|
|
chcheInputs.showCurrentLE2 = false;
|
|
chcheInputs.showCurrentSE1 = false;
|
|
chcheInputs.showCurrentSE2 = false;
|
|
chcheInputs.showShortLE1 = false;
|
|
chcheInputs.showShortLE2 = false;
|
|
chcheInputs.showShortSE1 = false;
|
|
chcheInputs.showShortSE2 = false;
|
|
chcheInputs.showMediumLE1 = false;
|
|
chcheInputs.showMediumLE2 = false;
|
|
chcheInputs.showMediumSE1 = false;
|
|
chcheInputs.showMediumSE2 = false;
|
|
chcheInputs.showLongLE1 = false;
|
|
chcheInputs.showLongLE2 = false;
|
|
chcheInputs.showLongSE1 = false;
|
|
chcheInputs.showLongSE2 = false;
|
|
chcheInputs.showHindLE1 = false;
|
|
chcheInputs.showHindLE2 = false;
|
|
chcheInputs.showHindSE1 = false;
|
|
chcheInputs.showHindSE2 = false;
|
|
|
|
//
|
|
chcheHelper = new XSCXCHCHEHelper();
|
|
chcheHelper.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
chcheInputs //
|
|
);
|
|
|
|
//
|
|
// XCHVLM ...
|
|
|
|
//
|
|
chvlmInputs.Default();
|
|
|
|
//
|
|
chvlmInputs.scMethod = scMethod;
|
|
chvlmInputs.scPeriod = scPeriod;
|
|
chvlmInputs.mcMethod = mcMethod;
|
|
chvlmInputs.mcPeriod = mcPeriod;
|
|
chvlmInputs.lcMethod = lcMethod;
|
|
chvlmInputs.lcPeriod = lcPeriod;
|
|
chvlmInputs.hcMethod = hcMethod;
|
|
chvlmInputs.hcPeriod = hcPeriod;
|
|
|
|
//
|
|
chvlmInputs.showCurrent = false;
|
|
chvlmInputs.showShort = false;
|
|
chvlmInputs.showMedium = false;
|
|
chvlmInputs.showLong = false;
|
|
chvlmInputs.showHind = false;
|
|
|
|
//
|
|
chvlmHelper = new XSCXCHVLMHelper();
|
|
chvlmHelper.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
chvlmInputs //
|
|
);
|
|
}
|
|
|
|
//
|
|
void FillConditionsImportantAreas(XCHStrategyConditions &conditions)
|
|
{
|
|
//
|
|
if (!conditions.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
conditions.support = support;
|
|
conditions.resistance = resistance;
|
|
conditions.bullishOB = bullishOB;
|
|
conditions.bearishOB = bearishOB;
|
|
conditions.bullishFVG = bullishFVG;
|
|
conditions.bearishFVG = bearishFVG;
|
|
conditions.bullishTrend = bullishTrend;
|
|
conditions.bearishTrend = bearishTrend;
|
|
|
|
//
|
|
conditions.bullishFVGUpper = bullishFVGUpper;
|
|
conditions.bullishFVGLower = bullishFVGLower;
|
|
conditions.bearishFVGUpper = bearishFVGUpper;
|
|
conditions.bearishFVGLower = bearishFVGLower;
|
|
|
|
//
|
|
Copy(
|
|
bullishTrendSwingHighs,
|
|
conditions.bullishTrendSwingHighs,
|
|
true //
|
|
);
|
|
|
|
//
|
|
Copy(
|
|
bullishTrendSwingLows,
|
|
conditions.bullishTrendSwingLows,
|
|
true //
|
|
);
|
|
|
|
//
|
|
Copy(
|
|
bearishTrendSwingHighs,
|
|
conditions.bearishTrendSwingHighs,
|
|
true //
|
|
);
|
|
|
|
//
|
|
Copy(
|
|
bearishTrendSwingLows,
|
|
conditions.bearishTrendSwingLows,
|
|
true //
|
|
);
|
|
}
|
|
|
|
//
|
|
// XCHE Custom Data ...
|
|
|
|
//
|
|
double chcheCLastLongExit1;
|
|
double chcheCLastLongExit2;
|
|
datetime chcheCLastLongExitTime;
|
|
double GetMaxCHCHECLastLong()
|
|
{
|
|
//
|
|
return MathMax(
|
|
chcheCLastLongExit1,
|
|
chcheCLastLongExit2 //
|
|
);
|
|
}
|
|
double GetMinCHCHECLastLong()
|
|
{
|
|
//
|
|
return MathMin(
|
|
chcheCLastLongExit1,
|
|
chcheCLastLongExit2 //
|
|
);
|
|
}
|
|
|
|
//
|
|
double chcheCLastShortExit1;
|
|
double chcheCLastShortExit2;
|
|
datetime chcheCLastShortExitTime;
|
|
double GetMaxCHCHECLastShort()
|
|
{
|
|
//
|
|
return MathMax(
|
|
chcheCLastShortExit1,
|
|
chcheCLastShortExit2 //
|
|
);
|
|
}
|
|
double GetMinCHCHECLastShort()
|
|
{
|
|
//
|
|
return MathMin(
|
|
chcheCLastShortExit1,
|
|
chcheCLastShortExit2 //
|
|
);
|
|
}
|
|
|
|
//
|
|
double GetMaxCHCHECLast()
|
|
{
|
|
//
|
|
return MathMax(
|
|
GetMaxCHCHECLastLong(),
|
|
GetMaxCHCHECLastShort() //
|
|
);
|
|
}
|
|
double GetMinCHCHECLast()
|
|
{
|
|
//
|
|
return MathMin(
|
|
GetMinCHCHECLastLong(),
|
|
GetMinCHCHECLastShort() //
|
|
);
|
|
}
|
|
|
|
//
|
|
bool HasCHCHECLast()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
IsValid(chcheCLastLongExitTime) ||
|
|
IsValid(chcheCLastShortExitTime);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Conditions Parser ...
|
|
struct XCHStartegyConditionsParser
|
|
{
|
|
//
|
|
string _version;
|
|
|
|
//
|
|
bool IsFiltered(
|
|
XSignal &signal, // Provided Signal
|
|
XCHStrategyConditions &conditions // Market Conditions
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (!signal.IsValid() || !conditions.IsValid())
|
|
{
|
|
//
|
|
result = true;
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
// |