last ...
This commit is contained in:
@@ -35,6 +35,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
// Props ...
|
||||
bool useGuards;
|
||||
double rfRewar;
|
||||
bool useQuarterTargets;
|
||||
X121SMCStrategyXWZWorkingZone workingZone;
|
||||
X121SMCStrategyXWZSignalConditions mConditions;
|
||||
@@ -213,6 +214,22 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
hasWorkingZoneOveralDirection = workingZone
|
||||
.DetectOveralDirection(wzOveralDir);
|
||||
|
||||
//
|
||||
// Detectiong Signal Boxes ...
|
||||
hasWaitingBoxes = workingZone
|
||||
.DetectSignalBoxes(
|
||||
X_CYCLE_ANALYSE,
|
||||
provider,
|
||||
zIndex //
|
||||
);
|
||||
if (hasWaitingBoxes)
|
||||
{
|
||||
//
|
||||
workingZone
|
||||
.ValidateWaitingBoxes(zIndex);
|
||||
hasWaitingBoxes = workingZone.HasWaitingBoxes();
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Working Zone Destory or not ...
|
||||
bool isWorkingZoneDestroyed = workingZone.IsDestroyed(
|
||||
@@ -517,20 +534,21 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
}
|
||||
|
||||
//
|
||||
double reward2 = 2 * risk;
|
||||
double reward3 = 3 * risk;
|
||||
double iTP2 = isBullish
|
||||
? entry + reward2
|
||||
: entry - reward2;
|
||||
double iTP3 = isBullish
|
||||
? entry + reward3
|
||||
: entry - reward3;
|
||||
// Reward to RF ...
|
||||
if (rfRewar > 0)
|
||||
{
|
||||
//
|
||||
double iRFReward = rfRewar * risk;
|
||||
double iRFTP = isBullish
|
||||
? entry + iRFReward
|
||||
: entry - iRFReward;
|
||||
|
||||
//
|
||||
Add(
|
||||
iTP3,
|
||||
targets //
|
||||
);
|
||||
//
|
||||
Add(
|
||||
iRFTP,
|
||||
targets //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Based On Priority ...
|
||||
@@ -1667,8 +1685,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
void Init()
|
||||
{
|
||||
//
|
||||
useGuards = true;
|
||||
useQuarterTargets = true;
|
||||
rfRewar = 2;
|
||||
useGuards = false;
|
||||
useQuarterTargets = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -722,6 +722,85 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool DetectSignalBoxes(
|
||||
ENUM_X_CYCLES cycle,
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Select Cycle ...
|
||||
XPOIState cState;
|
||||
X121Conditions cXConditions;
|
||||
XC121SMCCycleHelper *cHelper;
|
||||
X121SMCCycleConditions cConditions;
|
||||
result = provider.SelectCycle(
|
||||
cycle,
|
||||
cState,
|
||||
cXConditions,
|
||||
cHelper,
|
||||
cConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select Validate Rejection Boxes ...
|
||||
XBoxZone rejections[];
|
||||
int count = cHelper
|
||||
.DetectRejections(
|
||||
rejections,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(count);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
rejections,
|
||||
waitingBoxes,
|
||||
false //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
count = CountWaitingBoxes();
|
||||
result = IsValidSize(count);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int ValidateWaitingZones(
|
||||
int barIndex = 0 //
|
||||
@@ -821,8 +900,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
}
|
||||
|
||||
//
|
||||
has = IsValid() &&
|
||||
HasWaitingBoxes();
|
||||
has = HasWaitingBoxes();
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
@@ -834,12 +912,24 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
for (int i = 0; i < result; i++)
|
||||
{
|
||||
//
|
||||
has = IsValidBox(
|
||||
waitingBoxes[i],
|
||||
barIndex,
|
||||
period //
|
||||
);
|
||||
if (!has)
|
||||
XOHCL iBar;
|
||||
XBoxZone iBox = waitingBoxes[i];
|
||||
bool isInite = iBar
|
||||
.Init(
|
||||
iBox.symbol,
|
||||
iBox.period,
|
||||
iBox.from //
|
||||
);
|
||||
|
||||
//
|
||||
has = isInite &&
|
||||
IsBoxBreaked(
|
||||
iBox,
|
||||
iBar.Index() - 1,
|
||||
barIndex,
|
||||
period //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
@@ -849,10 +939,14 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
AddRef(
|
||||
waitingBoxes[i],
|
||||
iBox,
|
||||
unavailableBoxes //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -903,7 +997,9 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
ENUM_X_DIRECTION trend;
|
||||
result = IsValid() &&
|
||||
DetectOveralDirection(trend);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -928,8 +1024,10 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
// Senario 1:
|
||||
// ----------
|
||||
bool useSenario1 = true;
|
||||
// ---------------------------------------------
|
||||
// Detect Signal Box Based On Conditions ...
|
||||
// ---------------------------------------------
|
||||
bool useSenario1 = false;
|
||||
bool isSenario1Happend = false;
|
||||
bool isSenario1Bullish = false;
|
||||
bool isSenario1Bearish = false;
|
||||
@@ -965,13 +1063,50 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
// Senario 2:
|
||||
// ----------
|
||||
bool useSenario2 = false;
|
||||
// ---------------------------------------------------
|
||||
// Detect Signal Based On Breaked Rejection Boxes ...
|
||||
// ---------------------------------------------------
|
||||
bool useSenario2 = true;
|
||||
bool isSenario2Happend = false;
|
||||
bool isSenario2Bullish = false;
|
||||
bool isSenario2Bearish = false;
|
||||
if (useSenario2)
|
||||
{
|
||||
//
|
||||
// Senario 2 Working Based on
|
||||
// Breaked Boxes ...
|
||||
// Since we Works only
|
||||
// when Has UnAvailable Boxes ...
|
||||
has = HasUnavailableBoxes();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
isSenario2Happend = cParser.HasSenario2Conditions(
|
||||
X_CYCLE_DECISION,
|
||||
trend,
|
||||
unavailableBoxes,
|
||||
box,
|
||||
dir,
|
||||
provider,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
isSenario2Bullish =
|
||||
isSenario2Happend &&
|
||||
IsBullish(dir);
|
||||
|
||||
//
|
||||
isSenario2Bearish =
|
||||
isSenario2Happend &&
|
||||
IsBearish(dir);
|
||||
|
||||
//
|
||||
if (isSenario2Happend)
|
||||
{
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -985,6 +1120,17 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Senario 4:
|
||||
// ----------
|
||||
bool useSenario4 = false;
|
||||
bool isSenario4Happend = false;
|
||||
bool isSenario4Bullish = false;
|
||||
bool isSenario4Bearish = false;
|
||||
if (useSenario4)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Summarize All Senario(s) Conditions ...
|
||||
|
||||
@@ -993,6 +1139,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
//
|
||||
isSenario1Bullish ||
|
||||
isSenario2Bullish ||
|
||||
isSenario3Bullish ||
|
||||
isSenario3Bullish
|
||||
//
|
||||
;
|
||||
@@ -1002,6 +1149,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
//
|
||||
isSenario1Bearish ||
|
||||
isSenario2Bearish ||
|
||||
isSenario3Bearish ||
|
||||
isSenario3Bearish
|
||||
//
|
||||
;
|
||||
@@ -1373,50 +1521,42 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
|
||||
//
|
||||
XOHCL supPriceOutBar;
|
||||
XOHCL demPriceOutBar;
|
||||
bool hasSupPriceOutBar = false;
|
||||
result = DetectBoxNearestPriceOut(
|
||||
supBox,
|
||||
supPriceOutBar,
|
||||
period //
|
||||
supBox.period //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
demBox.Clean();
|
||||
supBox.Clean();
|
||||
supPriceOutBar.Clean();
|
||||
demPriceOutBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//
|
||||
XOHCL demPriceOutBar;
|
||||
bool hasDemPriceOutBar = false;
|
||||
result = DetectBoxNearestPriceOut(
|
||||
demBox,
|
||||
demPriceOutBar,
|
||||
period //
|
||||
demBox.period //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
demBox.Clean();
|
||||
supBox.Clean();
|
||||
supPriceOutBar.Clean();
|
||||
demPriceOutBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//
|
||||
hasSupPriceOutBar = supPriceOutBar.IsValid();
|
||||
hasDemPriceOutBar = demPriceOutBar.IsValid();
|
||||
|
||||
//
|
||||
// Specified Direction ...
|
||||
dir =
|
||||
(supPriceOutBar.IsValid() &&
|
||||
demPriceOutBar.IsValid())
|
||||
(hasSupPriceOutBar &&
|
||||
hasDemPriceOutBar)
|
||||
? supPriceOutBar.time > demPriceOutBar.time
|
||||
? X_DIRECTION_BEARISH
|
||||
: demPriceOutBar.time > supPriceOutBar.time
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_NONE
|
||||
: (hasSupPriceOutBar &&
|
||||
!hasDemPriceOutBar)
|
||||
? X_DIRECTION_BEARISH
|
||||
: (!hasSupPriceOutBar &&
|
||||
hasDemPriceOutBar)
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
@@ -1491,7 +1631,8 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
XCPOIDrawer *drawer,
|
||||
bool drawSupplyZone = false,
|
||||
bool drawDemandZone = false,
|
||||
bool drawWaitingZones = false)
|
||||
bool drawWaitingZones = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (drawer == NULL)
|
||||
|
||||
Reference in New Issue
Block a user