last works ...
This commit is contained in:
@@ -349,8 +349,8 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
}
|
||||
|
||||
//
|
||||
// Strategy 1 ...
|
||||
has = Strategy1HasSignal(
|
||||
// Strategy X ...
|
||||
has = StrategyXHasSignal(
|
||||
iBar,
|
||||
iZone,
|
||||
iTargets,
|
||||
@@ -465,18 +465,16 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
// Implementing Strategies ...
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy 1 ...
|
||||
* 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 ...
|
||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Strategy1HasSignal(
|
||||
bool StrategyXHasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
@@ -487,214 +485,41 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
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 //
|
||||
result = Strategy2HasSignal(
|
||||
bar,
|
||||
zone,
|
||||
targets,
|
||||
dir //
|
||||
);
|
||||
|
||||
//
|
||||
// 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 pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||
double pVale = fimaHelper.GetVale(pBar.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;
|
||||
|
||||
//
|
||||
// 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 &&
|
||||
isPBarCloseOverFast &&
|
||||
isP2BarBullishPinned &&
|
||||
isPBarHasBullishPatterns
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
isPeakOverLast &&
|
||||
isFastUnderLast &&
|
||||
isPBarCloseUnderFast &&
|
||||
isP2BarBearishPinned &&
|
||||
isPBarHasBearishPatterns
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
result = HasDirection(dir);
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
result = ToBox(
|
||||
p2Bar,
|
||||
result = Strategy3HasSignal(
|
||||
bar,
|
||||
zone,
|
||||
dir,
|
||||
X_BAR_PATTERN_PINNED //
|
||||
targets,
|
||||
dir //
|
||||
);
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.to = bar.time;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
zone,
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Targets ...
|
||||
if (result)
|
||||
{
|
||||
Print("Salam");
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy 1 ...
|
||||
* Check Bar Has Signal Based on Strategy 3 ...
|
||||
*
|
||||
* @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 ...
|
||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
@@ -980,6 +805,322 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy 3 ...
|
||||
*
|
||||
* @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 Strategy3HasSignal(
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user