last works ...
This commit is contained in:
@@ -0,0 +1,792 @@
|
||||
|
||||
// =======================================
|
||||
// Temp Signaller:
|
||||
// =======================================
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy X ...
|
||||
*
|
||||
* @param bar: XOHCL, reference to Bar ...
|
||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool StrategyXHasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
// Read PBar ...
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
result = result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading pBar Patterns ...
|
||||
XPatternAnalysis pBarAnalysis;
|
||||
poiDetector.AnalyseBarPatterns(
|
||||
pBar,
|
||||
pBarAnalysis,
|
||||
structureConfig.barsAnalysisConfig //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Bar Patterns ...
|
||||
bool isPBarHasBullishPatterns =
|
||||
(bar.close > pBar.low ||
|
||||
bar.open > pBar.low) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BULLISH)
|
||||
//
|
||||
);
|
||||
bool isPBarHasBearishPatterns =
|
||||
(bar.close < pBar.high ||
|
||||
bar.open < pBar.high) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BEARISH)
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Do ...
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
result = HasDirection(dir);
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
result = ToBox(
|
||||
p2Bar,
|
||||
zone,
|
||||
dir,
|
||||
X_BAR_PATTERN_PINNED //
|
||||
);
|
||||
|
||||
//
|
||||
// Manage Stops ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Targets ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// Signaller 1:
|
||||
// =======================================
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy 1 ...
|
||||
*
|
||||
* @param bar: XOHCL, reference to Bar ...
|
||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Strategy1HasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
// Read PBar ...
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
result = result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading pBar Patterns ...
|
||||
XPatternAnalysis pBarAnalysis;
|
||||
poiDetector.AnalyseBarPatterns(
|
||||
pBar,
|
||||
pBarAnalysis,
|
||||
structureConfig.barsAnalysisConfig //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Bar Patterns ...
|
||||
bool isPBarHasBullishPatterns =
|
||||
(bar.close > pBar.low ||
|
||||
bar.open > pBar.low) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BULLISH)
|
||||
//
|
||||
);
|
||||
bool isPBarHasBearishPatterns =
|
||||
(bar.close < pBar.high ||
|
||||
bar.open < pBar.high) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BEARISH)
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double peak = fimaHelper.GetPeak(bar.Index());
|
||||
double vale = fimaHelper.GetVale(bar.Index());
|
||||
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||
double p2Peak = fimaHelper.GetPeak(p2Bar.Index());
|
||||
double p2Vale = fimaHelper.GetVale(p2Bar.Index());
|
||||
bool isPPeakOverLast = fimaHelper.IsPeakOverLast(pBar.Index());
|
||||
bool isPValeUnderLast = fimaHelper.IsValeUnderLast(pBar.Index());
|
||||
bool isP2PeakOverLast = fimaHelper.IsPeakOverLast(p2Bar.Index());
|
||||
bool isP2ValeUnderLast = fimaHelper.IsValeUnderLast(p2Bar.Index());
|
||||
bool isPeakOverLast = isPPeakOverLast ||
|
||||
isP2PeakOverLast;
|
||||
bool isValeUnderLast = isPValeUnderLast ||
|
||||
isP2ValeUnderLast;
|
||||
bool isP2ValeOverLast = pVale > p2Vale;
|
||||
bool isP2PeakUnderLast = pPeak < p2Peak;
|
||||
|
||||
//
|
||||
// Check PBar Close Over Under Fast Ma ...
|
||||
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
||||
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
||||
bool isFastOverLast = fimaHelper.GetMAFast(pBar.Index()) > fimaHelper.GetMAFast(p2Bar.Index());
|
||||
bool isFastUnderLast = fimaHelper.GetMAFast(pBar.Index()) < fimaHelper.GetMAFast(p2Bar.Index());
|
||||
|
||||
//
|
||||
// Force P2Bar is Pin Bar ...
|
||||
ENUM_X_DIRECTION p2Dir;
|
||||
bool isP2BarPinned = poiDetector.IsPinnedBar(
|
||||
p2Bar,
|
||||
p2Dir //
|
||||
);
|
||||
bool isP2BarBullishPinned =
|
||||
isP2BarPinned &&
|
||||
IsXBullish(p2Dir);
|
||||
bool isP2BarBearishPinned =
|
||||
isP2BarPinned &&
|
||||
IsXBearish(p2Dir);
|
||||
|
||||
//
|
||||
// Do ...
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
isFastOverLast &&
|
||||
isValeUnderLast &&
|
||||
!isP2PeakUnderLast &&
|
||||
isPBarCloseOverFast &&
|
||||
isP2BarBullishPinned &&
|
||||
isPBarHasBullishPatterns
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
isPeakOverLast &&
|
||||
isFastUnderLast &&
|
||||
!isP2ValeOverLast &&
|
||||
isPBarCloseUnderFast &&
|
||||
isP2BarBearishPinned &&
|
||||
isPBarHasBearishPatterns
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
result = HasDirection(dir);
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
result = ToBox(
|
||||
p2Bar,
|
||||
zone,
|
||||
dir,
|
||||
X_BAR_PATTERN_PINNED //
|
||||
);
|
||||
|
||||
//
|
||||
// Manage Stops ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
double entry = GetEntry(zone.symbol, zone.dir);
|
||||
double riskSide = zone.IsBullish() ? zone.lower : zone.upper;
|
||||
double risk = MathAbs(entry - riskSide);
|
||||
|
||||
//
|
||||
// Collecting Affected Zones ...
|
||||
XBoxZone tmps[];
|
||||
XBoxZone zones[];
|
||||
XBoxZone actedZones[];
|
||||
XBoxZone insideZones[];
|
||||
XBoxZone breakedZones[];
|
||||
XBoxZone affectedZones[];
|
||||
|
||||
//
|
||||
// Support and Resistances ...
|
||||
poiDetector.CollectZones(bar, tmps);
|
||||
Copy(tmps, zones, false);
|
||||
|
||||
//
|
||||
// OBS ...
|
||||
poiDetector.CollectOBs(bar, tmps);
|
||||
Copy(tmps, zones, false);
|
||||
|
||||
//
|
||||
// FVGs ...
|
||||
poiDetector.CollectFVGs(bar, tmps);
|
||||
Copy(tmps, zones, false);
|
||||
|
||||
//
|
||||
ExtractAffectedZones(bar, zones, affectedZones);
|
||||
|
||||
//
|
||||
// Acteds Zones ...
|
||||
ExtractActeds(bar, actedZones, affectedZones);
|
||||
|
||||
//
|
||||
// Inside Zones ...
|
||||
ExtractInsides(bar, insideZones, affectedZones);
|
||||
|
||||
//
|
||||
// Breaked Zones ...
|
||||
ExtractBreakeds(bar, breakedZones, affectedZones);
|
||||
|
||||
//
|
||||
// Draw Affected Zones ...
|
||||
if (HasChild(affectedZones))
|
||||
{
|
||||
//
|
||||
UpdateToTime(affectedZones, bar.time);
|
||||
poiDrawer.DrawZones(affectedZones, structureDrawConfig.drawConfig);
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Acted Zones ...
|
||||
// if (HasChild(actedZones))
|
||||
// {
|
||||
// poiDrawer.DrawZones(actedZones, structureDrawConfig.drawConfig);
|
||||
// }
|
||||
|
||||
//
|
||||
// Draw Inside Zones ...
|
||||
// if (HasChild(insideZones))
|
||||
// {
|
||||
// poiDrawer.DrawZones(insideZones, structureDrawConfig.drawConfig);
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Draw Breaked Zones ...
|
||||
// if (HasChild(breakedZones))
|
||||
// {
|
||||
// poiDrawer.DrawZones(breakedZones, structureDrawConfig.drawConfig);
|
||||
// }
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
XClean(tmps);
|
||||
XClean(zones);
|
||||
XClean(actedZones);
|
||||
XClean(insideZones);
|
||||
XClean(breakedZones);
|
||||
XClean(affectedZones);
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.to = bar.time;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
zone,
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Targets ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// Signaller 2:
|
||||
// =======================================
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy 1 ...
|
||||
*
|
||||
* @param bar: XOHCL, reference to Bar ...
|
||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Strategy2HasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
// Read PBar ...
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
pBar.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Conditions ...
|
||||
int pullBackStartBar = -1;
|
||||
bool isPullBack = result &&
|
||||
poiDetector.IsPullbackPattern(
|
||||
pBar,
|
||||
zone,
|
||||
dir,
|
||||
2,
|
||||
false // Force Break ...
|
||||
);
|
||||
bool isPullbackBullish = isPullBack &&
|
||||
IsXBullish(dir);
|
||||
bool isPullbackBearish = isPullBack &&
|
||||
IsXBearish(dir);
|
||||
if (isPullBack)
|
||||
{
|
||||
pullBackStartBar = zone.FromIndex();
|
||||
}
|
||||
|
||||
//
|
||||
// Reading HK Bond ...
|
||||
|
||||
//
|
||||
double pHKBondUpper = fimaHelper.GetHKBondUpper(pBar.Index());
|
||||
double pHKBondLower = fimaHelper.GetHKBondLower(pBar.Index());
|
||||
int overHKBondUpperCount = fimaHelper.CountOverHKBondUpper(pullBackStartBar, X_PRICE_LOW);
|
||||
int underHKBondLowerCount = fimaHelper.CountUnderHKBondLower(pullBackStartBar, X_PRICE_HIGH);
|
||||
|
||||
//
|
||||
// Reading PV Requirements ...
|
||||
|
||||
//
|
||||
int lastPeakOverLastIDX = -1;
|
||||
int lastValeUnderLastIDX = -1;
|
||||
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||
int samePeaks = fimaHelper.CountSamePeaks(pBar.Index());
|
||||
int sameVales = fimaHelper.CountSameVales(pBar.Index());
|
||||
fimaHelper.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
|
||||
fimaHelper.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
|
||||
|
||||
//
|
||||
// Reading pBar Patterns ...
|
||||
XPatternAnalysis pBarAnalysis;
|
||||
poiDetector.AnalyseBarPatterns(
|
||||
pBar,
|
||||
pBarAnalysis,
|
||||
structureConfig.barsAnalysisConfig //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Bar Patterns ...
|
||||
bool isPBarHasBullishPatterns =
|
||||
(bar.close > pBar.low ||
|
||||
bar.open > pBar.low) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BULLISH)
|
||||
//
|
||||
);
|
||||
bool isPBarHasBearishPatterns =
|
||||
(bar.close < pBar.high ||
|
||||
bar.open < pBar.high) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BEARISH)
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Check PBar Close Over Under Fast Ma ...
|
||||
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
||||
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
||||
|
||||
//
|
||||
// Try To Find Affected Zone ...
|
||||
|
||||
//
|
||||
// Collecting Zones ...
|
||||
XBoxZone zones[];
|
||||
XBoxZone affectedZones[];
|
||||
XBoxZone affectedZonesBullish[];
|
||||
XBoxZone affectedZonesBearish[];
|
||||
int zonesCount = poiDetector.CollectZones(
|
||||
pBar,
|
||||
zones, //
|
||||
5, // Zones Loopback ...
|
||||
3 // Zones Validation Length ...
|
||||
// Required Zones ...
|
||||
// Loopback ...
|
||||
);
|
||||
int affectedZonesCount = ExtractAffectedZones(
|
||||
pBar,
|
||||
zones,
|
||||
affectedZones //
|
||||
);
|
||||
int affectedZonesBullishCount = ExtractByDirection(
|
||||
affectedZonesBullish,
|
||||
affectedZones,
|
||||
X_DIRECTION_BULLISH //
|
||||
);
|
||||
int affectedZonesBearishCount = ExtractByDirection(
|
||||
affectedZonesBearish,
|
||||
affectedZones,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
int insideBullishIDX = -1;
|
||||
int insideBearishIDX = -1;
|
||||
bool hasBullishInside =
|
||||
pBar.IsBullish() &&
|
||||
HasInside(
|
||||
insideBullishIDX,
|
||||
pBar,
|
||||
affectedZonesBullish //
|
||||
);
|
||||
bool hasBearishInside =
|
||||
pBar.IsBearish() &&
|
||||
HasInside(
|
||||
insideBearishIDX,
|
||||
pBar,
|
||||
affectedZonesBearish //
|
||||
);
|
||||
|
||||
//
|
||||
// Do ...
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
hasBullishInside &&
|
||||
isPullbackBullish &&
|
||||
isPBarHasBullishPatterns &&
|
||||
fimaHelper.IsSarBullish(pBar.Index()) &&
|
||||
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
|
||||
pVale <= affectedZonesBullish[insideBullishIDX].upper)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
hasBearishInside &&
|
||||
isPullbackBearish &&
|
||||
isPBarHasBearishPatterns &&
|
||||
fimaHelper.IsSarBearish(pBar.Index()) &&
|
||||
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
|
||||
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
affectedZonesBullish[insideBullishIDX],
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
affectedZonesBearish[insideBearishIDX],
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
result = HasDirection(dir);
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
if (isBullish)
|
||||
{
|
||||
zone = affectedZonesBullish[insideBullishIDX];
|
||||
}
|
||||
else
|
||||
{
|
||||
zone = affectedZonesBearish[insideBearishIDX];
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Targets ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
pBar.Clean();
|
||||
XClean(zones);
|
||||
pBarAnalysis.Clean();
|
||||
XClean(affectedZones);
|
||||
XClean(affectedZonesBullish);
|
||||
XClean(affectedZonesBearish);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -1,97 +1,295 @@
|
||||
|
||||
// //
|
||||
// isBullish =
|
||||
// //
|
||||
// // Vales Same ...
|
||||
// sameVales >= 7 &&
|
||||
// //
|
||||
// // PBar Patterns ...
|
||||
// isBarPatternsPassed &&
|
||||
// isPBarCloseOverFast &&
|
||||
// //
|
||||
// // Validate PullBack based on HK Bond ...
|
||||
// isPullbackBullish &&
|
||||
// pBar.close > pHKBondLower;
|
||||
// //
|
||||
// isBullish =
|
||||
// //
|
||||
// // Vales Same ...
|
||||
// sameVales >= 7 &&
|
||||
// //
|
||||
// // PBar Patterns ...
|
||||
// isBarPatternsPassed &&
|
||||
// isPBarCloseOverFast &&
|
||||
// //
|
||||
// // Validate PullBack based on HK Bond ...
|
||||
// isPullbackBullish &&
|
||||
// pBar.close > pHKBondLower;
|
||||
|
||||
//
|
||||
// poiDrawer.DrawPatternAnalysis(
|
||||
// pBarAnalysis,
|
||||
// structureDrawConfig.barAnalysisDrawConfig //
|
||||
// );
|
||||
//
|
||||
// poiDrawer.DrawPatternAnalysis(
|
||||
// pBarAnalysis,
|
||||
// structureDrawConfig.barAnalysisDrawConfig //
|
||||
// );
|
||||
|
||||
// //
|
||||
// if (IsValidSize(zonesCount))
|
||||
// {
|
||||
// //
|
||||
// poiDrawer.DrawZones(
|
||||
// zones,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
// }
|
||||
// //
|
||||
// if (IsValidSize(zonesCount))
|
||||
// {
|
||||
// //
|
||||
// poiDrawer.DrawZones(
|
||||
// zones,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (IsValidSize(affectedZonesCount))
|
||||
// {
|
||||
// //
|
||||
// poiDrawer.DrawZones(
|
||||
// affectedZones,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
// }
|
||||
// //
|
||||
// if (IsValidSize(affectedZonesCount))
|
||||
// {
|
||||
// //
|
||||
// poiDrawer.DrawZones(
|
||||
// affectedZones,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
// }
|
||||
|
||||
//
|
||||
// poiDrawer.DrawZones(
|
||||
// affectedZonesBullish,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
//
|
||||
// poiDrawer.DrawZones(
|
||||
// affectedZonesBullish,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
|
||||
// //
|
||||
// poiDrawer.DrawZones(
|
||||
// affectedZonesBearish,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
// //
|
||||
// poiDrawer.DrawZones(
|
||||
// affectedZonesBearish,
|
||||
// structureDrawConfig.drawConfig //
|
||||
// );
|
||||
|
||||
// //
|
||||
// // Update POI Zones ...
|
||||
// ENUM_X_DETECTOR_ZONE_ACTION zoneActions[];
|
||||
// poiDetector.UpdateZones(
|
||||
// iBar,
|
||||
// zoneActions //
|
||||
// // Validation Length ...
|
||||
// // Required Zones ...
|
||||
// // Loopback ...
|
||||
// );
|
||||
|
||||
//
|
||||
// Retrieve Conditions ...
|
||||
// conditions.Clean();
|
||||
// has = fimaHelper.GetConditions(
|
||||
// conditions,
|
||||
// barIndex,
|
||||
// 10 // Loopback ...
|
||||
// );
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// iBar.Clean();
|
||||
// conditions.Clean();
|
||||
|
||||
|
||||
// //
|
||||
// // Update POI Zones ...
|
||||
// ENUM_X_DETECTOR_ZONE_ACTION zoneActions[];
|
||||
// poiDetector.UpdateZones(
|
||||
// iBar,
|
||||
// zoneActions //
|
||||
// // Validation Length ...
|
||||
// // Required Zones ...
|
||||
// // Loopback ...
|
||||
// );
|
||||
// //
|
||||
// return;
|
||||
// }
|
||||
|
||||
//
|
||||
// structure.Clean();
|
||||
// poiDetector.AnalyseMarket(
|
||||
// structure,
|
||||
// structureConfig,
|
||||
// barIndex //
|
||||
// );
|
||||
// poiDrawer.drawnObjects.Clear();
|
||||
// poiDrawer.DrawMarketStructure(
|
||||
// structure,
|
||||
// structureDrawConfig //
|
||||
// );
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy X ...
|
||||
*
|
||||
* @param bar: XOHCL, reference to Bar ...
|
||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool StrategyXHasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
XOHCL continuationalBar;
|
||||
XBoxZone continuationalZones[];
|
||||
|
||||
//
|
||||
// Read PBar ...
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
result = result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
// Retrieve Conditions ...
|
||||
// conditions.Clean();
|
||||
// has = fimaHelper.GetConditions(
|
||||
// conditions,
|
||||
// barIndex,
|
||||
// 10 // Loopback ...
|
||||
// );
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// iBar.Clean();
|
||||
// conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
// //
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Reading pBar Patterns ...
|
||||
XPatternAnalysis pBarAnalysis;
|
||||
poiDetector.AnalyseBarPatterns(
|
||||
pBar,
|
||||
pBarAnalysis,
|
||||
structureConfig.barsAnalysisConfig //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Continuational Pullback ...
|
||||
bool isContinuationPullBack = poiDetector.IsContinuationPullbackPattern(
|
||||
pBar,
|
||||
zone,
|
||||
continuationalZones,
|
||||
dir,
|
||||
continuationalBar,
|
||||
3, // Continuational Length ...
|
||||
true, // Force Continuational Loopback Has Zones ...
|
||||
true, // Force Continuational Loopback Has Patterns ...
|
||||
2, // Pullback Length ...
|
||||
false // Force Pullback Break ...
|
||||
);
|
||||
|
||||
//
|
||||
// Do ...
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
IsXBullish(dir) &&
|
||||
isContinuationPullBack &&
|
||||
continuationalBar.GetUp() < pBar.GetDown() &&
|
||||
true
|
||||
// isPBarHasBullishPatterns
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
IsXBearish(dir) &&
|
||||
isContinuationPullBack &&
|
||||
continuationalBar.GetDown() > pBar.GetUp() &&
|
||||
true
|
||||
// isPBarHasBearishPatterns
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
// structure.Clean();
|
||||
// poiDetector.AnalyseMarket(
|
||||
// structure,
|
||||
// structureConfig,
|
||||
// barIndex //
|
||||
// );
|
||||
// poiDrawer.drawnObjects.Clear();
|
||||
// poiDrawer.DrawMarketStructure(
|
||||
// structure,
|
||||
// structureDrawConfig //
|
||||
// );
|
||||
result = HasDirection(dir);
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// zone.to = bar.time;
|
||||
// poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||
|
||||
//
|
||||
// Draw Continuational Zones ...
|
||||
UpdateToTime(continuationalZones, bar.time);
|
||||
poiDrawer.DrawZones(continuationalZones, structureDrawConfig.drawConfig);
|
||||
|
||||
//
|
||||
zone.Clean();
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
if (isBullish)
|
||||
{
|
||||
idx = GetHighestBelow(bar.GetDown(), continuationalZones);
|
||||
}
|
||||
else
|
||||
{
|
||||
idx = GetLowestAbove(bar.GetUp(), continuationalZones);
|
||||
}
|
||||
result = IsValidIndex(idx);
|
||||
if (result)
|
||||
{
|
||||
zone = continuationalZones[idx];
|
||||
}
|
||||
|
||||
//
|
||||
if (zone.IsValid())
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.bullishColor = clrYellow;
|
||||
iConfig.bearishColor = clrYellow;
|
||||
poiDrawer.DrawZones(continuationalZones, iConfig);
|
||||
}
|
||||
|
||||
//
|
||||
// Manage Stops ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Targets ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
continuationalBar.Clean();
|
||||
XClean(continuationalZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user