implement senario 1 ...
This commit is contained in:
@@ -450,51 +450,50 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
signalBoxDir //
|
||||
);
|
||||
|
||||
//
|
||||
// Selecting SL(s) ...
|
||||
|
||||
//
|
||||
double iSL = 0;
|
||||
|
||||
//
|
||||
// Default SL ...
|
||||
iSL = pivot;
|
||||
|
||||
//
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
|
||||
//
|
||||
// Select and Provide SL Based on ...
|
||||
if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_MA)
|
||||
{
|
||||
//
|
||||
// Default SL ...
|
||||
iSL = pivot;
|
||||
|
||||
//
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_BOX)
|
||||
{
|
||||
//
|
||||
// Default SL ...
|
||||
iSL = pivot;
|
||||
|
||||
//
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
iSL = MathMax(
|
||||
provider.decisionXConditions.se1Buffer[1],
|
||||
provider.decisionXConditions.se2Buffer[1] //
|
||||
);
|
||||
if (iSL > 0)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_AREA)
|
||||
{
|
||||
//
|
||||
// Default SL ...
|
||||
iSL = pivot;
|
||||
|
||||
//
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 1.5;
|
||||
iAtr *= 0;
|
||||
|
||||
//
|
||||
// Select Condition SL ...
|
||||
@@ -504,8 +503,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
double slsMax = GetMax(sls);
|
||||
|
||||
//
|
||||
double longSL = slsMin - iAtr;
|
||||
double shortSL = slsMax + iAtr;
|
||||
double longSL = slsMax - iAtr;
|
||||
double shortSL = slsMin + iAtr;
|
||||
|
||||
//
|
||||
sl = isBullish
|
||||
|
||||
@@ -2019,6 +2019,15 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int zIDX = barIndex;
|
||||
int cIDX = zIDX + 1;
|
||||
int pIDX = cIDX + 1;
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
@@ -2053,23 +2062,294 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
X121SMCStrategyConditionParser decisionParser;
|
||||
decisionParser.Parse(provider.decisionXConditions);
|
||||
|
||||
//
|
||||
bool has =
|
||||
//
|
||||
// false
|
||||
decisionParser.isX3MaCrossedInsideValesGoldenZone
|
||||
//
|
||||
;
|
||||
if (has)
|
||||
{
|
||||
Print("Condition ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Senario 1:
|
||||
// ----------
|
||||
|
||||
//
|
||||
// Senario 1 Bullish Conditions ...
|
||||
bool isSenario1Bullish =
|
||||
//
|
||||
// X3Ma / XVwap Switched To Bulish ...
|
||||
(
|
||||
//
|
||||
// X3Ma Switched To Bulish ...
|
||||
(
|
||||
//
|
||||
(provider.decisionXConditions.isX3MaFastCrossedOverMid &&
|
||||
decisionParser.isX3MaBullishStateUnderValesGoldenZone)
|
||||
//
|
||||
)
|
||||
//
|
||||
||
|
||||
//
|
||||
// XVWap Switched To Bulish ...
|
||||
(
|
||||
//
|
||||
(provider.decisionXConditions.isVWapFastCrossedOverMid &&
|
||||
decisionParser.isVWapBullishStateUnderValesGoldenZone)
|
||||
//
|
||||
)
|
||||
//
|
||||
)
|
||||
//
|
||||
&&
|
||||
//
|
||||
// Checking other Conditions ...
|
||||
(
|
||||
//
|
||||
// XSTR ...
|
||||
provider.decisionXConditions.isStrBullish &&
|
||||
//
|
||||
// XCHE ...
|
||||
provider.decisionXConditions.isCheBullish &&
|
||||
provider.decisionXConditions.le1Buffer[cIDX] < cBar.low &&
|
||||
provider.decisionXConditions.le2Buffer[cIDX] < cBar.low
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Senario 1 Bearish Conditions ...
|
||||
bool isSenario1Bearish =
|
||||
//
|
||||
// X3Ma / XVwap Switched To Bearish ...
|
||||
(
|
||||
//
|
||||
// X3Ma Switched To Bearish ...
|
||||
(
|
||||
//
|
||||
(provider.decisionXConditions.isX3MaFastCrossedUnderMid &&
|
||||
decisionParser.isX3MaBearishStateOverPeaksGoldenZone)
|
||||
//
|
||||
)
|
||||
//
|
||||
||
|
||||
//
|
||||
// XVWap Switched To Bearish ...
|
||||
(
|
||||
//
|
||||
(provider.decisionXConditions.isVWapFastCrossedUnderMid &&
|
||||
decisionParser.isVWapBearishStateOverPeaksGoldenZone)
|
||||
//
|
||||
)
|
||||
//
|
||||
)
|
||||
//
|
||||
&&
|
||||
//
|
||||
// Checking other Conditions ...
|
||||
(
|
||||
//
|
||||
// XSTR ...
|
||||
provider.decisionXConditions.isStrBearish &&
|
||||
//
|
||||
// XCHE ...
|
||||
provider.decisionXConditions.isCheBearish &&
|
||||
provider.decisionXConditions.se1Buffer[cIDX] > cBar.high &&
|
||||
provider.decisionXConditions.se2Buffer[cIDX] > cBar.high
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Filling Requirements using Senario 1 ...
|
||||
bool isSenari1Happend =
|
||||
isSenario1Bullish ||
|
||||
isSenario1Bearish;
|
||||
if (isSenari1Happend)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isSenario1Bullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
box.dir = dir;
|
||||
box.to = TimeCurrent();
|
||||
box.symbol = provider
|
||||
.decisionXConditions
|
||||
.symbol;
|
||||
box.period = provider
|
||||
.decisionXConditions
|
||||
.period;
|
||||
|
||||
//
|
||||
int fromIDX = -1;
|
||||
if (isSenario1Bullish)
|
||||
{
|
||||
//
|
||||
double vale = provider
|
||||
.decisionXConditions
|
||||
.valesBuffer[cIDX];
|
||||
|
||||
//
|
||||
box.lower = vale;
|
||||
|
||||
//
|
||||
box.upper = provider
|
||||
.decisionXConditions
|
||||
.valesGoldenBuffer[cIDX];
|
||||
|
||||
//
|
||||
int lowerValeIDX = -1;
|
||||
double lowerVale = provider
|
||||
.decisionCycleHelper
|
||||
.mX121Helper
|
||||
.xpvHelper
|
||||
.GetLowerVale(
|
||||
lowerValeIDX,
|
||||
vale,
|
||||
cBar.Index() //
|
||||
);
|
||||
|
||||
//
|
||||
int higherValeIDX = -1;
|
||||
double higherVale = provider
|
||||
.decisionCycleHelper
|
||||
.mX121Helper
|
||||
.xpvHelper
|
||||
.GetHigherVale(
|
||||
higherValeIDX,
|
||||
vale,
|
||||
cBar.Index() //
|
||||
);
|
||||
|
||||
//
|
||||
if (IsValidIndex(lowerValeIDX) &&
|
||||
IsValidIndex(higherValeIDX))
|
||||
{
|
||||
//
|
||||
fromIDX =
|
||||
lowerValeIDX < higherValeIDX
|
||||
? lowerValeIDX
|
||||
: higherValeIDX;
|
||||
}
|
||||
else if (IsValidIndex(lowerValeIDX) &&
|
||||
!IsValidIndex(higherValeIDX))
|
||||
{
|
||||
//
|
||||
fromIDX = lowerValeIDX;
|
||||
}
|
||||
else if (!IsValidIndex(lowerValeIDX) &&
|
||||
IsValidIndex(higherValeIDX))
|
||||
{
|
||||
//
|
||||
fromIDX = higherValeIDX;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
double peak = provider
|
||||
.decisionXConditions
|
||||
.peaksBuffer[cIDX];
|
||||
|
||||
//
|
||||
box.upper = peak;
|
||||
|
||||
//
|
||||
box.lower = provider
|
||||
.decisionXConditions
|
||||
.peaksGoldenBuffer[cIDX];
|
||||
|
||||
//
|
||||
int lowerPeakIDX = -1;
|
||||
double lowerPeak = provider
|
||||
.decisionCycleHelper
|
||||
.mX121Helper
|
||||
.xpvHelper
|
||||
.GetLowerPeak(
|
||||
lowerPeakIDX,
|
||||
peak,
|
||||
cBar.Index() //
|
||||
);
|
||||
|
||||
//
|
||||
int higherPeakIDX = -1;
|
||||
double higherPeak = provider
|
||||
.decisionCycleHelper
|
||||
.mX121Helper
|
||||
.xpvHelper
|
||||
.GetHigherPeak(
|
||||
higherPeakIDX,
|
||||
peak,
|
||||
cBar.Index() //
|
||||
);
|
||||
|
||||
//
|
||||
if (IsValidIndex(lowerPeakIDX) &&
|
||||
IsValidIndex(higherPeakIDX))
|
||||
{
|
||||
//
|
||||
fromIDX =
|
||||
lowerPeakIDX < higherPeakIDX
|
||||
? lowerPeakIDX
|
||||
: higherPeakIDX;
|
||||
}
|
||||
else if (IsValidIndex(lowerPeakIDX) &&
|
||||
!IsValidIndex(higherPeakIDX))
|
||||
{
|
||||
//
|
||||
fromIDX = lowerPeakIDX;
|
||||
}
|
||||
else if (!IsValidIndex(lowerPeakIDX) &&
|
||||
IsValidIndex(higherPeakIDX))
|
||||
{
|
||||
//
|
||||
fromIDX = higherPeakIDX;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidIndex(fromIDX))
|
||||
{
|
||||
//
|
||||
box.from = iTime(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
fromIDX //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
box.from = pBar.time;
|
||||
}
|
||||
|
||||
//
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||
}
|
||||
|
||||
//
|
||||
// Summarize All Senario(s) Conditions ...
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
isSenario1Bullish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
isSenario1Bearish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Check All Conditions ...
|
||||
result =
|
||||
box.IsValid() &&
|
||||
HasDirection(dir) &&
|
||||
(isBullish ||
|
||||
isBearish);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
|
||||
Reference in New Issue
Block a user