2016 lines
48 KiB
Plaintext
2016 lines
48 KiB
Plaintext
///////////////////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 XEU5 Signal Provider Indicators Library
|
|
// ----------------------------------------------------------------
|
|
//
|
|
// 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
|
|
|
|
//
|
|
// Include Provider Inputs ...
|
|
#include "x-saherelm.xeu5.provider.inputs.lib.mq5";
|
|
|
|
//
|
|
// START Define Enums ...
|
|
//
|
|
|
|
//
|
|
// Represent Market Conditions ...
|
|
struct XEU5_MARKET_CONDITIONS
|
|
{
|
|
//
|
|
// XTM ...
|
|
bool isXTMPeak;
|
|
bool isXTMVale;
|
|
bool isXTMBullish;
|
|
bool isXTMBearish;
|
|
bool isXTMNeutural;
|
|
bool isXTMEndBullish;
|
|
bool isXTMEndBearish;
|
|
bool isXTMStartBullish;
|
|
bool isXTMStartBearish;
|
|
bool isXTMEndBullishByNeutural;
|
|
bool isXTMEndBearishByNeutural;
|
|
bool isXTMStartBullishAfterNeutural;
|
|
bool isXTMStartBearishAfterNeutural;
|
|
|
|
//
|
|
// XLH ...
|
|
bool isXLHHHIncreased;
|
|
bool isXLHHHDecreased;
|
|
bool isXLHLLIncreased;
|
|
bool isXLHLLDecreased;
|
|
bool isXLHLowAttachedLL;
|
|
bool isXLHHighAttachedHH;
|
|
bool isXLHHHSameInLength;
|
|
bool isXLHLLSameInLength;
|
|
bool isXLHPriceOverSignal;
|
|
bool isXLHPriceUnderSignal;
|
|
bool isXLHPriceInSignalRange;
|
|
bool isXLHPriceCrossedOverSignal;
|
|
bool isXLHPriceCrossedUnderSignal;
|
|
|
|
//
|
|
// XTD ...
|
|
bool isXTDSignalPeak;
|
|
bool isXTDSignalVale;
|
|
bool isXTDBullishPeak;
|
|
bool isXTDBullishVale;
|
|
bool isXTDBearishPeak;
|
|
bool isXTDBearishVale;
|
|
bool isXTDBullOverBear;
|
|
bool isXTDBullUnderBear;
|
|
bool isXTDSignalOverBear;
|
|
bool isXTDSignalUnderBear;
|
|
bool isXTDBullCrossedOverBear;
|
|
bool isXTDBullCrossedUnderBear;
|
|
bool isXTDSignalCrossedOverBear;
|
|
bool isXTDSignalCrossedUnderBear;
|
|
|
|
//
|
|
// XRSI ...
|
|
bool isXRSIPeak;
|
|
bool isXRSIVale;
|
|
bool isXRSICrossedOverLongExit;
|
|
bool isXRSICrossedOverLongEntry;
|
|
bool isXRSICrossedUnderShortExit;
|
|
bool isXRSICrossedUnderShortEntry;
|
|
|
|
//
|
|
// XOBD ...
|
|
bool isXOBDSwingLow;
|
|
bool isXOBDSwingHigh;
|
|
|
|
//
|
|
// XCHLH ...
|
|
//
|
|
bool isXCHLHSameHHs;
|
|
bool isXCHLHSameLLs;
|
|
//
|
|
bool isXCHLHSCMCHHSame;
|
|
bool isXCHLHSCMCLLSame;
|
|
//
|
|
bool isXCHLHSCLCHHSame;
|
|
bool isXCHLHSCLCLLSame;
|
|
//
|
|
bool isXCHLHMCLCHHSame;
|
|
bool isXCHLHMCLCLLSame;
|
|
//
|
|
bool isXCHLHMCOnTopOfLC;
|
|
bool isXCHLHMCInBottomOfLC;
|
|
|
|
//
|
|
// XCHMA ...
|
|
//
|
|
bool isXCHMASCOverMax;
|
|
bool isXCHMASCOverMin;
|
|
bool isXCHMASCUnderMax;
|
|
bool isXCHMASCUnderMin;
|
|
//
|
|
bool isXCHMASCCrossedOverMax;
|
|
bool isXCHMASCCrossedUnderMax;
|
|
bool isXCHMASCCrossedOverMin;
|
|
bool isXCHMASCCrossedUnderMin;
|
|
//
|
|
bool isXCHMASCPeak;
|
|
bool isXCHMASCVale;
|
|
bool isXCHMASCTrendsUp;
|
|
bool isXCHMASCTrendsDown;
|
|
bool isXCHMASCFastOverSlow;
|
|
bool isXCHMASCFastUnderSlow;
|
|
bool isXCHMASCFastCrossedOverSlow;
|
|
bool isXCHMASCFastCrossedUnderSlow;
|
|
//
|
|
bool isXCHMAMCPeak;
|
|
bool isXCHMAMCVale;
|
|
bool isXCHMAMCTrendsUp;
|
|
bool isXCHMAMCTrendsDown;
|
|
bool isXCHMAMCFastOverSlow;
|
|
bool isXCHMAMCFastUnderSlow;
|
|
bool isXCHMAMCFastCrossedOverSlow;
|
|
bool isXCHMAMCFastCrossedUnderSlow;
|
|
//
|
|
bool isXCHMALCPeak;
|
|
bool isXCHMALCVale;
|
|
bool isXCHMALCTrendsUp;
|
|
bool isXCHMALCTrendsDown;
|
|
bool isXCHMALCFastOverSlow;
|
|
bool isXCHMALCFastUnderSlow;
|
|
bool isXCHMALCFastCrossedOverSlow;
|
|
bool isXCHMALCFastCrossedUnderSlow;
|
|
};
|
|
|
|
//
|
|
// Signal Additional Info ...
|
|
struct XEU5_SIGNAL
|
|
{
|
|
double tp;
|
|
double sl;
|
|
double riskFree;
|
|
int signalPusher;
|
|
};
|
|
|
|
//
|
|
// END Define Enums ...
|
|
//
|
|
|
|
//
|
|
// Imports all Indicators Helper here ...
|
|
input group "XEU5 Provider Indicators";
|
|
//
|
|
#include "x-saherelm.xtm.indicator.helper.lib.mq5";
|
|
#include "x-saherelm.xlh.indicator.helper.lib.mq5";
|
|
#include "x-saherelm.xtd.oscillator.helper.lib.mq5";
|
|
#include "x-saherelm.xobd.indicator.helper.lib.mq5";
|
|
#include "x-saherelm.xrsi.oscillator.helper.lib.mq5";
|
|
#include "x-saherelm.xchlh.oscillator.helper.lib.mq5";
|
|
#include "x-saherelm.xchma.oscillator.helper.lib.mq5";
|
|
|
|
//
|
|
int xEU5MaxLengthOfInputs = 0;
|
|
int xEU5CalculatedBars = 0;
|
|
|
|
//
|
|
// Here we Define some Global Market Variables to Analyse MArket Conditions
|
|
// using them at each time ...
|
|
XEU5_MARKET_CONDITIONS conditions = {};
|
|
|
|
//
|
|
datetime xEU5SwingLowTimes[];
|
|
datetime xEU5SwingHighTimes[];
|
|
|
|
//
|
|
double xEU5XCHMASCMin = 0;
|
|
double xEU5XCHMASCMax = 0;
|
|
datetime xEU5XCHMASCCrossedOverMinTimes[];
|
|
datetime xEU5XCHMASCCrossedUnderMinTimes[];
|
|
datetime xEU5XCHMASCCrossedOverMaxTimes[];
|
|
datetime xEU5XCHMASCCrossedUnderMaxTimes[];
|
|
datetime xEU5XCHMASCFastCrossedOverSlowTimes[];
|
|
datetime xEU5XCHMASCFastCrossedUnderSlowTimes[];
|
|
|
|
//
|
|
// Init Indicators ...
|
|
bool XEU5InitIndicators()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Check and Calculate Max Length in Inputs ...
|
|
//
|
|
|
|
//
|
|
// XTM ...
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xTMMaPeriod,
|
|
xEU5NumberOfItemsPerTick);
|
|
|
|
//
|
|
// XLH ...
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xLHLength,
|
|
xEU5NumberOfItemsPerTick);
|
|
|
|
//
|
|
// XTD ...
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xTDLength,
|
|
xEU5MaxLengthOfInputs);
|
|
|
|
//
|
|
// XRSI ...
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xRSILength,
|
|
xEU5MaxLengthOfInputs);
|
|
|
|
//
|
|
// XOBD ...
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xOBDLength,
|
|
xEU5MaxLengthOfInputs);
|
|
|
|
//
|
|
// XCHLH ...
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHLHLcLength,
|
|
xEU5MaxLengthOfInputs);
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHLHMcLength,
|
|
xEU5MaxLengthOfInputs);
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHLHScLength,
|
|
xEU5MaxLengthOfInputs);
|
|
|
|
//
|
|
// XCHMA ...
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHMAScFastLength,
|
|
xEU5MaxLengthOfInputs);
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHMAScSlowLength,
|
|
xEU5MaxLengthOfInputs);
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHMAMcFastLength,
|
|
xEU5MaxLengthOfInputs);
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHMAMcSlowLength,
|
|
xEU5MaxLengthOfInputs);
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHMALcFastLength,
|
|
xEU5MaxLengthOfInputs);
|
|
xEU5MaxLengthOfInputs = MathMax(
|
|
xCHMALcSlowLength,
|
|
xEU5MaxLengthOfInputs);
|
|
|
|
//
|
|
// Initialize Indicator/Oscillator Handlers ...
|
|
ResetLastError();
|
|
|
|
//
|
|
// XTM Init ...
|
|
result = XTMInitHandlers();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XLH Init ...
|
|
result = XLHInitHandlers();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XTD Init ...
|
|
result = XTDInitHandlers();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XRSI Init ...
|
|
result = XRSIInitHandlers();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XOBD Init ...
|
|
result = XOBDInitHandlers();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCLH Init ...
|
|
result = XCHLHInitHandlers();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCHMA Init ...
|
|
result = XCHMAInitHandlers();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = true;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Release Indicators ...
|
|
void XEU5ReleaseIndicators()
|
|
{
|
|
//
|
|
// Release Handlers ...
|
|
XTMReleaseHandlers();
|
|
XLHReleaseHandlers();
|
|
XTDReleaseHandlers();
|
|
XRSIReleaseHandlers();
|
|
XOBDReleaseHandlers();
|
|
XCHMAReleaseHandlers();
|
|
XCHLHReleaseHandlers();
|
|
}
|
|
|
|
//
|
|
// Handle Reading Buffers ...
|
|
void XEU5HandleReadingBuffers()
|
|
{
|
|
//
|
|
// Reading Calculated Bars for a Simple Handler ...
|
|
xEU5CalculatedBars = BarsCalculated(xTMHandler);
|
|
|
|
//
|
|
// Read Indicators Buffers ...
|
|
XTMReadBuffers(xEU5NumberOfItemsPerTick);
|
|
XLHReadBuffers(xEU5NumberOfItemsPerTick);
|
|
XTDReadBuffers(xEU5NumberOfItemsPerTick);
|
|
XRSIReadBuffers(xEU5NumberOfItemsPerTick);
|
|
XOBDReadBuffers(xEU5NumberOfItemsPerTick);
|
|
XCHMAReadBuffers(xEU5NumberOfItemsPerTick);
|
|
XCHLHReadBuffers(xEU5NumberOfItemsPerTick);
|
|
|
|
//
|
|
XEU5ReadConditions();
|
|
}
|
|
|
|
//
|
|
//
|
|
// START Combination Functions ...
|
|
//
|
|
//
|
|
|
|
//
|
|
// Can Open Long Trade ...
|
|
// this is a Function will Check all market Conditions and get all
|
|
// Strategy requirement Verifications for Long Signals ...
|
|
bool XEU5CanOpenLongTrade(
|
|
XEU5_SIGNAL &info // Retrieve Signal Additional Info on this Object
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
bool hasSignal = XEU5HasLongSignal(info);
|
|
|
|
//
|
|
result =
|
|
//
|
|
hasSignal
|
|
//
|
|
;
|
|
|
|
//
|
|
// TODO: Remove this On Production ...
|
|
if (result)
|
|
{
|
|
XEU5ClearConditions();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Can Close Long Trade ...
|
|
// this is a Function will Check all market Conditions and get all
|
|
// Strategy requirement Verifications for Long Signals ...
|
|
bool XEU5CanCloseLongTrade()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// XEU5_SIGNAL info = {};
|
|
// result = XEU5HasShortSignal(info);
|
|
|
|
// //
|
|
// result =
|
|
// //
|
|
// (
|
|
// //
|
|
// XCHMAIsSCFastUnderSlow(1) &&
|
|
// XCHMAIsMCFastUnderSlow(1) &&
|
|
// XCHMAIsLCFastUnderSlow(1)
|
|
// //
|
|
// )
|
|
// //
|
|
// &&
|
|
// //
|
|
// !(
|
|
// //
|
|
// XCHMAIsSCFastUnderSlow(2) &&
|
|
// XCHMAIsMCFastUnderSlow(2) &&
|
|
// XCHMAIsLCFastUnderSlow(2)
|
|
// //
|
|
// )
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Can Open Short Trade ...
|
|
// this is a Function will Check all market Conditions and get all
|
|
// Strategy requirement Verifications for Short Signals ...
|
|
bool XEU5CanOpenShortTrade(
|
|
XEU5_SIGNAL &info // Retrieve Signal Additional Info on this Object
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
bool hasSignal = XEU5HasShortSignal(info);
|
|
|
|
//
|
|
result =
|
|
//
|
|
hasSignal
|
|
//
|
|
;
|
|
|
|
//
|
|
// TODO: Remove this On Production ...
|
|
if (result)
|
|
{
|
|
XEU5ClearConditions();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Can Close Short Trade ...
|
|
// this is a Function will Check all market Conditions and get all
|
|
// Strategy requirement Verifications for Short Signals ...
|
|
bool XEU5CanCloseShortTrade()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
XEU5_SIGNAL info = {};
|
|
// result = XEU5HasLongSignal(info);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
//
|
|
// END Combination Functions ...
|
|
//
|
|
//
|
|
|
|
//
|
|
//
|
|
// START Combination Signaling ...
|
|
//
|
|
//
|
|
|
|
//
|
|
// Read All Globally Required Conditions ...
|
|
void XEU5ReadConditions()
|
|
{
|
|
//
|
|
XEU5ClearConditions();
|
|
|
|
//
|
|
conditions = XEU5GenerateMarketConditions(1);
|
|
|
|
//
|
|
datetime time = iTime(_Symbol, _Period, 1);
|
|
|
|
//
|
|
if (conditions.isXOBDSwingHigh)
|
|
{
|
|
Add(
|
|
time,
|
|
xEU5SwingHighTimes);
|
|
}
|
|
|
|
//
|
|
if (conditions.isXOBDSwingLow)
|
|
{
|
|
Add(
|
|
time,
|
|
xEU5SwingLowTimes);
|
|
}
|
|
|
|
//
|
|
if (conditions.isXCHMASCCrossedOverMax)
|
|
{
|
|
Add(
|
|
time,
|
|
xEU5XCHMASCCrossedOverMaxTimes);
|
|
}
|
|
|
|
//
|
|
if (conditions.isXCHMASCCrossedUnderMax)
|
|
{
|
|
Add(
|
|
time,
|
|
xEU5XCHMASCCrossedUnderMaxTimes);
|
|
}
|
|
|
|
//
|
|
if (conditions.isXCHMASCCrossedOverMin)
|
|
{
|
|
Add(
|
|
time,
|
|
xEU5XCHMASCCrossedOverMinTimes);
|
|
}
|
|
|
|
//
|
|
if (conditions.isXCHMASCCrossedUnderMin)
|
|
{
|
|
Add(
|
|
time,
|
|
xEU5XCHMASCCrossedUnderMinTimes);
|
|
}
|
|
|
|
//
|
|
if (conditions.isXCHMASCFastCrossedOverSlow)
|
|
{
|
|
//
|
|
Add(
|
|
time,
|
|
xEU5XCHMASCFastCrossedOverSlowTimes);
|
|
|
|
//
|
|
// Reset Min/Max ...
|
|
xEU5XCHMASCMin = 0;
|
|
xEU5XCHMASCMax = 0;
|
|
}
|
|
|
|
//
|
|
if (conditions.isXCHMASCFastCrossedUnderSlow)
|
|
{
|
|
//
|
|
Add(
|
|
time,
|
|
xEU5XCHMASCFastCrossedUnderSlowTimes);
|
|
|
|
//
|
|
// Reset Min/Max ...
|
|
xEU5XCHMASCMin = 0;
|
|
xEU5XCHMASCMax = 0;
|
|
}
|
|
|
|
//
|
|
// Calculate SC Min/Max ...
|
|
if (
|
|
conditions.isXCHMASCFastOverSlow ||
|
|
conditions.isXCHMASCFastUnderSlow)
|
|
{
|
|
//
|
|
// Calculate Min ...
|
|
double scMinValue = XCHMAGetCycleMinValue(
|
|
1,
|
|
X_XCHMA_CYCLE_SHORT);
|
|
xEU5XCHMASCMin =
|
|
xEU5XCHMASCMin == 0 || xEU5XCHMASCMin > scMinValue ? scMinValue : xEU5XCHMASCMin;
|
|
|
|
//
|
|
// Calculate Max ...
|
|
double scMaxValue = XCHMAGetCycleMinValue(
|
|
1,
|
|
X_XCHMA_CYCLE_SHORT);
|
|
xEU5XCHMASCMax =
|
|
xEU5XCHMASCMax == 0 || xEU5XCHMASCMax < scMaxValue ? scMaxValue : xEU5XCHMASCMax;
|
|
|
|
//
|
|
// Calculate Trend Power ...
|
|
double scTP = scMaxValue - scMinValue;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cleanup Conditions ...
|
|
void XEU5ClearConditions()
|
|
{
|
|
//
|
|
XEU5_MARKET_CONDITIONS mConditions = {};
|
|
|
|
//
|
|
conditions = mConditions;
|
|
}
|
|
|
|
//
|
|
// Generate Merket Conditions for Specified Bar Index ...
|
|
XEU5_MARKET_CONDITIONS XEU5GenerateMarketConditions(
|
|
int bar_index = 1 // Specified Bar Index ...
|
|
)
|
|
{
|
|
//
|
|
XEU5_MARKET_CONDITIONS mConditions = {};
|
|
|
|
//
|
|
// XTM ...
|
|
mConditions.isXTMPeak = XTMIsPeak(bar_index);
|
|
mConditions.isXTMVale = XTMIsVale(bar_index);
|
|
mConditions.isXTMBullish = XTMIsBullish(bar_index);
|
|
mConditions.isXTMBearish = XTMIsBearish(bar_index);
|
|
mConditions.isXTMNeutural = XTMIsNeutural(bar_index);
|
|
mConditions.isXTMEndBullish = XTMIsEndBullish(bar_index);
|
|
mConditions.isXTMEndBearish = XTMIsEndBearish(bar_index);
|
|
mConditions.isXTMStartBullish = XTMIsStartBullish(bar_index);
|
|
mConditions.isXTMStartBearish = XTMIsStartBearish(bar_index);
|
|
mConditions.isXTMEndBullishByNeutural = XTMIsEndBullishByNeutural(bar_index);
|
|
mConditions.isXTMEndBearishByNeutural = XTMIsEndBearishByNeutural(bar_index);
|
|
mConditions.isXTMStartBullishAfterNeutural = XTMIsStartBullishAfterNeutural(bar_index);
|
|
mConditions.isXTMStartBearishAfterNeutural = XTMIsStartBearishAfterNeutural(bar_index);
|
|
|
|
//
|
|
// XLH ...
|
|
mConditions.isXLHHHIncreased = XLHIsHHIncreased(bar_index);
|
|
mConditions.isXLHHHDecreased = XLHIsHHDecreased(bar_index);
|
|
mConditions.isXLHLLIncreased = XLHIsLLIncreased(bar_index);
|
|
mConditions.isXLHLLDecreased = XLHIsLLDecreased(bar_index);
|
|
mConditions.isXLHLowAttachedLL = XLHIsLowAttachedLL(bar_index);
|
|
mConditions.isXLHHighAttachedHH = XLHIsHighAttachedHH(bar_index);
|
|
mConditions.isXLHHHSameInLength = XLHIsHHSameInLength(bar_index);
|
|
mConditions.isXLHLLSameInLength = XLHIsLLSameInLength(bar_index);
|
|
mConditions.isXLHPriceOverSignal = XLHIsPriceOverSignal(bar_index);
|
|
mConditions.isXLHPriceUnderSignal = XLHIsPriceUnderSignal(bar_index);
|
|
mConditions.isXLHPriceInSignalRange = XLHIsPriceInSignalRange(bar_index);
|
|
mConditions.isXLHPriceCrossedOverSignal = XLHIsPriceCrossedOverSignal(bar_index);
|
|
mConditions.isXLHPriceCrossedUnderSignal = XLHIsPriceCrossedUnderSignal(bar_index);
|
|
|
|
//
|
|
// XTD ...
|
|
mConditions.isXTDSignalPeak = XTDIsSignalPeak(bar_index);
|
|
mConditions.isXTDSignalVale = XTDIsSignalVale(bar_index);
|
|
mConditions.isXTDBullishPeak = XTDIsBullishPeak(bar_index);
|
|
mConditions.isXTDBullishVale = XTDIsBullishVale(bar_index);
|
|
mConditions.isXTDBearishPeak = XTDIsBearishPeak(bar_index);
|
|
mConditions.isXTDBearishVale = XTDIsBearishVale(bar_index);
|
|
mConditions.isXTDBullOverBear = XTDIsBullOverBear(bar_index);
|
|
mConditions.isXTDBullUnderBear = XTDIsBullUnderBear(bar_index);
|
|
mConditions.isXTDSignalOverBear = XTDIsSignalOverBear(bar_index);
|
|
mConditions.isXTDSignalUnderBear = XTDIsSignalUnderBear(bar_index);
|
|
mConditions.isXTDBullCrossedOverBear = XTDIsBullCrossedOverBear(bar_index);
|
|
mConditions.isXTDBullCrossedUnderBear = XTDIsBullCrossedUnderBear(bar_index);
|
|
mConditions.isXTDSignalCrossedOverBear = XTDIsSignalCrossedOverBear(bar_index);
|
|
mConditions.isXTDSignalCrossedUnderBear = XTDIsSignalCrossedUnderBear(bar_index);
|
|
|
|
//
|
|
// XRSI ...
|
|
mConditions.isXRSIPeak = XRSIIsPeak(bar_index);
|
|
mConditions.isXRSIVale = XRSIIsVale(bar_index);
|
|
mConditions.isXRSICrossedOverLongExit = XRSIIsCrossedOverLongExit(bar_index);
|
|
mConditions.isXRSICrossedOverLongEntry = XRSIIsCrossedOverLongEntry(bar_index);
|
|
mConditions.isXRSICrossedUnderShortExit = XRSIIsCrossedUnderShortExit(bar_index);
|
|
mConditions.isXRSICrossedUnderShortEntry = XRSIIsCrossedUnderShortEntry(bar_index);
|
|
|
|
//
|
|
// XOBD ...
|
|
mConditions.isXOBDSwingLow = XOBDIsSwingLow(bar_index);
|
|
mConditions.isXOBDSwingHigh = XOBDIsSwingHigh(bar_index);
|
|
|
|
//
|
|
// XCHLH ...
|
|
//
|
|
mConditions.isXCHLHSameHHs = XCHLHIsSameHHs(bar_index);
|
|
mConditions.isXCHLHSameLLs = XCHLHIsSameLLs(bar_index);
|
|
//
|
|
mConditions.isXCHLHSCMCHHSame = XCHLHIsMCSCHasSameHH(bar_index);
|
|
mConditions.isXCHLHSCMCLLSame = XCHLHIsMCSCHasSameLL(bar_index);
|
|
//
|
|
mConditions.isXCHLHSCLCHHSame = XCHLHIsLCSCHasSameHH(bar_index);
|
|
mConditions.isXCHLHSCLCLLSame = XCHLHIsLCSCHasSameLL(bar_index);
|
|
//
|
|
mConditions.isXCHLHMCLCHHSame = XCHLHIsLCMCHasSameHH(bar_index);
|
|
mConditions.isXCHLHMCLCLLSame = XCHLHIsLCMCHasSameLL(bar_index);
|
|
//
|
|
mConditions.isXCHLHMCOnTopOfLC = XCHLHIsMCOnTopOfLC(bar_index);
|
|
mConditions.isXCHLHMCInBottomOfLC = XCHLHIsMCInBottomOfLC(bar_index);
|
|
|
|
//
|
|
// XCHMA ...
|
|
//
|
|
mConditions.isXCHMASCOverMax = XCHMAIsSCOverMax(bar_index);
|
|
mConditions.isXCHMASCOverMin = XCHMAIsSCOverMin(bar_index);
|
|
mConditions.isXCHMASCUnderMax = XCHMAIsSCUnderMax(bar_index);
|
|
mConditions.isXCHMASCUnderMin = XCHMAIsSCUnderMin(bar_index);
|
|
//
|
|
mConditions.isXCHMASCCrossedOverMax = XCHMAIsSCCrossedOverMax(bar_index);
|
|
mConditions.isXCHMASCCrossedUnderMax = XCHMAIsSCCrossedUnderMax(bar_index);
|
|
mConditions.isXCHMASCCrossedOverMin = XCHMAIsSCCrossedOverMin(bar_index);
|
|
mConditions.isXCHMASCCrossedUnderMin = XCHMAIsSCCrossedUnderMin(bar_index);
|
|
//
|
|
mConditions.isXCHMASCPeak = XCHMAIsSCPeak(bar_index);
|
|
mConditions.isXCHMASCVale = XCHMAIsSCVale(bar_index);
|
|
mConditions.isXCHMASCTrendsUp = XCHMAIsSCTrendsUp(bar_index);
|
|
mConditions.isXCHMASCTrendsDown = XCHMAIsSCTrendsDown(bar_index);
|
|
mConditions.isXCHMASCFastOverSlow = XCHMAIsSCFastOverSlow(bar_index);
|
|
mConditions.isXCHMASCFastUnderSlow = XCHMAIsSCFastUnderSlow(bar_index);
|
|
mConditions.isXCHMASCFastCrossedOverSlow = XCHMAIsSCFastCrossedOverSlow(bar_index);
|
|
mConditions.isXCHMASCFastCrossedUnderSlow = XCHMAIsSCFastCrossedUnderSlow(bar_index);
|
|
//
|
|
mConditions.isXCHMAMCPeak = XCHMAIsMCPeak(bar_index);
|
|
mConditions.isXCHMAMCVale = XCHMAIsMCVale(bar_index);
|
|
mConditions.isXCHMAMCTrendsUp = XCHMAIsMCTrendsUp(bar_index);
|
|
mConditions.isXCHMAMCTrendsDown = XCHMAIsMCTrendsDown(bar_index);
|
|
mConditions.isXCHMAMCFastOverSlow = XCHMAIsMCFastOverSlow(bar_index);
|
|
mConditions.isXCHMAMCFastUnderSlow = XCHMAIsMCFastUnderSlow(bar_index);
|
|
mConditions.isXCHMAMCFastCrossedOverSlow = XCHMAIsMCFastCrossedOverSlow(bar_index);
|
|
mConditions.isXCHMAMCFastCrossedUnderSlow = XCHMAIsMCFastCrossedUnderSlow(bar_index);
|
|
//
|
|
mConditions.isXCHMALCPeak = XCHMAIsLCPeak(bar_index);
|
|
mConditions.isXCHMALCVale = XCHMAIsLCVale(bar_index);
|
|
mConditions.isXCHMALCTrendsUp = XCHMAIsLCTrendsUp(bar_index);
|
|
mConditions.isXCHMALCTrendsDown = XCHMAIsLCTrendsDown(bar_index);
|
|
mConditions.isXCHMALCFastOverSlow = XCHMAIsLCFastOverSlow(bar_index);
|
|
mConditions.isXCHMALCFastUnderSlow = XCHMAIsLCFastUnderSlow(bar_index);
|
|
mConditions.isXCHMALCFastCrossedOverSlow = XCHMAIsLCFastCrossedOverSlow(bar_index);
|
|
mConditions.isXCHMALCFastCrossedUnderSlow = XCHMAIsLCFastCrossedUnderSlow(bar_index);
|
|
|
|
//
|
|
return mConditions;
|
|
}
|
|
|
|
//
|
|
// Converts Market Conditions to Specific String Representation ...
|
|
string XEU5GetConditionsString(
|
|
string separator = ",", // Specify Separator
|
|
bool ignoreFalses = true // Ignore False Conditions
|
|
)
|
|
{
|
|
//
|
|
XEU5_MARKET_CONDITIONS mConditions = {};
|
|
|
|
//
|
|
mConditions = conditions;
|
|
|
|
//
|
|
string result = "\n";
|
|
|
|
//
|
|
// XOBD ...
|
|
result +=
|
|
"| XOBD |" + separator;
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXOBDSwingLow))
|
|
{
|
|
result += "isXOBDSwingLow: " + (string)mConditions.isXOBDSwingLow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXOBDSwingHigh))
|
|
{
|
|
result += "isXOBDSwingHigh: " + (string)mConditions.isXOBDSwingHigh + separator;
|
|
}
|
|
|
|
//
|
|
// Separator ...
|
|
result += separator;
|
|
|
|
//
|
|
// XTM ...
|
|
result +=
|
|
"| XTM |" + separator;
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMPeak))
|
|
{
|
|
result += "isXTMPeak: " + (string)mConditions.isXTMPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMVale))
|
|
{
|
|
result += "isXTMVale: " + (string)mConditions.isXTMVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMStartBullish))
|
|
{
|
|
result += "isXTMStartBullish: " + (string)mConditions.isXTMStartBullish + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMStartBullishAfterNeutural))
|
|
{
|
|
result += "isXTMStartBullishAfterNeutural: " + (string)mConditions.isXTMStartBullishAfterNeutural + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMBullish))
|
|
{
|
|
result += "isXTMBullish: " + (string)mConditions.isXTMBullish + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMEndBullish))
|
|
{
|
|
result += "isXTMEndBullish: " + (string)mConditions.isXTMEndBullish + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMEndBullishByNeutural))
|
|
{
|
|
result += "isXTMEndBullishByNeutural: " + (string)mConditions.isXTMEndBullishByNeutural + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMStartBearish))
|
|
{
|
|
result += "isXTMStartBearish: " + (string)mConditions.isXTMStartBearish + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMStartBearishAfterNeutural))
|
|
{
|
|
result += "isXTMStartBearishAfterNeutural: " + (string)mConditions.isXTMStartBearishAfterNeutural + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMBearish))
|
|
{
|
|
result += "isXTMBearish: " + (string)mConditions.isXTMBearish + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMEndBearish))
|
|
{
|
|
result += "isXTMEndBearish: " + (string)mConditions.isXTMEndBearish + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMEndBearishByNeutural))
|
|
{
|
|
result += "isXTMEndBearishByNeutural: " + (string)mConditions.isXTMEndBearishByNeutural + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTMNeutural))
|
|
{
|
|
result += "isXTMNeutural: " + (string)mConditions.isXTMNeutural + separator;
|
|
}
|
|
|
|
//
|
|
// Separator ...
|
|
result += separator;
|
|
|
|
//
|
|
// XTD ...
|
|
result +=
|
|
"| XTD |" + separator;
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDSignalPeak))
|
|
{
|
|
result += "isXTDSignalPeak: " + (string)mConditions.isXTDSignalPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDSignalVale))
|
|
{
|
|
result += "isXTDSignalVale: " + (string)mConditions.isXTDSignalVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBullishPeak))
|
|
{
|
|
result += "isXTDBullishPeak: " + (string)mConditions.isXTDBullishPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBullishVale))
|
|
{
|
|
result += "isXTDBullishVale: " + (string)mConditions.isXTDBullishVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBearishPeak))
|
|
{
|
|
result += "isXTDBearishPeak: " + (string)mConditions.isXTDBearishPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBearishVale))
|
|
{
|
|
result += "isXTDBearishVale: " + (string)mConditions.isXTDBearishVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBullOverBear))
|
|
{
|
|
result += "isXTDBullOverBear: " + (string)mConditions.isXTDBullOverBear + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBullUnderBear))
|
|
{
|
|
result += "isXTDBullUnderBear: " + (string)mConditions.isXTDBullUnderBear + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDSignalOverBear))
|
|
{
|
|
result += "isXTDSignalOverBear: " + (string)mConditions.isXTDSignalOverBear + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDSignalUnderBear))
|
|
{
|
|
result += "isXTDSignalUnderBear: " + (string)mConditions.isXTDSignalUnderBear + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBullCrossedOverBear))
|
|
{
|
|
result += "isXTDBullCrossedOverBear: " + (string)mConditions.isXTDBullCrossedOverBear + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDBullCrossedUnderBear))
|
|
{
|
|
result += "isXTDBullCrossedUnderBear: " + (string)mConditions.isXTDBullCrossedUnderBear + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDSignalCrossedOverBear))
|
|
{
|
|
result += "isXTDSignalCrossedOverBear: " + (string)mConditions.isXTDSignalCrossedOverBear + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXTDSignalCrossedUnderBear))
|
|
{
|
|
result += "isXTDSignalCrossedUnderBear: " + (string)mConditions.isXTDSignalCrossedUnderBear + separator;
|
|
}
|
|
|
|
//
|
|
// Separator ...
|
|
result += separator;
|
|
|
|
//
|
|
// XLH ...
|
|
result +=
|
|
"| XLH |" + separator;
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHHHIncreased))
|
|
{
|
|
result += "isXLHHHIncreased: " + (string)mConditions.isXLHHHIncreased + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHHHDecreased))
|
|
{
|
|
result += "isXLHHHDecreased: " + (string)mConditions.isXLHHHDecreased + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHLLIncreased))
|
|
{
|
|
result += "isXLHLLIncreased: " + (string)mConditions.isXLHLLIncreased + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHLLDecreased))
|
|
{
|
|
result += "isXLHLLDecreased: " + (string)mConditions.isXLHLLDecreased + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHHighAttachedHH))
|
|
{
|
|
result += "isXLHHighAttachedHH: " + (string)mConditions.isXLHHighAttachedHH + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHLowAttachedLL))
|
|
{
|
|
result += "isXLHLowAttachedLL: " + (string)mConditions.isXLHLowAttachedLL + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHHHSameInLength))
|
|
{
|
|
result += "isXLHHHSameInLength: " + (string)mConditions.isXLHHHSameInLength + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHLLSameInLength))
|
|
{
|
|
result += "isXLHLLSameInLength: " + (string)mConditions.isXLHLLSameInLength + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHPriceCrossedOverSignal))
|
|
{
|
|
result += "isXLHPriceCrossedOverSignal: " + (string)mConditions.isXLHPriceCrossedOverSignal + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHPriceOverSignal))
|
|
{
|
|
result += "isXLHPriceOverSignal: " + (string)mConditions.isXLHPriceOverSignal + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHPriceCrossedUnderSignal))
|
|
{
|
|
result += "isXLHPriceCrossedUnderSignal: " + (string)mConditions.isXLHPriceCrossedUnderSignal + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHPriceUnderSignal))
|
|
{
|
|
result += "isXLHPriceUnderSignal: " + (string)mConditions.isXLHPriceUnderSignal + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXLHPriceInSignalRange))
|
|
{
|
|
result += "isXLHPriceInSignalRange: " + (string)mConditions.isXLHPriceInSignalRange + separator;
|
|
}
|
|
|
|
//
|
|
// Separator ...
|
|
result += separator;
|
|
|
|
//
|
|
// XRSI ...
|
|
result +=
|
|
"| XRSI |" + separator;
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXRSIPeak))
|
|
{
|
|
result += "isXRSIPeak: " + (string)mConditions.isXRSIPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXRSIVale))
|
|
{
|
|
result += "isXRSIVale: " + (string)mConditions.isXRSIVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXRSICrossedOverLongExit))
|
|
{
|
|
result += "isXRSICrossedOverLongExit: " + (string)mConditions.isXRSICrossedOverLongExit + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXRSICrossedOverLongEntry))
|
|
{
|
|
result += "isXRSICrossedOverLongEntry: " + (string)mConditions.isXRSICrossedOverLongEntry + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXRSICrossedUnderShortExit))
|
|
{
|
|
result += "isXRSICrossedUnderShortExit: " + (string)mConditions.isXRSICrossedUnderShortExit + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXRSICrossedUnderShortEntry))
|
|
{
|
|
result += "isXRSICrossedUnderShortEntry: " + (string)mConditions.isXRSICrossedUnderShortEntry + separator;
|
|
}
|
|
|
|
//
|
|
// Separator ...
|
|
result += separator;
|
|
|
|
//
|
|
// XCHLH ...
|
|
result +=
|
|
"| XCHLH |" + separator;
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHSameHHs))
|
|
{
|
|
result += "isXCHLHSameHHs: " + (string)mConditions.isXCHLHSameHHs + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHSameLLs))
|
|
{
|
|
result += "isXCHLHSameLLs: " + (string)mConditions.isXCHLHSameLLs + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHSCMCHHSame))
|
|
{
|
|
result += "isXCHLHSCMCHHSame: " + (string)mConditions.isXCHLHSCMCHHSame + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHSCMCLLSame))
|
|
{
|
|
result += "isXCHLHSCMCLLSame: " + (string)mConditions.isXCHLHSCMCLLSame + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHSCLCHHSame))
|
|
{
|
|
result += "isXCHLHSCLCHHSame: " + (string)mConditions.isXCHLHSCLCHHSame + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHSCLCLLSame))
|
|
{
|
|
result += "isXCHLHSCLCLLSame: " + (string)mConditions.isXCHLHSCLCLLSame + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHMCLCHHSame))
|
|
{
|
|
result += "isXCHLHMCLCHHSame: " + (string)mConditions.isXCHLHMCLCHHSame + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHMCLCLLSame))
|
|
{
|
|
result += "isXCHLHMCLCLLSame: " + (string)mConditions.isXCHLHMCLCLLSame + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHMCOnTopOfLC))
|
|
{
|
|
result += "isXCHLHMCOnTopOfLC: " + (string)mConditions.isXCHLHMCOnTopOfLC + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHLHMCInBottomOfLC))
|
|
{
|
|
result += "isXCHLHMCInBottomOfLC: " + (string)mConditions.isXCHLHMCInBottomOfLC + separator;
|
|
}
|
|
|
|
//
|
|
// Separator ...
|
|
result += separator;
|
|
|
|
//
|
|
// XCHMA ...
|
|
result +=
|
|
"| XCHMA |" + separator;
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCOverMax))
|
|
{
|
|
result += "isXCHMASCOverMax: " + (string)mConditions.isXCHMASCOverMax + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCOverMin))
|
|
{
|
|
result += "isXCHMASCOverMin: " + (string)mConditions.isXCHMASCOverMin + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCUnderMax))
|
|
{
|
|
result += "isXCHMASCUnderMax: " + (string)mConditions.isXCHMASCUnderMax + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCUnderMin))
|
|
{
|
|
result += "isXCHMASCUnderMin: " + (string)mConditions.isXCHMASCUnderMin + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCCrossedOverMax))
|
|
{
|
|
result += "isXCHMASCCrossedOverMax: " + (string)mConditions.isXCHMASCCrossedOverMax + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCCrossedUnderMax))
|
|
{
|
|
result += "isXCHMASCCrossedUnderMax: " + (string)mConditions.isXCHMASCCrossedUnderMax + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCCrossedOverMin))
|
|
{
|
|
result += "isXCHMASCCrossedOverMin: " + (string)mConditions.isXCHMASCCrossedOverMin + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCCrossedUnderMin))
|
|
{
|
|
result += "isXCHMASCCrossedUnderMin: " + (string)mConditions.isXCHMASCCrossedUnderMin + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCPeak))
|
|
{
|
|
result += "isXCHMASCPeak: " + (string)mConditions.isXCHMASCPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCVale))
|
|
{
|
|
result += "isXCHMASCVale: " + (string)mConditions.isXCHMASCVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCTrendsUp))
|
|
{
|
|
result += "isXCHMASCTrendsUp: " + (string)mConditions.isXCHMASCTrendsUp + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCTrendsDown))
|
|
{
|
|
result += "isXCHMASCTrendsDown: " + (string)mConditions.isXCHMASCTrendsDown + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCFastOverSlow))
|
|
{
|
|
result += "isXCHMASCFastOverSlow: " + (string)mConditions.isXCHMASCFastOverSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCFastUnderSlow))
|
|
{
|
|
result += "isXCHMASCFastUnderSlow: " + (string)mConditions.isXCHMASCFastUnderSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCFastCrossedOverSlow))
|
|
{
|
|
result += "isXCHMASCFastCrossedOverSlow: " + (string)mConditions.isXCHMASCFastCrossedOverSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMASCFastCrossedUnderSlow))
|
|
{
|
|
result += "isXCHMASCFastCrossedUnderSlow: " + (string)mConditions.isXCHMASCFastCrossedUnderSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCPeak))
|
|
{
|
|
result += "isXCHMAMCPeak: " + (string)mConditions.isXCHMAMCPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCVale))
|
|
{
|
|
result += "isXCHMAMCVale: " + (string)mConditions.isXCHMAMCVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCTrendsUp))
|
|
{
|
|
result += "isXCHMAMCTrendsUp: " + (string)mConditions.isXCHMAMCTrendsUp + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCTrendsDown))
|
|
{
|
|
result += "isXCHMAMCTrendsDown: " + (string)mConditions.isXCHMAMCTrendsDown + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCFastOverSlow))
|
|
{
|
|
result += "isXCHMAMCFastOverSlow: " + (string)mConditions.isXCHMAMCFastOverSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCFastUnderSlow))
|
|
{
|
|
result += "isXCHMAMCFastUnderSlow: " + (string)mConditions.isXCHMAMCFastUnderSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCFastCrossedOverSlow))
|
|
{
|
|
result += "isXCHMAMCFastCrossedOverSlow: " + (string)mConditions.isXCHMAMCFastCrossedOverSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMAMCFastCrossedUnderSlow))
|
|
{
|
|
result += "isXCHMAMCFastCrossedUnderSlow: " + (string)mConditions.isXCHMAMCFastCrossedUnderSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCPeak))
|
|
{
|
|
result += "isXCHMALCPeak: " + (string)mConditions.isXCHMALCPeak + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCVale))
|
|
{
|
|
result += "isXCHMALCVale: " + (string)mConditions.isXCHMALCVale + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCTrendsUp))
|
|
{
|
|
result += "isXCHMALCTrendsUp: " + (string)mConditions.isXCHMALCTrendsUp + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCTrendsDown))
|
|
{
|
|
result += "isXCHMALCTrendsDown: " + (string)mConditions.isXCHMALCTrendsDown + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCFastOverSlow))
|
|
{
|
|
result += "isXCHMALCFastOverSlow: " + (string)mConditions.isXCHMALCFastOverSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCFastUnderSlow))
|
|
{
|
|
result += "isXCHMALCFastUnderSlow: " + (string)mConditions.isXCHMALCFastUnderSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCFastCrossedOverSlow))
|
|
{
|
|
result += "isXCHMALCFastCrossedOverSlow: " + (string)mConditions.isXCHMALCFastCrossedOverSlow + separator;
|
|
}
|
|
|
|
//
|
|
if (
|
|
!ignoreFalses ||
|
|
(ignoreFalses && mConditions.isXCHMALCFastCrossedUnderSlow))
|
|
{
|
|
result += "isXCHMALCFastCrossedUnderSlow: " + (string)mConditions.isXCHMALCFastCrossedUnderSlow + separator;
|
|
}
|
|
|
|
//
|
|
// Separator ...
|
|
result += separator;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve First Higher SwingHigh from Specified Value ...
|
|
double XEU5GetFirstBiggerSwingHigh(
|
|
double value)
|
|
{
|
|
//
|
|
double result = value > 0 ? value : 0;
|
|
|
|
//
|
|
// Validate Args ...
|
|
int swingHighsCount = ArraySize(xEU5SwingHighTimes);
|
|
if (swingHighsCount <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Swing Highs Time Array as Series ...
|
|
ArraySetAsSeries(xEU5SwingHighTimes, true);
|
|
|
|
//
|
|
// Loop ...
|
|
for (int i = 0; i < swingHighsCount; i++)
|
|
{
|
|
//
|
|
datetime iTime = xEU5SwingHighTimes[i];
|
|
int iBar = iBarShift(_Symbol, _Period, iTime);
|
|
XOHCL iCandle = GetCandle(iBar + 3);
|
|
double iValue = iCandle.low;
|
|
|
|
//
|
|
if (iValue > value)
|
|
{
|
|
//
|
|
result = iValue;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve First Lower SwingHigh from Specified Value ...
|
|
double XEU5GetFirstLowerSwingHigh(
|
|
double value)
|
|
{
|
|
//
|
|
double result = value > 0 ? value : 0;
|
|
|
|
//
|
|
// Validate Args ...
|
|
int swingHighsCount = ArraySize(xEU5SwingHighTimes);
|
|
if (swingHighsCount <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Swing Highs Time Array as Series ...
|
|
ArraySetAsSeries(xEU5SwingHighTimes, true);
|
|
|
|
//
|
|
// Loop ...
|
|
for (int i = 0; i < swingHighsCount; i++)
|
|
{
|
|
//
|
|
datetime iTime = xEU5SwingHighTimes[i];
|
|
int iBar = iBarShift(_Symbol, _Period, iTime);
|
|
XOHCL iCandle = GetCandle(iBar + 3);
|
|
double iValue = iCandle.low;
|
|
|
|
//
|
|
if (iValue < value)
|
|
{
|
|
//
|
|
result = iValue;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve First Higher SwingLow from Specified Value ...
|
|
double XEU5GetFirstBiggerSwingLow(
|
|
double value)
|
|
{
|
|
//
|
|
double result = value > 0 ? value : 0;
|
|
|
|
//
|
|
// Validate Args ...
|
|
int swingLowsCount = ArraySize(xEU5SwingLowTimes);
|
|
if (swingLowsCount <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Swing Highs Time Array as Series ...
|
|
ArraySetAsSeries(xEU5SwingLowTimes, true);
|
|
|
|
//
|
|
// Loop ...
|
|
for (int i = 0; i < swingLowsCount; i++)
|
|
{
|
|
//
|
|
datetime iTime = xEU5SwingLowTimes[i];
|
|
int iBar = iBarShift(_Symbol, _Period, iTime);
|
|
XOHCL iCandle = GetCandle(iBar + 3);
|
|
double iValue = iCandle.low;
|
|
|
|
//
|
|
if (iValue > value)
|
|
{
|
|
//
|
|
result = iValue;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve First Lower SwingLow from Specified Value ...
|
|
double XEU5GetFirstLowerSwingLow(
|
|
double value)
|
|
{
|
|
//
|
|
double result = value > 0 ? value : 0;
|
|
|
|
//
|
|
// Validate Args ...
|
|
int swingLowsCount = ArraySize(xEU5SwingLowTimes);
|
|
if (swingLowsCount <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Swing Highs Time Array as Series ...
|
|
ArraySetAsSeries(xEU5SwingLowTimes, true);
|
|
|
|
//
|
|
// Loop ...
|
|
for (int i = 0; i < swingLowsCount; i++)
|
|
{
|
|
//
|
|
datetime iTime = xEU5SwingLowTimes[i];
|
|
int iBar = iBarShift(_Symbol, _Period, iTime);
|
|
XOHCL iCandle = GetCandle(iBar + 3);
|
|
double iValue = iCandle.low;
|
|
|
|
//
|
|
if (iValue < value)
|
|
{
|
|
//
|
|
result = iValue;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Market Conditions by Combination of Power of All tools for LONGs ...
|
|
bool XEU5HasLongSignal(
|
|
XEU5_SIGNAL &info // Retrieve Signal Additional Info on this Object
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Required Data ...
|
|
double entry = GetEntry(X_SIGNAL_LONG);
|
|
double nearHH = GetHighestHigh(3, 1);
|
|
double nearLL = GetLowestLow(3, 1);
|
|
XOHCL candle1 = GetCandle(1);
|
|
|
|
//
|
|
bool isSharpChanged = IsSharpIncreasedChanged(
|
|
5,
|
|
1,
|
|
xTMMaBuffer);
|
|
|
|
//
|
|
bool isCandleSharpChanged = IsSharpIncreasedChanged(
|
|
5,
|
|
1,
|
|
PRICE_CLOSE);
|
|
|
|
//
|
|
bool isMCOverLC = XCHMAIsCycleOverAnother(1, X_XCHMA_CYCLE_MEDIUM, X_XCHMA_CYCLE_LONG);
|
|
bool isMCUnderLC = XCHMAIsCycleUnderAnother(1, X_XCHMA_CYCLE_MEDIUM, X_XCHMA_CYCLE_LONG);
|
|
bool isLCOverMC = XCHMAIsCycleOverAnother(1, X_XCHMA_CYCLE_LONG, X_XCHMA_CYCLE_MEDIUM);
|
|
bool isLCUndrMC = XCHMAIsCycleUnderAnother(1, X_XCHMA_CYCLE_LONG, X_XCHMA_CYCLE_MEDIUM);
|
|
|
|
//
|
|
bool isXCHMABasedSignalVerified =
|
|
//
|
|
(
|
|
//
|
|
isMCOverLC
|
|
? !(
|
|
conditions.isXCHMAMCPeak ||
|
|
(conditions.isXCHMAMCFastOverSlow &&
|
|
conditions.isXCHMAMCTrendsDown))
|
|
: true
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
(
|
|
//
|
|
conditions.isXLHPriceOverSignal && conditions.isXCHLHMCOnTopOfLC
|
|
? !(
|
|
conditions.isXCHLHSameHHs &&
|
|
conditions.isXLHLLSameInLength)
|
|
: true
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool chmaBasedSignal =
|
|
//
|
|
conditions.isXCHMASCCrossedOverMax &&
|
|
isXCHMABasedSignalVerified
|
|
//
|
|
&&
|
|
//
|
|
!isSharpChanged
|
|
//
|
|
&&
|
|
//
|
|
!isCandleSharpChanged
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chmaBasedSignal)
|
|
{
|
|
//
|
|
info.signalPusher++;
|
|
|
|
//
|
|
double hh = xCHLHScHHBuffer[1];
|
|
double ll = xCHLHScLLBuffer[1];
|
|
|
|
//
|
|
double stp = XEU5GetFirstBiggerSwingHigh(entry);
|
|
double ssl = XEU5GetFirstLowerSwingLow(entry);
|
|
|
|
//
|
|
double tp = stp > entry ? MathAbs(entry - stp) : MathAbs(hh - entry) + PipsToPrice(1);
|
|
double sl = 0; // ssl < entry ? MathAbs(entry - ssl) : MathAbs(ll - entry) - PipsToPrice(1);
|
|
|
|
//
|
|
if (
|
|
xEU5RiskFreeRate > 0 &&
|
|
xEU5RiskFreeTradesInPips > 0 &&
|
|
xEU5MinRewardPerTradeInPips > 0)
|
|
{
|
|
//
|
|
double minReward = PipsToPrice(xEU5MinRewardPerTradeInPips);
|
|
double riskFreeReward = PipsToPrice(xEU5RiskFreeTradesInPips);
|
|
if (tp > entry + minReward)
|
|
{
|
|
info.riskFree = minReward;
|
|
}
|
|
else if (tp > entry + riskFreeReward)
|
|
{
|
|
info.riskFree = riskFreeReward;
|
|
}
|
|
}
|
|
|
|
//
|
|
info.tp = tp;
|
|
info.sl = sl;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
// swingBasedSignal
|
|
// //
|
|
// ||
|
|
//
|
|
chmaBasedSignal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
// TODO: Remove This for Production ...
|
|
string msg = XEU5GetConditionsString("\n");
|
|
LogMessage(msg);
|
|
|
|
// //
|
|
// LogMessage("isMCOverLC: " + (string)isMCOverLC);
|
|
// LogMessage("isMCUnderLC: " + (string)isMCUnderLC);
|
|
// LogMessage("isLCOverMC: " + (string)isLCOverMC);
|
|
// LogMessage("isLCUndrMC: " + (string)isLCUndrMC);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Market Conditions by Combination of Power of All tools for SHORTs ...
|
|
bool XEU5HasShortSignal(
|
|
XEU5_SIGNAL &info // Retrieve Signal Additional Info on this Object
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Required Data ...
|
|
double entry = GetEntry(X_SIGNAL_LONG);
|
|
double nearHH = GetHighestHigh(3, 1);
|
|
double nearLL = GetLowestLow(3, 1);
|
|
XOHCL candle1 = GetCandle(1);
|
|
|
|
//
|
|
bool isSharpChanged = IsSharpDecreasedChanged(
|
|
5,
|
|
1,
|
|
xTMMaBuffer);
|
|
|
|
//
|
|
bool isCandleSharpChanged = IsSharpDecreasedChanged(
|
|
5,
|
|
1,
|
|
PRICE_CLOSE);
|
|
|
|
//
|
|
bool chmaBasedSignal =
|
|
//
|
|
conditions.isXCHMASCCrossedUnderMin
|
|
// conditions.isXCHMAMCFastCrossedUnderSlow
|
|
//
|
|
// (
|
|
// //
|
|
// XCHMAIsSCFastUnderSlow(1) &&
|
|
// XCHMAIsMCFastUnderSlow(1) &&
|
|
// XCHMAIsLCFastUnderSlow(1)
|
|
// //
|
|
// )
|
|
// //
|
|
// &&
|
|
// //
|
|
// !(
|
|
// //
|
|
// XCHMAIsSCFastUnderSlow(2) &&
|
|
// XCHMAIsMCFastUnderSlow(2) &&
|
|
// XCHMAIsLCFastUnderSlow(2)
|
|
// //
|
|
// )
|
|
//
|
|
// &&
|
|
// //
|
|
// conditions.isXCHMASCCrossedUnderMax
|
|
//
|
|
;
|
|
|
|
//
|
|
if (chmaBasedSignal)
|
|
{
|
|
//
|
|
info.signalPusher++;
|
|
|
|
//
|
|
double hh = xCHLHScHHBuffer[1];
|
|
double ll = xCHLHScLLBuffer[1];
|
|
|
|
//
|
|
double stp = XEU5GetFirstLowerSwingLow(entry);
|
|
double ssl = XEU5GetFirstBiggerSwingHigh(entry);
|
|
|
|
//
|
|
double tp = MathAbs(entry - stp);
|
|
double sl = 0; // MathAbs(entry - ssl);
|
|
|
|
//
|
|
info.tp = tp;
|
|
info.sl = sl;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
// swingBasedSignal
|
|
// //
|
|
// ||
|
|
//
|
|
chmaBasedSignal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
// TODO: Remove This for Production ...
|
|
string msg = XEU5GetConditionsString("\n");
|
|
LogMessage(msg);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
//
|
|
// END Combination Signaling ...
|
|
//
|
|
//
|