last ...
This commit is contained in:
@@ -1261,11 +1261,416 @@ if (useSenario1)
|
|||||||
//
|
//
|
||||||
;
|
;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
//
|
||||||
|
isSenario2Happend = cParser.HasSenario2Conditions(
|
||||||
|
X_CYCLE_DECISION, // TFT Cycle ...
|
||||||
|
X_CYCLE_ANALYSE, // MTF Cycle ...
|
||||||
|
X_CYCLE_CONSOLIDATION, // HTF Cycle ...
|
||||||
|
box,
|
||||||
|
holderBox,
|
||||||
|
dir,
|
||||||
|
provider,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
//
|
||||||
|
isSenario2Bullish =
|
||||||
|
isSenario2Happend &&
|
||||||
|
IsBullish(dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
isSenario2Bearish =
|
||||||
|
isSenario2Happend &&
|
||||||
|
IsBearish(dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isSenario2Happend)
|
||||||
|
{
|
||||||
|
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Extract Cycles ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// TTF Cycle ...
|
||||||
|
XPOIState ttfState;
|
||||||
|
X121Conditions ttfXConditions;
|
||||||
|
XC121SMCCycleHelper *ttfHelper;
|
||||||
|
X121SMCCycleConditions ttfConditions;
|
||||||
|
result = provider.SelectCycle(
|
||||||
|
ttfCycle,
|
||||||
|
ttfState,
|
||||||
|
ttfXConditions,
|
||||||
|
ttfHelper,
|
||||||
|
ttfConditions //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ttfState.Clean();
|
||||||
|
ZeroMemory(ttfHelper);
|
||||||
|
ttfConditions.Clean();
|
||||||
|
ttfXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Parse(ttfXConditions);
|
||||||
|
|
||||||
|
//
|
||||||
|
// MTF Cycle ...
|
||||||
|
XPOIState mtfState;
|
||||||
|
X121Conditions mtfXConditions;
|
||||||
|
XC121SMCCycleHelper *mtfHelper;
|
||||||
|
X121SMCCycleConditions mtfConditions;
|
||||||
|
result = provider.SelectCycle(
|
||||||
|
mtfCycle,
|
||||||
|
mtfState,
|
||||||
|
mtfXConditions,
|
||||||
|
mtfHelper,
|
||||||
|
mtfConditions //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ttfState.Clean();
|
||||||
|
mtfState.Clean();
|
||||||
|
ZeroMemory(ttfHelper);
|
||||||
|
ttfConditions.Clean();
|
||||||
|
ZeroMemory(mtfHelper);
|
||||||
|
mtfConditions.Clean();
|
||||||
|
ttfXConditions.Clean();
|
||||||
|
mtfXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Parse(mtfXConditions);
|
||||||
|
|
||||||
|
//
|
||||||
|
// HTF Cycle ...
|
||||||
|
XPOIState htfState;
|
||||||
|
X121Conditions htfXConditions;
|
||||||
|
XC121SMCCycleHelper *htfHelper;
|
||||||
|
X121SMCCycleConditions htfConditions;
|
||||||
|
result = provider.SelectCycle(
|
||||||
|
htfCycle,
|
||||||
|
htfState,
|
||||||
|
htfXConditions,
|
||||||
|
htfHelper,
|
||||||
|
htfConditions //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ttfState.Clean();
|
||||||
|
mtfState.Clean();
|
||||||
|
htfState.Clean();
|
||||||
|
ZeroMemory(ttfHelper);
|
||||||
|
ZeroMemory(mtfHelper);
|
||||||
|
ZeroMemory(htfHelper);
|
||||||
|
ttfConditions.Clean();
|
||||||
|
mtfConditions.Clean();
|
||||||
|
htfConditions.Clean();
|
||||||
|
ttfXConditions.Clean();
|
||||||
|
mtfXConditions.Clean();
|
||||||
|
htfXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Parse(htfXConditions);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//
|
||||||
|
dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
box.dir = dir;
|
||||||
|
box.to = TimeCurrent();
|
||||||
|
box.symbol = ttfXConditions.symbol;
|
||||||
|
box.period = ttfXConditions.period;
|
||||||
|
|
||||||
|
//
|
||||||
|
int fromIDX = -1;
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double vale = ttfXConditions.valesBuffer[cIDX];
|
||||||
|
box.lower = vale;
|
||||||
|
box.upper = ttfXConditions.valesGoldenBuffer[cIDX];
|
||||||
|
|
||||||
|
//
|
||||||
|
int lowerValeIDX = -1;
|
||||||
|
double lowerVale = ttfHelper
|
||||||
|
.mX121Helper
|
||||||
|
.xpvHelper
|
||||||
|
.GetLowerVale(
|
||||||
|
lowerValeIDX,
|
||||||
|
vale,
|
||||||
|
cBar.Index() //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
int higherValeIDX = -1;
|
||||||
|
double higherVale = ttfHelper
|
||||||
|
.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 = ttfXConditions.peaksBuffer[cIDX];
|
||||||
|
box.upper = peak;
|
||||||
|
|
||||||
|
//
|
||||||
|
box.lower = ttfXConditions.peaksGoldenBuffer[cIDX];
|
||||||
|
|
||||||
|
//
|
||||||
|
int lowerPeakIDX = -1;
|
||||||
|
double lowerPeak = ttfHelper
|
||||||
|
.mX121Helper
|
||||||
|
.xpvHelper
|
||||||
|
.GetLowerPeak(
|
||||||
|
lowerPeakIDX,
|
||||||
|
peak,
|
||||||
|
cBar.Index() //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
int higherPeakIDX = -1;
|
||||||
|
double higherPeak = ttfHelper
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Holder Box ...
|
||||||
|
XBoxZone tmpBoxes[];
|
||||||
|
if (htfState.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Demand Zones ...
|
||||||
|
XBoxZone tmp[];
|
||||||
|
ToBox(
|
||||||
|
htfState.demandZones,
|
||||||
|
tmp //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
tmp,
|
||||||
|
tmpBoxes,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
Clean(tmp);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish Order Blocks ...
|
||||||
|
ToBox(
|
||||||
|
htfState.bullishOrderBlocks,
|
||||||
|
tmp //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
tmp,
|
||||||
|
tmpBoxes,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
Clean(tmp);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish Fair Value Gaps ...
|
||||||
|
ToBox(
|
||||||
|
htfState.bullishFairValueGaps,
|
||||||
|
tmp //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
tmp,
|
||||||
|
tmpBoxes,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
Clean(tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Supply Zones ...
|
||||||
|
XBoxZone tmp[];
|
||||||
|
ToBox(
|
||||||
|
htfState.supplyZones,
|
||||||
|
tmp //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
tmp,
|
||||||
|
tmpBoxes,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
Clean(tmp);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish Order Blocks ...
|
||||||
|
ToBox(
|
||||||
|
htfState.bearishOrderBlocks,
|
||||||
|
tmp //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
tmp,
|
||||||
|
tmpBoxes,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
Clean(tmp);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish Fair Value Gaps ...
|
||||||
|
ToBox(
|
||||||
|
htfState.bearishFairValueGaps,
|
||||||
|
tmp //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
tmp,
|
||||||
|
tmpBoxes,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
Clean(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
has = HasChild(tmpBoxes);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
while (HasChild(tmpBoxes))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = GetOldest(tmpBoxes);
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone iBox = tmpBoxes[idx];
|
||||||
|
ArrayRemove(
|
||||||
|
tmpBoxes,
|
||||||
|
idx,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
has = IsBoxInside(
|
||||||
|
box,
|
||||||
|
iBox //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
holderBox = iBox;
|
||||||
|
holderBox.to = TimeCurrent();
|
||||||
|
iBox.Clean();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpBoxes);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Conditions to Force Has Holder Box ...
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
holderBox.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBullish = false;
|
||||||
|
isBearish = false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -1135,6 +1135,40 @@ bool IsInsideBox(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Bar is Inside Specified Box ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL instance reference, Specified Bar ...
|
||||||
|
* @param box: XCBozZone instance Reference ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsInsideBox(
|
||||||
|
XOHCL &bar,
|
||||||
|
XBoxZone &box //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
result = bar.IsValid() &&
|
||||||
|
box.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
bar.close <= box.upper &&
|
||||||
|
bar.close >= box.lower;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Value is Above Specified Box ...
|
* Check Value is Above Specified Box ...
|
||||||
*
|
*
|
||||||
@@ -1235,6 +1269,7 @@ bool IsBoxUsed(
|
|||||||
bool isBullish = IsBullish(forDir);
|
bool isBullish = IsBullish(forDir);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
bool isTouched = false;
|
||||||
for (int i = fromIndex; i >= toIndex; i--)
|
for (int i = fromIndex; i >= toIndex; i--)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1246,10 +1281,11 @@ bool IsBoxUsed(
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isTouched =
|
isTouched =
|
||||||
isBullish
|
isInited &&
|
||||||
? iBar.high > box.lower
|
(isBullish
|
||||||
: iBar.low < box.upper;
|
? iBar.low > box.upper
|
||||||
|
: iBar.high < box.lower);
|
||||||
if (!isTouched)
|
if (!isTouched)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -1257,74 +1293,26 @@ bool IsBoxUsed(
|
|||||||
|
|
||||||
//
|
//
|
||||||
iBar.Clean();
|
iBar.Clean();
|
||||||
result = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isTouched;
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find an Inside Box of source in a Collection ...
|
* Validate Box ...
|
||||||
*
|
*
|
||||||
* @param index: int, Founded Index ...
|
* @param box: XBoxZone instance ...
|
||||||
* @param source: XBoxZone instance ...
|
* @param barIndex: int, Current Bar Index ...
|
||||||
* @param dest: XBoxZone instance Collection ...
|
* @param forPeriod: Testing Period ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool HasInsideBox(
|
bool IsBoxValid(
|
||||||
int &index,
|
|
||||||
XBoxZone &source,
|
|
||||||
XBoxZone &dest[] //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
index = -1;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = source.IsValid() &&
|
|
||||||
HasChild(dest);
|
|
||||||
|
|
||||||
//
|
|
||||||
int count = ArraySize(dest);
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XBoxZone iBox = dest[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isInside = !iBox.IsSameAs(source) &&
|
|
||||||
IsBoxInsideOr(
|
|
||||||
iBox,
|
|
||||||
source //
|
|
||||||
);
|
|
||||||
if (isInside)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
index = i;
|
|
||||||
iBox.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
iBox.Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result = IsValidIndex(index);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsValidBox(
|
|
||||||
XBoxZone &box,
|
XBoxZone &box,
|
||||||
int barIndex = 0,
|
int barIndex = 0,
|
||||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||||
@@ -1401,6 +1389,149 @@ bool IsValidBox(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check a Box is Breaked or not ...
|
||||||
|
*
|
||||||
|
* @param box: XBoxZone instance Reference ...
|
||||||
|
* @param fromIndex: int ...
|
||||||
|
* @param toIndex: int
|
||||||
|
* @param forPeriod: Specified Period ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsBoxBreaked(
|
||||||
|
XBoxZone &box,
|
||||||
|
int fromIndex,
|
||||||
|
int toIndex = 0,
|
||||||
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (toIndex < 0)
|
||||||
|
{
|
||||||
|
toIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
box.IsValid() &&
|
||||||
|
fromIndex > 0 &&
|
||||||
|
fromIndex > toIndex
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid(forPeriod))
|
||||||
|
{
|
||||||
|
forPeriod = box.period;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION forDir = box.dir;
|
||||||
|
bool isBullish = IsBullish(forDir);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBreaked = false;
|
||||||
|
for (int i = fromIndex; i >= toIndex; i--)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isInited = iBar.Init(
|
||||||
|
box.symbol,
|
||||||
|
forPeriod,
|
||||||
|
i //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBreaked =
|
||||||
|
isInited &&
|
||||||
|
(isBullish
|
||||||
|
? iBar.high <= box.lower
|
||||||
|
: iBar.low >= box.upper);
|
||||||
|
if (!isBreaked)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBreaked;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find an Inside Box of source in a Collection ...
|
||||||
|
*
|
||||||
|
* @param index: int, Founded Index ...
|
||||||
|
* @param source: XBoxZone instance ...
|
||||||
|
* @param dest: XBoxZone instance Collection ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool HasInsideBox(
|
||||||
|
int &index,
|
||||||
|
XBoxZone &source,
|
||||||
|
XBoxZone &dest[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
index = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = source.IsValid() &&
|
||||||
|
HasChild(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(dest);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XBoxZone iBox = dest[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isInside = !iBox.IsSameAs(source) &&
|
||||||
|
IsBoxInsideOr(
|
||||||
|
iBox,
|
||||||
|
source //
|
||||||
|
);
|
||||||
|
if (isInside)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
iBox.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValidIndex(index);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts to XBoxZone ...
|
* Converts to XBoxZone ...
|
||||||
*
|
*
|
||||||
@@ -3032,7 +3163,7 @@ bool DetectBoxNearestPriceOut(
|
|||||||
//
|
//
|
||||||
int fromIndex = iBarShift(
|
int fromIndex = iBarShift(
|
||||||
box.symbol,
|
box.symbol,
|
||||||
box.period,
|
forPeriod,
|
||||||
box.from //
|
box.from //
|
||||||
);
|
);
|
||||||
result = IsValidIndex(fromIndex);
|
result = IsValidIndex(fromIndex);
|
||||||
|
|||||||
@@ -54,6 +54,21 @@ string ToString(ENUM_X_CYCLES value)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsValid(ENUM_X_CYCLES value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
value != X_CYCLE_NONE ||
|
||||||
|
value != X_CYCLE_TRIGGER ||
|
||||||
|
value != X_CYCLE_VERIFICATION;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
enum ENUM_X_CYCLE_EVENTS
|
enum ENUM_X_CYCLE_EVENTS
|
||||||
{
|
{
|
||||||
SAR_CHANGE_DETECTED,
|
SAR_CHANGE_DETECTED,
|
||||||
@@ -584,6 +599,224 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int DetectRejections(
|
||||||
|
XBoxZone &rejections[],
|
||||||
|
int barIndex = 0,
|
||||||
|
bool forceBarType = true,
|
||||||
|
bool forceFiboPressure = true,
|
||||||
|
bool forceUnUsedRejections = true,
|
||||||
|
int maxAllowedLoopback = 587 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize Args ...
|
||||||
|
Clean(rejections);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
bool has = false;
|
||||||
|
for (int i = barIndex + 1; i < barIndex + maxAllowedLoopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Init Indexed Bar ...
|
||||||
|
XOHCL iBar;
|
||||||
|
XOHCL iCBar;
|
||||||
|
XOHCL iPBar;
|
||||||
|
has = GetBar(iBar, i);
|
||||||
|
has =
|
||||||
|
has &&
|
||||||
|
iBar.GetPreviousBar(iCBar);
|
||||||
|
has =
|
||||||
|
has &&
|
||||||
|
iCBar.GetPreviousBar(iPBar);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
iCBar.Clean();
|
||||||
|
iPBar.Clean();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check CBar Bullish Fibo Pressure ...
|
||||||
|
bool cBarHasBullishFiboPressure =
|
||||||
|
mBarAnalyser
|
||||||
|
.HasFiboPressure(
|
||||||
|
iCBar,
|
||||||
|
X_DIRECTION_BULLISH,
|
||||||
|
X_FIBO_LEVEL_382 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check CBar Bearish Fibo Pressure ...
|
||||||
|
bool cBarHasBearishFiboPressure =
|
||||||
|
mBarAnalyser
|
||||||
|
.HasFiboPressure(
|
||||||
|
iCBar,
|
||||||
|
X_DIRECTION_BEARISH,
|
||||||
|
X_FIBO_LEVEL_382 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar is Bullish Rejection Swing ...
|
||||||
|
bool isBullishRejection =
|
||||||
|
//
|
||||||
|
iCBar.low < iBar.low &&
|
||||||
|
iCBar.low < iPBar.low &&
|
||||||
|
//
|
||||||
|
iCBar.low < iCBar.GetDown() &&
|
||||||
|
iCBar.GetLowShadow() > iCBar.GetBody() &&
|
||||||
|
iCBar.GetLowShadow() > iCBar.GetHighShadow()
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar is Bearish Rejection Swing ...
|
||||||
|
bool isBearishRejection =
|
||||||
|
//
|
||||||
|
iCBar.high > iBar.high &&
|
||||||
|
iCBar.high > iPBar.high &&
|
||||||
|
//
|
||||||
|
iCBar.high > iCBar.GetUp() &&
|
||||||
|
iCBar.GetHighShadow() > iCBar.GetBody() &&
|
||||||
|
iCBar.GetHighShadow() > iCBar.GetLowShadow()
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Apply Fibo Pressure ...
|
||||||
|
if (forceFiboPressure)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBullishRejection =
|
||||||
|
isBullishRejection &&
|
||||||
|
cBarHasBullishFiboPressure;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearishRejection =
|
||||||
|
isBearishRejection &&
|
||||||
|
cBarHasBearishFiboPressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Apply Force Bar Type ...
|
||||||
|
if (forceBarType)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBullishRejection =
|
||||||
|
isBullishRejection &&
|
||||||
|
iCBar.IsBullish();
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearishRejection =
|
||||||
|
isBearishRejection &&
|
||||||
|
iCBar.IsBearish();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
has = isBullishRejection ||
|
||||||
|
isBearishRejection;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XBoxZone iBox;
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.to = iBar.time;
|
||||||
|
iBox.from = iCBar.time;
|
||||||
|
iBox.period = iBar.period;
|
||||||
|
iBox.symbol = iBar.symbol;
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.dir =
|
||||||
|
isBullishRejection
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.upper =
|
||||||
|
isBullishRejection
|
||||||
|
? iCBar.GetDown()
|
||||||
|
: iCBar.high;
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.lower =
|
||||||
|
isBullishRejection
|
||||||
|
? iCBar.low
|
||||||
|
: iCBar.GetUp();
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.type =
|
||||||
|
isBullishRejection
|
||||||
|
? "XSwingLow"
|
||||||
|
: "XSwingHigh";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Box ...
|
||||||
|
has = iBox.IsValid();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Apply Force Unused Rejections ...
|
||||||
|
if (forceUnUsedRejections)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
has = !IsBoxBreaked(
|
||||||
|
iBox,
|
||||||
|
iCBar.Index() + 1,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = FindIndex(
|
||||||
|
iBox,
|
||||||
|
rejections //
|
||||||
|
);
|
||||||
|
has = !IsValidIndex(idx);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
iBox,
|
||||||
|
rejections //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
iCBar.Clean();
|
||||||
|
iPBar.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(rejections);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtuals ...
|
// Virtuals ...
|
||||||
|
|
||||||
@@ -638,7 +871,7 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
bool mShowBidLine = true; // show bid line
|
bool mShowBidLine = true; // show bid line
|
||||||
bool mShowAskLine = true; // show ask line
|
bool mShowAskLine = true; // show ask line
|
||||||
bool mShowGrid = false; // show grids on chart
|
bool mShowGrid = false; // show grids on chart
|
||||||
bool mShowVolumes = false; // show volumes
|
bool mShowVolumes = true; // show volumes
|
||||||
bool mShowTradeLevels = true; // Displaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders)
|
bool mShowTradeLevels = true; // Displaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders)
|
||||||
bool mAutoScroll = true; // chart autoscroll
|
bool mAutoScroll = true; // chart autoscroll
|
||||||
bool mQuickNavigation = true; // chart quick navigation state
|
bool mQuickNavigation = true; // chart quick navigation state
|
||||||
@@ -2676,5 +2909,262 @@ struct X121SMCStrategyConditionParser
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool HasSenario2Conditions(
|
||||||
|
ENUM_X_CYCLES ttfCycle,
|
||||||
|
ENUM_X_DIRECTION trend,
|
||||||
|
XBoxZone &unavailableBoxes[],
|
||||||
|
XBoxZone &box,
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
X121SMCStrategySignalProviderData &provider,
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
result =
|
||||||
|
IsValid(ttfCycle) &&
|
||||||
|
HasDirection(trend) &&
|
||||||
|
HasChild(unavailableBoxes);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool hasBullishTrend = IsBullish(trend);
|
||||||
|
bool hasBearishTrend = IsBearish(trend);
|
||||||
|
|
||||||
|
//
|
||||||
|
// TTF Cycle Extract ...
|
||||||
|
XPOIState ttfState;
|
||||||
|
X121Conditions ttfXConditions;
|
||||||
|
XC121SMCCycleHelper *ttfHelper;
|
||||||
|
X121SMCCycleConditions ttfConditions;
|
||||||
|
result = provider.SelectCycle(
|
||||||
|
ttfCycle,
|
||||||
|
ttfState,
|
||||||
|
ttfXConditions,
|
||||||
|
ttfHelper,
|
||||||
|
ttfConditions //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ttfState.Clean();
|
||||||
|
ZeroMemory(ttfHelper);
|
||||||
|
ttfConditions.Clean();
|
||||||
|
ttfXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Parse(ttfXConditions);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize Args ...
|
||||||
|
|
||||||
|
//
|
||||||
|
box.Clean();
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
|
||||||
|
//
|
||||||
|
double ask = GetAsk(ttfState.symbol);
|
||||||
|
double bid = GetBid(ttfState.symbol);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL zBar;
|
||||||
|
XOHCL cBar;
|
||||||
|
XOHCL pBar;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initial Bars ...
|
||||||
|
result = zBar.Init(
|
||||||
|
ttfState.symbol,
|
||||||
|
ttfState.period,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
zBar.GetPreviousBar(cBar);
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
cBar.GetPreviousBar(pBar);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zBar.Clean();
|
||||||
|
cBar.Clean();
|
||||||
|
pBar.Clean();
|
||||||
|
ttfState.Clean();
|
||||||
|
ZeroMemory(ttfHelper);
|
||||||
|
ttfConditions.Clean();
|
||||||
|
ttfXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// First we Have to Detect Inside Box ...
|
||||||
|
XBoxZone insideBox;
|
||||||
|
count = ArraySize(unavailableBoxes);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XBoxZone iBox = unavailableBoxes[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isInside =
|
||||||
|
IsInsideBox(
|
||||||
|
zBar,
|
||||||
|
iBox //
|
||||||
|
);
|
||||||
|
if (isInside)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Since we have to Follow Trend based on Breaked Boxes ...
|
||||||
|
// we have to use:
|
||||||
|
// - Breaked Bullish Boxes on Bearish Trend ...
|
||||||
|
// - Breaked Bearish Boxes on Bullish Trend ...
|
||||||
|
isInside =
|
||||||
|
hasBullishTrend
|
||||||
|
? iBox.IsBearish()
|
||||||
|
: hasBearishTrend
|
||||||
|
? iBox.IsBullish()
|
||||||
|
: false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isInside)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
insideBox = iBox;
|
||||||
|
iBox.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = insideBox.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zBar.Clean();
|
||||||
|
cBar.Clean();
|
||||||
|
pBar.Clean();
|
||||||
|
ttfState.Clean();
|
||||||
|
insideBox.Clean();
|
||||||
|
ZeroMemory(ttfHelper);
|
||||||
|
ttfConditions.Clean();
|
||||||
|
ttfXConditions.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
insideBox.from = insideBox.to;
|
||||||
|
insideBox.to = zBar.time;
|
||||||
|
|
||||||
|
//
|
||||||
|
XCBoxObject *iObj;
|
||||||
|
has = ttfHelper.mPOIDrawer.DrawBox(
|
||||||
|
insideBox,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (has) {
|
||||||
|
//
|
||||||
|
iObj.Width(2);
|
||||||
|
iObj.BoxColor(clrGray);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Print("Has Inside Box ...");
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish Conditions ...
|
||||||
|
isBullish = (
|
||||||
|
//
|
||||||
|
false
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish Conditions ...
|
||||||
|
isBearish = (
|
||||||
|
//
|
||||||
|
false
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Filling Requirements ...
|
||||||
|
result =
|
||||||
|
isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check All Conditions ...
|
||||||
|
result =
|
||||||
|
box.IsValid() &&
|
||||||
|
HasDirection(dir) &&
|
||||||
|
(isBullish ||
|
||||||
|
isBearish //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resource ...
|
||||||
|
|
||||||
|
//
|
||||||
|
zBar.Clean();
|
||||||
|
cBar.Clean();
|
||||||
|
pBar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
ttfState.Clean();
|
||||||
|
ZeroMemory(ttfHelper);
|
||||||
|
ttfConditions.Clean();
|
||||||
|
ttfXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
bool useGuards;
|
bool useGuards;
|
||||||
|
double rfRewar;
|
||||||
bool useQuarterTargets;
|
bool useQuarterTargets;
|
||||||
X121SMCStrategyXWZWorkingZone workingZone;
|
X121SMCStrategyXWZWorkingZone workingZone;
|
||||||
X121SMCStrategyXWZSignalConditions mConditions;
|
X121SMCStrategyXWZSignalConditions mConditions;
|
||||||
@@ -213,6 +214,22 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
hasWorkingZoneOveralDirection = workingZone
|
hasWorkingZoneOveralDirection = workingZone
|
||||||
.DetectOveralDirection(wzOveralDir);
|
.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 ...
|
// Checking Working Zone Destory or not ...
|
||||||
bool isWorkingZoneDestroyed = workingZone.IsDestroyed(
|
bool isWorkingZoneDestroyed = workingZone.IsDestroyed(
|
||||||
@@ -517,20 +534,21 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
double reward2 = 2 * risk;
|
// Reward to RF ...
|
||||||
double reward3 = 3 * risk;
|
if (rfRewar > 0)
|
||||||
double iTP2 = isBullish
|
{
|
||||||
? entry + reward2
|
//
|
||||||
: entry - reward2;
|
double iRFReward = rfRewar * risk;
|
||||||
double iTP3 = isBullish
|
double iRFTP = isBullish
|
||||||
? entry + reward3
|
? entry + iRFReward
|
||||||
: entry - reward3;
|
: entry - iRFReward;
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iTP3,
|
iRFTP,
|
||||||
targets //
|
targets //
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Based On Priority ...
|
// Based On Priority ...
|
||||||
@@ -1667,8 +1685,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
useGuards = true;
|
rfRewar = 2;
|
||||||
useQuarterTargets = true;
|
useGuards = false;
|
||||||
|
useQuarterTargets = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -722,6 +722,85 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
return result;
|
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 ValidateWaitingZones(
|
||||||
int barIndex = 0 //
|
int barIndex = 0 //
|
||||||
@@ -821,8 +900,7 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
has = IsValid() &&
|
has = HasWaitingBoxes();
|
||||||
HasWaitingBoxes();
|
|
||||||
if (!has)
|
if (!has)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -834,12 +912,24 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
for (int i = 0; i < result; i++)
|
for (int i = 0; i < result; i++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
has = IsValidBox(
|
XOHCL iBar;
|
||||||
waitingBoxes[i],
|
XBoxZone iBox = waitingBoxes[i];
|
||||||
barIndex,
|
bool isInite = iBar
|
||||||
period //
|
.Init(
|
||||||
);
|
iBox.symbol,
|
||||||
if (!has)
|
iBox.period,
|
||||||
|
iBox.from //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
has = isInite &&
|
||||||
|
IsBoxBreaked(
|
||||||
|
iBox,
|
||||||
|
iBar.Index() - 1,
|
||||||
|
barIndex,
|
||||||
|
period //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
@@ -849,10 +939,14 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
AddRef(
|
AddRef(
|
||||||
waitingBoxes[i],
|
iBox,
|
||||||
unavailableBoxes //
|
unavailableBoxes //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
iBar.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -903,7 +997,9 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = IsValid();
|
ENUM_X_DIRECTION trend;
|
||||||
|
result = IsValid() &&
|
||||||
|
DetectOveralDirection(trend);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -928,8 +1024,10 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Senario 1:
|
// Senario 1:
|
||||||
// ----------
|
// ---------------------------------------------
|
||||||
bool useSenario1 = true;
|
// Detect Signal Box Based On Conditions ...
|
||||||
|
// ---------------------------------------------
|
||||||
|
bool useSenario1 = false;
|
||||||
bool isSenario1Happend = false;
|
bool isSenario1Happend = false;
|
||||||
bool isSenario1Bullish = false;
|
bool isSenario1Bullish = false;
|
||||||
bool isSenario1Bearish = false;
|
bool isSenario1Bearish = false;
|
||||||
@@ -965,13 +1063,50 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Senario 2:
|
// Senario 2:
|
||||||
// ----------
|
// ---------------------------------------------------
|
||||||
bool useSenario2 = false;
|
// Detect Signal Based On Breaked Rejection Boxes ...
|
||||||
|
// ---------------------------------------------------
|
||||||
|
bool useSenario2 = true;
|
||||||
bool isSenario2Happend = false;
|
bool isSenario2Happend = false;
|
||||||
bool isSenario2Bullish = false;
|
bool isSenario2Bullish = false;
|
||||||
bool isSenario2Bearish = false;
|
bool isSenario2Bearish = false;
|
||||||
if (useSenario2)
|
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 ...
|
// Summarize All Senario(s) Conditions ...
|
||||||
|
|
||||||
@@ -993,6 +1139,7 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
//
|
//
|
||||||
isSenario1Bullish ||
|
isSenario1Bullish ||
|
||||||
isSenario2Bullish ||
|
isSenario2Bullish ||
|
||||||
|
isSenario3Bullish ||
|
||||||
isSenario3Bullish
|
isSenario3Bullish
|
||||||
//
|
//
|
||||||
;
|
;
|
||||||
@@ -1002,6 +1149,7 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
//
|
//
|
||||||
isSenario1Bearish ||
|
isSenario1Bearish ||
|
||||||
isSenario2Bearish ||
|
isSenario2Bearish ||
|
||||||
|
isSenario3Bearish ||
|
||||||
isSenario3Bearish
|
isSenario3Bearish
|
||||||
//
|
//
|
||||||
;
|
;
|
||||||
@@ -1373,50 +1521,42 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
XOHCL supPriceOutBar;
|
XOHCL supPriceOutBar;
|
||||||
XOHCL demPriceOutBar;
|
bool hasSupPriceOutBar = false;
|
||||||
result = DetectBoxNearestPriceOut(
|
result = DetectBoxNearestPriceOut(
|
||||||
supBox,
|
supBox,
|
||||||
supPriceOutBar,
|
supPriceOutBar,
|
||||||
period //
|
supBox.period //
|
||||||
);
|
);
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
demBox.Clean();
|
|
||||||
supBox.Clean();
|
|
||||||
supPriceOutBar.Clean();
|
|
||||||
demPriceOutBar.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
XOHCL demPriceOutBar;
|
||||||
}
|
bool hasDemPriceOutBar = false;
|
||||||
result = DetectBoxNearestPriceOut(
|
result = DetectBoxNearestPriceOut(
|
||||||
demBox,
|
demBox,
|
||||||
demPriceOutBar,
|
demPriceOutBar,
|
||||||
period //
|
demBox.period //
|
||||||
);
|
);
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
demBox.Clean();
|
|
||||||
supBox.Clean();
|
|
||||||
supPriceOutBar.Clean();
|
|
||||||
demPriceOutBar.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
hasSupPriceOutBar = supPriceOutBar.IsValid();
|
||||||
}
|
hasDemPriceOutBar = demPriceOutBar.IsValid();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Specified Direction ...
|
// Specified Direction ...
|
||||||
dir =
|
dir =
|
||||||
(supPriceOutBar.IsValid() &&
|
(hasSupPriceOutBar &&
|
||||||
demPriceOutBar.IsValid())
|
hasDemPriceOutBar)
|
||||||
? supPriceOutBar.time > demPriceOutBar.time
|
? supPriceOutBar.time > demPriceOutBar.time
|
||||||
? X_DIRECTION_BEARISH
|
? X_DIRECTION_BEARISH
|
||||||
: demPriceOutBar.time > supPriceOutBar.time
|
: demPriceOutBar.time > supPriceOutBar.time
|
||||||
? X_DIRECTION_BULLISH
|
? X_DIRECTION_BULLISH
|
||||||
: X_DIRECTION_NONE
|
: X_DIRECTION_NONE
|
||||||
|
: (hasSupPriceOutBar &&
|
||||||
|
!hasDemPriceOutBar)
|
||||||
|
? X_DIRECTION_BEARISH
|
||||||
|
: (!hasSupPriceOutBar &&
|
||||||
|
hasDemPriceOutBar)
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
: X_DIRECTION_NONE;
|
: X_DIRECTION_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1491,7 +1631,8 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
XCPOIDrawer *drawer,
|
XCPOIDrawer *drawer,
|
||||||
bool drawSupplyZone = false,
|
bool drawSupplyZone = false,
|
||||||
bool drawDemandZone = false,
|
bool drawDemandZone = false,
|
||||||
bool drawWaitingZones = false)
|
bool drawWaitingZones = false //
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (drawer == NULL)
|
if (drawer == NULL)
|
||||||
|
|||||||
@@ -704,7 +704,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
useXWZSignal = true;
|
useXWZSignal = true;
|
||||||
useXWZSignalGuard = true;
|
useXWZSignalGuard = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
string symbol = GetSymbol();
|
string symbol = GetSymbol();
|
||||||
@@ -767,7 +767,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
|
|
||||||
//
|
//
|
||||||
x121Inputs.xatrInputs.atrMultiplier = 1.5;
|
x121Inputs.xatrInputs.atrMultiplier = 1.5;
|
||||||
x121Inputs.xatrInputs.atrSmoothingMode = X_MA_MODE_EMA;
|
x121Inputs.xatrInputs.atrSmoothingMode = X_MA_MODE_NONE;
|
||||||
|
x121Inputs.xpvInputs.goldenZoneLevel = X_FIBO_LEVEL_236;
|
||||||
|
|
||||||
//
|
//
|
||||||
x121Inputs.xvwapInputs.vwapFastLength = 20;
|
x121Inputs.xvwapInputs.vwapFastLength = 20;
|
||||||
@@ -817,8 +818,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
|
|
||||||
//
|
//
|
||||||
// XATR ...
|
// XATR ...
|
||||||
x121Inputs.xatrInputs.showATRUpper = showAll || false;
|
x121Inputs.xatrInputs.showATRUpper = showAll || true;
|
||||||
x121Inputs.xatrInputs.showATRLower = showAll || false;
|
x121Inputs.xatrInputs.showATRLower = showAll || true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// XSTR ...
|
// XSTR ...
|
||||||
|
|||||||
Reference in New Issue
Block a user