last preparation of XCATB indicator, helper and tester EA ...

This commit is contained in:
2025-05-23 20:29:37 +03:30
parent 99f0e57d2e
commit 2f865670c5
10 changed files with 9267 additions and 4378 deletions
+98 -84
View File
@@ -29,58 +29,6 @@
//
// Definiions ...
//
enum ENUM_XCAEA_TIGGER_TYPE
{
XCA_TRIGGER_NONE, // None
XCA_TRIGGER_BULL, // TriggerBull
XCA_TRIGGER_BEAR, // TriggerBear
};
//
bool IsValid(ENUM_XCAEA_TIGGER_TYPE value)
{
return value != XCA_TRIGGER_NONE;
}
//
string ToString(ENUM_XCAEA_TIGGER_TYPE value)
{
return EnumToString(value);
}
//
ENUM_XCAEA_TIGGER_TYPE GetType(string type)
{
//
ENUM_XCAEA_TIGGER_TYPE result = XCA_TRIGGER_NONE;
//
bool isTriggerBull = type == ToString(XCA_TRIGGER_BULL);
bool isTriggerBear = type == ToString(XCA_TRIGGER_BEAR);
//
if (isTriggerBull)
{
result = XCA_TRIGGER_BULL;
}
else if (isTriggerBear)
{
result = XCA_TRIGGER_BEAR;
}
//
return result;
}
//
ENUM_X_DIRECTION GetDirection(ENUM_XCAEA_TIGGER_TYPE value)
{
return value == XCA_TRIGGER_BULL
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
}
//
struct XTriggerBlock
{
@@ -200,9 +148,70 @@ int CountX121TriggerBlocks()
}
//
void CleanX121TriggerBlocks()
void CleanX121TriggerBlocks(int maxAllowed = 0)
{
Clean(mX121TriggerBlocks) l
//
if (maxAllowed <= 0)
{
Clean(mX121TriggerBlocks);
}
else if (maxAllowed > 0)
{
//
CleanupArray(
mX121TriggerBlocks,
maxAllowed //
);
}
}
//
bool GetNewestX121TriggerBlock(
string forSymbol,
ENUM_TIMEFRAMES forPeriod,
XTriggerBlock &tb //
)
{
//
bool result = false;
//
tb.Clean();
//
result =
IsValid(forSymbol) &&
IsValid(forPeriod) &&
HasX121TriggerBlocks();
if (!result)
{
return result;
}
//
// Loop Through Trigger Blocks to Find Filtered Newest ...
int count = CountX121TriggerBlocks();
for (int i = 0; i < count; i++)
{
//
bool canSet = !tb.IsValid()
? true
: tb.ToIndex() < mX121TriggerBlocks[i].ToIndex();
if (canSet)
{
tb = mX121TriggerBlocks[i];
}
}
//
result = tb.IsValid();
if (!result)
{
tb.Clean();
}
//
return result;
}
//
@@ -365,7 +374,9 @@ bool DetectTriggerBlock(
// Clone Trigger Block ...
if (has)
{
//
tb.trigger = tb.ob;
tb.trigger.type = "XTRGB";
}
//
@@ -713,29 +724,29 @@ bool DetectTriggerBlock(
double rsiTrend = (_rsiOBLevel + _rsiOSLevel) / 2;
//
double iRSI = rsiBuffer[barIndex];
double iPRSI = rsiBuffer[barIndex + 1];
double iP2RSI = rsiBuffer[barIndex + 2];
double iRSI = _rsiBuffer[barIndex];
double iPRSI = _rsiBuffer[barIndex + 1];
double iP2RSI = _rsiBuffer[barIndex + 2];
//
bool isRSICrossedOverOS =
iRSI > rsiOSLevel &&
iPRSI <= rsiOSLevel;
iRSI > _rsiOSLevel &&
iPRSI <= _rsiOSLevel;
//
bool isRSICrossedUnderOB =
iRSI < rsiOBLevel &&
iPRSI >= rsiOBLevel;
iRSI < _rsiOBLevel &&
iPRSI >= _rsiOBLevel;
//
bool isPRSICrossedOverOS =
iPRSI > rsiOSLevel &&
iP2RSI <= rsiOSLevel;
iPRSI > _rsiOSLevel &&
iP2RSI <= _rsiOSLevel;
//
bool isPRSICrossedUnderOB =
iPRSI < rsiOBLevel &&
iP2RSI >= rsiOBLevel;
iPRSI < _rsiOBLevel &&
iP2RSI >= _rsiOBLevel;
//
has =
@@ -754,36 +765,36 @@ bool DetectTriggerBlock(
{
//
// ADX ...
double iADX = adxBuffer[barIndex];
double iPADX = adxBuffer[barIndex + 1];
double iP2ADX = adxBuffer[barIndex + 2];
double iADX = _adxBuffer[barIndex];
double iPADX = _adxBuffer[barIndex + 1];
double iP2ADX = _adxBuffer[barIndex + 2];
//
// ADX +DI ...
double iADXP = adxpBuffer[barIndex];
double iPADXP = adxpBuffer[barIndex + 1];
double iP2ADXP = adxpBuffer[barIndex + 2];
double iADXP = _adxpBuffer[barIndex];
double iPADXP = _adxpBuffer[barIndex + 1];
double iP2ADXP = _adxpBuffer[barIndex + 2];
//
// ADX -DI ...
double iADXN = adxnBuffer[barIndex];
double iPADXN = adxnBuffer[barIndex + 1];
double iP2ADXN = adxnBuffer[barIndex + 2];
double iADXN = _adxnBuffer[barIndex];
double iPADXN = _adxnBuffer[barIndex + 1];
double iP2ADXN = _adxnBuffer[barIndex + 2];
//
// Preparing Conditions ...
//
bool isADXBullish = iADX > adxThreshold;
bool isADXBearish = iADX < adxThreshold;
bool isADXBullish = iADX > _adxThreshold;
bool isADXBearish = iADX < _adxThreshold;
//
bool isPADXBullish = iPADX > adxThreshold;
bool isPADXBearish = iPADX < adxThreshold;
bool isPADXBullish = iPADX > _adxThreshold;
bool isPADXBearish = iPADX < _adxThreshold;
//
bool isP2ADXBullish = iP2ADX > adxThreshold;
bool isP2ADXBearish = iP2ADX < adxThreshold;
bool isP2ADXBullish = iP2ADX > _adxThreshold;
bool isP2ADXBearish = iP2ADX < _adxThreshold;
//
bool isADXSwitchedToBullish =
@@ -854,12 +865,12 @@ bool DetectTriggerBlock(
double trends[];
int toIDX = tb.ToIndex();
int fromIDX = tb.FromIndex();
double iTrend = trendBuffer[toIDX];
double iTrend = _trendBuffer[toIDX];
for (int i = toIDX; i <= fromIDX; i++)
{
//
Add(
trendBuffer[i],
_trendBuffer[i],
trends //
);
}
@@ -1077,7 +1088,7 @@ bool DetectTriggerBlock(
}
//
double iATR = atrBuffer[barIndex];
double iATR = _atrBuffer[barIndex];
double slAdditional = _slAtrMultiplier * iATR;
//
@@ -1089,10 +1100,13 @@ bool DetectTriggerBlock(
);
//
Add(
// Add Trigger Block to Collection
// and Cleanup Unuseds ...
AddRef(
tb,
mX121TriggerBlocks //
);
CleanX121TriggerBlocks(20);
}
//