last works on XCAEA Pivots ...

This commit is contained in:
2025-04-24 05:53:12 +03:30
parent a21799a9aa
commit 65178361d8
6 changed files with 3963 additions and 823 deletions
+853
View File
@@ -0,0 +1,853 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------------
// Name: XCXCAEASignaller ...
// Description: Class for XCAEA Signaller ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm Class for XCAEA Signaller"
#property strict
//
// Imports ...
#include "../../Classes/x-saherelm.base.class.mq5"
#include "../../Classes/x-saherelm.x-cobject.class.mq5"
#include "../Classes/xcaea.x-poi.detector.class.mq5"
#include "../Classes/xcaea.x-poi.drawer.class.mq5"
#include "../Helpers/xcaea.helper.mq5"
#include "../Libraries/xcaea.signaller.lib.mq5"
//
// Definitions ...
class XCXCAEASignaller : XCBase
{
//
// Public ...
public:
//
// Props ...
bool useGuards;
XCAEAInputs inputs;
XBarTracker barTraker;
XCXCAEAHelper *helper;
XCXCAEAPOIDrawer *drawer;
bool continuesRFTillTarget;
XBoxZone unAvailableBoxes[];
XCXCAEAPOIDetector *detector;
XCAEAStrategyConditions mConditions;
XCAEAStrategyConditions mConditionsCollection[];
//
// Constructor ...
XCXCAEASignaller(
string _symbol,
ENUM_TIMEFRAMES _period //
)
{
//
symbol = _symbol;
period = _period;
//
Init();
}
//
// Deconstructor ...
~XCXCAEASignaller()
{
DeInit();
}
//
// Properties ...
string GetSymbol()
{
return symbol;
}
ENUM_TIMEFRAMES GetPeriod()
{
return period;
}
//
// Signaller Tools ...
/**
* Detect Setup Conditions based on Signalling ...
*
* @param maxAllowedSLDistanceInPoint: int, Max Allowed SL Distance in Points (if Bigger thn Zero Provided) ...
*
* @return ( bool )
*/
bool DetectSignalSetup(
double tpReward = 3,
double maxAllowedSLDistanceInPoint = 100 //
)
{
//
bool result = false;
//
// Check Bar Processing ...
if (!barTraker.CanProcessBar())
{
return result;
}
//
bool isBullish = false;
bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
int loopback = 10;
//
int idx = -1;
int count = 0;
bool has = false;
//
double ask = GetAsk(symbol);
double bid = GetBid(symbol);
datetime cTime = TimeCurrent();
double points = GetPoints(symbol);
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
XOHCL pPBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
result =
result &&
zBar.GetPreviousBar(cBar);
result =
result &&
cBar.GetPreviousBar(pBar);
result =
result &&
pBar.GetPreviousBar(pPBar);
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
pPBar.Clean();
//
return result;
}
//
// Setup Conditions ...
XBoxZone boxes[];
XBoxZone pivotBox;
XBoxZone signalBox;
double additionalSL = 0;
XBoxZone bullishBoxes[];
XBoxZone bearishBoxes[];
bool hasSignalBox = false;
XCAEAConditions conditions;
ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE;
//
// Detecting Pivots ...
detector.Update(
zIndex //
);
//
// Validate Pivots ...
detector.Validate(
unAvailableBoxes,
zIndex //
);
//
// Draw Founded Pivots ...
drawer.Draw(cTime);
//
// Retrieve Valid Boxes ...
// //
// // Bullish ...
// int bullishBoxesCount =
// detector
// .FillBullishBoxes(bullishBoxes);
// //
// // Bearish ...
// int bearishBoxesCount =
// detector
// .FillBearishBoxes(bearishBoxes);
// //
// Copy(
// bullishBoxes,
// boxes,
// false //
// );
// Copy(
// bearishBoxes,
// boxes,
// false //
// );
int boxesCount = ArraySize(boxes);
bool hasBoxes = IsValidSize(boxesCount);
//
// Filter UnAvailable Boxes ...
if (hasBoxes)
{
//
// Remove UnAvailable Boxes ...
has = HasChild(unAvailableBoxes);
if (has)
{
//
count = ArraySize(unAvailableBoxes);
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = unAvailableBoxes[i];
//
has = FindBoxIndex(
idx,
iBox,
boxes //
);
if (has)
{
//
ArrayRemove(
boxes,
idx,
1 //
);
}
}
}
//
hasBoxes = HasChild(boxes);
boxesCount = ArraySize(boxes);
}
//
//
//
//
// if (hasBoxes)
// {
// }
//
// Detect Sinal Box ...
hasSignalBox = DetectXCAEAConditions(
boxes,
conditions,
pivotBox,
signalBox,
additionalSL,
signalBoxDir,
helper,
zIndex,
loopback //
);
//
// Make Pivot Box UnAvailable ...
if (pivotBox.IsValid())
{
//
AddRef(
pivotBox,
unAvailableBoxes //
);
}
//
isBullish = hasSignalBox &&
IsBullish(signalBoxDir);
//
isBearish = hasSignalBox &&
IsBearish(signalBoxDir);
//
result = isBullish ||
isBearish;
if (result)
{
//
// Do What we Want ...
barTraker.Waits();
//
// Draw Signal Box ...
XCBoxObject *iObj;
bool isCreated = helper.poiDrawer.DrawBox(
signalBox,
iObj //
);
if (isCreated)
{
//
mObjects.Add(iObj);
ZeroMemory(iObj);
//
Print("Signal Box ...");
}
//
// Prepare Conditions ...
mConditions.symbol = symbol;
mConditions.period = period;
//
double spread = GetSpread(symbol);
//
double entry =
isBullish
? signalBox.upper
: signalBox.lower;
//
double sl =
isBullish
? signalBox.lower
: signalBox.upper;
if (additionalSL > 0)
{
//
sl =
isBullish
? sl - additionalSL
: sl + additionalSL;
}
//
double risk =
isBullish
? entry - sl
: sl - entry;
risk += spread;
if (risk >= maxAllowedSLDistanceInPoint * points)
{
//
// Fix Risk in Big Distances ...
double hh5 = zBar.FindHighest(5, MODE_HIGH);
double ll5 = zBar.FindLowest(5, MODE_LOW);
//
double hhll5Delta = hh5 - ll5;
double riskDelta = hhll5Delta / 2;
risk = riskDelta;
}
//
double rewardTP = risk * tpReward;
//
double tp =
isBullish
? entry + rewardTP
: entry - rewardTP;
//
// Filling ...
mConditions.sl = sl;
mConditions.tp = tp;
mConditions.pivot =
isBullish
? sl
: entry;
mConditions.point =
isBullish
? entry
: sl;
mConditions.dir = signalBoxDir;
mConditions.provider = "XCAEA";
mConditions.signalBox = signalBox;
mConditions.setupTime = zBar.time;
mConditions.conditions = conditions;
//
// Select RF Rewards ...
if (continuesRFTillTarget)
{
//
double rfReward = 1;
while (rfReward < tpReward)
{
//
double rewardRF = risk * rfReward;
double rfTP =
isBullish
? entry + rewardRF
: entry - rewardRF;
//
Add(
rfTP,
mConditions.targets //
);
//
rfReward++;
}
}
else
{
//
double rfReward = 1;
//
double rewardRF = risk * rfReward;
double rfTP =
isBullish
? entry + rewardRF
: entry - rewardRF;
//
Add(
rfTP,
mConditions.targets //
);
}
}
//
// Cleanup Resource ...
//
Clean(boxes);
Clean(bullishBoxes);
Clean(bearishBoxes);
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
pPBar.Clean();
//
pivotBox.Clean();
signalBox.Clean();
conditions.Clean();
//
return result;
}
/**
* Detect Trigger Conditions for Specified Signal ...
*
* @param conditions: XCAEAStrategyConditions instance Reference, Specified Signal Conditions ...
* @param maxAllowedSetupAge: specified Setup Age for Expiration (if bigger than Zero) ...
*
* @return ( bool )
*/
bool DetectSignalTrigger(
XCAEAStrategyConditions &conditions,
int maxAllowedSetupAge = 60 //
)
{
//
bool result = false;
//
result = conditions.IsSetuped();
if (!result)
{
return result;
}
//
datetime setupTime = conditions.setupTime;
ENUM_X_DIRECTION setupDir = conditions.dir;
//
bool isBullish = IsBullish(setupDir);
bool isBearish = IsBearish(setupDir);
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
int loopback = 10;
//
double ask = GetAsk(symbol);
double bid = GetBid(symbol);
datetime cTime = TimeCurrent();
double points = GetPoints(symbol);
//
// Check Signal Validation ...
// IMPORTANT: since all Validations done in SetUp Process ...
// here we only Execute Signal ...
//
result = isBullish ||
isBearish;
//
if (result)
{
//
conditions.triggerTime = cTime;
conditions.type = isBullish
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
}
//
// Cleanup ...
//
return result;
}
/**
* Detect Guards bsed on Signalling Class ...
*
* @param guards: XCAEAGuard instance Collection, Holds Provided Guards ...
* @param positions: XPosition instance Collection, Provides Signalling Based Positions for Apply Guards on them ...
* @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ...
*
* @return ( bool )
*/
bool DetectGuards(
XCAEAGuard &guards[],
const XPosition &positions[] //
)
{
//
bool result = false;
//
return result;
}
/**
* Add Conditions to Conditions Collection if not Exists ...
*
* @param maxAllowed: int, Specified Max Allowed Holding Conditions ...
*
* @return ( int )
*/
int AddConditionsIfNotExists(
int maxAllowed = 10 //
)
{
//
int result = 0;
//
bool isSetuped = IsValid(mConditions.setupTime) &&
HasDirection(mConditions.dir);
if (!isSetuped)
{
return result;
}
//
int count = ArraySize(mConditionsCollection);
if (IsValidSize(count))
{
//
// Copy Original Items ...
XCAEAStrategyConditions tmpItems[];
Copy(
mConditionsCollection,
tmpItems //
);
//
// Prese Item Data ...
bool isBullish = IsBullish(mConditions.dir);
//
for (int i = 0; i < count; i++)
{
//
XCAEAStrategyConditions iItem = tmpItems[i];
//
bool canRemove = mConditions.dir == iItem.dir &&
mConditions.pivot == iItem.pivot;
if (canRemove)
{
//
ArrayRemove(
mConditionsCollection,
i,
1 //
);
}
}
//
Clean(tmpItems);
}
//
AddRef(
mConditions,
mConditionsCollection //
);
//
// Remove Olds ...
CleanupArray(
mConditionsCollection,
maxAllowed //
);
//
result = ArraySize(mConditionsCollection);
//
return result;
}
//
// Protected ...
protected:
//
//
// Private ...
private:
//
// Props ...
string symbol;
ENUM_TIMEFRAMES period;
CArrayObj mObjects;
CArrayObj mBarObjects;
/**
* Initialize ...
*/
void Init()
{
//
useGuards = false;
continuesRFTillTarget = true;
//
barTraker.Init(
symbol,
period //
);
//
inputs.Default();
//
// Configure Indicators ...
//
// XCC ...
inputs.ccInputs.showCandles = true;
//
// XCT ...
inputs.ctInputs.showCandleTime = true;
//
// XCA ...
//
inputs.caInputs.supResSmoothingLength = 7;
inputs.caInputs.supResSmoothingMode = X_MA_MODE_NONE;
//
inputs.caInputs.showKI = true;
inputs.caInputs.showTKI = false;
inputs.caInputs.showSar = false;
inputs.caInputs.showVidya = true;
inputs.caInputs.showTrend = false;
inputs.caInputs.showSwings = false;
inputs.caInputs.showLongCycle = false;
inputs.caInputs.showHindCycle = false;
inputs.caInputs.showFiboLevel1 = false;
inputs.caInputs.showFiboLevel2 = false;
inputs.caInputs.showFiboLevel3 = false;
inputs.caInputs.showShortCycle = false;
inputs.caInputs.showMediumCycle = false;
inputs.caInputs.showPeaksAndVales = true;
inputs.caInputs.showPeakAndValeGolden = false;
inputs.caInputs.showSupportAndResistance = false;
//
// XOSCS ...
// inputs.oscsInputs.rsiLength = 5;
// inputs.oscsInputs.cciLength = 5;
// inputs.oscsInputs.mfiLength = 5;
// inputs.oscsInputs.rviLength = 5;
//
// Oscillators Views ...
inputs.showCCI = false;
inputs.showRSI = false;
inputs.showMFI = false;
inputs.showRVI = false;
inputs.showADX = false;
inputs.showMACD = false;
//
// XCAEA Helper ...
helper = new XCXCAEAHelper();
helper.Init(
symbol,
period,
inputs //
);
//
// Initialize and Configure Detector ...
detector = new XCXCAEAPOIDetector(helper);
//
// Configure Detector ...
detector.detectRSIPeakPivots = true;
detector.detectRSIValePivots = true;
detector.detectCCIPeakPivots = true;
detector.detectCCIValePivots = true;
detector.detectFVGBullishPivots = true;
detector.detectFVGBearishPivots = true;
detector.detectValeSupSWLPivots = true;
detector.detectPeakResSWHPivots = true;
detector.detectPVFVGBullishPivots = true;
detector.detectPVFVGBearishPivots = true;
//
// Initialize and Configure Drawer ...
drawer = new XCXCAEAPOIDrawer(detector);
//
drawer.ignoreUpdateOSCTos = true;
//
// Configure Drawer ...
drawer.drawRSIPeakPivots = true;
drawer.drawRSIValePivots = true;
drawer.drawCCIPeakPivots = true;
drawer.drawCCIValePivots = true;
drawer.drawFVGBullishPivots = false;
drawer.drawFVGBearishPivots = false;
drawer.drawValeSupSWLPivots = true;
drawer.drawPeakResSWHPivots = true;
drawer.drawPVFVGBullishPivots = true;
drawer.drawPVFVGBearishPivots = true;
//
// Configure Widths ...
drawer.rsiPeakPivotsWidth = 4;
drawer.rsiValePivotsWidth = 4;
drawer.cciPeakPivotsWidth = 4;
drawer.cciValePivotsWidth = 4;
drawer.fvgBullishPivotsWidth = 2;
drawer.fvgBearishPivotsWidth = 2;
drawer.valeSupSWLPivotsWidth = 1;
drawer.peakResSWHPivotsWidth = 1;
drawer.pvFVGBullishPivotsWidth = 1;
drawer.pvFVGBearishPivotsWidth = 1;
//
// Configure Colors ...
drawer.rsiPeakPivotsColor = clrMagenta;
drawer.rsiValePivotsColor = clrAqua;
drawer.cciPeakPivotsColor = clrMagenta;
drawer.cciValePivotsColor = clrAqua;
drawer.fvgBullishPivotsColor = clrLime;
drawer.fvgBearishPivotsColor = clrRed;
drawer.valeSupSWLPivotsColor = clrAqua;
drawer.peakResSWHPivotsColor = clrMagenta;
drawer.pvFVGBullishPivotsColor = clrLime;
drawer.pvFVGBearishPivotsColor = clrRed;
//
// Configures Styles ...
drawer.rsiPeakPivotsStyle = STYLE_DASH;
drawer.rsiValePivotsStyle = STYLE_DASH;
drawer.cciPeakPivotsStyle = STYLE_DASH;
drawer.cciValePivotsStyle = STYLE_DASH;
drawer.fvgBullishPivotsStyle = STYLE_DASHDOTDOT;
drawer.fvgBearishPivotsStyle = STYLE_DASHDOTDOT;
drawer.valeSupSWLPivotsStyle = STYLE_SOLID;
drawer.peakResSWHPivotsStyle = STYLE_SOLID;
drawer.pvFVGBullishPivotsStyle = STYLE_DASHDOTDOT;
drawer.pvFVGBearishPivotsStyle = STYLE_DASHDOTDOT;
//
}
/**
* DeInitialize ...
*/
void DeInit()
{
//
inputs.Clean();
//
ZeroMemory(drawer);
ZeroMemory(helper);
ZeroMemory(detector);
//
mConditions.Clean();
Clean(mConditionsCollection);
//
mObjects.Clear();
mBarObjects.Clear();
//
barTraker.Clean();
}
//
};
//
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+178
View File
@@ -38,6 +38,9 @@ class XCXCAEAPOIDrawer : public XCBase
//
// Props ...
//
bool ignoreUpdateOSCTos;
//
// Drawers ...
bool drawRSIPeakPivots;
@@ -48,6 +51,8 @@ class XCXCAEAPOIDrawer : public XCBase
bool drawFVGBearishPivots;
bool drawValeSupSWLPivots;
bool drawPeakResSWHPivots;
bool drawPVFVGBullishPivots;
bool drawPVFVGBearishPivots;
//
// Colors ...
@@ -65,6 +70,8 @@ class XCXCAEAPOIDrawer : public XCBase
color fvgBearishPivotsColor;
color valeSupSWLPivotsColor;
color peakResSWHPivotsColor;
color pvFVGBullishPivotsColor;
color pvFVGBearishPivotsColor;
//
// Width ...
@@ -82,6 +89,8 @@ class XCXCAEAPOIDrawer : public XCBase
int fvgBearishPivotsWidth;
int valeSupSWLPivotsWidth;
int peakResSWHPivotsWidth;
int pvFVGBullishPivotsWidth;
int pvFVGBearishPivotsWidth;
//
// Style ...
@@ -99,6 +108,8 @@ class XCXCAEAPOIDrawer : public XCBase
ENUM_LINE_STYLE fvgBearishPivotsStyle;
ENUM_LINE_STYLE valeSupSWLPivotsStyle;
ENUM_LINE_STYLE peakResSWHPivotsStyle;
ENUM_LINE_STYLE pvFVGBullishPivotsStyle;
ENUM_LINE_STYLE pvFVGBearishPivotsStyle;
//
// Colorize Props ...
@@ -144,6 +155,9 @@ class XCXCAEAPOIDrawer : public XCBase
//
virtual void Default()
{
//
ignoreUpdateOSCTos = true;
//
drawRSIPeakPivots = false;
drawRSIValePivots = false;
@@ -153,6 +167,8 @@ class XCXCAEAPOIDrawer : public XCBase
drawFVGBearishPivots = false;
drawValeSupSWLPivots = false;
drawPeakResSWHPivots = false;
drawPVFVGBullishPivots = false;
drawPVFVGBearishPivots = false;
//
defaultBullishColor = clrLime;
@@ -163,12 +179,14 @@ class XCXCAEAPOIDrawer : public XCBase
cciValePivotsColor = defaultBullishColor;
fvgBullishPivotsColor = defaultBullishColor;
valeSupSWLPivotsColor = defaultBullishColor;
pvFVGBullishPivotsColor = defaultBullishColor;
//
rsiPeakPivotsColor = defaultBearishColor;
cciPeakPivotsColor = defaultBearishColor;
fvgBearishPivotsColor = defaultBearishColor;
peakResSWHPivotsColor = defaultBearishColor;
pvFVGBearishPivotsColor = defaultBearishColor;
//
defaultBullishWidth = 1;
@@ -179,12 +197,14 @@ class XCXCAEAPOIDrawer : public XCBase
cciValePivotsWidth = defaultBullishWidth;
fvgBullishPivotsWidth = defaultBullishWidth;
valeSupSWLPivotsWidth = defaultBullishWidth;
pvFVGBullishPivotsWidth = defaultBullishWidth;
//
rsiPeakPivotsWidth = defaultBearishWidth;
cciPeakPivotsWidth = defaultBearishWidth;
fvgBearishPivotsWidth = defaultBearishWidth;
peakResSWHPivotsWidth = defaultBearishWidth;
pvFVGBearishPivotsWidth = defaultBearishWidth;
//
defaultBullishStyle = STYLE_SOLID;
@@ -195,12 +215,14 @@ class XCXCAEAPOIDrawer : public XCBase
cciValePivotsStyle = defaultBullishStyle;
fvgBullishPivotsStyle = defaultBullishStyle;
valeSupSWLPivotsStyle = defaultBullishStyle;
pvFVGBullishPivotsStyle = defaultBullishStyle;
//
rsiPeakPivotsStyle = defaultBearishStyle;
cciPeakPivotsStyle = defaultBearishStyle;
fvgBearishPivotsStyle = defaultBearishStyle;
peakResSWHPivotsStyle = defaultBearishStyle;
pvFVGBearishPivotsStyle = defaultBearishStyle;
}
//
@@ -215,6 +237,8 @@ class XCXCAEAPOIDrawer : public XCBase
DrawFVGBearishPivots(to);
DrawValeSupSWLPivots(to);
DrawPeakResSWHPivots(to);
DrawPVFVGBullishPivots(to);
DrawPVFVGBearishPivots(to);
}
//
@@ -229,6 +253,8 @@ class XCXCAEAPOIDrawer : public XCBase
mFVGBearishPivotObjects.Clear();
mValeSupSWLPivotObjects.Clear();
mPeakResSWHPivotObjects.Clear();
mPVFVGBullishPivotObjects.Clear();
mPVFVGBearishPivotObjects.Clear();
}
//
@@ -253,6 +279,10 @@ class XCXCAEAPOIDrawer : public XCBase
}
//
if (ignoreUpdateOSCTos)
{
to = NULL;
}
bool canUpdateTo = IsValid(to);
//
@@ -311,6 +341,10 @@ class XCXCAEAPOIDrawer : public XCBase
}
//
if (ignoreUpdateOSCTos)
{
to = NULL;
}
bool canUpdateTo = IsValid(to);
//
@@ -369,6 +403,10 @@ class XCXCAEAPOIDrawer : public XCBase
}
//
if (ignoreUpdateOSCTos)
{
to = NULL;
}
bool canUpdateTo = IsValid(to);
//
@@ -427,6 +465,10 @@ class XCXCAEAPOIDrawer : public XCBase
}
//
if (ignoreUpdateOSCTos)
{
to = NULL;
}
bool canUpdateTo = IsValid(to);
//
@@ -699,6 +741,140 @@ class XCXCAEAPOIDrawer : public XCBase
}
}
//
void DrawPVFVGBullishPivots(datetime to = NULL)
{
//
bool has = drawPVFVGBullishPivots;
if (!has)
{
return;
}
//
has = detector.HasPVFVGBullishPivots();
if (!has)
{
return;
}
//
bool canUpdateTo = IsValid(to);
//
int count = detector.CountPVFVGBullishPivots();
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox;
has = detector.pvFVGBullishPivots[i].GetSelectedFVG(iBox);
if (!has)
{
//
iBox.Clean();
continue;
}
//
if (canUpdateTo)
{
iBox.to = to;
}
//
XCBoxObject *iObj;
has = drawer.DrawBox(
iBox,
iObj //
);
//
if (has)
{
//
// Style Object ...
iObj.BoxColor(pvFVGBullishPivotsColor);
iObj.BoxWidth(pvFVGBullishPivotsWidth);
iObj.BoxStyle(pvFVGBullishPivotsStyle);
//
// Store Object ...
mPVFVGBullishPivotObjects.Add(iObj);
}
//
iBox.Clean();
ZeroMemory(iObj);
}
}
//
void DrawPVFVGBearishPivots(datetime to = NULL)
{
//
bool has = drawPVFVGBearishPivots;
if (!has)
{
return;
}
//
has = detector.HasPVFVGBearishPivots();
if (!has)
{
return;
}
//
bool canUpdateTo = IsValid(to);
//
int count = detector.CountPVFVGBearishPivots();
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox;
has = detector.pvFVGBearishPivots[i].GetSelectedFVG(iBox);
if (!has)
{
//
iBox.Clean();
continue;
}
//
if (canUpdateTo)
{
iBox.to = to;
}
//
XCBoxObject *iObj;
has = drawer.DrawBox(
iBox,
iObj //
);
//
if (has)
{
//
// Style Object ...
iObj.BoxColor(pvFVGBearishPivotsColor);
iObj.BoxWidth(pvFVGBearishPivotsWidth);
iObj.BoxStyle(pvFVGBearishPivotsStyle);
//
// Store Object ...
mPVFVGBearishPivotObjects.Add(iObj);
}
//
iBox.Clean();
ZeroMemory(iObj);
}
}
//
// Protected ...
protected:
@@ -724,6 +900,8 @@ class XCXCAEAPOIDrawer : public XCBase
CArrayObj mFVGBearishPivotObjects;
CArrayObj mValeSupSWLPivotObjects;
CArrayObj mPeakResSWHPivotObjects;
CArrayObj mPVFVGBullishPivotObjects;
CArrayObj mPVFVGBearishPivotObjects;
//
};
+25 -431
View File
@@ -421,7 +421,7 @@ int AddGuard(
//
bool DetectXCAEAConditions(
XBoxZone &boxes[],
XBoxZone &pivots[],
XCAEAConditions &conditions,
XBoxZone &pivotBox,
XBoxZone &box,
@@ -492,121 +492,6 @@ bool DetectXCAEAConditions(
//
// Reading Parameters ...
//
// KI ...
//
double cKI = conditions.kiBuffer[cIDX];
double pKI = conditions.kiBuffer[pIDX];
double p2KI = conditions.kiBuffer[p2IDX];
//
double cKIState = conditions.kiStateBuffer[cIDX];
double pKIState = conditions.kiStateBuffer[pIDX];
double p2KIState = conditions.kiStateBuffer[p2IDX];
//
// TKI ...
//
double cTKI = conditions.tkiBuffer[cIDX];
double pTKI = conditions.tkiBuffer[pIDX];
double p2TKI = conditions.tkiBuffer[p2IDX];
//
double cTKIState = conditions.tkiStateBuffer[cIDX];
double pTKIState = conditions.tkiStateBuffer[pIDX];
double p2TKIState = conditions.tkiStateBuffer[p2IDX];
//
// TREND ...
//
double cTrend = conditions.trendBuffer[cIDX];
double pTrend = conditions.trendBuffer[pIDX];
double p2Trend = conditions.trendBuffer[p2IDX];
//
double ctrendState = conditions.trendStateBuffer[cIDX];
double ptrendState = conditions.trendStateBuffer[pIDX];
double p2trendState = conditions.trendStateBuffer[p2IDX];
//
// SWING Low ...
double cSWL = conditions.swingLowBuffer[cIDX];
double pSWL = conditions.swingLowBuffer[pIDX];
double p2SWL = conditions.swingLowBuffer[p2IDX];
//
// SWING High ...
double cSWH = conditions.swingHighBuffer[cIDX];
double pSWH = conditions.swingHighBuffer[pIDX];
double p2SWH = conditions.swingHighBuffer[p2IDX];
//
// PEAK ...
double zPeak = conditions.peakBuffer[zIDX];
double cPeak = conditions.peakBuffer[cIDX];
double pPeak = conditions.peakBuffer[pIDX];
double p2Peak = conditions.peakBuffer[p2IDX];
double p3Peak = conditions.peakBuffer[p3IDX];
//
// VALE ...
double zVale = conditions.valeBuffer[zIDX];
double cVale = conditions.valeBuffer[cIDX];
double pVale = conditions.valeBuffer[pIDX];
double p2Vale = conditions.valeBuffer[p2IDX];
double p3Vale = conditions.valeBuffer[p3IDX];
//
// VIDYA ...
double zVidya = conditions.vidyaBuffer[zIDX];
double cVidya = conditions.vidyaBuffer[cIDX];
double pVidya = conditions.vidyaBuffer[pIDX];
double p2Vidya = conditions.vidyaBuffer[p2IDX];
double p3Vidya = conditions.vidyaBuffer[p3IDX];
//
double zVidyaState = conditions.vidyaStateBuffer[zIDX];
double cVidyaState = conditions.vidyaStateBuffer[cIDX];
double pVidyaState = conditions.vidyaStateBuffer[pIDX];
double p2VidyaState = conditions.vidyaStateBuffer[p2IDX];
double p3VidyaState = conditions.vidyaStateBuffer[p3IDX];
//
// RSI ...
double zRSI = conditions.rsiBuffer[zIDX];
double cRSI = conditions.rsiBuffer[cIDX];
double pRSI = conditions.rsiBuffer[pIDX];
double p2RSI = conditions.rsiBuffer[p2IDX];
double p3RSI = conditions.rsiBuffer[p3IDX];
//
// CCI ...
double zCCI = conditions.cciBuffer[zIDX];
double cCCI = conditions.cciBuffer[cIDX];
double pCCI = conditions.cciBuffer[pIDX];
double p2CCI = conditions.cciBuffer[p2IDX];
double p3CCI = conditions.cciBuffer[p3IDX];
//
// RVI ...
//
double zRVI = conditions.rviBuffer[zIDX];
double cRVI = conditions.rviBuffer[cIDX];
double pRVI = conditions.rviBuffer[pIDX];
double p2RVI = conditions.rviBuffer[p2IDX];
double p3RVI = conditions.rviBuffer[p3IDX];
//
double zRVISignal = conditions.rviSignalBuffer[zIDX];
double cRVISignal = conditions.rviSignalBuffer[cIDX];
double pRVISignal = conditions.rviSignalBuffer[pIDX];
double p2RVISignal = conditions.rviSignalBuffer[p2IDX];
double p3RVISignal = conditions.rviSignalBuffer[p3IDX];
//
// Reading Bars ...
@@ -770,293 +655,17 @@ bool DetectXCAEAConditions(
// Conditions ...
//
bool isRSIBullish =
zRSI >= cRSI &&
cRSI > pRSI;
bool isRSIBearish =
zRSI <= cRSI &&
cRSI < pRSI;
//
bool isCCIBullish =
zCCI >= cCCI &&
cCCI > pCCI &&
(zCCI > conditions.cciOSLevel ||
cCCI > conditions.cciOSLevel);
bool isCCIBearish =
zCCI >= cCCI &&
cCCI > pCCI &&
(zCCI < conditions.cciOBLevel ||
cCCI < conditions.cciOBLevel);
//
// Detect Selected Box ...
XBoxZone oscBoxes[];
XBoxZone lastOSCBox;
// Detect Selected Pivot ...
XBoxZone oscPivots[];
XBoxZone lastOSCPivot;
double providedSL = 0;
bool isBoxFVG = false;
bool hasOSCBox = false;
bool hasPivotBox = false;
bool isBoxPeakVale = false;
bool isBoxRejected = false;
bool isBoxActivated = false;
bool isBoxFullSifeRejected = false;
bool hasBoxes = HasChild(boxes);
if (hasBoxes)
bool hasPivots = HasChild(pivots);
if (hasPivots)
{
//
// Detect Selected Boxes ...
XBoxZone tmp[];
Copy(
boxes,
tmp //
);
while (HasChild(tmp))
{
//
idx = GetYoungest(tmp);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XBoxZone iBox;
iBox = tmp[idx];
ArrayRemove(
tmp,
idx,
1 //
);
//
// Check Selected Box not RSI or CCI ...
isBoxFVG = Contains(
"XCA_FVG",
iBox.type //
);
isBoxPeakVale =
Contains(
"XCA_PEAKSWHRES",
iBox.type //
) ||
Contains(
"XCA_VALESWLSUP",
iBox.type //
);
has = isBoxFVG ||
isBoxPeakVale;
if (!has)
{
//
bool isOSC = Contains(
"XCA_CCI_VALE",
iBox.type //
) ||
Contains(
"XCA_CCI_PEAK",
iBox.type //
) ||
Contains(
"XCA_RSI_VALE",
iBox.type //
) ||
Contains(
"XCA_RSI_PEAK",
iBox.type //
);
if (isOSC)
{
//
AddRef(
iBox,
oscBoxes //
);
}
//
iBox.Clean();
//
continue;
}
//
bool isBullish = iBox.IsBullish();
bool isBearish = iBox.IsBearish();
//
double rejectedCheckPrice =
isBullish
? iBox.upper
: iBox.lower;
double rejectedFullCheckPrice =
isBullish
? iBox.lower
: iBox.upper;
//
// Check Box Selecting Senarios ...
//
// Selecting Rejected Boxes ...
isBoxRejected = cBar.IsRejected(
rejectedCheckPrice,
iBox.dir,
false,
false //
);
//
// Selecting Rejected Boxes ...
isBoxFullSifeRejected = cBar.IsRejected(
rejectedFullCheckPrice,
iBox.dir,
false,
false //
);
//
// Selecting Activation Boxes ...
//
bool isBullishActivated =
isBullish &&
cBar.IsBullish() &&
cBar.GetUp() > rejectedCheckPrice &&
cBar.GetDown() < rejectedCheckPrice;
//
bool isBearishActivated =
isBearish &&
cBar.IsBearish() &&
cBar.GetUp() > rejectedCheckPrice &&
cBar.GetDown() < rejectedCheckPrice;
//
isBoxActivated = isBullishActivated ||
isBearishActivated;
//
// Detect Box is Selected or not ...
has =
isBoxRejected ||
isBoxActivated ||
isBoxFullSifeRejected;
if (has)
{
//
pivotBox = iBox;
//
iBox.Clean();
break;
}
//
iBox.Clean();
}
//
Clean(tmp);
}
//
// Check OSC Boxes ...
bool hasOSCBoxes = HasChild(oscBoxes);
if (hasOSCBoxes)
{
//
// Detect Newest OSC Box ...
idx = GetYoungest(oscBoxes);
has = IsValidIndex(idx);
if (has)
{
lastOSCBox = oscBoxes[idx];
}
//
// Validate OSC Box is Valid or not ...
has = lastOSCBox.IsValid();
if (has)
{
//
// Check Bar is Inside OSC Box or not ...
has = cBar.time > lastOSCBox.from &&
cBar.time <= lastOSCBox.to;
if (!has)
{
lastOSCBox.Clean();
}
}
//
hasOSCBox = lastOSCBox.IsValid();
if (hasOSCBox)
{
// //
// XCBoxObject *iObj;
// has = helper.poiDrawer.DrawBox(
// lastOSCBox,
// iObj //
// );
// if (has) {
// iObj.BoxWidth(4);
// }
}
}
//
// Force Conditions to Have Selected Box ...
hasPivotBox = hasBoxes &&
pivotBox.IsValid();
if (hasPivotBox)
{
// //
// pivotBox.to = TimeCurrent();
// //
// // Draw Pivot Box Here ...
// if (isBoxPeakVale)
// {
// //
// XCBoxObject *iObj;
// has = helper.poiDrawer.DrawBox(
// pivotBox,
// iObj //
// );
// if (has)
// {
// //
// iObj.BoxWidth(5);
// iObj.BoxColor(clrDodgerBlue);
// Print("Draw Pivot Box ...");
// }
// }
}
//
// If all Conditions required Boxes ...
// if (!result)
// {
// //
// zBar.Clean();
// cBar.Clean();
// pBar.Clean();
// p2Bar.Clean();
// p3Bar.Clean();
// p4Bar.Clean();
// //
// box.Clean();
// pivotBox.Clean();
// conditions.Clean();
// //
// return result;
// }
//
// Signaller Summarization ...
@@ -1066,32 +675,14 @@ bool DetectXCAEAConditions(
//
bool isCond1Bullish =
//
false &&
hasPivotBox &&
isBoxPeakVale &&
isScoreBullish &&
pivotBox.IsBullish() &&
(conditions.isValeUnderLast ||
(conditions.isValeSameLast &&
pConditions.isValeUnderLast)) &&
conditions.isRSICrossedOverOS &&
conditions.isCCICrossedOverOS
false
//
;
//
bool isCond1Bearish =
//
false &&
hasPivotBox &&
isBoxPeakVale &&
isScoreBearish &&
pivotBox.IsBearish() &&
(conditions.isPeakOverLast ||
(conditions.isPeakSameLast &&
pConditions.isPeakOverLast)) &&
conditions.isRSICrossedUnderOB &&
conditions.isCCICrossedUnderOB
false
//
;
@@ -1119,20 +710,14 @@ bool DetectXCAEAConditions(
//
bool isCond2Bullish =
//
hasOSCBox &&
// cVidyaState < 0 &&
lastOSCBox.IsBullish() // &&
// lastOSCBox.upper < cVidya
false
//
;
//
bool isCond2Bearish =
//
hasOSCBox &&
// cVidyaState > 0 &&
lastOSCBox.IsBearish() // &&
// lastOSCBox.lower > cVidya
false
//
;
@@ -1143,24 +728,30 @@ bool DetectXCAEAConditions(
{
//
providedSL =
isCond1Bullish
isCond2Bullish
? MathMin(pBar.low, pivotBox.lower)
: MathMax(pBar.high, pivotBox.upper);
//
Print("Cond2");
isCond2Bullish = false;
isCond2Bearish = false;
}
//
// Cond3 Act Using CCi Peaks and Vales ...
//
bool isCond3Bullish = false;
bool isCond3Bullish =
//
false
//
;
//
bool isCond3Bearish = false;
bool isCond3Bearish =
//
false
//
;
//
bool isCond3 = isCond3Bullish ||
@@ -1168,6 +759,10 @@ bool DetectXCAEAConditions(
if (isCond3)
{
//
providedSL =
isCond3Bullish
? MathMin(pBar.low, pivotBox.lower)
: MathMax(pBar.high, pivotBox.upper);
//
Print("Cond3");
@@ -1267,7 +862,6 @@ bool DetectXCAEAConditions(
p2Bar.Clean();
p3Bar.Clean();
p4Bar.Clean();
Clean(oscBoxes);
pConditions.Clean();
//
+71 -51
View File
@@ -167,12 +167,12 @@ class XCXCAEASignaller : XCBase
//
// Setup Conditions ...
XBoxZone boxes[];
XBoxZone pivots[];
XBoxZone pivotBox;
XBoxZone signalBox;
int pivotsCount = 0;
bool hasPivots = false;
double additionalSL = 0;
XBoxZone bullishBoxes[];
XBoxZone bearishBoxes[];
bool hasSignalBox = false;
XCAEAConditions conditions;
ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE;
@@ -182,11 +182,6 @@ class XCXCAEASignaller : XCBase
detector.Update(
zIndex //
);
//
if (detector.newValeSupSWLPivotDetected) {
Print("Salam");
}
//
// Validate Pivots ...
@@ -201,36 +196,12 @@ class XCXCAEASignaller : XCBase
//
// Retrieve Valid Boxes ...
// //
// // Bullish ...
// int bullishBoxesCount =
// detector
// .FillBullishBoxes(bullishBoxes);
// //
// // Bearish ...
// int bearishBoxesCount =
// detector
// .FillBearishBoxes(bearishBoxes);
// //
// Copy(
// bullishBoxes,
// boxes,
// false //
// );
// Copy(
// bearishBoxes,
// boxes,
// false //
// );
int boxesCount = ArraySize(boxes);
bool hasBoxes = IsValidSize(boxesCount);
pivotsCount = detector.FillPivots(pivots);
hasPivots = IsValidSize(pivotsCount);
//
// Filter UnAvailable Boxes ...
if (hasBoxes)
if (hasPivots)
{
//
// Remove UnAvailable Boxes ...
@@ -248,13 +219,13 @@ class XCXCAEASignaller : XCBase
has = FindBoxIndex(
idx,
iBox,
boxes //
pivots //
);
if (has)
{
//
ArrayRemove(
boxes,
pivots,
idx,
1 //
);
@@ -263,23 +234,18 @@ class XCXCAEASignaller : XCBase
}
//
hasBoxes = HasChild(boxes);
boxesCount = ArraySize(boxes);
hasPivots = HasChild(pivots);
pivotsCount = ArraySize(pivots);
}
//
//
//
//
// if (hasBoxes)
// {
// }
//
// Detect Sinal Box ...
hasSignalBox = DetectXCAEAConditions(
boxes,
pivots,
conditions,
pivotBox,
signalBox,
@@ -301,6 +267,17 @@ class XCXCAEASignaller : XCBase
);
}
//
// Make Signal Box UnAvailable ...
if (signalBox.IsValid())
{
//
AddRef(
signalBox,
unAvailableBoxes //
);
}
//
isBullish = hasSignalBox &&
IsBullish(signalBoxDir);
@@ -458,9 +435,7 @@ class XCXCAEASignaller : XCBase
// Cleanup Resource ...
//
Clean(boxes);
Clean(bullishBoxes);
Clean(bearishBoxes);
Clean(pivots);
//
zBar.Clean();
@@ -762,24 +737,69 @@ class XCXCAEASignaller : XCBase
detector.detectFVGBearishPivots = true;
detector.detectValeSupSWLPivots = true;
detector.detectPeakResSWHPivots = true;
detector.detectPVFVGBullishPivots = true;
detector.detectPVFVGBearishPivots = true;
//
// Initialize and Configure Drawer ...
drawer = new XCXCAEAPOIDrawer(detector);
//
drawer.ignoreUpdateOSCTos = true;
//
// Configure Drawer ...
drawer.drawRSIPeakPivots = true;
drawer.drawRSIValePivots = true;
drawer.drawCCIPeakPivots = true;
drawer.drawCCIValePivots = true;
drawer.drawFVGBullishPivots = true;
drawer.drawFVGBearishPivots = true;
drawer.drawFVGBullishPivots = false;
drawer.drawFVGBearishPivots = false;
drawer.drawValeSupSWLPivots = true;
drawer.drawPeakResSWHPivots = true;
drawer.drawPVFVGBullishPivots = true;
drawer.drawPVFVGBearishPivots = true;
//
// Configure Widths ...
drawer.rsiPeakPivotsWidth = 4;
drawer.rsiValePivotsWidth = 4;
drawer.cciPeakPivotsWidth = 4;
drawer.cciValePivotsWidth = 4;
drawer.fvgBullishPivotsWidth = 2;
drawer.fvgBearishPivotsWidth = 2;
drawer.valeSupSWLPivotsWidth = 1;
drawer.peakResSWHPivotsWidth = 1;
drawer.pvFVGBullishPivotsWidth = 1;
drawer.pvFVGBearishPivotsWidth = 1;
//
// Configure Colors ...
drawer.rsiPeakPivotsColor = clrMagenta;
drawer.rsiValePivotsColor = clrAqua;
drawer.cciPeakPivotsColor = clrMagenta;
drawer.cciValePivotsColor = clrAqua;
drawer.fvgBullishPivotsColor = clrLime;
drawer.fvgBearishPivotsColor = clrRed;
drawer.valeSupSWLPivotsColor = clrAqua;
drawer.peakResSWHPivotsColor = clrMagenta;
drawer.pvFVGBullishPivotsColor = clrLime;
drawer.pvFVGBearishPivotsColor = clrRed;
//
// Configures Styles ...
drawer.rsiPeakPivotsStyle = STYLE_DASH;
drawer.rsiValePivotsStyle = STYLE_DASH;
drawer.cciPeakPivotsStyle = STYLE_DASH;
drawer.cciValePivotsStyle = STYLE_DASH;
drawer.fvgBullishPivotsStyle = STYLE_DASHDOTDOT;
drawer.fvgBearishPivotsStyle = STYLE_DASHDOTDOT;
drawer.valeSupSWLPivotsStyle = STYLE_SOLID;
drawer.peakResSWHPivotsStyle = STYLE_SOLID;
drawer.pvFVGBullishPivotsStyle = STYLE_DASHDOTDOT;
drawer.pvFVGBearishPivotsStyle = STYLE_DASHDOTDOT;
//
// UnActive Pivots ...
}
/**