last ...
This commit is contained in:
@@ -1047,6 +1047,256 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool DetectNearestVolumeSwitched(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int barIndex = 0,
|
||||
int maxAllowedBars = 20 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
maxAllowedBars = NormalizeInt(maxAllowedBars, 20);
|
||||
|
||||
//
|
||||
// Looping Through LoopBack Period ...
|
||||
// for Detecting Result ...
|
||||
for (int i = barIndex; i < barIndex + maxAllowedBars; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
double iBullVMa = mX121Helper.xvolumeHelper.GetBullishVolumeMa(i);
|
||||
double iBullVMaP = mX121Helper.xvolumeHelper.GetBullishVolumeMa(i + 1);
|
||||
|
||||
//
|
||||
double iBearVMa = mX121Helper.xvolumeHelper.GetBearishVolumeMa(i);
|
||||
double iBearVMaP = mX121Helper.xvolumeHelper.GetBearishVolumeMa(i + 1);
|
||||
|
||||
//
|
||||
bool isBullVMaOverBearVMa = iBullVMa > iBearVMa;
|
||||
bool isBullVMaOverBearVMaP = iBullVMaP > iBearVMaP;
|
||||
bool isCrossOver = isBullVMaOverBearVMa &&
|
||||
!isBullVMaOverBearVMaP;
|
||||
|
||||
//
|
||||
bool isBullVMaUnderBearVMa = iBullVMa < iBearVMa;
|
||||
bool isBullVMaUnderBearVMaP = iBullVMaP < iBearVMaP;
|
||||
bool isCrossUnder = isBullVMaUnderBearVMa &&
|
||||
!isBullVMaUnderBearVMaP;
|
||||
|
||||
//
|
||||
result = isCrossOver ||
|
||||
isCrossUnder;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
bar = iBar;
|
||||
|
||||
//
|
||||
dir = isCrossOver
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool DetectNearestDeltaSwitched(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int barIndex = 0,
|
||||
int maxAllowedBars = 20 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
maxAllowedBars = NormalizeInt(maxAllowedBars, 20);
|
||||
|
||||
//
|
||||
// Looping Through LoopBack Period ...
|
||||
// for Detecting Result ...
|
||||
for (int i = barIndex; i < barIndex + maxAllowedBars; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
double iDelta = mX121Helper.xdeltaHelper.GetDelta(i);
|
||||
double iDeltaP = mX121Helper.xdeltaHelper.GetDelta(i + 1);
|
||||
|
||||
//
|
||||
double iDeltaMa = mX121Helper.xdeltaHelper.GetDeltaMa(i);
|
||||
double iDeltaMaP = mX121Helper.xdeltaHelper.GetDeltaMa(i + 1);
|
||||
|
||||
//
|
||||
bool isDeltaOverMa = iDelta > iDeltaMa;
|
||||
bool isDeltaOverMaP = iDeltaP > iDeltaMaP;
|
||||
|
||||
//
|
||||
bool isDeltaUnderMa = iDelta < iDeltaMa;
|
||||
bool isDeltaUnderMaP = iDeltaP < iDeltaMaP;
|
||||
|
||||
//
|
||||
bool isCrossOver = isDeltaOverMa &&
|
||||
!isDeltaOverMaP;
|
||||
|
||||
//
|
||||
bool isCrossUnder = isDeltaUnderMa &&
|
||||
!isDeltaUnderMaP;
|
||||
|
||||
//
|
||||
result = isCrossOver ||
|
||||
isCrossUnder;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
bar = iBar;
|
||||
|
||||
//
|
||||
dir = isCrossOver
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool DetectNearestStrSwitched(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int barIndex = 0,
|
||||
int maxAllowedBars = 20 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
maxAllowedBars = NormalizeInt(maxAllowedBars, 20);
|
||||
|
||||
//
|
||||
// Looping Through LoopBack Period ...
|
||||
// for Detecting Result ...
|
||||
for (int i = barIndex; i < barIndex + maxAllowedBars; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
double iStrState = mX121Helper.xstrHelper.GetSTRState(i);
|
||||
double iStrStateP = mX121Helper.xstrHelper.GetSTRState(i + 1);
|
||||
|
||||
//
|
||||
bool isStrBullish = iStrState > 0;
|
||||
bool isStrBullishP = iStrStateP > 0;
|
||||
|
||||
//
|
||||
bool isStrBearish = iStrState < 0;
|
||||
bool isStrBearishP = iStrStateP < 0;
|
||||
|
||||
//
|
||||
bool isBullish = isStrBullish &&
|
||||
!isStrBullishP;
|
||||
|
||||
//
|
||||
bool isBearish = isStrBearish &&
|
||||
!isStrBearishP;
|
||||
|
||||
//
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
bar = iBar;
|
||||
|
||||
//
|
||||
dir = isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
@@ -2411,7 +2661,7 @@ struct X121SMCStrategyConditionParser
|
||||
|
||||
//
|
||||
// Rejected Boxes ...
|
||||
bool HasRejectedBoxConditions(
|
||||
bool HasRejectedBocXConditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XSignalBox &box,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
@@ -2702,7 +2952,7 @@ struct X121SMCStrategyConditionParser
|
||||
|
||||
//
|
||||
// Activated Boxes ...
|
||||
bool HasActivatedBoxConditions(
|
||||
bool HasActivatedBocXConditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XSignalBox &box,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
@@ -3017,7 +3267,7 @@ struct X121SMCStrategyConditionParser
|
||||
|
||||
//
|
||||
// Breaked Boxes ...
|
||||
bool HasBreakedBoxConditions(
|
||||
bool HasBreakedBocXConditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XSignalBox &box,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
@@ -4069,5 +4319,310 @@ struct X121SMCStrategyConditionParser
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool HasXICHConditions(
|
||||
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;
|
||||
}
|
||||
Parse(cXConditions);
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
// XDELTA ...
|
||||
|
||||
//
|
||||
bool isDeltaSwitchedToBullish =
|
||||
(cXConditions.isDeltaCrossedOverMa &&
|
||||
cXConditions.isDeltaSwitchedToBullish);
|
||||
bool isDeltaBullish =
|
||||
(cXConditions.isDeltaOverMa &&
|
||||
cXConditions.isDeltaBullish);
|
||||
bool isDeltaIsBullish =
|
||||
isDeltaBullish ||
|
||||
isDeltaSwitchedToBullish;
|
||||
|
||||
//
|
||||
bool isDeltaSwitchedToBearish =
|
||||
(cXConditions.isDeltaCrossedUnderMa &&
|
||||
cXConditions.isDeltaSwitchedToBearish);
|
||||
bool isDeltaBearish =
|
||||
(cXConditions.isDeltaUnderMa &&
|
||||
cXConditions.isDeltaBearish);
|
||||
bool isDeltaIsBearish =
|
||||
isDeltaBearish ||
|
||||
isDeltaSwitchedToBearish;
|
||||
|
||||
//
|
||||
// XVOLUME ...
|
||||
|
||||
//
|
||||
bool isVolumeSwitchedToBullish =
|
||||
(cXConditions.isVolumeSwitchedToBullish &&
|
||||
cXConditions.isBullishVolumeSwitchedToIncreased);
|
||||
bool isVolumeBullish =
|
||||
(cXConditions.isBullishVolumeIncreased &&
|
||||
cXConditions.isBullishVolumeMaOverBearishVolumeMa);
|
||||
bool isVolumeIsBullish =
|
||||
isVolumeBullish ||
|
||||
isVolumeSwitchedToBullish;
|
||||
|
||||
//
|
||||
bool isVolumeSwitchedToBearish =
|
||||
(cXConditions.isVolumeSwitchedToBearish &&
|
||||
cXConditions.isBearishVolumeSwitchedToIncreased);
|
||||
bool isVolumeBearish =
|
||||
(cXConditions.isBullishVolumeMaUnderBearishVolumeMa &&
|
||||
cXConditions.isBearishVolumeIncreased);
|
||||
bool isVolumeIsBearish =
|
||||
isVolumeBearish ||
|
||||
isVolumeSwitchedToBearish;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
bool isStrIsBullish =
|
||||
(cXConditions.isStrBullish ||
|
||||
cXConditions.isStrSwitchedToBullish);
|
||||
bool isStrIsBearish =
|
||||
(cXConditions.isStrBearish ||
|
||||
cXConditions.isStrSwitchedToBearish);
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
bool isIchIsBullish =
|
||||
(cXConditions.isTenkanSenOverKijunSen ||
|
||||
cXConditions.isTenkanSenCrossedOverKijunSen);
|
||||
bool isIchIsBearish =
|
||||
(cXConditions.isTenkanSenUnderKijunSen ||
|
||||
cXConditions.isTenkanSenCrossedUnderKijunSen);
|
||||
|
||||
//
|
||||
// Checking TK Zone ...
|
||||
|
||||
//
|
||||
bool isBullishTKZone =
|
||||
isIchIsBullish &&
|
||||
cBar.low < cXConditions.tenkanSenBuffer[cIndex] &&
|
||||
cBar.low > cXConditions.kijunSenBuffer[cIndex] &&
|
||||
cBar.low < pBar.low &&
|
||||
zBar.open > cBar.low;
|
||||
|
||||
//
|
||||
bool isBearishTKZone =
|
||||
isIchIsBearish &&
|
||||
cBar.high > cXConditions.tenkanSenBuffer[cIndex] &&
|
||||
cBar.high < cXConditions.kijunSenBuffer[cIndex] &&
|
||||
cBar.high > pBar.high &&
|
||||
zBar.open < cBar.high;
|
||||
|
||||
//
|
||||
// Summarize Conditions ...
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
// false
|
||||
isStrIsBullish &&
|
||||
isIchIsBullish &&
|
||||
isBullishTKZone &&
|
||||
isDeltaIsBullish &&
|
||||
isVolumeIsBullish
|
||||
//
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
// false
|
||||
isStrIsBearish &&
|
||||
isIchIsBearish &&
|
||||
isBearishTKZone &&
|
||||
isDeltaIsBearish &&
|
||||
isVolumeIsBearish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
pivot = isBullish
|
||||
? cBar.low - (points * 5)
|
||||
: cBar.high + (points * 5);
|
||||
|
||||
//
|
||||
point = GetEntry(
|
||||
cBar.symbol,
|
||||
signalBoxDir //
|
||||
);
|
||||
|
||||
//
|
||||
box.upper =
|
||||
isBullish
|
||||
? point
|
||||
: pivot;
|
||||
|
||||
//
|
||||
box.lower =
|
||||
isBullish
|
||||
? pivot
|
||||
: point;
|
||||
|
||||
//
|
||||
bool drawBoxes = true;
|
||||
if (drawBoxes)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
Print("Signal ...");
|
||||
result = false;
|
||||
isBearish = false;
|
||||
isBullish = false;
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user