last works on XCZone test EA ...
This commit is contained in:
@@ -169,7 +169,8 @@ string ToString(ENUM_X_CHART_IDS value)
|
|||||||
bool ToSignal(
|
bool ToSignal(
|
||||||
XBoxZone &box,
|
XBoxZone &box,
|
||||||
XSignal &signal,
|
XSignal &signal,
|
||||||
double &rewardRatios[] //
|
double &rewardRatios[],
|
||||||
|
double additionalSL = 0 //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -188,10 +189,15 @@ bool ToSignal(
|
|||||||
|
|
||||||
//
|
//
|
||||||
XOHCL entryBar;
|
XOHCL entryBar;
|
||||||
|
int entryIDX = box.ToIndex();
|
||||||
|
if (entryIDX > 0)
|
||||||
|
{
|
||||||
|
entryIDX--;
|
||||||
|
}
|
||||||
result = entryBar.Init(
|
result = entryBar.Init(
|
||||||
box.symbol,
|
box.symbol,
|
||||||
box.period,
|
box.period,
|
||||||
box.ToIndex() - 1 //
|
entryIDX //
|
||||||
);
|
);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@@ -231,6 +237,14 @@ bool ToSignal(
|
|||||||
isBullish
|
isBullish
|
||||||
? box.lower
|
? box.lower
|
||||||
: box.upper;
|
: box.upper;
|
||||||
|
if (additionalSL > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
sl =
|
||||||
|
isBullish
|
||||||
|
? sl - additionalSL
|
||||||
|
: sl + additionalSL;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
double risk = MathAbs(entry - sl);
|
double risk = MathAbs(entry - sl);
|
||||||
|
|||||||
+41
-4
@@ -15,6 +15,12 @@
|
|||||||
#include "../XCAEA/Helpers/xcaea.helper.mq5"
|
#include "../XCAEA/Helpers/xcaea.helper.mq5"
|
||||||
#include "../XCAEA/Libraries/xcaea.trigger.block.lib.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 ...
|
// Variables ...
|
||||||
XCAEAInputs eaInputs;
|
XCAEAInputs eaInputs;
|
||||||
@@ -22,7 +28,7 @@ XCXCAEAHelper *eaHelper;
|
|||||||
XBarTracker eaBarTraker;
|
XBarTracker eaBarTraker;
|
||||||
|
|
||||||
//
|
//
|
||||||
CArrayObj eaObjects;
|
CArrayObj *eaObjects;
|
||||||
|
|
||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
//| Expert initialization function |
|
//| Expert initialization function |
|
||||||
@@ -36,6 +42,10 @@ int OnInit()
|
|||||||
_Period //
|
_Period //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Objects ...
|
||||||
|
eaObjects = new CArrayObj();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure XCA ...
|
// Configure XCA ...
|
||||||
eaInputs.Default();
|
eaInputs.Default();
|
||||||
@@ -46,7 +56,7 @@ int OnInit()
|
|||||||
|
|
||||||
//
|
//
|
||||||
// we Can make Show all requirements here ...
|
// we Can make Show all requirements here ...
|
||||||
eaInputs.caInputs.showSar = true;
|
eaInputs.caInputs.showSar = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
eaHelper = new XCXCAEAHelper();
|
eaHelper = new XCXCAEAHelper();
|
||||||
@@ -153,6 +163,30 @@ void OnTick()
|
|||||||
tbConfig.filterBasedOnScores = true;
|
tbConfig.filterBasedOnScores = true;
|
||||||
tbConfig.filterBasedOnVolumes = 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 ...
|
// Do Detection ...
|
||||||
has = DetectTriggerBlock(
|
has = DetectTriggerBlock(
|
||||||
@@ -160,7 +194,9 @@ void OnTick()
|
|||||||
eaHelper,
|
eaHelper,
|
||||||
tbConfig,
|
tbConfig,
|
||||||
zBar.Index(),
|
zBar.Index(),
|
||||||
10 //
|
10,
|
||||||
|
eaSLAdditionalPoint,
|
||||||
|
eaSLATRMultiplier //
|
||||||
);
|
);
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
@@ -181,7 +217,8 @@ void OnTick()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
Print("Trigger Block Detected ...");
|
string message = tb.signal.GetMessage("Provided");
|
||||||
|
Print(message);
|
||||||
}
|
}
|
||||||
tb.Clean();
|
tb.Clean();
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ struct XCAEATriggerBlockConfiguration
|
|||||||
bool filterBasedOnScores; // Filter Trigger Block Based on Scores
|
bool filterBasedOnScores; // Filter Trigger Block Based on Scores
|
||||||
bool filterBasedOnVolumes; // Filter Trigger Block Based on Volumes
|
bool filterBasedOnVolumes; // Filter Trigger Block Based on Volumes
|
||||||
|
|
||||||
|
//
|
||||||
|
double targets[]; // Targets Collection for R:R on Signal Preparation
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor ...
|
// Constructor ...
|
||||||
XCAEATriggerBlockConfiguration()
|
XCAEATriggerBlockConfiguration()
|
||||||
@@ -147,6 +150,9 @@ struct XCAEATriggerBlockConfiguration
|
|||||||
filterBasedOnScores = false;
|
filterBasedOnScores = false;
|
||||||
filterBasedOnVolumes = false;
|
filterBasedOnVolumes = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(targets);
|
||||||
|
|
||||||
//
|
//
|
||||||
ZeroMemory(this);
|
ZeroMemory(this);
|
||||||
}
|
}
|
||||||
@@ -171,6 +177,9 @@ struct XTriggerBlock
|
|||||||
XCAEAConditions conditions; // Market Conditions
|
XCAEAConditions conditions; // Market Conditions
|
||||||
XCAEATriggerBlockConfiguration configuration; // Detection Configuration
|
XCAEATriggerBlockConfiguration configuration; // Detection Configuration
|
||||||
|
|
||||||
|
//
|
||||||
|
XSignal signal; // Pepared Signal
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor ...
|
// Constructor ...
|
||||||
XTriggerBlock()
|
XTriggerBlock()
|
||||||
@@ -188,6 +197,7 @@ struct XTriggerBlock
|
|||||||
//
|
//
|
||||||
ob.Clean();
|
ob.Clean();
|
||||||
fvg.Clean();
|
fvg.Clean();
|
||||||
|
signal.Clean();
|
||||||
trigger.Clean();
|
trigger.Clean();
|
||||||
swingBar.Clean();
|
swingBar.Clean();
|
||||||
rLiquidity.Clean();
|
rLiquidity.Clean();
|
||||||
@@ -236,7 +246,9 @@ bool DetectTriggerBlock(
|
|||||||
XCXCAEAHelper *helper,
|
XCXCAEAHelper *helper,
|
||||||
XCAEATriggerBlockConfiguration &config,
|
XCAEATriggerBlockConfiguration &config,
|
||||||
int bar_index = 0,
|
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 ...
|
// Attach Configuration if Trigger Block Founded ...
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
trigger.configuration = config;
|
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,
|
XTriggerBlock &trigger,
|
||||||
CArrayObj *&objects,
|
CArrayObj *&objects,
|
||||||
XCXCAEAHelper *helper,
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user