add supports for VIDYA in xca and also it's helper and in xcaea ...

This commit is contained in:
2025-04-23 08:16:08 +03:30
parent f48d272bba
commit f648037c07
3 changed files with 540 additions and 17 deletions
+309 -5
View File
@@ -55,9 +55,11 @@ enum ENUM_X121_XCA_BUFFERS
X121_XCA_SWING_LOW_LINE = 22,
X121_XCA_SWING_HIGH_LINE = 23,
X121_XCA_TKI_LINE = 24,
X121_XCA_TREND_STATE_LINE = 26,
X121_XCA_KI_STATE_LINE = 27,
X121_XCA_TKI_STATE_LINE = 28,
X121_XCA_VIDYA_LINE = 26,
X121_XCA_TREND_STATE_LINE = 28,
X121_XCA_KI_STATE_LINE = 29,
X121_XCA_TKI_STATE_LINE = 30,
X121_XCA_VIDYA_STATE_LINE = 31,
};
//
@@ -111,6 +113,12 @@ struct X121XCAInputs
// KI ...
int kiLength; // KI Length
//
// VIDYA ...
int vidyaCMOLength; // CMO (Candle Momentum) Length
int vidyaEMALength; // EMA Length
ENUM_APPLIED_PRICE vidyaAppliedTo; // Applied To
//
// Swing Detection ...
int swingLength; // Length
@@ -130,6 +138,7 @@ struct X121XCAInputs
bool showSar; // Show Sar
bool showKI; // Show KI
bool showTKI; // Show TKI
bool showVidya; // Show Vidya
bool showTrend; // Show Trend
bool showSwings; // Show Swings
bool showFiboLevel1; // Show Fibo Level 1
@@ -208,6 +217,12 @@ struct X121XCAInputs
// KI ...
kiLength = 0; // KI Length
//
// VIDYA ...
vidyaCMOLength = 0;
vidyaEMALength = 0;
vidyaAppliedTo = PRICE_CLOSE;
//
// Swing Detection ...
swingLength = 0; // Length
@@ -227,6 +242,7 @@ struct X121XCAInputs
showSar = true; // Show Sar
showKI = true; // Show KI
showTKI = true; // Show TKI
showVidya = true; // Show Vidya
showTrend = true; // Show Trend
showSwings = true; // Show Swings
showFiboLevel1 = true; // Show Fibo Level 1
@@ -298,6 +314,12 @@ struct X121XCAInputs
// KI ...
kiLength = 26; // KI Length
//
// VIDYA ...
vidyaCMOLength = 20;
vidyaEMALength = 14;
vidyaAppliedTo = PRICE_CLOSE;
//
// Swing Detection ...
swingLength = 5; // Length
@@ -312,6 +334,7 @@ struct X121XCAInputs
showSar = true; // Show Sar
showKI = true; // Show KI
showTKI = true; // Show TKI
showVidya = true; // Show Vidya
showTrend = true; // Show Trend
showSwings = true; // Show Swings
showFiboLevel1 = true; // Show Fibo Level 1
@@ -349,6 +372,8 @@ struct X121XCAInputs
kiLength > 0 &&
swingLength > 0 &&
sarMax > sarStep &&
vidyaCMOLength > 0 &&
vidyaEMALength > 0 &&
//
// XCA ...
(IsValid(scMethod, scPeriod) &&
@@ -371,6 +396,8 @@ struct X121XCAInputs
//
result = MathMax(kiLength, swingLength);
result = MathMax(result, vidyaCMOLength);
result = MathMax(result, vidyaEMALength);
//
return result;
@@ -402,12 +429,14 @@ struct X121XCAConditions
double sarBuffer[];
double peakBuffer[];
double valeBuffer[];
double vidyaBuffer[];
double trendBuffer[];
double kiStateBuffer[];
double supportBuffer[];
double tkiStateBuffer[];
double swingLowBuffer[];
double swingHighBuffer[];
double vidyaStateBuffer[];
double resistanceBuffer[];
double peakGoldenBuffer[];
double valeGoldenBuffer[];
@@ -449,6 +478,21 @@ struct X121XCAConditions
bool isTKISwitchedToBullish;
bool isTKISwitchedToBearish;
//
// VIDYA ...
//
bool isVidyaRejectUp;
bool isVidyaRejectDown;
//
bool isVidyaBullish;
bool isVidyaBearish;
//
bool isVidyaSwitchedToBullish;
bool isVidyaSwitchedToBearish;
//
// SAR ...
@@ -596,6 +640,7 @@ struct X121XCAConditions
Clean(sarBuffer);
Clean(peakBuffer);
Clean(valeBuffer);
Clean(vidyaBuffer);
Clean(trendBuffer);
Clean(kiStateBuffer);
Clean(supportBuffer);
@@ -608,6 +653,7 @@ struct X121XCAConditions
Clean(fiboLevel1Buffer);
Clean(fiboLevel2Buffer);
Clean(fiboLevel3Buffer);
Clean(vidyaStateBuffer);
Clean(trendStateBuffer);
//
@@ -624,6 +670,7 @@ struct X121XCAConditions
ArraySetAsSeries(sarBuffer, true);
ArraySetAsSeries(peakBuffer, true);
ArraySetAsSeries(valeBuffer, true);
ArraySetAsSeries(vidyaBuffer, true);
ArraySetAsSeries(trendBuffer, true);
ArraySetAsSeries(kiStateBuffer, true);
ArraySetAsSeries(supportBuffer, true);
@@ -636,6 +683,7 @@ struct X121XCAConditions
ArraySetAsSeries(fiboLevel1Buffer, true);
ArraySetAsSeries(fiboLevel2Buffer, true);
ArraySetAsSeries(fiboLevel3Buffer, true);
ArraySetAsSeries(vidyaStateBuffer, true);
ArraySetAsSeries(trendStateBuffer, true);
//
@@ -671,6 +719,21 @@ struct X121XCAConditions
isTKISwitchedToBullish = false;
isTKISwitchedToBearish = false;
//
// VIDYA ...
//
isVidyaRejectUp = false;
isVidyaRejectDown = false;
//
isVidyaBullish = false;
isVidyaBearish = false;
//
isVidyaSwitchedToBullish = false;
isVidyaSwitchedToBearish = false;
//
// SAR ...
@@ -866,6 +929,37 @@ struct X121XCAConditions
bearishScore += minScore;
}
//
// VIDYA ...
//
if (isVidyaBullish)
{
bullishScore += minScore;
}
if (isVidyaRejectUp)
{
bullishScore += minScore;
}
if (isVidyaSwitchedToBullish)
{
bullishScore += minScore;
}
//
if (isVidyaBearish)
{
bearishScore += minScore;
}
if (isVidyaRejectDown)
{
bearishScore += minScore;
}
if (isVidyaSwitchedToBearish)
{
bearishScore += minScore;
}
//
// SAR ...
@@ -1136,6 +1230,12 @@ struct X121XCAConditions
ToString("isTKIBearish", isTKIBearish, ignoreFalseConditions, separator) +
ToString("isTKISwitchedToBullish", isTKISwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isTKISwitchedToBearish", isTKISwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isVidyaRejectUp", isVidyaRejectUp, ignoreFalseConditions, separator) +
ToString("isVidyaRejectDown", isVidyaRejectDown, ignoreFalseConditions, separator) +
ToString("isVidyaBullish", isVidyaBullish, ignoreFalseConditions, separator) +
ToString("isVidyaBearish", isVidyaBearish, ignoreFalseConditions, separator) +
ToString("isVidyaSwitchedToBullish", isVidyaSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isVidyaSwitchedToBearish", isVidyaSwitchedToBearish, ignoreFalseConditions, separator) +
ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) +
ToString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) +
ToString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) +
@@ -1258,6 +1358,7 @@ class XCX121XCAHelper : public XCBaseHelper
Clean(sarBuffer);
Clean(peakBuffer);
Clean(valeBuffer);
Clean(vidyaBuffer);
Clean(trendBuffer);
Clean(kiStateBuffer);
Clean(supportBuffer);
@@ -1271,6 +1372,7 @@ class XCX121XCAHelper : public XCBaseHelper
Clean(fiboLevel2Buffer);
Clean(fiboLevel3Buffer);
Clean(trendStateBuffer);
Clean(vidyaStateBuffer);
}
//
@@ -1309,6 +1411,7 @@ class XCX121XCAHelper : public XCBaseHelper
ArraySetAsSeries(sarBuffer, true);
ArraySetAsSeries(peakBuffer, true);
ArraySetAsSeries(valeBuffer, true);
ArraySetAsSeries(vidyaBuffer, true);
ArraySetAsSeries(trendBuffer, true);
ArraySetAsSeries(kiStateBuffer, true);
ArraySetAsSeries(supportBuffer, true);
@@ -1321,6 +1424,7 @@ class XCX121XCAHelper : public XCBaseHelper
ArraySetAsSeries(fiboLevel1Buffer, true);
ArraySetAsSeries(fiboLevel2Buffer, true);
ArraySetAsSeries(fiboLevel3Buffer, true);
ArraySetAsSeries(vidyaStateBuffer, true);
ArraySetAsSeries(trendStateBuffer, true);
//
@@ -1356,6 +1460,10 @@ class XCX121XCAHelper : public XCBaseHelper
mInputs.sarMax,
"", // KI ...
mInputs.kiLength,
"", // VIDYA ...
mInputs.vidyaCMOLength,
mInputs.vidyaEMALength,
mInputs.vidyaAppliedTo,
"", // Swing Detection ...
mInputs.swingLength,
"", // Support and Resistance ...
@@ -1366,6 +1474,7 @@ class XCX121XCAHelper : public XCBaseHelper
mInputs.showSar,
mInputs.showKI,
mInputs.showTKI,
mInputs.showVidya,
mInputs.showTrend,
mInputs.showSwings,
mInputs.showFiboLevel1,
@@ -1630,6 +1739,110 @@ class XCX121XCAHelper : public XCBaseHelper
);
}
//
// VIDYA ...
//
double GetVidya(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(vidyaBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return vidyaBuffer[barIndex];
}
//
int CopyVidya(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
vidyaBuffer,
buffer,
forceClean
//
);
}
//
// VIDYA STATE ...
//
double GetVidyaState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(vidyaStateBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return vidyaStateBuffer[barIndex];
}
//
int CopyVidyaState(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
vidyaStateBuffer,
buffer,
forceClean
//
);
}
//
// SHORT ...
@@ -2889,6 +3102,20 @@ class XCX121XCAHelper : public XCBaseHelper
conditions.tkiStateBuffer //
);
//
CopyVidya(
zIndex,
loopback,
conditions.vidyaBuffer //
);
//
CopyVidyaState(
zIndex,
loopback,
conditions.vidyaStateBuffer //
);
//
CopySHH(
zIndex,
@@ -3135,9 +3362,50 @@ class XCX121XCAHelper : public XCBaseHelper
//
bool isTKISwitchedToBullish = isTKIBullish &&
!isTKIBullishPrev;
!isTKIBullishPrev;
bool isTKISwitchedToBearish = isTKIBearish &&
!isTKIBearishPrev;
!isTKIBearishPrev;
//
// VIDYA ...
//
double cVidya = conditions.vidyaBuffer[cIDX];
double pVidya = conditions.vidyaBuffer[pIDX];
double p2Vidya = conditions.vidyaBuffer[p2IDX];
//
double cVidyaState = conditions.vidyaStateBuffer[cIDX];
double pVidyaState = conditions.vidyaStateBuffer[pIDX];
double p2VidyaState = conditions.vidyaStateBuffer[p2IDX];
//
bool isVidyaRejectUp = cBar.IsRejected(
cVidya,
X_DIRECTION_BULLISH,
false,
false //
);
bool isVidyaRejectDown = cBar.IsRejected(
cVidya,
X_DIRECTION_BEARISH,
false,
false //
);
//
bool isVidyaBullish = cVidyaState > 0;
bool isVidyaBullishPrev = pVidyaState > 0;
//
bool isVidyaBearish = cVidyaState < 0;
bool isVidyaBearishPrev = pVidyaState < 0;
//
bool isVidyaSwitchedToBullish = isVidyaBullish &&
!isVidyaBullishPrev;
bool isVidyaSwitchedToBearish = isVidyaBearish &&
!isVidyaBearishPrev;
//
// SAR ...
@@ -3356,6 +3624,8 @@ class XCX121XCAHelper : public XCBaseHelper
conditions.isTKIRejectUp = isTKIRejectUp;
conditions.isPeakIsPivot = isPeakIsPivot;
conditions.isValeIsPivot = isValeIsPivot;
conditions.isVidyaBullish = isVidyaBullish;
conditions.isVidyaBearish = isVidyaBearish;
conditions.isKIRejectDown = isKIRejectDown;
conditions.isPeakSameLast = isPeakSameLast;
conditions.isPeakOverLast = isPeakOverLast;
@@ -3398,6 +3668,8 @@ class XCX121XCAHelper : public XCBaseHelper
conditions.isLastSwingHighRejected = isLastSwingHighRejected;
conditions.isLastResistanceBreaked = isLastResistanceBreaked;
conditions.isSupportSameAsSwingLow = isSupportSameAsSwingLow;
conditions.isVidyaSwitchedToBullish = isVidyaSwitchedToBullish;
conditions.isVidyaSwitchedToBearish = isVidyaSwitchedToBearish;
conditions.isLastResistanceRejected = isLastResistanceRejected;
conditions.isTrendSwitchedToBullish = isTrendSwitchedToBullish;
conditions.isTrendSwitchedToBearish = isTrendSwitchedToBearish;
@@ -3440,6 +3712,7 @@ class XCX121XCAHelper : public XCBaseHelper
double sarBuffer[];
double peakBuffer[];
double valeBuffer[];
double vidyaBuffer[];
double trendBuffer[];
double kiStateBuffer[];
double supportBuffer[];
@@ -3452,6 +3725,7 @@ class XCX121XCAHelper : public XCBaseHelper
double fiboLevel1Buffer[];
double fiboLevel2Buffer[];
double fiboLevel3Buffer[];
double vidyaStateBuffer[];
double trendStateBuffer[];
//
@@ -3485,6 +3759,15 @@ class XCX121XCAHelper : public XCBaseHelper
tkiBuffer //
);
//
CopyBuffer(
mHandler,
X121_XCA_VIDYA_LINE,
barIndex,
maxRequiredBars,
vidyaBuffer //
);
//
CopyBuffer(
mHandler,
@@ -3611,6 +3894,15 @@ class XCX121XCAHelper : public XCBaseHelper
tkiStateBuffer //
);
//
CopyBuffer(
mHandler,
X121_XCA_VIDYA_STATE_LINE,
barIndex,
maxRequiredBars,
vidyaStateBuffer //
);
//
CopyBuffer(
mHandler,
@@ -3719,6 +4011,12 @@ class XCX121XCAHelper : public XCBaseHelper
maxAllowed //
);
//
CleanupArray(
vidyaBuffer,
maxAllowed //
);
//
CleanupArray(
sHHBuffer,
@@ -3803,6 +4101,12 @@ class XCX121XCAHelper : public XCBaseHelper
maxAllowed //
);
//
CleanupArray(
vidyaStateBuffer,
maxAllowed //
);
//
CleanupArray(
supportBuffer,