last works ...
This commit is contained in:
@@ -1062,12 +1062,14 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
|
||||
//
|
||||
// Validator Flags ...
|
||||
bool validateByZones = true;
|
||||
bool validateByZones = false;
|
||||
bool validateHasLiquidity = true;
|
||||
bool validateByXFIMARejected = true;
|
||||
bool validateByXFIMAMACrossed = true;
|
||||
bool validateByCyclesMATresnding = true;
|
||||
bool validateByHasDirectionalZones = true;
|
||||
bool validateByHasInDirectionalZones = true;
|
||||
bool validateByHasDirectionalZones = false;
|
||||
bool validateByHasInDirectionalZones = false;
|
||||
bool validateByInDirectionalZonesPlacement = false;
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
@@ -1078,6 +1080,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
XOHCL p3Bar;
|
||||
XBoxZone zones[];
|
||||
double rejecteds[];
|
||||
XBoxZone liquidity;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
XBoxZone directionalZone;
|
||||
@@ -1180,6 +1183,137 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
//
|
||||
result = isBullish || isBearish;
|
||||
|
||||
//
|
||||
// Prepare Zone Based on Started Conditions ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
dir = hasBullishBar
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
if (isPBarIsPinBar)
|
||||
{
|
||||
//
|
||||
result = ToBox(
|
||||
pBar,
|
||||
zone,
|
||||
dir,
|
||||
X_BAR_PATTERN_PINNED //
|
||||
);
|
||||
}
|
||||
else if (isPBarSignalKeyBar)
|
||||
{
|
||||
//
|
||||
result = ToBox(
|
||||
pBar,
|
||||
zone,
|
||||
dir,
|
||||
X_BAR_PATTERN_SIGNALKEY //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
// Forward Zone to Break By Shadow ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
XOHCL tmpBar;
|
||||
int idx = zone.FromIndex() - 1;
|
||||
bool canContinue = true;
|
||||
while (canContinue)
|
||||
{
|
||||
//
|
||||
idx++;
|
||||
tmpBar.Clean();
|
||||
canContinue = bar.BarAt(idx, tmpBar);
|
||||
if (!canContinue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
canContinue =
|
||||
isBullish
|
||||
? tmpBar.low > zone.lower
|
||||
: tmpBar.high < zone.upper;
|
||||
if (!canContinue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
zone.from = tmpBar.time;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Liquidity Zone ...
|
||||
if (zone.IsValid() && tmpBar.IsValid())
|
||||
{
|
||||
//
|
||||
liquidity = zone;
|
||||
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
liquidity.upper = zone.lower;
|
||||
liquidity.lower = tmpBar.low;
|
||||
}
|
||||
else if (isBearish)
|
||||
{
|
||||
//
|
||||
liquidity.lower = zone.upper;
|
||||
liquidity.upper = tmpBar.high;
|
||||
}
|
||||
|
||||
//
|
||||
liquidity.type = "XLiquidoty";
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
tmpBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Reset Flags ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
result = false;
|
||||
isBullish = false;
|
||||
isBearish = false;
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate By Liquidity Zone ...
|
||||
if (result && validateHasLiquidity)
|
||||
{
|
||||
//
|
||||
result = result &&
|
||||
liquidity.IsValid();
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
result = false;
|
||||
isBullish = false;
|
||||
isBearish = false;
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate By XFIMA Rejections ...
|
||||
if (result && validateByXFIMARejected)
|
||||
@@ -1256,11 +1390,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
isCyclesMABearish;
|
||||
|
||||
//
|
||||
// Summarize Result ...
|
||||
result = isBullish || isBearish;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect a Zone ...
|
||||
// Validate by Has a Zone (FVG, Support, Resistance) ...
|
||||
if (result && validateByZones)
|
||||
{
|
||||
@@ -1296,7 +1430,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
result = result && IsValidSize(zonesCount);
|
||||
|
||||
//
|
||||
// Validate By Directional Zones Existance ...
|
||||
// Validate By Direction Zones Existance ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
@@ -1315,100 +1449,105 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
// Select Directional Zone ...
|
||||
int idx = -1;
|
||||
if (isBullish && IsValidSize(bullishCount))
|
||||
{
|
||||
idx = GetYoungest(bullishZones);
|
||||
}
|
||||
else if (isBearish && IsValidSize(bearishCount))
|
||||
{
|
||||
idx = GetYoungest(bearishZones);
|
||||
}
|
||||
if (IsValidIndex(idx))
|
||||
{
|
||||
if (isBullish)
|
||||
{
|
||||
directionalZone = bullishZones[idx];
|
||||
}
|
||||
else if (isBearish)
|
||||
{
|
||||
directionalZone = bearishZones[idx];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Select Indirectional Zone ...
|
||||
idx = -1;
|
||||
if (isBullish && IsValidSize(bearishCount))
|
||||
{
|
||||
idx = GetYoungest(bearishZones);
|
||||
}
|
||||
else if (isBearish && IsValidSize(bullishCount))
|
||||
{
|
||||
idx = GetYoungest(bullishZones);
|
||||
}
|
||||
if (IsValidIndex(idx))
|
||||
{
|
||||
if (isBullish)
|
||||
{
|
||||
inDirectionalZone = bearishZones[idx];
|
||||
}
|
||||
else if (isBearish)
|
||||
{
|
||||
inDirectionalZone = bullishZones[idx];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate by Has Directional Zones ...
|
||||
if (result && validateByHasDirectionalZones)
|
||||
{
|
||||
//
|
||||
// Validate by Existance ...
|
||||
result =
|
||||
result &&
|
||||
(isBullish
|
||||
? IsValidSize(bullishCount)
|
||||
: IsValidSize(bearishCount));
|
||||
|
||||
//
|
||||
// Select Directional Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
int idx = -1;
|
||||
if (isBullish)
|
||||
{
|
||||
idx = GetYoungest(bullishZones);
|
||||
}
|
||||
else
|
||||
{
|
||||
idx = GetYoungest(bearishZones);
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(idx);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
directionalZone = bullishZones[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
directionalZone = bearishZones[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result = directionalZone.IsValid();
|
||||
result = result && directionalZone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Validate by Has InDirectional Zones ...
|
||||
if (result && validateByHasInDirectionalZones)
|
||||
{
|
||||
result = result && inDirectionalZone.IsValid();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Directional and In Directional Zones Distance ...
|
||||
if (result && validateByInDirectionalZonesPlacement)
|
||||
{
|
||||
//
|
||||
double points = GetPoints(bar.symbol);
|
||||
double slAddition =
|
||||
slAdditionDistance > 0
|
||||
? slAdditionDistance * points
|
||||
: 0;
|
||||
double spread = GetSpread(bar.symbol);
|
||||
double entry = GetEntry(bar.symbol, dir);
|
||||
double sl = isBullish
|
||||
? zone.lower - slAddition
|
||||
: zone.upper + slAddition;
|
||||
double risk = MathAbs(entry - sl);
|
||||
double reward = risk * defaultSignalR2R;
|
||||
double tp = isBullish
|
||||
? entry + reward
|
||||
: entry - reward;
|
||||
|
||||
//
|
||||
if (inDirectionalZone.IsValid())
|
||||
{
|
||||
//
|
||||
// Validate by Existance ...
|
||||
result =
|
||||
result &&
|
||||
(isBullish
|
||||
? IsValidSize(bearishCount)
|
||||
: IsValidSize(bullishCount));
|
||||
isBullish =
|
||||
isBullish &&
|
||||
tp < inDirectionalZone.lower &&
|
||||
entry < inDirectionalZone.lower;
|
||||
|
||||
//
|
||||
// Select InDirectional Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
int idx = -1;
|
||||
if (isBullish)
|
||||
{
|
||||
idx = GetYoungest(bearishZones);
|
||||
}
|
||||
else
|
||||
{
|
||||
idx = GetYoungest(bullishZones);
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(idx);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
inDirectionalZone = bearishZones[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
inDirectionalZone = bullishZones[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
isBearish =
|
||||
isBearish &&
|
||||
tp > inDirectionalZone.upper &&
|
||||
entry > inDirectionalZone.upper;
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result = inDirectionalZone.IsValid();
|
||||
result = isBullish || isBearish;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1435,6 +1574,46 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
if (result && validateByXFIMAMACrossed)
|
||||
{
|
||||
//
|
||||
bool isBarHasBullishCross = fimaParser.IsMAFastCrossedOverLast(bar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedOverSlow(bar.Index());
|
||||
bool isPBarHasBullishCross = fimaParser.IsMAFastCrossedOverLast(pBar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedOverSlow(pBar.Index());
|
||||
bool isP2BarHasBullishCross = fimaParser.IsMAFastCrossedOverLast(p2Bar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedOverSlow(p2Bar.Index());
|
||||
bool isP3BarHasBullishCross = fimaParser.IsMAFastCrossedOverLast(p3Bar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedOverSlow(p3Bar.Index());
|
||||
bool hasBullishCross = isBarHasBullishCross ||
|
||||
isPBarHasBullishCross ||
|
||||
isP2BarHasBullishCross ||
|
||||
isP3BarHasBullishCross;
|
||||
|
||||
//
|
||||
bool isBarHasBearishCross = fimaParser.IsMAFastCrossedUnderLast(bar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedUnderSlow(bar.Index());
|
||||
bool isPBarHasBearishCross = fimaParser.IsMAFastCrossedUnderLast(pBar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedUnderSlow(pBar.Index());
|
||||
bool isP2BarHasBearishCross = fimaParser.IsMAFastCrossedUnderLast(p2Bar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedUnderSlow(p2Bar.Index());
|
||||
bool isP3BarHasBearishCross = fimaParser.IsMAFastCrossedUnderLast(p3Bar.Index()) &&
|
||||
fimaParser.IsMAFastCrossedUnderSlow(p3Bar.Index());
|
||||
bool hasBearishCross = isBarHasBearishCross ||
|
||||
isPBarHasBearishCross ||
|
||||
isP2BarHasBearishCross ||
|
||||
isP3BarHasBearishCross;
|
||||
|
||||
//
|
||||
isBullish =
|
||||
isBullish &&
|
||||
hasBullishCross;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
isBearish &&
|
||||
hasBearishCross;
|
||||
|
||||
//
|
||||
// Summarize Result ...
|
||||
result = isBullish || isBearish;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1487,19 +1666,90 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
poiDrawer.DrawZones(zones, iConfig);
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Crossed Trends ...
|
||||
if (validateByXFIMAMACrossed)
|
||||
{
|
||||
//
|
||||
XTrend fastTrend;
|
||||
XTrend slowTrend;
|
||||
bool has = fastTrend.Init(
|
||||
p2Bar.symbol,
|
||||
p2Bar.period,
|
||||
bar.time,
|
||||
fimaHelper.GetMAFast(p2Bar.Index()),
|
||||
p2Bar.time,
|
||||
fimaHelper.GetMAFast(bar.Index()),
|
||||
bar.time //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
poiDrawer.DrawTrendLine(fastTrend, iConfig);
|
||||
}
|
||||
has = slowTrend.Init(
|
||||
p2Bar.symbol,
|
||||
p2Bar.period,
|
||||
bar.time,
|
||||
fimaHelper.GetMASlow(p2Bar.Index()),
|
||||
p2Bar.time,
|
||||
fimaHelper.GetMASlow(bar.Index()),
|
||||
bar.time //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
poiDrawer.DrawTrendLine(slowTrend, iConfig);
|
||||
}
|
||||
fastTrend.Clean();
|
||||
slowTrend.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Liquidity Zone ...
|
||||
if (liquidity.IsValid())
|
||||
{
|
||||
//
|
||||
iConfig.bullishColor = clrGreen;
|
||||
iConfig.bearishColor = clrRed;
|
||||
poiDrawer.DrawZone(liquidity, iConfig);
|
||||
iConfig.bullishColor = structureDrawConfig.drawConfig.bullishColor;
|
||||
iConfig.bearishColor = structureDrawConfig.drawConfig.bearishColor;
|
||||
}
|
||||
|
||||
//
|
||||
// Specified Zones ...
|
||||
XPOIDrawConfig iSConfig = iConfig;
|
||||
iSConfig.zonesWidth = 2;
|
||||
iSConfig.bullishColor = clrYellow;
|
||||
iSConfig.zonesStyle = STYLE_DASHDOTDOT;
|
||||
iSConfig.bearishColor = clrDarkOrange;
|
||||
|
||||
//
|
||||
// Draw Zone ...
|
||||
if (zone.IsValid())
|
||||
{
|
||||
//
|
||||
iSConfig.zonesStyle = STYLE_SOLID;
|
||||
poiDrawer.DrawZone(zone, iSConfig);
|
||||
iSConfig.zonesStyle = STYLE_DASHDOTDOT;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Directional Zone ...
|
||||
if (directionalZone.IsValid())
|
||||
{
|
||||
poiDrawer.DrawZone(directionalZone, iConfig);
|
||||
poiDrawer.DrawZone(directionalZone, iSConfig);
|
||||
}
|
||||
|
||||
//
|
||||
// Draw InDirectional Zone ...
|
||||
if (inDirectionalZone.IsValid())
|
||||
{
|
||||
poiDrawer.DrawZone(inDirectionalZone, iConfig);
|
||||
poiDrawer.DrawZone(inDirectionalZone, iSConfig);
|
||||
}
|
||||
|
||||
//
|
||||
iConfig.Clean();
|
||||
iSConfig.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1509,9 +1759,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
DebugBreak();
|
||||
|
||||
//
|
||||
result = false;
|
||||
isBullish = false;
|
||||
isBearish = false;
|
||||
// result = false;
|
||||
// isBullish = false;
|
||||
// isBearish = false;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1536,72 +1786,21 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
// Since Zone Prepared in Above Steps ...
|
||||
// here we only Validate it ...
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Draws ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
XPatternAnalysisDrawConfig iPatternsConfig = structureDrawConfig.barAnalysisDrawConfig;
|
||||
iConfig.trendRayLeft = false;
|
||||
iConfig.trendRayRight = false;
|
||||
|
||||
//
|
||||
// Draw Zone ...
|
||||
if (zone.IsValid())
|
||||
// Replace Zones SL Edge based on Sweeped Liquidity ...
|
||||
if (liquidity.IsValid())
|
||||
{
|
||||
//
|
||||
iConfig.zonesStyle = STYLE_DASHDOT;
|
||||
iConfig.bullishColor = clrYellow;
|
||||
iConfig.bearishColor = clrDarkOrange;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(zone, iConfig);
|
||||
if (isBullish)
|
||||
{
|
||||
zone.lower = liquidity.lower;
|
||||
}
|
||||
else if (isBearish)
|
||||
{
|
||||
zone.upper = liquidity.upper;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// poiDrawer.DrawZone(mcPVZone, iConfig);
|
||||
// poiDrawer.DrawZone(lcPVZone, iConfig);
|
||||
// poiDrawer.DrawZone(hcPVZone, iConfig);
|
||||
|
||||
//
|
||||
// poiDrawer.DrawZone(pinBarZone, iConfig);
|
||||
// poiDrawer.DrawZone(pullbackZone, iConfig);
|
||||
// poiDrawer.DrawTrendLine(pinBarZoneTrend, iConfig);
|
||||
|
||||
//
|
||||
poiDrawer.DrawPatternAnalysis(pBarPatterns, iPatternsConfig);
|
||||
poiDrawer.DrawPatternAnalysis(p2BarPatterns, iPatternsConfig);
|
||||
poiDrawer.DrawPatternAnalysis(p3BarPatterns, iPatternsConfig);
|
||||
|
||||
//
|
||||
// if (hasATRBox)
|
||||
// {
|
||||
// poiDrawer.DrawZone(atrBox, iConfig);
|
||||
// }
|
||||
|
||||
//
|
||||
// if (hasDoublePatterns)
|
||||
// {
|
||||
// //
|
||||
// poiDrawer.DrawPatternAnalysis(iPatterns, iPatternsConfig);
|
||||
// poiDrawer.DrawPatternAnalysis(iPPatterns, iPatternsConfig);
|
||||
// }
|
||||
|
||||
//
|
||||
iConfig.Clean();
|
||||
iPatternsConfig.Clean();
|
||||
|
||||
//
|
||||
DebugBreak();
|
||||
|
||||
// //
|
||||
// result = false;
|
||||
// isBullish = false;
|
||||
// isBearish = false;
|
||||
// zone.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1624,6 +1823,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
p3Bar.Clean();
|
||||
XClean(zones);
|
||||
XClean(rejecteds);
|
||||
liquidity.Clean();
|
||||
pBarPatterns.Clean();
|
||||
p2BarPatterns.Clean();
|
||||
p3BarPatterns.Clean();
|
||||
|
||||
Reference in New Issue
Block a user