complete signaller trigger cond 1 and 2 and apply sorting for Tagets and etc ...
This commit is contained in:
@@ -1609,11 +1609,227 @@ bool CanTriggerCond1(
|
||||
// Define Requirements ...
|
||||
|
||||
//
|
||||
bool has = false;
|
||||
string symbol = helper.GetSymbol();
|
||||
bool isBullish = decisionZone.IsBullish();
|
||||
bool isBearish = decisionZone.IsBearish();
|
||||
ENUM_TIMEFRAMES period = helper.GetPeriod();
|
||||
|
||||
//
|
||||
int toIDX = decisionZone.ToIndex();
|
||||
int fromIDX = decisionZone.FromIndex();
|
||||
|
||||
//
|
||||
// Reading Bars ...
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
result = zBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
zBar.GetPreviousBar(cBar);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
result =
|
||||
result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Bar's Conditions ...
|
||||
XCAEAConditions iConditions;
|
||||
result = helper.GetConditions(
|
||||
iConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Conditions Values ...
|
||||
|
||||
//
|
||||
int zIDX = 0;
|
||||
int cIDX = zIDX + 1;
|
||||
int pIDX = cIDX + 1;
|
||||
int p2IDX = pIDX + 1;
|
||||
int p3IDX = p2IDX + 1;
|
||||
|
||||
//
|
||||
// PEAK ...
|
||||
double zPeak = iConditions.peakBuffer[zIDX];
|
||||
double cPeak = iConditions.peakBuffer[cIDX];
|
||||
double pPeak = iConditions.peakBuffer[pIDX];
|
||||
double p2Peak = iConditions.peakBuffer[p2IDX];
|
||||
double p3Peak = iConditions.peakBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// VALE ...
|
||||
double zVale = iConditions.valeBuffer[zIDX];
|
||||
double cVale = iConditions.valeBuffer[cIDX];
|
||||
double pVale = iConditions.valeBuffer[pIDX];
|
||||
double p2Vale = iConditions.valeBuffer[p2IDX];
|
||||
double p3Vale = iConditions.valeBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// SWH ...
|
||||
double zSWH = iConditions.swingHighBuffer[zIDX];
|
||||
double cSWH = iConditions.swingHighBuffer[cIDX];
|
||||
double pSWH = iConditions.swingHighBuffer[pIDX];
|
||||
double p2SWH = iConditions.swingHighBuffer[p2IDX];
|
||||
double p3SWH = iConditions.swingHighBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// SWL ...
|
||||
double zSWL = iConditions.swingLowBuffer[zIDX];
|
||||
double cSWL = iConditions.swingLowBuffer[cIDX];
|
||||
double pSWL = iConditions.swingLowBuffer[pIDX];
|
||||
double p2SWL = iConditions.swingLowBuffer[p2IDX];
|
||||
double p3SWL = iConditions.swingLowBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// Required Conditions ...
|
||||
|
||||
//
|
||||
bool isPeakBraked =
|
||||
zPeak == cPeak &&
|
||||
cPeak == pPeak &&
|
||||
(pPeak > p2Peak ||
|
||||
pPeak > p3Peak);
|
||||
|
||||
//
|
||||
bool isValeBraked =
|
||||
zVale == cVale &&
|
||||
cVale == pVale &&
|
||||
(pVale < p2Vale ||
|
||||
pVale < p3Vale);
|
||||
|
||||
//
|
||||
bool isSWHBraked =
|
||||
zSWH == cSWH &&
|
||||
cSWH == pSWH &&
|
||||
(pSWH > p2SWH ||
|
||||
pSWH > p3SWH);
|
||||
|
||||
//
|
||||
bool isSWLBraked =
|
||||
zSWL == cSWL &&
|
||||
cSWL == pSWL &&
|
||||
(pSWL < p2SWL ||
|
||||
pSWL < p3SWL);
|
||||
|
||||
//
|
||||
// Select Activated Pivot ...
|
||||
XBoxZone selectedPivot;
|
||||
bool hasPivots = HasChild(decisionPivots);
|
||||
int pivotsCount = ArraySize(decisionPivots);
|
||||
if (hasPivots)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < pivotsCount; i++)
|
||||
{
|
||||
//
|
||||
// Detect Type of Pivot ...
|
||||
ENUM_XCA_PIVOTS iType = GetPivotType(decisionPivots[i]);
|
||||
|
||||
//
|
||||
// Check Rejection of Block ...
|
||||
|
||||
//
|
||||
bool isBullishBraked =
|
||||
isBullish &&
|
||||
(isSWLBraked &&
|
||||
isValeBraked) &&
|
||||
iType == XCA_OB_BULL &&
|
||||
decisionPivots[i].IsBullish() &&
|
||||
zVale < decisionPivots[i].upper &&
|
||||
zVale > decisionPivots[i].lower;
|
||||
|
||||
//
|
||||
bool isBearishBraked =
|
||||
isBearish &&
|
||||
(isSWHBraked &&
|
||||
isPeakBraked) &&
|
||||
iType == XCA_OB_BEAR &&
|
||||
decisionPivots[i].IsBearish() &&
|
||||
zPeak < decisionPivots[i].upper &&
|
||||
zPeak > decisionPivots[i].lower;
|
||||
|
||||
//
|
||||
has = isBullishBraked ||
|
||||
isBearishBraked;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
selectedPivot = decisionPivots[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool hasSelectedPivot = selectedPivot.IsValid();
|
||||
|
||||
//
|
||||
// Draw Selected Pivot ...
|
||||
if (allowDraws &&
|
||||
hasSelectedPivot)
|
||||
{
|
||||
//
|
||||
// Draw Pivot ...
|
||||
XCBoxObject *iObj;
|
||||
|
||||
//
|
||||
has = helper.poiDrawer.DrawBox(
|
||||
selectedPivot,
|
||||
iObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
color iColor =
|
||||
isBullish
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
|
||||
//
|
||||
iObj.BoxWidth(2);
|
||||
iObj.BoxColor(iColor);
|
||||
iObj.BoxStyle(STYLE_SOLID);
|
||||
|
||||
//
|
||||
drawns.Add(iObj);
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(iObj);
|
||||
}
|
||||
|
||||
//
|
||||
// Parse Conditions ...
|
||||
|
||||
@@ -1622,11 +1838,15 @@ bool CanTriggerCond1(
|
||||
|
||||
//
|
||||
bool canTriggerLong =
|
||||
false;
|
||||
isBullish &&
|
||||
hasSelectedPivot &&
|
||||
selectedPivot.IsBullish();
|
||||
|
||||
//
|
||||
bool canTriggerShort =
|
||||
false;
|
||||
isBearish &&
|
||||
hasSelectedPivot &&
|
||||
selectedPivot.IsBearish();
|
||||
|
||||
//
|
||||
result = canTriggerLong ||
|
||||
@@ -1641,15 +1861,51 @@ bool CanTriggerCond1(
|
||||
|
||||
//
|
||||
// Trigger Stop Loss ...
|
||||
sl = 0;
|
||||
sl = isBullish
|
||||
? selectedPivot.lower
|
||||
: selectedPivot.upper;
|
||||
|
||||
//
|
||||
// Trigger Targets ...
|
||||
XTarget iTarget;
|
||||
if (canTriggerLong &&
|
||||
zBar.close < decisionZone.upper)
|
||||
{
|
||||
//
|
||||
iTarget.doRF = true;
|
||||
iTarget.target = decisionZone.upper;
|
||||
}
|
||||
if (canTriggerShort &&
|
||||
zBar.close > decisionZone.lower)
|
||||
{
|
||||
//
|
||||
iTarget.doRF = true;
|
||||
iTarget.target = decisionZone.lower;
|
||||
}
|
||||
|
||||
//
|
||||
if (iTarget.IsValid())
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iTarget,
|
||||
targets //
|
||||
);
|
||||
}
|
||||
iTarget.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
iConditions.Clean();
|
||||
selectedPivot.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -1692,6 +1948,7 @@ bool CanTriggerCond2(
|
||||
// Define Requirements ...
|
||||
|
||||
//
|
||||
bool has = false;
|
||||
string symbol = helper.GetSymbol();
|
||||
bool isBullish = decisionZone.IsBullish();
|
||||
bool isBearish = decisionZone.IsBearish();
|
||||
@@ -1726,28 +1983,31 @@ bool CanTriggerCond2(
|
||||
}
|
||||
|
||||
//
|
||||
bool has = false;
|
||||
// Select Activated Pivot ...
|
||||
XBoxZone selectedPivot;
|
||||
bool hasPivots = HasChild(decisionPivots);
|
||||
int pivotsCount = ArraySize(decisionPivots);
|
||||
|
||||
//
|
||||
// Select Activated Pivot ...
|
||||
if (hasPivots)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < pivotsCount; i++)
|
||||
{
|
||||
//
|
||||
// Detect Type of Pivot ...
|
||||
ENUM_XCA_PIVOTS iType = GetPivotType(decisionPivots[i]);
|
||||
|
||||
//
|
||||
// Check Rejection of Block ...
|
||||
has =
|
||||
isBullish
|
||||
? cBar.IsBullish() &&
|
||||
iType == XCA_OB_BULL &&
|
||||
decisionPivots[i].IsBullish() &&
|
||||
cBar.low < decisionPivots[i].upper &&
|
||||
cBar.low > decisionPivots[i].lower &&
|
||||
cBar.close > decisionPivots[i].upper
|
||||
: cBar.IsBearish() &&
|
||||
iType == XCA_OB_BEAR &&
|
||||
decisionPivots[i].IsBearish() &&
|
||||
cBar.high > decisionPivots[i].lower &&
|
||||
cBar.high < decisionPivots[i].upper &&
|
||||
@@ -1756,82 +2016,10 @@ bool CanTriggerCond2(
|
||||
{
|
||||
selectedPivot = decisionPivots[i];
|
||||
}
|
||||
|
||||
// //
|
||||
// // Draw Pivot ...
|
||||
// XCBoxObject *iObj;
|
||||
|
||||
// //
|
||||
// has = helper.poiDrawer.DrawBox(
|
||||
// decisionPivots[i],
|
||||
// iObj //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// drawns.Add(iObj);
|
||||
// }
|
||||
|
||||
// //
|
||||
// ZeroMemory(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Selected Pivot is Exists or not ...
|
||||
bool hasSelectedPivot = selectedPivot.IsValid();
|
||||
|
||||
//
|
||||
// Detect Liquidity For Selected Pivot ...
|
||||
double ssl = 0;
|
||||
double bsl = 0;
|
||||
bool hasSSL = false;
|
||||
bool hasBSL = false;
|
||||
if (hasSelectedPivot)
|
||||
{
|
||||
//
|
||||
// Required Info ...
|
||||
// int toIDX = selectedPivot.ToIndex();
|
||||
// int fromIDX = selectedPivot.FromIndex();
|
||||
|
||||
// //
|
||||
// // SSL ...
|
||||
// datetime sslTo = NULL;
|
||||
// datetime sslFrom = NULL;
|
||||
|
||||
// //
|
||||
// // BSL ...
|
||||
// datetime bslTo = NULL;
|
||||
// datetime bslFrom = NULL;
|
||||
|
||||
// //
|
||||
// // Loop ...
|
||||
// XOHCL iBar;
|
||||
// for (int i = fromIDX; i > toIDX; i--)
|
||||
// {
|
||||
// //
|
||||
// hasSSL =
|
||||
// ssl > 0 &&
|
||||
// IsValid(sslTo) &&
|
||||
// IsValid(sslFrom);
|
||||
|
||||
// //
|
||||
// hasBSL =
|
||||
// bsl > 0 &&
|
||||
// IsValid(bslTo) &&
|
||||
// IsValid(bslFrom);
|
||||
|
||||
// //
|
||||
// iBar.Clean();
|
||||
|
||||
// //
|
||||
// if (hasSSL && hasBSL)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Selected Pivot ...
|
||||
if (allowDraws &&
|
||||
@@ -1909,6 +2097,7 @@ bool CanTriggerCond2(
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
selectedPivot.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user