last works ...
This commit is contained in:
@@ -634,6 +634,13 @@ bool DetectX121SMCTestSiganlTrigger(
|
||||
{
|
||||
//
|
||||
// Cleanup Setup Conditions ...
|
||||
int setupAge = conditions.GetSetupAge();
|
||||
if (IsValidSize(setupAge) &&
|
||||
IsValidSize(maxAllowedSetupAge) &&
|
||||
setupAge >= maxAllowedSetupAge)
|
||||
{
|
||||
conditions.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
@@ -965,6 +965,13 @@ bool DetectX121SMCXPVDPSiganlTrigger(
|
||||
{
|
||||
//
|
||||
// Cleanup Setup Conditions ...
|
||||
int setupAge = conditions.GetSetupAge();
|
||||
if (IsValidSize(setupAge) &&
|
||||
IsValidSize(maxAllowedSetupAge) &&
|
||||
setupAge >= maxAllowedSetupAge)
|
||||
{
|
||||
conditions.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
@@ -854,6 +854,30 @@ bool DetectX121SMCXVWPBSiganlTrigger(
|
||||
//
|
||||
// Trigger Conditions ...
|
||||
|
||||
//
|
||||
double vwapFast = triggerConditions.x121Conditions.vwapFastBuffer[1];
|
||||
double vwapMid = triggerConditions.x121Conditions.vwapMidBuffer[1];
|
||||
double vwapSlow = triggerConditions.x121Conditions.vwapSlowBuffer[1];
|
||||
|
||||
//
|
||||
double vwaps[3] = {
|
||||
vwapFast,
|
||||
vwapMid,
|
||||
vwapSlow,
|
||||
};
|
||||
double vwapMax = GetMax(vwaps);
|
||||
double vwapMin = GetMin(vwaps);
|
||||
|
||||
//
|
||||
bool isNewPeak = triggerConditions.x121Conditions.isNewPeak;
|
||||
bool isNewPeakOverLast = triggerConditions.x121Conditions.isNewPeakOverLast;
|
||||
bool isNewPeakUnderLast = triggerConditions.x121Conditions.isNewPeakUnderLast;
|
||||
|
||||
//
|
||||
bool isNewVale = triggerConditions.x121Conditions.isNewVale;
|
||||
bool isNewValeOverLast = triggerConditions.x121Conditions.isNewValeOverLast;
|
||||
bool isNewValeUnderLast = triggerConditions.x121Conditions.isNewValeUnderLast;
|
||||
|
||||
//
|
||||
double triggerPeak = triggerConditions.x121Conditions.peaksBuffer[1];
|
||||
double decisionPeak = decisionConditions.x121Conditions.peaksBuffer[1];
|
||||
@@ -870,6 +894,14 @@ bool DetectX121SMCXVWPBSiganlTrigger(
|
||||
|
||||
//
|
||||
bool isPeaksSameFormed =
|
||||
//
|
||||
(
|
||||
//
|
||||
triggerPeak == decisionPeak
|
||||
//
|
||||
)
|
||||
//
|
||||
||
|
||||
//
|
||||
(
|
||||
//
|
||||
@@ -903,6 +935,14 @@ bool DetectX121SMCXVWPBSiganlTrigger(
|
||||
|
||||
//
|
||||
bool isValesSameFormed =
|
||||
//
|
||||
(
|
||||
//
|
||||
triggerVale == decisionVale
|
||||
//
|
||||
)
|
||||
//
|
||||
||
|
||||
//
|
||||
(
|
||||
//
|
||||
@@ -953,21 +993,69 @@ bool DetectX121SMCXVWPBSiganlTrigger(
|
||||
}
|
||||
|
||||
//
|
||||
conditions.Clean();
|
||||
// Check Last VWap State Change ...
|
||||
XValueChange vwapStateChnges[];
|
||||
int vwapStateChngesCount = triggerCycleHelper
|
||||
.FillVWapStateChanges(vwapStateChnges);
|
||||
XValueChange lastVWapStateChnged;
|
||||
bool hasLastVWapStateChanged = false;
|
||||
if (IsValidSize(vwapStateChngesCount) &&
|
||||
vwapStateChngesCount >= 2)
|
||||
{
|
||||
//
|
||||
lastVWapStateChnged = vwapStateChnges[vwapStateChngesCount - 2];
|
||||
hasLastVWapStateChanged = lastVWapStateChnged.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
double donOpenUpper = triggerConditions.x121Conditions.donOpenUpperBuffer[1];
|
||||
double donOpenLower = triggerConditions.x121Conditions.donOpenLowerBuffer[1];
|
||||
|
||||
//
|
||||
double donCloseUpper = triggerConditions.x121Conditions.donCloseUpperBuffer[1];
|
||||
double donCloseLower = triggerConditions.x121Conditions.donCloseLowerBuffer[1];
|
||||
|
||||
//
|
||||
bool isDonUpperBullish = donCloseUpper > donOpenUpper;
|
||||
bool isDonUpperBearish = donCloseUpper < donOpenUpper;
|
||||
|
||||
//
|
||||
bool isDonLowerBullish = donCloseLower > donOpenLower;
|
||||
bool isDonLowerBearish = donCloseLower < donOpenLower;
|
||||
|
||||
//
|
||||
bool isDonBullishFormed =
|
||||
//
|
||||
(isDonUpperBullish ||
|
||||
isDonLowerBullish)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isDonBearishFormed =
|
||||
//
|
||||
(isDonUpperBearish ||
|
||||
isDonLowerBearish)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
(isNewValeOverLast ||
|
||||
isNewPeakOverLast) &&
|
||||
isDonBullishFormed &&
|
||||
hasLastVWapStateChanged &&
|
||||
(isBullish &&
|
||||
IsBullish(lastVWapStateChnged.dir));
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
(isNewPeakUnderLast ||
|
||||
isNewValeUnderLast) &&
|
||||
isDonBearishFormed &&
|
||||
hasLastVWapStateChanged &&
|
||||
(isBearish &&
|
||||
IsBearish(lastVWapStateChnged.dir));
|
||||
|
||||
//
|
||||
result = isBullish ||
|
||||
@@ -976,19 +1064,46 @@ bool DetectX121SMCXVWPBSiganlTrigger(
|
||||
{
|
||||
//
|
||||
// Cleanup Setup Conditions ...
|
||||
int setupAge = conditions.GetSetupAge();
|
||||
if (IsValidSize(setupAge) &&
|
||||
IsValidSize(maxAllowedSetupAge) &&
|
||||
setupAge >= maxAllowedSetupAge)
|
||||
{
|
||||
conditions.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Selecting SL ...
|
||||
|
||||
//
|
||||
double longSL = 0;
|
||||
double shortSL = 0;
|
||||
double entry = GetEntry(
|
||||
conditions.symbol,
|
||||
setupDir //
|
||||
);
|
||||
|
||||
//
|
||||
double longDistance = MathAbs(vwapMax - MathMax(triggerVale, donCloseLower)) / 2;
|
||||
double shortDistance = MathAbs(vwapMin - MathMin(triggerPeak, donCloseUpper)) / 2;
|
||||
|
||||
//
|
||||
longSL = entry - longDistance;
|
||||
shortSL = entry + shortDistance;
|
||||
|
||||
//
|
||||
conditions.triggerTime = cTime;
|
||||
conditions.sl = isBullish
|
||||
? 0
|
||||
: 0;
|
||||
? vwapMin
|
||||
: vwapMax;
|
||||
conditions.type = isBullish
|
||||
? X_POSITION_TYPE_LONG
|
||||
: X_POSITION_TYPE_SHORT;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -321,6 +321,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
signal.trailSLStartOnReachTPLevel = 3;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Signal Protecting ...
|
||||
if (hasXVWPBSignal) {
|
||||
//
|
||||
signal.fullTPLevel = r2r;
|
||||
signal.partialCloseOnTPLevel = 2;
|
||||
signal.partialCloseMultiplier = 0.5;
|
||||
|
||||
//
|
||||
signal.riskFreeOnBreakEven = true;
|
||||
signal.tpLevelForBreakEven = 1;
|
||||
|
||||
//
|
||||
signal.trailSL = true;
|
||||
signal.trailSLStartOnReachTPLevel = 2;
|
||||
}
|
||||
|
||||
//
|
||||
result = PrepareSignal(signal);
|
||||
if (result)
|
||||
|
||||
Reference in New Issue
Block a user