complete conditions Calculation ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,133 @@
|
||||
isXTMPeak
|
||||
isXTMVale
|
||||
isXTMBullish
|
||||
isXTMBearish
|
||||
isXTMNeutural
|
||||
isXTMEndBullish
|
||||
isXTMEndBearish
|
||||
isXTMStartBullish
|
||||
isXTMStartBearish
|
||||
isXTMEndBullishByNeutural
|
||||
isXTMEndBearishByNeutural
|
||||
isXTMStartBullishAfterNeutural
|
||||
isXTMStartBearishAfterNeutural
|
||||
|
||||
isXAMAPeak
|
||||
isXAMAVale
|
||||
isXAMABullish
|
||||
isXAMABearish
|
||||
isXAMANeutural
|
||||
isXAMAEndBullish
|
||||
isXAMAEndBearish
|
||||
isXAMAStartBullish
|
||||
isXAMAStartBearish
|
||||
isXAMAEndBullishByNeutural
|
||||
isXAMAEndBearishByNeutural
|
||||
isXAMAStartBullishAfterNeutural
|
||||
isXAMAStartBearishAfterNeutural
|
||||
|
||||
isXLHHHIncreased
|
||||
isXLHHHDecreased
|
||||
isXLHLLIncreased
|
||||
isXLHLLDecreased
|
||||
isXLHLowAttachedLL
|
||||
isXLHHighAttachedHH
|
||||
isXLHHHSameInLength
|
||||
isXLHLLSameInLength
|
||||
isXLHPriceOverSignal
|
||||
isXLHPriceUnderSignal
|
||||
isXLHPriceInSignalRange
|
||||
isXLHPriceCrossedOverSignal
|
||||
isXLHPriceCrossedUnderSignal
|
||||
|
||||
isXTDSignalPeak
|
||||
isXTDSignalVale
|
||||
isXTDBullishPeak
|
||||
isXTDBullishVale
|
||||
isXTDBearishPeak
|
||||
isXTDBearishVale
|
||||
isXTDBullOverBear
|
||||
isXTDBullUnderBear
|
||||
isXTDSignalOverBear
|
||||
isXTDSignalUnderBear
|
||||
isXTDBullCrossedOverBear
|
||||
isXTDBullCrossedUnderBear
|
||||
isXTDSignalCrossedOverBear
|
||||
isXTDSignalCrossedUnderBear
|
||||
|
||||
isXFIPeak
|
||||
isXFIVale
|
||||
isXFICrossedOverZero
|
||||
isXFIOverZero
|
||||
isXFICrossedUnderZero
|
||||
isXFIUnderZero
|
||||
|
||||
isXTSAllSame
|
||||
isXTSCurrentMin
|
||||
isXTSCurrentMax
|
||||
isXTSCurrentOverFarest
|
||||
isXTSCurrentOverNearest
|
||||
isXTSCurrentOverMediest
|
||||
isXTSCurrentUnderFarest
|
||||
isXTSCurrentUnderNearest
|
||||
isXTSCurrentUnderMediest
|
||||
isXTSCurrentCrossedOverFarest
|
||||
isXTSCurrentCrossedOverNearest
|
||||
isXTSCurrentCrossedOverMediest
|
||||
isXTSCurrentCrossedUnderFarest
|
||||
isXTSCurrentCrossedUnderNearest
|
||||
isXTSCurrentCrossedUnderMediest
|
||||
|
||||
isXRSIPeak
|
||||
isXRSIVale
|
||||
isXRSICrossedOverLongExit
|
||||
isXRSICrossedOverLongEntry
|
||||
isXRSICrossedUnderShortExit
|
||||
isXRSICrossedUnderShortEntry
|
||||
|
||||
isXOBDSwingLow
|
||||
isXOBDSwingHigh
|
||||
|
||||
isXCHLHSameHHs
|
||||
isXCHLHSameLLs
|
||||
isXCHLHSCMCHHSame
|
||||
isXCHLHSCMCLLSame
|
||||
isXCHLHSCLCHHSame
|
||||
isXCHLHSCLCLLSame
|
||||
isXCHLHMCLCHHSame
|
||||
isXCHLHMCLCLLSame
|
||||
isXCHLHMCOnTopOfLC
|
||||
isXCHLHMCInBottomOfLC
|
||||
|
||||
isXCHMASCOverMax
|
||||
isXCHMASCOverMin
|
||||
isXCHMASCUnderMax
|
||||
isXCHMASCUnderMin
|
||||
isXCHMASCCrossedOverMax
|
||||
isXCHMASCCrossedUnderMax
|
||||
isXCHMASCCrossedOverMin
|
||||
isXCHMASCCrossedUnderMin
|
||||
isXCHMASCPeak
|
||||
isXCHMASCVale
|
||||
isXCHMASCTrendsUp
|
||||
isXCHMASCTrendsDown
|
||||
isXCHMASCFastOverSlow
|
||||
isXCHMASCFastUnderSlow
|
||||
isXCHMASCFastCrossedOverSlow
|
||||
isXCHMASCFastCrossedUnderSlow
|
||||
isXCHMAMCPeak
|
||||
isXCHMAMCVale
|
||||
isXCHMAMCTrendsUp
|
||||
isXCHMAMCTrendsDown
|
||||
isXCHMAMCFastOverSlow
|
||||
isXCHMAMCFastUnderSlow
|
||||
isXCHMAMCFastCrossedOverSlow
|
||||
isXCHMAMCFastCrossedUnderSlow
|
||||
isXCHMALCPeak
|
||||
isXCHMALCVale
|
||||
isXCHMALCTrendsUp
|
||||
isXCHMALCTrendsDown
|
||||
isXCHMALCFastOverSlow
|
||||
isXCHMALCFastUnderSlow
|
||||
isXCHMALCFastCrossedOverSlow
|
||||
isXCHMALCFastCrossedUnderSlow
|
||||
@@ -140,7 +140,7 @@ void OnTick()
|
||||
//
|
||||
signal.Clean();
|
||||
conditions.Clear();
|
||||
x5Provider.HasSignal(0, signal, conditions);
|
||||
x5Provider.HasSignal(1, signal, conditions);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -2195,6 +2195,125 @@ struct XMarketCycle
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Specific Range of Bars ...
|
||||
// using Start Bar Index ...
|
||||
int GetBars(
|
||||
XOHCL &result[], // Hold Result
|
||||
int from = 0, // Start Bar Index
|
||||
int count = 1, // Number of Bars
|
||||
bool forceClean = true // Clean Result Array
|
||||
)
|
||||
{
|
||||
//
|
||||
int mResult = 0;
|
||||
|
||||
//
|
||||
if (from < 0)
|
||||
{
|
||||
from = 0;
|
||||
}
|
||||
|
||||
//
|
||||
int total = Bars(
|
||||
symbol,
|
||||
period);
|
||||
if (from > total - 2)
|
||||
{
|
||||
from = total - 2;
|
||||
}
|
||||
|
||||
//
|
||||
if (count < 0)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
|
||||
//
|
||||
int start = from;
|
||||
int end = start + count;
|
||||
if (end > total - 1)
|
||||
{
|
||||
end = total - 1;
|
||||
}
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(result);
|
||||
}
|
||||
|
||||
//
|
||||
int beforeSize = ArraySize(result);
|
||||
|
||||
//
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
bool isValid = iBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
i
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iBar,
|
||||
result
|
||||
//
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int afterSize = ArraySize(result);
|
||||
|
||||
//
|
||||
mResult = afterSize - beforeSize;
|
||||
|
||||
//
|
||||
return mResult;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Specific Range of Bars ...
|
||||
// using Start Bar Time ...
|
||||
int GetBars(
|
||||
XOHCL &result[], // Hold Result
|
||||
datetime from = NULL, // Start Bar Time
|
||||
int count = 1, // Number of Bars
|
||||
bool forceClean = true // Clean Result Array
|
||||
)
|
||||
{
|
||||
//
|
||||
from = NormalizeTime(from);
|
||||
|
||||
//
|
||||
int barIndex = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
from,
|
||||
false
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
return GetBars(
|
||||
result,
|
||||
symbol,
|
||||
period,
|
||||
barIndex,
|
||||
count,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Bar Time ...
|
||||
datetime GetBarTime(int barIndex)
|
||||
@@ -3296,6 +3415,49 @@ MqlDateTime GetBarTimeStruct(
|
||||
//
|
||||
// Other Tools ...
|
||||
|
||||
//
|
||||
template <typename T>
|
||||
bool IsSame(
|
||||
T &buffer[], // Search Buffer
|
||||
int count = 5 // Number of Searchs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int bufferSize = ArraySize(buffer);
|
||||
result = bufferSize > 0;
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Count ...
|
||||
result = count < bufferSize;
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
T iTem = buffer[0];
|
||||
for (int i = 0; i < count; i++) {
|
||||
//
|
||||
if (iTem != buffer[i]) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
if (!result) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check first Cross Over second at index ...
|
||||
bool IsCrossedOver(
|
||||
@@ -3400,6 +3562,200 @@ bool IsUnder(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if a Value Increasing in Loopback ...
|
||||
bool IsIncreasing(
|
||||
const int from, // Last Time Index
|
||||
const int to, // Fisr Tima Index
|
||||
const double &buffer[] // the Buffer which required to search
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
from <= to ||
|
||||
ArraySize(buffer) < from + 1)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop through Items ...
|
||||
double toValue = buffer[to];
|
||||
double fromValue = buffer[from];
|
||||
result = toValue > fromValue;
|
||||
for (int i = to + 1; i <= from - 1; i++)
|
||||
{
|
||||
//
|
||||
double iValue = buffer[i];
|
||||
bool isPassed = toValue >= iValue;
|
||||
|
||||
//
|
||||
bool isIIncreasing = IsIncreasing(
|
||||
from,
|
||||
i,
|
||||
buffer);
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result = result && isPassed && isIIncreasing;
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if a Value Decreasing in Loopback ...
|
||||
bool IsDecreasing(
|
||||
const int from, // Last Time Index
|
||||
const int to, // Fisr Tima Index
|
||||
const double &buffer[] // the Buffer which required to search
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
from <= to ||
|
||||
ArraySize(buffer) < from + 1)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop through Items ...
|
||||
double toValue = buffer[to];
|
||||
double fromValue = buffer[from];
|
||||
result = toValue < fromValue;
|
||||
for (int i = to + 1; i <= from - 1; i++)
|
||||
{
|
||||
//
|
||||
double iValue = buffer[i];
|
||||
bool isPassed = toValue <= iValue;
|
||||
|
||||
//
|
||||
bool isIDecreasing = IsDecreasing(
|
||||
from,
|
||||
i,
|
||||
buffer);
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result = result && isPassed && isIDecreasing;
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsTrendingUp(
|
||||
const double &buffer1[], // First Buffer
|
||||
const double &buffer2[] // Seccend Buffer
|
||||
) {
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int buffer1Count = ArraySize(buffer1);
|
||||
int buffer2Count = ArraySize(buffer2);
|
||||
if (buffer1Count <= 0 || buffer2Count <= 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = MathMin(buffer1Count, buffer2Count);
|
||||
if (count <= 1) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int upCounts = 0;
|
||||
int downCounts = 0;
|
||||
double value = MathAbs(buffer1[0] - buffer2[0]);
|
||||
for (int i = 1; i < count; i++) {
|
||||
//
|
||||
double iValue = MathAbs(buffer1[i] - buffer2[i]);
|
||||
|
||||
//
|
||||
if (value > iValue) {
|
||||
upCounts++;
|
||||
}
|
||||
|
||||
//
|
||||
if (value < iValue) {
|
||||
downCounts++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = upCounts > 1 && upCounts > downCounts;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsTrendingDown(
|
||||
const double &buffer1[], // First Buffer
|
||||
const double &buffer2[] // Seccend Buffer
|
||||
) {
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int buffer1Count = ArraySize(buffer1);
|
||||
int buffer2Count = ArraySize(buffer2);
|
||||
if (buffer1Count <= 0 || buffer2Count <= 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = MathMin(buffer1Count, buffer2Count);
|
||||
if (count <= 1) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int upCounts = 0;
|
||||
int downCounts = 0;
|
||||
double value = MathAbs(buffer1[0] - buffer2[0]);
|
||||
for (int i = 1; i < count; i++) {
|
||||
//
|
||||
double iValue = MathAbs(buffer1[i] - buffer2[i]);
|
||||
|
||||
//
|
||||
if (value > iValue) {
|
||||
upCounts++;
|
||||
}
|
||||
|
||||
//
|
||||
if (value < iValue) {
|
||||
downCounts++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = downCounts > 1 && downCounts > upCounts;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Slope of Specified Buffer at Specified Index ...
|
||||
double GetSlope(
|
||||
|
||||
Reference in New Issue
Block a user