Complete Strategy 4 Signals ...
This commit is contained in:
@@ -2190,9 +2190,13 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
//
|
//
|
||||||
ValidateBoxes(
|
ValidateBoxes(
|
||||||
_zones,
|
_zones,
|
||||||
bar.Index() //
|
bar.Index() // Bars Length ...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
UpdateToTime(_zones, bar.time);
|
||||||
|
RemoveBreakedZones(_zones, X_PRICE_CLOSE);
|
||||||
|
|
||||||
//
|
//
|
||||||
result = HasChild(_zones);
|
result = HasChild(_zones);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -4654,6 +4654,57 @@ bool ToBox(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts Order Flow to Zone ...
|
||||||
|
*
|
||||||
|
* @param zone: XBoxZone, reference to holds result ...
|
||||||
|
* @param orderFlow: XBoxZone, collection reference to provides order flow ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool ToBox(
|
||||||
|
XBoxZone &zone,
|
||||||
|
XBoxZone &orderFlow[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
zone.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = HasChild(orderFlow);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
zone = orderFlow[0];
|
||||||
|
int idx = GetHighest(orderFlow);
|
||||||
|
if (IsValidIndex(idx))
|
||||||
|
{
|
||||||
|
zone.upper = orderFlow[idx].upper;
|
||||||
|
}
|
||||||
|
idx = GetLowest(orderFlow);
|
||||||
|
if (IsValidIndex(idx))
|
||||||
|
{
|
||||||
|
zone.lower = orderFlow[idx].lower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
zone.type = "XOrderFlowP";
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Bar to OB Box ...
|
* Converts a Bar to OB Box ...
|
||||||
*
|
*
|
||||||
@@ -4993,7 +5044,10 @@ bool ToResistanceBox(
|
|||||||
*
|
*
|
||||||
* @return ( int )
|
* @return ( int )
|
||||||
*/
|
*/
|
||||||
int RemoveBreakedZones(XBoxZone &source[])
|
int RemoveBreakedZones(
|
||||||
|
XBoxZone &source[],
|
||||||
|
bool forceBreak = false //
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@@ -5014,22 +5068,37 @@ int RemoveBreakedZones(XBoxZone &source[])
|
|||||||
tmps //
|
tmps //
|
||||||
);
|
);
|
||||||
XClean(source);
|
XClean(source);
|
||||||
|
XOHCL tmpBars[];
|
||||||
|
int breakerBars = 0;
|
||||||
while (HasChild(tmps))
|
while (HasChild(tmps))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
iZone.Clean();
|
iZone.Clean();
|
||||||
iZone = tmps[0];
|
iZone = tmps[0];
|
||||||
ArrayRemove(tmps, 0, 1);
|
ArrayRemove(tmps, 0, 1);
|
||||||
has = iZone.IsValid() &&
|
has = IsXValid(iZone.breakAt);
|
||||||
!IsXValid(iZone.breakAt);
|
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
continue;
|
||||||
AddIfNotExists(
|
|
||||||
iZone,
|
|
||||||
source //
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (forceBreak)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
breakerBars = GetBreakerBars(iZone, tmpBars);
|
||||||
|
has = IsValidSize(breakerBars);
|
||||||
|
}
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
AddIfNotExists(
|
||||||
|
iZone,
|
||||||
|
source //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -5904,6 +5973,113 @@ int GetTesterBars(
|
|||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsBreaked(
|
||||||
|
XBoxZone &zone,
|
||||||
|
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = zone.IsValid() &&
|
||||||
|
IsXValid(priceType);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
double iPrice;
|
||||||
|
bool isBullish;
|
||||||
|
int start = zone.ToIndex();
|
||||||
|
int end = zone.FromIndex();
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Initialize Indexed Bar ...
|
||||||
|
iBar.Clean();
|
||||||
|
result = iBar.Init(zone.symbol, zone.period, i);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish = zone.IsBullish();
|
||||||
|
iPrice = iBar.GetPrice(priceType);
|
||||||
|
result = isBullish
|
||||||
|
? iPrice < zone.lower
|
||||||
|
: iPrice > zone.upper;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
iBar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RemoveBreakedZones(
|
||||||
|
XBoxZone &source[],
|
||||||
|
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (!HasChild(source) || !IsXValid(priceType))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone tmp[];
|
||||||
|
Copy(source, tmp);
|
||||||
|
XClean(source);
|
||||||
|
XBoxZone iTMP;
|
||||||
|
bool isBreaked = false;
|
||||||
|
while (HasChild(tmp))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iTMP.Clean();
|
||||||
|
iTMP = tmp[0];
|
||||||
|
ArrayRemove(tmp, 0, 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBreaked = IsBreaked(iTMP, priceType);
|
||||||
|
if (!isBreaked)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddIfNotExists(iTMP, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(source);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
XClean(tmp);
|
||||||
|
iTMP.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -907,7 +907,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Target Flags ...
|
// Target Flags ...
|
||||||
bool hasPartialCloseOnTp1 = true;
|
bool hasPartialCloseOnTp1 = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool doRFOnEntryOnTP1 = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw Flags ...
|
// Draw Flags ...
|
||||||
@@ -918,6 +921,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
bool drawMarketStructureOrderFlow = true;
|
bool drawMarketStructureOrderFlow = true;
|
||||||
XPOIDrawConfig iDrawConfig;
|
XPOIDrawConfig iDrawConfig;
|
||||||
|
|
||||||
|
//
|
||||||
|
drawLeg = false;
|
||||||
|
drawOrderFlow = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signal Checking ...
|
// Signal Checking ...
|
||||||
|
|
||||||
@@ -927,15 +934,16 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Check Market ...
|
// Check Market ...
|
||||||
result = HasLeg() &&
|
// result = HasLeg() &&
|
||||||
HasOrderFlow() &&
|
// HasOrderFlow() &&
|
||||||
orderFlowDir == leg.dir;
|
// orderFlowDir == leg.dir;
|
||||||
if (result)
|
// result = HasBearishOrderFlow();
|
||||||
{
|
// if (result)
|
||||||
//
|
// {
|
||||||
result = false;
|
// //
|
||||||
DebugBreak();
|
// result = false;
|
||||||
}
|
// DebugBreak();
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signaller 1 ...
|
// Signaller 1 ...
|
||||||
@@ -1125,9 +1133,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
//
|
//
|
||||||
iTarget.Clean();
|
iTarget.Clean();
|
||||||
iTarget.target = tp1;
|
iTarget.target = tp1;
|
||||||
iTarget.doRFOnEntry = true;
|
|
||||||
iTarget.actingDistance = 5;
|
iTarget.actingDistance = 5;
|
||||||
iTarget.volumeMultiplier = 0.8;
|
iTarget.volumeMultiplier = 0.8;
|
||||||
|
iTarget.doRFOnEntry = doRFOnEntryOnTP1;
|
||||||
|
|
||||||
//
|
//
|
||||||
AddRef(iTarget, targets);
|
AddRef(iTarget, targets);
|
||||||
@@ -2025,6 +2033,23 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
/**
|
/**
|
||||||
* Check Bar Has Signal Based on Strategy 4 ...
|
* Check Bar Has Signal Based on Strategy 4 ...
|
||||||
*
|
*
|
||||||
|
* Strategy 4:
|
||||||
|
* ===========
|
||||||
|
* - Works Based on Order Flow ...
|
||||||
|
* - Looking for new and Fresh Order Flow ...
|
||||||
|
* - Validate Bar is Inside Order Flow ...
|
||||||
|
* - Validate Bar has Proper Pattern ...
|
||||||
|
* - Validate Bar Based on ATR Band in two Step:
|
||||||
|
* - Step 1: Bars is Inside ATR Band (Middle) ...
|
||||||
|
* - Step 2: Trigger Bars Close Price based on ATR Band ...
|
||||||
|
* - Validate Order Flow based on Market Structure Zone ...
|
||||||
|
* - Validate Trigger Bar based on InDirectional Market Structure Zones ...
|
||||||
|
*
|
||||||
|
* Manipulations:
|
||||||
|
* ================
|
||||||
|
* there are Some Flags properties to Change Validations in Strategy ...
|
||||||
|
* we can use them for Testing Purposes ...
|
||||||
|
*
|
||||||
* @param bar: XOHCL, reference to Bar ...
|
* @param bar: XOHCL, reference to Bar ...
|
||||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||||
@@ -2062,6 +2087,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
bool validateByBarPatterns = true;
|
bool validateByBarPatterns = true;
|
||||||
bool validateByBarInsideATRBand = true;
|
bool validateByBarInsideATRBand = true;
|
||||||
bool validateByBarBasedOnATRBand = true;
|
bool validateByBarBasedOnATRBand = true;
|
||||||
|
bool validateMarketStructureHasDirectionalZone = true;
|
||||||
|
bool validateMarketStructureDirectionalZoneInsideOrderFlow = true;
|
||||||
|
bool validateMarketStructureHasNotInDirectionalZoneOrUnReachedTP = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Define Requirements ...
|
// Define Requirements ...
|
||||||
@@ -2098,9 +2126,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// Retrieve pBar Patterns ...
|
// Retrieve pBar Patterns ...
|
||||||
XPatternAnalysis pBarPatterns;
|
XPatternAnalysis pBarPatterns;
|
||||||
XPatternAnalysisConfig patternConfig = structureConfig.barsAnalysisConfig;
|
XPatternAnalysisConfig patternConfig = structureConfig.barsAnalysisConfig;
|
||||||
// patternConfig.Default();
|
|
||||||
// patternConfig.supportAndResistanceLoopbackLength = 21;
|
|
||||||
// patternConfig.supportAndResistanceValidationLength = 7;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
poiDetector.AnalyseBarPatterns(
|
poiDetector.AnalyseBarPatterns(
|
||||||
@@ -2111,7 +2136,19 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Detecting OrderFlow ...
|
// Detecting OrderFlow ...
|
||||||
bool hasOrderFlow = HasOrderFlow();
|
XBoxZone oFlow[];
|
||||||
|
bool hasOrderFlow = poiDetector.HasOrderFlow(
|
||||||
|
p3Bar,
|
||||||
|
dir,
|
||||||
|
oFlow,
|
||||||
|
structureConfig.orderFlowValidation,
|
||||||
|
structureConfig.orderFlowUseOB,
|
||||||
|
structureConfig.orderFlowUseFVG,
|
||||||
|
structureConfig.orderFlowUseSupportAndResistance,
|
||||||
|
patternConfig.supportAndResistanceLoopbackLength,
|
||||||
|
patternConfig.supportAndResistanceValidationLength,
|
||||||
|
structureConfig.loopback //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
double atrBandUpper = EMPTY_VALUE;
|
double atrBandUpper = EMPTY_VALUE;
|
||||||
@@ -2139,15 +2176,16 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
double orderFlowLower = 0;
|
double orderFlowLower = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
int idx = GetHighest(orderFlow);
|
int idx = -1;
|
||||||
|
idx = GetHighest(oFlow);
|
||||||
if (IsValidIndex(idx))
|
if (IsValidIndex(idx))
|
||||||
{
|
{
|
||||||
orderFlowUpper = orderFlow[idx].upper;
|
orderFlowUpper = oFlow[idx].upper;
|
||||||
}
|
}
|
||||||
idx = GetLowest(orderFlow);
|
idx = GetLowest(oFlow);
|
||||||
if (IsValidIndex(idx))
|
if (IsValidIndex(idx))
|
||||||
{
|
{
|
||||||
orderFlowLower = orderFlow[idx].lower;
|
orderFlowLower = oFlow[idx].lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2179,6 +2217,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
//
|
//
|
||||||
// Bullish ...
|
// Bullish ...
|
||||||
bool isPBarHasBullishPatterns =
|
bool isPBarHasBullishPatterns =
|
||||||
|
result &&
|
||||||
// (bar.close > pBar.low ||
|
// (bar.close > pBar.low ||
|
||||||
// bar.open > pBar.low) &&
|
// bar.open > pBar.low) &&
|
||||||
(
|
(
|
||||||
@@ -2194,6 +2233,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
//
|
//
|
||||||
// Bearish ...
|
// Bearish ...
|
||||||
bool isPBarHasBearishPatterns =
|
bool isPBarHasBearishPatterns =
|
||||||
|
result &&
|
||||||
// (bar.close < pBar.high ||
|
// (bar.close < pBar.high ||
|
||||||
// bar.open < pBar.high) &&
|
// bar.open < pBar.high) &&
|
||||||
(
|
(
|
||||||
@@ -2296,46 +2336,171 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = false;
|
// for Bullish has Support ...
|
||||||
isBullish = false;
|
// for Bearish has Resistance ...
|
||||||
isBearish = false;
|
if (result && validateMarketStructureHasDirectionalZone)
|
||||||
if (result)
|
|
||||||
{
|
{
|
||||||
// //
|
//
|
||||||
// UpdateToTime(orderFlow, bar.time);
|
XOHCL tmpBar;
|
||||||
// poiDrawer.DrawZones(orderFlow, structureDrawConfig.drawConfig);
|
XPivot tmpPivot;
|
||||||
// poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
XBoxZone support;
|
||||||
|
XBoxZone resistance;
|
||||||
|
|
||||||
// //
|
//
|
||||||
// // Draw ATR Band Middle ...
|
// Check Market Strucutre Has Support / Resistance ...
|
||||||
// if (NotEmptyZero(atrBandMiddle))
|
bool hasSupport = pBarPatterns.IsSupport();
|
||||||
// {
|
bool hasResistance = pBarPatterns.IsResistance();
|
||||||
// //
|
|
||||||
// XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
|
||||||
// iConfig.trendRayLeft = false;
|
|
||||||
// iConfig.trendRayRight = false;
|
|
||||||
|
|
||||||
// //
|
//
|
||||||
// datetime to = bar.time;
|
// Retrieve Support / Resistance Zone ...
|
||||||
// datetime from = p2Bar.BeforeOn();
|
if (hasSupport)
|
||||||
// string trendName = "ATRBandMiddle_" + ToXString(TimeToSeconds(p2Bar.time));
|
{
|
||||||
// poiDrawer.DrawTrendLine(
|
pBarPatterns.GetSupport(tmpBar, tmpPivot, support);
|
||||||
// trendName,
|
}
|
||||||
// atrBandMiddle,
|
if (hasResistance)
|
||||||
// from,
|
{
|
||||||
// atrBandMiddle,
|
pBarPatterns.GetResistance(tmpBar, tmpPivot, resistance);
|
||||||
// to,
|
}
|
||||||
// iConfig,
|
|
||||||
// clrYellow //
|
|
||||||
// );
|
|
||||||
|
|
||||||
// //
|
//
|
||||||
// iConfig.Clean();
|
// Validate Support and Resistance by Order Flow ...
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
//
|
||||||
// Print("OrderFlow ...");
|
// Converts Order Flow to Zone ...
|
||||||
// DebugBreak();
|
XBoxZone ofZone;
|
||||||
|
bool hasOFBox = ToBox(ofZone, oFlow);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Market Strucutre Support and Resistance Validation ...
|
||||||
|
if (validateMarketStructureDirectionalZoneInsideOrderFlow)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasSupport =
|
||||||
|
hasOFBox &&
|
||||||
|
hasSupport &&
|
||||||
|
ofZone.lower < support.lower &&
|
||||||
|
ofZone.upper > support.upper;
|
||||||
|
|
||||||
|
//
|
||||||
|
hasResistance =
|
||||||
|
hasOFBox &&
|
||||||
|
hasResistance &&
|
||||||
|
ofZone.lower < resistance.lower &&
|
||||||
|
ofZone.upper > resistance.upper;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Directional Support or Resistance Exists ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
hasSupport;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
hasResistance;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
ofZone.Clean();
|
||||||
|
tmpBar.Clean();
|
||||||
|
support.Clean();
|
||||||
|
tmpPivot.Clean();
|
||||||
|
resistance.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Makret Structure Has Not Indirectional Zone ...
|
||||||
|
if (result && validateMarketStructureHasNotInDirectionalZoneOrUnReachedTP)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL tmpBar;
|
||||||
|
XPivot tmpPivot;
|
||||||
|
XBoxZone support;
|
||||||
|
XBoxZone resistance;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Market Strucutre Has Support / Resistance ...
|
||||||
|
bool hasSupport = pBarPatterns.IsSupport();
|
||||||
|
bool hasResistance = pBarPatterns.IsResistance();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Support / Resistance Zone ...
|
||||||
|
if (hasSupport)
|
||||||
|
{
|
||||||
|
pBarPatterns.GetSupport(tmpBar, tmpPivot, support);
|
||||||
|
}
|
||||||
|
if (hasResistance)
|
||||||
|
{
|
||||||
|
pBarPatterns.GetResistance(tmpBar, tmpPivot, resistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Converts Order Flow to Zone ...
|
||||||
|
XBoxZone ofZone;
|
||||||
|
bool hasOFBox = ToBox(ofZone, oFlow);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool hasIndirectionalZone =
|
||||||
|
(isBullish && hasResistance) ||
|
||||||
|
(isBearish && hasSupport);
|
||||||
|
if (hasIndirectionalZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Here we Have to Validate Zone Place ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double point = GetPoints(bar.symbol);
|
||||||
|
double entry = GetEntry(bar.symbol, dir);
|
||||||
|
double slAddition = slAdditionDistance > 0 ? slAdditionDistance : 0;
|
||||||
|
double risk = MathAbs(entry - (isBullish ? oFlow[0].lower : oFlow[0].upper)) + (slAddition * point);
|
||||||
|
double reward = (defaultSignalR2R * risk);
|
||||||
|
double tp = isBullish
|
||||||
|
? entry + reward
|
||||||
|
: entry - reward;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
if (isBullish && hasResistance)
|
||||||
|
{
|
||||||
|
hasResistance = resistance.lower <= tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
if (isBearish && hasSupport)
|
||||||
|
{
|
||||||
|
hasSupport = support.upper >= tp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
!hasResistance;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
!hasSupport;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
ofZone.Clean();
|
||||||
|
tmpBar.Clean();
|
||||||
|
support.Clean();
|
||||||
|
tmpPivot.Clean();
|
||||||
|
resistance.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2377,6 +2542,16 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// Manage Stops ...
|
// Manage Stops ...
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Since Stop Management Changes Zones Edge(s) ...
|
||||||
|
// we do it here for Refining Zone ...
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||||
|
poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
|
||||||
|
//
|
||||||
|
DebugBreak();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2387,6 +2562,38 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// Prepare Targets ...
|
// Prepare Targets ...
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
XTarget iTarget;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Requirements ...
|
||||||
|
double point = GetPoints(bar.symbol);
|
||||||
|
double entry = GetEntry(bar.symbol, dir);
|
||||||
|
double slAddition = slAdditionDistance > 0 ? slAdditionDistance : 0;
|
||||||
|
double risk = MathAbs(entry - (isBullish ? zone.lower : zone.upper)) + (slAddition * point);
|
||||||
|
double reward = (defaultSignalR2R * risk);
|
||||||
|
double tp = isBullish
|
||||||
|
? entry + reward
|
||||||
|
: entry - reward;
|
||||||
|
|
||||||
|
//
|
||||||
|
// High Risk Target is Used to Protect In Profit Positiions
|
||||||
|
// from Reversal Patterns ...
|
||||||
|
double highRiskR2r = (defaultSignalR2R / 5) * 4;
|
||||||
|
double highRiskReward = highRiskR2r * risk;
|
||||||
|
double highRiskTP = isBullish
|
||||||
|
? entry + highRiskReward
|
||||||
|
: entry - highRiskReward;
|
||||||
|
iTarget.Clean();
|
||||||
|
iTarget.actingDistance = 5;
|
||||||
|
iTarget.doRFOnEntry = true;
|
||||||
|
iTarget.target = highRiskTP;
|
||||||
|
iTarget.volumeMultiplier = 0.8;
|
||||||
|
AddRef(iTarget, targets);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
iTarget.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user