last works on XCZone test EA ...

This commit is contained in:
2025-05-21 00:29:33 +03:30
parent 70876676f5
commit 3e29a557bf
3 changed files with 150 additions and 8 deletions
+16 -2
View File
@@ -169,7 +169,8 @@ string ToString(ENUM_X_CHART_IDS value)
bool ToSignal(
XBoxZone &box,
XSignal &signal,
double &rewardRatios[] //
double &rewardRatios[],
double additionalSL = 0 //
)
{
//
@@ -188,10 +189,15 @@ bool ToSignal(
//
XOHCL entryBar;
int entryIDX = box.ToIndex();
if (entryIDX > 0)
{
entryIDX--;
}
result = entryBar.Init(
box.symbol,
box.period,
box.ToIndex() - 1 //
entryIDX //
);
if (!result)
{
@@ -231,6 +237,14 @@ bool ToSignal(
isBullish
? box.lower
: box.upper;
if (additionalSL > 0)
{
//
sl =
isBullish
? sl - additionalSL
: sl + additionalSL;
}
//
double risk = MathAbs(entry - sl);
+41 -4
View File
@@ -15,6 +15,12 @@
#include "../XCAEA/Helpers/xcaea.helper.mq5"
#include "../XCAEA/Libraries/xcaea.trigger.block.lib.mq5"
//
// Inputs ...
input group "Signals";
input double eaSLAdditionalPoint = 0.0; // Additional SL in Point
input double eaSLATRMultiplier = 0.0; // Additional SL using ATR Multiplier
//
// Variables ...
XCAEAInputs eaInputs;
@@ -22,7 +28,7 @@ XCXCAEAHelper *eaHelper;
XBarTracker eaBarTraker;
//
CArrayObj eaObjects;
CArrayObj *eaObjects;
//+------------------------------------------------------------------+
//| Expert initialization function |
@@ -36,6 +42,10 @@ int OnInit()
_Period //
);
//
// Objects ...
eaObjects = new CArrayObj();
//
// Configure XCA ...
eaInputs.Default();
@@ -46,7 +56,7 @@ int OnInit()
//
// we Can make Show all requirements here ...
eaInputs.caInputs.showSar = true;
eaInputs.caInputs.showSar = false;
//
eaHelper = new XCXCAEAHelper();
@@ -153,6 +163,30 @@ void OnTick()
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(
@@ -160,7 +194,9 @@ void OnTick()
eaHelper,
tbConfig,
zBar.Index(),
10 //
10,
eaSLAdditionalPoint,
eaSLATRMultiplier //
);
if (has)
{
@@ -181,7 +217,8 @@ void OnTick()
}
//
Print("Trigger Block Detected ...");
string message = tb.signal.GetMessage("Provided");
Print(message);
}
tb.Clean();
+93 -2
View File
@@ -111,6 +111,9 @@ struct XCAEATriggerBlockConfiguration
bool filterBasedOnScores; // Filter Trigger Block Based on Scores
bool filterBasedOnVolumes; // Filter Trigger Block Based on Volumes
//
double targets[]; // Targets Collection for R:R on Signal Preparation
//
// Constructor ...
XCAEATriggerBlockConfiguration()
@@ -147,6 +150,9 @@ struct XCAEATriggerBlockConfiguration
filterBasedOnScores = false;
filterBasedOnVolumes = false;
//
Clean(targets);
//
ZeroMemory(this);
}
@@ -171,6 +177,9 @@ struct XTriggerBlock
XCAEAConditions conditions; // Market Conditions
XCAEATriggerBlockConfiguration configuration; // Detection Configuration
//
XSignal signal; // Pepared Signal
//
// Constructor ...
XTriggerBlock()
@@ -188,6 +197,7 @@ struct XTriggerBlock
//
ob.Clean();
fvg.Clean();
signal.Clean();
trigger.Clean();
swingBar.Clean();
rLiquidity.Clean();
@@ -236,7 +246,9 @@ bool DetectTriggerBlock(
XCXCAEAHelper *helper,
XCAEATriggerBlockConfiguration &config,
int bar_index = 0,
int loopback = 10 //
int loopback = 10,
double slAdditionalPoint = 0,
double slATRMultiplier = 0 //
)
{
//
@@ -1176,7 +1188,35 @@ bool DetectTriggerBlock(
// Attach Configuration if Trigger Block Founded ...
if (result)
{
//
trigger.configuration = config;
//
// Prepare Trigger Signal ...
if (HasChild(config.targets))
{
//
// Calculating Additional SL Value for Signals ...
double additionalSL = 0;
if (slATRMultiplier > 0)
{
//
double cATR = trigger.conditions.atrBuffer[cIDX];
additionalSL += (cATR * slATRMultiplier);
}
if (slAdditionalPoint > 0)
{
additionalSL += (slAdditionalPoint * points);
}
//
ToSignal(
trigger.trigger,
trigger.signal,
config.targets,
additionalSL //
);
}
}
//
@@ -1197,7 +1237,8 @@ bool DrawTriggerBlock(
XTriggerBlock &trigger,
CArrayObj *&objects,
XCXCAEAHelper *helper,
datetime to = NULL //
datetime to = NULL,
int rrZoneLength = 10 //
)
{
//
@@ -1389,6 +1430,56 @@ bool DrawTriggerBlock(
}
}
//
// Draw RR of Signal ...
if (trigger.signal.IsValid() &&
rrZoneLength > 0)
{
//
XCRRObject *iRRObj;
iRRObj = new XCRRObject();
result = iRRObj.Create(
helper.poiDrawer.ChartIdentification(),
helper.poiDrawer.SubWindowIdentification(),
trigger.signal,
rrZoneLength //
);
if (result)
{
//
int iWidth = 2;
ENUM_LINE_STYLE iStyle = STYLE_SOLID;
//
iRRObj.TPWidth(iWidth);
iRRObj.SLWidth(iWidth);
iRRObj.EntryWidth(iWidth);
iRRObj.TargetWidth(iWidth);
//
iRRObj.TPStyle(iStyle);
iRRObj.SLStyle(iStyle);
iRRObj.EntryStyle(iStyle);
iRRObj.TargetStyle(iStyle);
//
iRRObj.TPColor(clrLime);
iRRObj.SLColor(clrRed);
iRRObj.EntryColor(clrYellow);
iRRObj.TargetColor(clrLightBlue);
//
objects.Add(iRRObj);
}
ZeroMemory(iRRObj);
//
if (result)
{
return result;
}
}
//
return result;
}