This commit is contained in:
2025-01-02 13:24:37 +03:30
parent 1c169cebe2
commit 410c6793ae
8 changed files with 795 additions and 266 deletions
+169 -16
View File
@@ -128,6 +128,12 @@ struct X121Inputs
double sarStep; // Step
double sarMax; // Maximum
//
// RSI ...
int rsiLength; // RSI Length
double rsiOverSoldLevel; // RSI Over Sold Level
double rsiOverBoughtLevel; // RSI Over Bought Level
//
// Atr Detection ...
int atrLength; // Length
@@ -250,6 +256,12 @@ struct X121Inputs
hhMode = MODE_HIGH;
llMode = MODE_LOW;
//
// RSI ...
rsiLength = 0;
rsiOverSoldLevel = 0;
rsiOverBoughtLevel = 0;
//
// Paraboli Sar Detection ...
sarStep = 0;
@@ -368,6 +380,12 @@ struct X121Inputs
hhMode = MODE_HIGH;
llMode = MODE_LOW;
//
// RSI ...
rsiLength = 14;
rsiOverSoldLevel = 30;
rsiOverBoughtLevel = 70;
//
// Paraboli Sar Detection ...
sarStep = 0.02;
@@ -466,6 +484,11 @@ struct X121Inputs
//
result =
//
// RSI ...
rsiLength > 0 &&
rsiOverSoldLevel > 0 &&
rsiOverBoughtLevel > 0 &&
rsiOverSoldLevel < rsiOverBoughtLevel &&
// PSAR ...
sarMax > 0 &&
sarStep > 0 &&
@@ -514,6 +537,7 @@ struct X121Inputs
//
// ATR ...
result = MathMax(result, atrLength);
result = MathMax(result, rsiLength);
//
return result;
@@ -571,12 +595,24 @@ struct X121Conditions
double vwapFastStateBuffer[];
double vwapMidStateBuffer[];
double vwapSlowStateBuffer[];
double validPeaksBuffer[];
double validValesBuffer[];
double rsiBuffer[];
//
// Conditions ...
//
// XRSI ...
//
bool isRSIOverBought;
bool isRSICrossedOverOverBought;
bool isRSICrossedUnderOverBought;
//
bool isRSIOverSold;
bool isRSICrossedUnderOverSold;
bool isRSICrossedOverOverSold;
//
// XSAR ...
@@ -746,8 +782,7 @@ struct X121Conditions
Clean(vwapFastStateBuffer);
Clean(vwapMidStateBuffer);
Clean(vwapSlowStateBuffer);
Clean(validPeaksBuffer);
Clean(validValesBuffer);
Clean(rsiBuffer);
//
ArraySetAsSeries(peaksBuffer, true);
@@ -789,12 +824,24 @@ struct X121Conditions
ArraySetAsSeries(vwapFastStateBuffer, true);
ArraySetAsSeries(vwapMidStateBuffer, true);
ArraySetAsSeries(vwapSlowStateBuffer, true);
ArraySetAsSeries(validPeaksBuffer, true);
ArraySetAsSeries(validValesBuffer, true);
ArraySetAsSeries(rsiBuffer, true);
//
// Conditions ...
//
// XRSI ...
//
isRSIOverBought = false;
isRSICrossedUnderOverBought = false;
isRSICrossedOverOverBought = false;
//
isRSIOverSold = false;
isRSICrossedOverOverSold = false;
isRSICrossedUnderOverSold = false;
//
// XSAR ...
@@ -1089,6 +1136,7 @@ class XCX121Helper : public XCBaseHelper
// Deconstructor ...
~XCX121Helper()
{
IndicatorRelease(mRSIHandler);
}
//
@@ -1168,6 +1216,7 @@ class XCX121Helper : public XCBaseHelper
ArraySetAsSeries(vwapFastStateBuffer, true);
ArraySetAsSeries(vwapMidStateBuffer, true);
ArraySetAsSeries(vwapSlowStateBuffer, true);
ArraySetAsSeries(rsiBuffer, true);
//
mHandler = iCustom(
@@ -1290,6 +1339,19 @@ class XCX121Helper : public XCBaseHelper
return result;
}
//
mRSIHandler = iRSI(
symbol,
period,
mInputs.rsiLength,
PRICE_CLOSE //
);
result = mRSIHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
@@ -1324,18 +1386,60 @@ class XCX121Helper : public XCBaseHelper
);
}
/**
* Retrieve DON Chain Length ...
*
* @return ( int )
*/
int GetDonChainLength()
//
// Implement Value Getters ...
//
// XRSI ...
//
double GetRSI(
int barIndex // Bar Index
)
{
return mInputs.donchainLength;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(rsiBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return rsiBuffer[barIndex];
}
//
// Implement Value Getters ...
int CopyRSI(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
rsiBuffer,
buffer,
forceClean
//
);
}
//
// SAR ...
@@ -3717,6 +3821,13 @@ class XCX121Helper : public XCBaseHelper
//
// Buffers ...
//
CopyRSI(
zIndex,
loopback,
conditions.rsiBuffer //
);
//
CopySar(
zIndex,
@@ -3997,6 +4108,29 @@ class XCX121Helper : public XCBaseHelper
int cIDX = 1;
int pIDX = cIDX + 1;
//
// XRSI ...
//
bool isRSIOverBought = conditions.rsiBuffer[cIDX] > mInputs.rsiOverBoughtLevel;
bool isRSIOverBoughtPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiOverBoughtLevel;
//
bool isRSICrossedOverOverBought = isRSIOverBought &&
!isRSIOverBoughtPrev;
bool isRSICrossedUnderOverBought = !isRSIOverBought &&
isRSIOverBoughtPrev;
//
bool isRSIOverSold = conditions.rsiBuffer[cIDX] < mInputs.rsiOverSoldLevel;
bool isRSIOverSoldPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiOverSoldLevel;
//
bool isRSICrossedUnderOverSold = isRSIOverSold &&
!isRSIOverSoldPrev;
bool isRSICrossedOverOverSold = !isRSIOverSold &&
isRSIOverSoldPrev;
//
// XSAR ...
@@ -4174,6 +4308,12 @@ class XCX121Helper : public XCBaseHelper
//
// Set ...
conditions.isRSIOverBought = isRSIOverBought;
conditions.isRSICrossedOverOverBought = isRSICrossedOverOverBought;
conditions.isRSICrossedUnderOverBought = isRSICrossedUnderOverBought;
conditions.isRSIOverSold = isRSIOverSold;
conditions.isRSICrossedUnderOverSold = isRSICrossedUnderOverSold;
conditions.isRSICrossedOverOverSold = isRSICrossedOverOverSold;
conditions.isSarBullish = isSarBullish;
conditions.isSarBearish = isSarBearish;
conditions.isSarSwitchedToBullish = isSarSwitchedToBullish;
@@ -4245,6 +4385,9 @@ class XCX121Helper : public XCBaseHelper
//
// Buffers ...
//
int mRSIHandler; // RSI Handler ...
//
// Buffers ...
double peaksBuffer[];
@@ -4286,8 +4429,7 @@ class XCX121Helper : public XCBaseHelper
double vwapFastStateBuffer[];
double vwapMidStateBuffer[];
double vwapSlowStateBuffer[];
double validPeaksBuffer[];
double validValesBuffer[];
double rsiBuffer[];
//
// Tools ...
@@ -4307,6 +4449,17 @@ class XCX121Helper : public XCBaseHelper
//
// Buffers ...
//
// RSI ...
CopyBuffer(
mRSIHandler,
0,
0,
totalBars,
rsiBuffer
//
);
//
// XSAR ...
CopyBuffer(