This commit is contained in:
2025-03-31 13:11:12 +03:30
parent 4a82add5f9
commit 756868e56b
4 changed files with 716 additions and 9 deletions
@@ -0,0 +1,221 @@
//
// Detect Signals Based On XPV Indicator Golden Zones ...
//
bool HasTMPConditions(
ENUM_X_CYCLES cycle,
XBoxZone &box,
ENUM_X_DIRECTION &dir,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
//
bool result = false;
//
box.Clean();
dir = X_DIRECTION_NONE;
//
// Fil Selected Data ...
XPOIState cState;
X121Conditions cXConditions;
XPOIStateEvents cStateEvents;
XC121SMCCycleHelper *cHelper;
X121SMCCycleConditions cConditions;
result = provider.SelectCycle(
cycle,
cState,
cStateEvents,
cXConditions,
cHelper,
cConditions //
);
if (!result)
{
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
cStateEvents.Clean();
//
return result;
}
//
// Normalize Args ...
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int idx = -1;
int count = 0;
bool has = false;
//
int zIDX = barIndex;
int cIDX = zIDX + 1;
int pIDX = cIDX + 1;
int ppIDX = pIDX + 1;
//
bool isBullish = false;
bool isBearish = false;
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
XOHCL pPBar;
//
// Initial Bars ...
result = zBar.Init(
cState.symbol,
cState.period,
barIndex //
);
result =
result &&
zBar.GetPreviousBar(cBar);
result =
result &&
cBar.GetPreviousBar(pBar);
result =
result &&
pBar.GetPreviousBar(pPBar);
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
//
return result;
}
//
// Checking Conditions ...
//
// Summarize Conditions ...
//
isBullish =
//
false
//
;
//
isBearish =
//
false
//
;
//
// Filling Requirements ...
result =
isBullish ||
isBearish;
if (result)
{
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
box.dir = dir;
box.from = pPBar.time;
box.to = TimeCurrent();
box.symbol = cBar.symbol;
box.period = cBar.period;
//
double points = GetPoints(box.symbol);
//
// Usually is Preffered SL ...
double pivot = 0;
//
// Usually is Current Price or Entry Price ...
double point = GetEntry(
cBar.symbol,
dir //
);
//
box.upper =
isBullish
? point
: pivot;
//
box.lower =
isBullish
? pivot
: point;
//
XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer;
bool drawBoxes = true;
if (drawBoxes)
{
//
if (box.IsValid()) {
//
XCBoxObject *iObj;
bool isCreated = drawer.DrawBox(
box,
iObj //
);
//
if (isCreated) {
//
// TODO: ...
}
}
}
}
//
// Check All Conditions ...
result =
box.IsValid() &&
HasDirection(dir) &&
(isBullish ||
isBearish);
//
// Cleanup Resources ...
zBar.Clean();
cBar.Clean();
pBar.Clean();
pPBar.Clean();
cState.Clean();
cConditions.Clean();
cConditions.Clean();
ZeroMemory(cHelper);
cStateEvents.Clean();
cXConditions.Clean();
//
return result;
}
@@ -206,7 +206,7 @@ class XCX121SMCXINDSignalDetector : public XCBase
//
//
hasSignalBox = HasXSTRConditions(
hasSignalBox = HasXPVConditions(
X_CYCLE_DECISION,
signalBox,
signalBoxDir,
@@ -226,6 +226,491 @@ struct X121SMCStrategyXINDSignalConditions
//
// Signalling Conditions Parsers ...
//
// Detect Signals Based On XPV Indicator Golden Zones ...
//
bool HasXPVConditions(
ENUM_X_CYCLES cycle,
XBoxZone &box,
ENUM_X_DIRECTION &dir,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
//
bool result = false;
//
box.Clean();
dir = X_DIRECTION_NONE;
//
// Fil Selected Data ...
XPOIState cState;
X121Conditions cXConditions;
XPOIStateEvents cStateEvents;
XC121SMCCycleHelper *cHelper;
X121SMCCycleConditions cConditions;
result = provider.SelectCycle(
cycle,
cState,
cStateEvents,
cXConditions,
cHelper,
cConditions //
);
if (!result)
{
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
cStateEvents.Clean();
//
return result;
}
//
// Normalize Args ...
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int idx = -1;
int count = 0;
bool has = false;
//
int zIDX = barIndex;
int cIDX = zIDX + 1;
int pIDX = cIDX + 1;
int ppIDX = pIDX + 1;
//
bool isBullish = false;
bool isBearish = false;
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
XOHCL pPBar;
//
// Initial Bars ...
result = zBar.Init(
cState.symbol,
cState.period,
barIndex //
);
result =
result &&
zBar.GetPreviousBar(cBar);
result =
result &&
cBar.GetPreviousBar(pBar);
result =
result &&
pBar.GetPreviousBar(pPBar);
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
//
return result;
}
//
// Checking Conditions ...
//
// Retrieve Some Values ...
//
double peak = cXConditions.peaksBuffer[cIDX];
double peakZ = cXConditions.peaksBuffer[zIDX];
double peakP = cXConditions.peaksBuffer[pIDX];
double peakPP = cXConditions.peaksBuffer[ppIDX];
//
double vale = cXConditions.valesBuffer[cIDX];
double valeZ = cXConditions.valesBuffer[zIDX];
double valeP = cXConditions.valesBuffer[pIDX];
double valePP = cXConditions.valesBuffer[ppIDX];
//
double atrUpperSM = cXConditions.atrUpperSMBuffer[cIDX];
double atrLowerSM = cXConditions.atrLowerSMBuffer[cIDX];
//
double atrUpperSMZ = cXConditions.atrUpperSMBuffer[zIDX];
double atrLowerSMZ = cXConditions.atrLowerSMBuffer[zIDX];
//
double atrUpperSMP = cXConditions.atrUpperSMBuffer[pIDX];
double atrLowerSMP = cXConditions.atrLowerSMBuffer[pIDX];
//
double atrUpperSMPP = cXConditions.atrUpperSMBuffer[ppIDX];
double atrLowerSMPP = cXConditions.atrLowerSMBuffer[ppIDX];
//
double rsiChange = cXConditions.rsiChangeBuffer[cIDX];
double rsiChangeZ = cXConditions.rsiChangeBuffer[zIDX];
double rsiChangeP = cXConditions.rsiChangeBuffer[pIDX];
double rsiChangePP = cXConditions.rsiChangeBuffer[ppIDX];
//
double rsiChangeSM = cXConditions.rsiChangeSMBuffer[cIDX];
double rsiChangeSMZ = cXConditions.rsiChangeSMBuffer[zIDX];
double rsiChangeSMP = cXConditions.rsiChangeSMBuffer[pIDX];
double rsiChangeSMPP = cXConditions.rsiChangeSMBuffer[ppIDX];
//
double peaksGolden = cXConditions.peaksGoldenBuffer[cIDX];
double peaksGoldenZ = cXConditions.peaksGoldenBuffer[zIDX];
double peaksGoldenP = cXConditions.peaksGoldenBuffer[pIDX];
double peaksGoldenPP = cXConditions.peaksGoldenBuffer[ppIDX];
//
double valesGolden = cXConditions.valesGoldenBuffer[cIDX];
double valesGoldenZ = cXConditions.valesGoldenBuffer[zIDX];
double valesGoldenP = cXConditions.valesGoldenBuffer[pIDX];
double valesGoldenPP = cXConditions.valesGoldenBuffer[ppIDX];
//
double priceChange = cXConditions.priceChangeBuffer[cIDX];
double priceChangeZ = cXConditions.priceChangeBuffer[zIDX];
double priceChangeP = cXConditions.priceChangeBuffer[pIDX];
double priceChangePP = cXConditions.priceChangeBuffer[ppIDX];
//
double priceChangeSM = cXConditions.priceChangeSMBuffer[cIDX];
double priceChangeSMZ = cXConditions.priceChangeSMBuffer[zIDX];
double priceChangeSMP = cXConditions.priceChangeSMBuffer[pIDX];
double priceChangeSMPP = cXConditions.priceChangeSMBuffer[ppIDX];
//
//
//
//
bool isSwingLow =
//
(pBar.low < pPBar.low &&
pBar.low < cBar.low &&
zBar.open > cBar.low)
//
;
//
bool isSwingHigh =
//
pBar.high > pPBar.high &&
pBar.high > cBar.high &&
zBar.open < cBar.high
//
;
//
bool isBarsOverPeaksGoldenZone =
//
cBar.high > peaksGolden &&
pBar.high > peaksGoldenP
//
;
//
bool isBarsUnderValesGoldenZone =
//
cBar.low < valesGolden &&
pBar.low < valesGoldenP
//
;
//
bool isBarsOverAtrUpper =
//
cBar.high > atrUpperSM &&
pBar.high > atrUpperSMP
//
;
//
bool isBarsUnderAtrLower =
//
cBar.low < atrLowerSM &&
pBar.low < atrLowerSMP
//
;
//
bool isRsiChangeOverAtrUpper =
rsiChangeP > atrUpperSMP;
//
bool isRsiChangeUnderAtrLower =
rsiChangeP < atrLowerSMP;
//
bool isPriceChangeOverAtrUpper =
priceChangeP > atrUpperSMP;
//
bool isPriceChangeUnderAtrLower =
priceChangeP < atrLowerSMP;
//
// XPV Peaks or Vales ...
//
bool isCBarEqualsToPeak = cBar.high == peak;
bool isCBarEqualsToVale = cBar.low == vale;
//
bool isPBarEqualsToPeak = pBar.high == peakP;
bool isPBarEqualsToVale = pBar.low == valeP;
//
// Detect VPatterns ...
//
bool isRsiChangeBullishVPattern =
//
rsiChangeP < rsiChangePP &&
rsiChangeP < rsiChange &&
rsiChangeP < rsiChangeZ
//
;
//
bool isRsiChangeBearishVPattern =
//
rsiChangeP > rsiChangePP &&
rsiChangeP > rsiChange &&
rsiChangeP > rsiChangeZ
//
;
//
bool isPriceChangeBullishVPattern =
//
priceChangeP < priceChangePP &&
priceChangeP < priceChange &&
priceChangeP < priceChangeZ
//
;
//
bool isPriceChangeBearishVPattern =
//
priceChangeP > priceChangePP &&
priceChangeP > priceChange &&
priceChangeP > priceChangeZ
//
;
//
// Checking Bar States ...
//
bool isCBarHasBullishFibPressure =
//
cBar.HasFiboPressure(
X_DIRECTION_BULLISH,
X_FIBO_LEVEL_382 //
)
//
;
//
bool isPBarHasBullishFibPressure =
//
pBar.HasFiboPressure(
X_DIRECTION_BULLISH,
X_FIBO_LEVEL_382 //
)
//
;
//
bool isCBarHasBearishFibPressure =
//
cBar.HasFiboPressure(
X_DIRECTION_BEARISH,
X_FIBO_LEVEL_382 //
)
//
;
//
bool isPBarHasBearishFibPressure =
//
pBar.HasFiboPressure(
X_DIRECTION_BEARISH,
X_FIBO_LEVEL_382 //
)
//
;
//
bool isBarValidForBullish =
//
isCBarHasBullishFibPressure
//
;
//
bool isBarValidForBearish =
//
isCBarHasBearishFibPressure
//
;
//
// Summarize Conditions ...
//
isBullish =
//
// isSwingLow &&
// isBarsUnderAtrLower &&
// isBarValidForBullish &&
// isBarsUnderValesGoldenZone
//
// isCBarEqualsToVale &&
(isRsiChangeUnderAtrLower &&
isRsiChangeBullishVPattern) &&
(isPriceChangeUnderAtrLower &&
isPriceChangeBullishVPattern)
//
;
//
isBearish =
//
// isSwingHigh &&
// isBarsOverAtrUpper &&
// isBarValidForBearish &&
// isBarsOverPeaksGoldenZone
//
// isCBarEqualsToPeak &&
(isRsiChangeOverAtrUpper &&
isRsiChangeBearishVPattern) &&
(isPriceChangeOverAtrUpper &&
isPriceChangeBearishVPattern)
//
;
//
// Filling Requirements ...
result =
isBullish ||
isBearish;
if (result)
{
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
box.dir = dir;
box.from = pPBar.time;
box.to = TimeCurrent();
box.symbol = cBar.symbol;
box.period = cBar.period;
//
double points = GetPoints(box.symbol);
//
// Usually is Preffered SL ...
double pivot = 0;
//
// Usually is Current Price or Entry Price ...
double point = GetEntry(
cBar.symbol,
dir //
);
//
box.upper =
isBullish
? point
: pivot;
//
box.lower =
isBullish
? pivot
: point;
//
XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer;
bool drawBoxes = true;
if (drawBoxes)
{
//
if (box.IsValid())
{
//
XCBoxObject *iObj;
bool isCreated = drawer.DrawBox(
box,
iObj //
);
//
if (isCreated)
{
//
// TODO: ...
}
}
}
}
//
// Check All Conditions ...
result =
box.IsValid() &&
HasDirection(dir) &&
(isBullish ||
isBearish);
//
// Cleanup Resources ...
zBar.Clean();
cBar.Clean();
pBar.Clean();
pPBar.Clean();
cState.Clean();
cConditions.Clean();
cConditions.Clean();
ZeroMemory(cHelper);
cStateEvents.Clean();
cXConditions.Clean();
//
return result;
}
//
bool HasXSTRConditions(
ENUM_X_CYCLES cycle,
@@ -962,7 +962,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
bool showAll = false;
//
x121Inputs.showRSI = showAll || true;
x121Inputs.showRSI = showAll || false;
//
//
@@ -976,6 +976,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Presentations ...
x121Inputs.xccInputs.showCandles = showAll || false;
//
// XPV ...
@@ -1011,7 +1012,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Presentations ...
x121Inputs.xhkInputs.drawRawXHKCandles = showAll || true;
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true;
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false;
//
// XMAS ...
@@ -1021,9 +1022,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Presentations ...
x121Inputs.xmasInputs.showMid = showAll || true;
x121Inputs.xmasInputs.showUpper = showAll || true;
x121Inputs.xmasInputs.showLower = showAll || true;
x121Inputs.xmasInputs.showMid = showAll || false;
x121Inputs.xmasInputs.showUpper = showAll || false;
x121Inputs.xmasInputs.showLower = showAll || false;
//
// XATR ...
@@ -1035,8 +1036,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Presentations ...
x121Inputs.xatrInputs.showAtrUpper = showAll || false;
x121Inputs.xatrInputs.showAtrLower = showAll || false;
x121Inputs.xatrInputs.showRSIChange = showAll || false;
x121Inputs.xatrInputs.showPriceChange = showAll || false;
x121Inputs.xatrInputs.showRSIChange = showAll || true;
x121Inputs.xatrInputs.showPriceChange = showAll || true;
x121Inputs.xatrInputs.showSmoothedAtrUpper = showAll || true;
x121Inputs.xatrInputs.showSmoothedAtrLower = showAll || true;
x121Inputs.xatrInputs.showSmoothedRSIChange = showAll || true;
@@ -1050,7 +1051,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Presentations ...
x121Inputs.xstrInputs.showStr = showAll || true;
x121Inputs.xstrInputs.showStr = showAll || false;
x121Inputs.xstrInputs.showStrUpper = showAll || false;
x121Inputs.xstrInputs.showStrLower = showAll || false;