last ...
This commit is contained in:
@@ -615,6 +615,119 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DetectRangeBlocks(
|
||||
XOHCL &bar,
|
||||
XBoxZone &upper,
|
||||
XBoxZone &lower,
|
||||
int loopback = 288,
|
||||
ENUM_SERIESMODE upperRangeUpperMode = MODE_HIGH,
|
||||
ENUM_SERIESMODE upperRangeLowerMode = MODE_LOW,
|
||||
ENUM_SERIESMODE lowerRangeUpperMode = MODE_HIGH,
|
||||
ENUM_SERIESMODE lowerRangeLowerMode = MODE_LOW //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
upper.Clean();
|
||||
lower.Clean();
|
||||
loopback = NormalizeInt(loopback, 10);
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
bar.Index() + loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double hhUpper = iBar.FindHighest(loopback, upperRangeUpperMode);
|
||||
double hhLower = iBar.FindHighest(loopback, upperRangeLowerMode);
|
||||
|
||||
//
|
||||
double llUpper = iBar.FindLowest(loopback, lowerRangeUpperMode);
|
||||
double llLower = iBar.FindLowest(loopback, lowerRangeLowerMode);
|
||||
|
||||
//
|
||||
double bhhUpper = bar.FindHighest(iBar.Index() - bar.Index(), upperRangeUpperMode);
|
||||
double bhhLower = bar.FindHighest(iBar.Index() - bar.Index(), upperRangeLowerMode);
|
||||
|
||||
//
|
||||
double bllUpper = bar.FindLowest(iBar.Index() - bar.Index(), lowerRangeUpperMode);
|
||||
double bllLower = bar.FindLowest(iBar.Index() - bar.Index(), lowerRangeLowerMode);
|
||||
|
||||
//
|
||||
hhUpper = MathMax(hhUpper, bhhUpper);
|
||||
hhLower = MathMax(hhLower, bhhLower);
|
||||
|
||||
//
|
||||
llUpper = MathMin(llUpper, bllUpper);
|
||||
llLower = MathMin(llLower, bllLower);
|
||||
|
||||
//
|
||||
datetime from = GetBarTime(
|
||||
iBar.symbol,
|
||||
iBar.period,
|
||||
iBar.Index() + loopback //
|
||||
);
|
||||
|
||||
//
|
||||
upper.from = from;
|
||||
upper.type = "XRNG";
|
||||
upper.to = bar.time;
|
||||
upper.upper = hhUpper;
|
||||
upper.lower = hhLower;
|
||||
upper.symbol = iBar.symbol;
|
||||
upper.period = iBar.period;
|
||||
upper.dir = X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
lower.from = from;
|
||||
lower.type = "XRNG";
|
||||
lower.to = bar.time;
|
||||
lower.upper = llUpper;
|
||||
lower.lower = llLower;
|
||||
lower.symbol = iBar.symbol;
|
||||
lower.period = iBar.period;
|
||||
lower.dir = X_DIRECTION_BULLISH;
|
||||
|
||||
//
|
||||
result = upper.IsValid() &&
|
||||
lower.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
upper.Clean();
|
||||
lower.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Same Bars ...
|
||||
*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "EA based on X121 XCA and X3MA indicators"
|
||||
#property description "EA based on X121 XCZone indicators"
|
||||
#property strict
|
||||
|
||||
//
|
||||
@@ -17,9 +17,6 @@
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
input group "Signals";
|
||||
input double eaSLAdditionalPoint = 0.0; // Additional SL in Point
|
||||
input double eaSLATRMultiplier = 0.0; // Additional SL using ATR Multiplier
|
||||
|
||||
//
|
||||
// Variables ...
|
||||
@@ -105,11 +102,6 @@ void OnTick()
|
||||
//
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
// Required Chart Identification ...
|
||||
ulong chartId = eaHelper.poiDrawer.ChartIdentification();
|
||||
int subWindow = eaHelper.poiDrawer.SubWindowIdentification();
|
||||
|
||||
//
|
||||
// Retrieve Bars ...
|
||||
XOHCL zBar;
|
||||
@@ -132,96 +124,6 @@ void OnTick()
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Trigger Block ...
|
||||
XTriggerBlock tb;
|
||||
XCAEATriggerBlockConfiguration tbConfig;
|
||||
|
||||
//
|
||||
// Configure Detector ...
|
||||
|
||||
//
|
||||
// Validation ...
|
||||
tbConfig.maxAllowedRange = 0.0;
|
||||
tbConfig.minAllowedBlockEdgeLength = 7;
|
||||
|
||||
//
|
||||
// Validation ...
|
||||
tbConfig.forceFVGBarType = true;
|
||||
tbConfig.forceHasSwingBar = true;
|
||||
tbConfig.forceOBOppositBar = true;
|
||||
tbConfig.forceHasLiquidity = false;
|
||||
tbConfig.forceGapBarBreakout = true;
|
||||
tbConfig.forceHasReversalLiquidity = true;
|
||||
|
||||
//
|
||||
// Filters ...
|
||||
tbConfig.filterBasedOnSar = true;
|
||||
tbConfig.filterBasedOnADX = true;
|
||||
tbConfig.filterBasedOnRSI = true;
|
||||
tbConfig.filterBasedOnTrend = true;
|
||||
tbConfig.filterBasedOnScores = true;
|
||||
tbConfig.filterBasedOnVolumes = true;
|
||||
|
||||
//
|
||||
// Targets ...
|
||||
double targets[] = {
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
};
|
||||
Copy(
|
||||
targets,
|
||||
tbConfig.targets //
|
||||
);
|
||||
|
||||
//
|
||||
// Do Detection ...
|
||||
has = DetectTriggerBlock(
|
||||
tb,
|
||||
eaHelper,
|
||||
tbConfig,
|
||||
zBar.Index(),
|
||||
10,
|
||||
eaSLAdditionalPoint,
|
||||
eaSLATRMultiplier //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
CArrayObj *tObjects;
|
||||
tObjects = new CArrayObj();
|
||||
|
||||
//
|
||||
has = DrawTriggerBlock(
|
||||
tb,
|
||||
tObjects,
|
||||
eaHelper,
|
||||
zBar.time //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
AddObjects(tObjects, eaObjects);
|
||||
}
|
||||
|
||||
//
|
||||
string message = tb.signal.GetMessage("Provided");
|
||||
Print(message);
|
||||
}
|
||||
tb.Clean();
|
||||
|
||||
//
|
||||
// Do What we Want ...
|
||||
// When we Need Waits Until Next Bar ...
|
||||
@@ -231,8 +133,6 @@ void OnTick()
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
tb.Clean();
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
tbConfig.Clean();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -311,7 +311,7 @@ bool DetectTriggerBlock(
|
||||
helper
|
||||
.barAnalyser
|
||||
.IsTrigger(
|
||||
cBar,
|
||||
zBar,
|
||||
trigger.trigger,
|
||||
trigger.ob,
|
||||
trigger.fvg,
|
||||
|
||||
Reference in New Issue
Block a user