Last ...
This commit is contained in:
@@ -73,10 +73,62 @@ enum ENUM_X_CHART_IDS
|
|||||||
X_UPPER,
|
X_UPPER,
|
||||||
X_LOWER,
|
X_LOWER,
|
||||||
X_ENTRY,
|
X_ENTRY,
|
||||||
|
X_TARGET,
|
||||||
X_SL,
|
X_SL,
|
||||||
X_TP
|
X_TP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
string ToString(ENUM_X_CHART_IDS value) {
|
||||||
|
//
|
||||||
|
string result = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch(value) {
|
||||||
|
//
|
||||||
|
case X_TO:
|
||||||
|
result = "TO";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_FROM:
|
||||||
|
result = "FROM";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_UPPER:
|
||||||
|
result = "UPPER";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_LOWER:
|
||||||
|
result = "LOWER";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_ENTRY:
|
||||||
|
result = "ENTRY";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_TARGET:
|
||||||
|
result = "TARGET";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_SL:
|
||||||
|
result = "SL";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_TP:
|
||||||
|
result = "TP";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implementation ...
|
// Implementation ...
|
||||||
|
|
||||||
@@ -1760,6 +1812,29 @@ class XCSignalObject : public XCBaseObject
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TARGET ...
|
||||||
|
if (signal.target > 0) {
|
||||||
|
//
|
||||||
|
string targetName = ToString(X_TARGET) + "_" + nameMD5;
|
||||||
|
result = mTargetTrend.Create(
|
||||||
|
chart_id,
|
||||||
|
targetName,
|
||||||
|
window,
|
||||||
|
time1,
|
||||||
|
signal.target,
|
||||||
|
time2,
|
||||||
|
signal.target //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
mTPTrend.Delete();
|
||||||
|
mSLTrend.Delete();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// ENTRY ...
|
// ENTRY ...
|
||||||
string entrName = ToString(X_ENTRY) + "_" + nameMD5;
|
string entrName = ToString(X_ENTRY) + "_" + nameMD5;
|
||||||
@@ -1777,6 +1852,7 @@ class XCSignalObject : public XCBaseObject
|
|||||||
//
|
//
|
||||||
mTPTrend.Delete();
|
mTPTrend.Delete();
|
||||||
mSLTrend.Delete();
|
mSLTrend.Delete();
|
||||||
|
mTargetTrend.Delete();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1871,6 +1947,46 @@ class XCSignalObject : public XCBaseObject
|
|||||||
mSLTrend.Style(value);
|
mSLTrend.Style(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TARGET ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Target Width ...
|
||||||
|
*
|
||||||
|
* @param value: Integer ...
|
||||||
|
*/
|
||||||
|
void TargetWidth(int value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (value < 1)
|
||||||
|
{
|
||||||
|
value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mTargetTrend.Width(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Target Color ...
|
||||||
|
*
|
||||||
|
* @param value: Color ...
|
||||||
|
*/
|
||||||
|
void TargetColor(color value)
|
||||||
|
{
|
||||||
|
mTargetTrend.Color(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Target Style ...
|
||||||
|
*
|
||||||
|
* @param value: ENUM_LINE_STYLE ...
|
||||||
|
*/
|
||||||
|
void TargetStyle(ENUM_LINE_STYLE value)
|
||||||
|
{
|
||||||
|
mTargetTrend.Style(value);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// ENTRY ...
|
// ENTRY ...
|
||||||
|
|
||||||
@@ -1929,6 +2045,7 @@ class XCSignalObject : public XCBaseObject
|
|||||||
CChartObjectTrend mTPTrend;
|
CChartObjectTrend mTPTrend;
|
||||||
CChartObjectTrend mSLTrend;
|
CChartObjectTrend mSLTrend;
|
||||||
CChartObjectTrend mEntryTrend;
|
CChartObjectTrend mEntryTrend;
|
||||||
|
CChartObjectTrend mTargetTrend;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -2518,6 +2518,7 @@ class XCPOIDrawer : public XCBase
|
|||||||
*
|
*
|
||||||
* @param state: XPOIState instance Reference ...
|
* @param state: XPOIState instance Reference ...
|
||||||
* @param drawnObjects: CArrayObj instance for Holding Drawn Objects ...
|
* @param drawnObjects: CArrayObj instance for Holding Drawn Objects ...
|
||||||
|
* @param drawTicksZone: Boolean ...
|
||||||
* @param ignoreSwingHighs: Boolean ...
|
* @param ignoreSwingHighs: Boolean ...
|
||||||
* @param ignoreSwingLows: Boolean ...
|
* @param ignoreSwingLows: Boolean ...
|
||||||
* @param ignoreSupportZones: Boolean ...
|
* @param ignoreSupportZones: Boolean ...
|
||||||
@@ -2536,6 +2537,7 @@ class XCPOIDrawer : public XCBase
|
|||||||
int DrawState(
|
int DrawState(
|
||||||
XPOIState &state,
|
XPOIState &state,
|
||||||
XCBaseObject *&drawnObjects[],
|
XCBaseObject *&drawnObjects[],
|
||||||
|
bool drawTicksZone = false,
|
||||||
bool ignoreSwingHighs = false,
|
bool ignoreSwingHighs = false,
|
||||||
bool ignoreSwingLows = false,
|
bool ignoreSwingLows = false,
|
||||||
bool ignoreSupportZones = false,
|
bool ignoreSupportZones = false,
|
||||||
@@ -3013,6 +3015,24 @@ class XCPOIDrawer : public XCBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (drawTicksZone && state.ticksZone != NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCTicksZoneObject *iObj;
|
||||||
|
bool isCreated = CreateTicksZone(
|
||||||
|
state.ticksZone,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
Add(
|
||||||
|
(XCBaseObject *)iObj,
|
||||||
|
drawnObjects //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ArraySize(drawnObjects);
|
result = ArraySize(drawnObjects);
|
||||||
|
|
||||||
@@ -3025,7 +3045,7 @@ class XCPOIDrawer : public XCBase
|
|||||||
*
|
*
|
||||||
* @param pivot: XPVPivot instance Reference ...
|
* @param pivot: XPVPivot instance Reference ...
|
||||||
* @param drawState: Boolean ...
|
* @param drawState: Boolean ...
|
||||||
* @param filterByPrice: Boolean ...
|
* @param drawTicksZone: Boolean ...
|
||||||
* @param ignoreSwingHighs: Boolean ...
|
* @param ignoreSwingHighs: Boolean ...
|
||||||
* @param ignoreSwingLows: Boolean ...
|
* @param ignoreSwingLows: Boolean ...
|
||||||
* @param ignoreSupportZones: Boolean ...
|
* @param ignoreSupportZones: Boolean ...
|
||||||
@@ -3044,7 +3064,8 @@ class XCPOIDrawer : public XCBase
|
|||||||
int DrawPivot(
|
int DrawPivot(
|
||||||
XPVPivot &pivot,
|
XPVPivot &pivot,
|
||||||
XCBaseObject *&drawnObjects[],
|
XCBaseObject *&drawnObjects[],
|
||||||
bool drawState = true,
|
bool drawState = false,
|
||||||
|
bool drawTicksZone = false,
|
||||||
bool ignoreSwingHighs = false,
|
bool ignoreSwingHighs = false,
|
||||||
bool ignoreSwingLows = false,
|
bool ignoreSwingLows = false,
|
||||||
bool ignoreSupportZones = false,
|
bool ignoreSupportZones = false,
|
||||||
@@ -3099,7 +3120,7 @@ class XCPOIDrawer : public XCBase
|
|||||||
(XCBaseObject *)iPivotObj,
|
(XCBaseObject *)iPivotObj,
|
||||||
drawnObjects //
|
drawnObjects //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ArraySize(drawnObjects);
|
result = ArraySize(drawnObjects);
|
||||||
|
|
||||||
@@ -3120,6 +3141,7 @@ class XCPOIDrawer : public XCBase
|
|||||||
int stateCount = DrawState(
|
int stateCount = DrawState(
|
||||||
pivot.state,
|
pivot.state,
|
||||||
stateObjects,
|
stateObjects,
|
||||||
|
drawTicksZone,
|
||||||
ignoreSwingHighs,
|
ignoreSwingHighs,
|
||||||
ignoreSwingLows,
|
ignoreSwingLows,
|
||||||
ignoreSupportZones,
|
ignoreSupportZones,
|
||||||
|
|||||||
@@ -0,0 +1,852 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 X121 SMC Signal Class
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Name:
|
||||||
|
// Description: provide all Signalling functions ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property library
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://www.saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
||||||
|
#include "../Libraries/x-121.smc.lib.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
struct X121SMCStrategyXTWPVSignalConditions
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol;
|
||||||
|
ENUM_TIMEFRAMES period;
|
||||||
|
|
||||||
|
//
|
||||||
|
double sl;
|
||||||
|
double target;
|
||||||
|
ENUM_X_DIRECTION dir;
|
||||||
|
ENUM_X_POSITION_TYPES type;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Setup Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime setupTime;
|
||||||
|
datetime triggerTime;
|
||||||
|
|
||||||
|
//
|
||||||
|
XPVPivot parentPivot;
|
||||||
|
XPVPivot childPivot;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
X121SMCStrategyXTWPVSignalConditions()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleaning Up ...
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
sl = 0;
|
||||||
|
target = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
type = X_POSITION_TYPE_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
symbol = NULL;
|
||||||
|
period = NULL;
|
||||||
|
setupTime = NULL;
|
||||||
|
triggerTime = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
ExtensionClean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Condition is Setting Up ...
|
||||||
|
*
|
||||||
|
* @param dir: ENUM_X_DIRECTION member, Setting Up Direction ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsSetuped()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid(setupTime) &&
|
||||||
|
HasDirection(dir);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Setup Age ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetSetupAge()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsSetuped())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect How we Can Trigger Signal ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool CanTrigger()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
sl > 0 &&
|
||||||
|
IsValid(symbol) &&
|
||||||
|
IsValid(period) &&
|
||||||
|
IsValid(triggerTime) &&
|
||||||
|
type != X_POSITION_TYPE_ALL &&
|
||||||
|
type != X_POSITION_TYPE_NONE
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extensions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean Additional Properties ...
|
||||||
|
*/
|
||||||
|
void ExtensionClean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
CleanPivots();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CleanPivots()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
parentPivot.Clean();
|
||||||
|
childPivot.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasParentPivot()
|
||||||
|
{
|
||||||
|
return parentPivot.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasChildPivot()
|
||||||
|
{
|
||||||
|
return childPivot.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extension Functions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Setup Conditions ...
|
||||||
|
bool DetectX121SMCXTWPVSiganlSetup(
|
||||||
|
string _symbol,
|
||||||
|
ENUM_TIMEFRAMES _period,
|
||||||
|
//
|
||||||
|
X121SMCStrategyXTWPVSignalConditions &conditions,
|
||||||
|
//
|
||||||
|
XC121SMCCycleHelper *triggerCycleHelper,
|
||||||
|
XC121SMCCycleHelper *decisionCycleHelper,
|
||||||
|
XC121SMCCycleHelper *analyseCycleHelper,
|
||||||
|
XC121SMCCycleHelper *verificationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *consolidationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *visionCycleHelper
|
||||||
|
//
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int zIndex = 0;
|
||||||
|
int cIndex = zIndex + 1;
|
||||||
|
int pIndex = cIndex + 1;
|
||||||
|
int ppIndex = pIndex + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int loopback = 10;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = _symbol;
|
||||||
|
ENUM_TIMEFRAMES period = _period;
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.symbol = symbol;
|
||||||
|
conditions.period = period;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL zBar;
|
||||||
|
result = zBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
zIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
result = cBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
cIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double ask = GetAsk(symbol);
|
||||||
|
double bid = GetBid(symbol);
|
||||||
|
datetime cTime = TimeCurrent();
|
||||||
|
|
||||||
|
//
|
||||||
|
double ll = cBar.FindLowest(9, MODE_LOW);
|
||||||
|
double hh = cBar.FindHighest(9, MODE_HIGH);
|
||||||
|
|
||||||
|
//
|
||||||
|
int zoneValidationDivider = 10;
|
||||||
|
int validPivotRepetition = triggerCycleHelper.mX121Helper
|
||||||
|
.GetDonChainLength();
|
||||||
|
|
||||||
|
//
|
||||||
|
double selectedSL = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger ...
|
||||||
|
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
||||||
|
X121SMCCycleConditions triggerConditions;
|
||||||
|
result = triggerCycleHelper.GetConditions(
|
||||||
|
triggerCycleEvents,
|
||||||
|
triggerPoiEvents,
|
||||||
|
triggerConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decision ...
|
||||||
|
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
||||||
|
X121SMCCycleConditions decisionConditions;
|
||||||
|
result = decisionCycleHelper.GetConditions(
|
||||||
|
decisionCycleEvents,
|
||||||
|
decisionPoiEvents,
|
||||||
|
decisionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Analyse ...
|
||||||
|
ENUM_XPOI_EVENTS analysePoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
||||||
|
X121SMCCycleConditions analyseConditions;
|
||||||
|
result = analyseCycleHelper.GetConditions(
|
||||||
|
analyseCycleEvents,
|
||||||
|
analysePoiEvents,
|
||||||
|
analyseConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Verification ...
|
||||||
|
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
||||||
|
X121SMCCycleConditions verificationConditions;
|
||||||
|
result = verificationCycleHelper.GetConditions(
|
||||||
|
verificationCycleEvents,
|
||||||
|
verificationPoiEvents,
|
||||||
|
verificationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Consolidation ...
|
||||||
|
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
||||||
|
X121SMCCycleConditions consolidationConditions;
|
||||||
|
result = consolidationCycleHelper.GetConditions(
|
||||||
|
consolidationCycleEvents,
|
||||||
|
consolidationPoiEvents,
|
||||||
|
consolidationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vision ...
|
||||||
|
ENUM_XPOI_EVENTS visionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
||||||
|
X121SMCCycleConditions visionConditions;
|
||||||
|
result = visionCycleHelper.GetConditions(
|
||||||
|
visionCycleEvents,
|
||||||
|
visionPoiEvents,
|
||||||
|
visionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles POI States ...
|
||||||
|
XPOIState triggerState = triggerConditions.state;
|
||||||
|
XPOIState decisionState = decisionConditions.state;
|
||||||
|
XPOIState analyseState = analyseConditions.state;
|
||||||
|
XPOIState verificationState = verificationConditions.state;
|
||||||
|
XPOIState consolidationState = consolidationConditions.state;
|
||||||
|
XPOIState visionState = visionConditions.state;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Setup Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Market Trend ...
|
||||||
|
// ENUM_X_DIRECTION trend;
|
||||||
|
// bool hasTrend = verificationCycleHelper
|
||||||
|
// .DetectTrend(trend);
|
||||||
|
// bool hasBullishTrend = hasTrend &&
|
||||||
|
// IsBullish(trend);
|
||||||
|
// bool hasBearishTrend = hasTrend &&
|
||||||
|
// IsBearish(trend);
|
||||||
|
// result = hasBullishTrend ||
|
||||||
|
// hasBearishTrend;
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Active Pivots ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPVPivot peakPivot;
|
||||||
|
bool hasPeakPivot = analyseCycleHelper
|
||||||
|
.GetActivePeakPivot(peakPivot);
|
||||||
|
|
||||||
|
//
|
||||||
|
XPVPivot valePivot;
|
||||||
|
bool hasValePivot = analyseCycleHelper
|
||||||
|
.GetActiveValePivot(valePivot);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Parent Pivot ...
|
||||||
|
bool hasParentPivot = conditions.HasParentPivot();
|
||||||
|
if (!hasParentPivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (hasPeakPivot && !hasValePivot)
|
||||||
|
{
|
||||||
|
conditions.parentPivot = peakPivot;
|
||||||
|
}
|
||||||
|
else if (hasValePivot && !hasPeakPivot)
|
||||||
|
{
|
||||||
|
conditions.parentPivot = valePivot;
|
||||||
|
}
|
||||||
|
else if (hasPeakPivot && hasValePivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (peakPivot.from < valePivot.from)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.parentPivot = peakPivot;
|
||||||
|
conditions.childPivot = valePivot;
|
||||||
|
}
|
||||||
|
else if (valePivot.from < peakPivot.from)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.parentPivot = valePivot;
|
||||||
|
conditions.childPivot = peakPivot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hasParentPivot = conditions.HasParentPivot();
|
||||||
|
result = hasParentPivot;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Child Pivot ...
|
||||||
|
bool hasChildPivot = conditions.HasChildPivot();
|
||||||
|
if (!hasChildPivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (hasPeakPivot && !hasValePivot)
|
||||||
|
{
|
||||||
|
conditions.childPivot = peakPivot;
|
||||||
|
}
|
||||||
|
else if (hasValePivot && !hasPeakPivot)
|
||||||
|
{
|
||||||
|
conditions.childPivot = valePivot;
|
||||||
|
}
|
||||||
|
else if (hasPeakPivot && hasValePivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (peakPivot.from < valePivot.from)
|
||||||
|
{
|
||||||
|
conditions.childPivot = peakPivot;
|
||||||
|
}
|
||||||
|
else if (valePivot.from < peakPivot.from)
|
||||||
|
{
|
||||||
|
conditions.childPivot = valePivot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hasChildPivot = conditions.HasChildPivot();
|
||||||
|
result = hasChildPivot;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hasParentPivot && hasChildPivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isChildSame =
|
||||||
|
conditions.childPivot.from == peakPivot.from ||
|
||||||
|
conditions.childPivot.from == valePivot.from;
|
||||||
|
result = isChildSame;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.CleanPivots();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Direction ...
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.setupTime = cTime;
|
||||||
|
conditions.dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Trigger Conditions ...
|
||||||
|
bool DetectX121SMCXTWPVSiganlTrigger(
|
||||||
|
//
|
||||||
|
X121SMCStrategyXTWPVSignalConditions &conditions,
|
||||||
|
//
|
||||||
|
string _symbol,
|
||||||
|
ENUM_TIMEFRAMES _period,
|
||||||
|
//
|
||||||
|
XC121SMCCycleHelper *triggerCycleHelper,
|
||||||
|
XC121SMCCycleHelper *decisionCycleHelper,
|
||||||
|
XC121SMCCycleHelper *analyseCycleHelper,
|
||||||
|
XC121SMCCycleHelper *verificationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *consolidationCycleHelper,
|
||||||
|
XC121SMCCycleHelper *visionCycleHelper,
|
||||||
|
//
|
||||||
|
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 = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int zIndex = 0;
|
||||||
|
int cIndex = zIndex + 1;
|
||||||
|
int pIndex = cIndex + 1;
|
||||||
|
int ppIndex = pIndex + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int loopback = 10;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = _symbol;
|
||||||
|
ENUM_TIMEFRAMES period = _period;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL zBar;
|
||||||
|
result = zBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
zIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
result = cBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
cIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double ask = GetAsk(symbol);
|
||||||
|
double bid = GetBid(symbol);
|
||||||
|
datetime cTime = TimeCurrent();
|
||||||
|
|
||||||
|
//
|
||||||
|
double ll = cBar.FindLowest(9, MODE_LOW);
|
||||||
|
double hh = cBar.FindHighest(9, MODE_HIGH);
|
||||||
|
|
||||||
|
//
|
||||||
|
int zoneValidationDivider = 10;
|
||||||
|
int validPivotRepetition = triggerCycleHelper.mX121Helper
|
||||||
|
.GetDonChainLength();
|
||||||
|
|
||||||
|
//
|
||||||
|
double selectedSL = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger ...
|
||||||
|
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
||||||
|
X121SMCCycleConditions triggerConditions;
|
||||||
|
result = triggerCycleHelper.GetConditions(
|
||||||
|
triggerCycleEvents,
|
||||||
|
triggerPoiEvents,
|
||||||
|
triggerConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decision ...
|
||||||
|
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
||||||
|
X121SMCCycleConditions decisionConditions;
|
||||||
|
result = decisionCycleHelper.GetConditions(
|
||||||
|
decisionCycleEvents,
|
||||||
|
decisionPoiEvents,
|
||||||
|
decisionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Analyse ...
|
||||||
|
ENUM_XPOI_EVENTS analysePoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
||||||
|
X121SMCCycleConditions analyseConditions;
|
||||||
|
result = analyseCycleHelper.GetConditions(
|
||||||
|
analyseCycleEvents,
|
||||||
|
analysePoiEvents,
|
||||||
|
analyseConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Verification ...
|
||||||
|
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
||||||
|
X121SMCCycleConditions verificationConditions;
|
||||||
|
result = verificationCycleHelper.GetConditions(
|
||||||
|
verificationCycleEvents,
|
||||||
|
verificationPoiEvents,
|
||||||
|
verificationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Consolidation ...
|
||||||
|
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
||||||
|
X121SMCCycleConditions consolidationConditions;
|
||||||
|
result = consolidationCycleHelper.GetConditions(
|
||||||
|
consolidationCycleEvents,
|
||||||
|
consolidationPoiEvents,
|
||||||
|
consolidationConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vision ...
|
||||||
|
ENUM_XPOI_EVENTS visionPoiEvents[];
|
||||||
|
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
||||||
|
X121SMCCycleConditions visionConditions;
|
||||||
|
result = visionCycleHelper.GetConditions(
|
||||||
|
visionCycleEvents,
|
||||||
|
visionPoiEvents,
|
||||||
|
visionConditions,
|
||||||
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cycles POI States ...
|
||||||
|
XPOIState triggerState = triggerConditions.state;
|
||||||
|
XPOIState decisionState = decisionConditions.state;
|
||||||
|
XPOIState analyseState = analyseConditions.state;
|
||||||
|
XPOIState verificationState = verificationConditions.state;
|
||||||
|
XPOIState consolidationState = consolidationConditions.state;
|
||||||
|
XPOIState visionState = visionConditions.state;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check VWap State ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapBullishState = triggerConditions.x121Conditions.isVWapBullishState;
|
||||||
|
bool isVWapBearishState = triggerConditions.x121Conditions.isVWapBearishState;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
IsBullish(setupDir) &&
|
||||||
|
isVWapBullishState;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
IsBearish(setupDir) &&
|
||||||
|
isVWapBearishState;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Waitings For Sar Switched to Direction ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double sar = triggerConditions.x121Conditions.sarBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isSarSwitchedToBullish = triggerConditions.x121Conditions.isSarSwitchedToBullish;
|
||||||
|
bool isSarSwitchedToBearish = triggerConditions.x121Conditions.isSarSwitchedToBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
isBullish &&
|
||||||
|
isSarSwitchedToBullish
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
isBearish &&
|
||||||
|
isSarSwitchedToBearish
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Cleanup Setup Conditions ...
|
||||||
|
int setupAge = conditions.GetSetupAge();
|
||||||
|
if (IsValidSize(setupAge) &&
|
||||||
|
IsValidSize(maxAllowedSetupAge) &&
|
||||||
|
setupAge >= maxAllowedSetupAge)
|
||||||
|
{
|
||||||
|
conditions.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Nearest FVG or Supply Zone For Traget ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Select Source State ...
|
||||||
|
XPOIState state = triggerState;
|
||||||
|
|
||||||
|
//
|
||||||
|
double target = CalculateTarget(
|
||||||
|
cBar,
|
||||||
|
state,
|
||||||
|
setupDir //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = target > 0;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.target = target;
|
||||||
|
conditions.triggerTime = cTime;
|
||||||
|
conditions.sl = isBullish
|
||||||
|
? sar
|
||||||
|
: sar;
|
||||||
|
conditions.type = isBullish
|
||||||
|
? X_POSITION_TYPE_LONG
|
||||||
|
: X_POSITION_TYPE_SHORT;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
@@ -50,7 +50,7 @@ input int eaMaxAllowedLongs = 5; // Max Allowed Long
|
|||||||
input int eaMaxAllowedShorts = 5; // Max Allowed Short Signals
|
input int eaMaxAllowedShorts = 5; // Max Allowed Short Signals
|
||||||
input bool eaUseMaxAllowedSignalsPerSymbol = true; // Use Max Allowed Signal Types Per Symbol
|
input bool eaUseMaxAllowedSignalsPerSymbol = true; // Use Max Allowed Signal Types Per Symbol
|
||||||
input double eaLastPositionProfitForAcceptNextInPoint = 30; // Last Position Profit In Points for Accept new Signal
|
input double eaLastPositionProfitForAcceptNextInPoint = 30; // Last Position Profit In Points for Accept new Signal
|
||||||
input int eaDelaysBetweenTwoSignalsInBar = 50; // Delay between two Signals in Bars
|
input int eaDelaysBetweenTwoSignalsInBar = 10; // Delay between two Signals in Bars
|
||||||
input double eaMaxAllowedSpread = 25; // Max Allowed Spread for Signalling
|
input double eaMaxAllowedSpread = 25; // Max Allowed Spread for Signalling
|
||||||
input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Verification for Signalling
|
input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Verification for Signalling
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ input bool eaUseDynamicVolume = false; // Use Dy
|
|||||||
input double eaDynamicVolumeStep = 0.01; // Increase Volume Step
|
input double eaDynamicVolumeStep = 0.01; // Increase Volume Step
|
||||||
input double eaDynamicVolumeBalanceFactor = 200; // Balance Factor for Generate Dynamic Volume
|
input double eaDynamicVolumeBalanceFactor = 200; // Balance Factor for Generate Dynamic Volume
|
||||||
input double eaMaxAllowedDrawdownToOpenTrades = 3; // Max Allowed Drawdown for Open Trades
|
input double eaMaxAllowedDrawdownToOpenTrades = 3; // Max Allowed Drawdown for Open Trades
|
||||||
input int eaMaxAllowedSLToPauseSignallingPerSymbol = 1; // Max Allowed SL for Pause Signalling Per Symbol
|
input int eaMaxAllowedSLToPauseSignallingPerSymbol = 2; // Max Allowed SL for Pause Signalling Per Symbol
|
||||||
input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 14400; // Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds
|
input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 14400; // Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -50,6 +50,56 @@ enum ENUM_X_DIRECTION
|
|||||||
X_DIRECTION_BEARISH, // Bearish
|
X_DIRECTION_BEARISH, // Bearish
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
enum ENUM_X_FIBO_LEVELS
|
||||||
|
{
|
||||||
|
X_FIBO_LEVEL_236,
|
||||||
|
X_FIBO_LEVEL_382,
|
||||||
|
X_FIBO_LEVEL_500,
|
||||||
|
X_FIBO_LEVEL_618,
|
||||||
|
X_FIBO_LEVEL_764,
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetFiboLevelValue(ENUM_X_FIBO_LEVELS value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
case X_FIBO_LEVEL_236:
|
||||||
|
result = 0.236;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_FIBO_LEVEL_382:
|
||||||
|
result = 0.382;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_FIBO_LEVEL_500:
|
||||||
|
result = 0.500;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_FIBO_LEVEL_618:
|
||||||
|
result = 0.618;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_FIBO_LEVEL_764:
|
||||||
|
result = 0.764;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
string ToString(ENUM_X_DIRECTION value)
|
string ToString(ENUM_X_DIRECTION value)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -13269,6 +13319,28 @@ bool IsSpecifiedBearish(ENUM_X_DIRECTION value)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION Opposit(ENUM_X_DIRECTION value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION result = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!HasDirection(value))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
IsBullish(value)
|
||||||
|
? X_DIRECTION_BEARISH
|
||||||
|
: X_DIRECTION_BULLISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Moving Average ...
|
// Moving Average ...
|
||||||
|
|
||||||
|
|||||||
@@ -1301,6 +1301,29 @@ class XCSwing : public XCBasePOI
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Time of Swing ...
|
||||||
|
*
|
||||||
|
* @return ( datetime )
|
||||||
|
*/
|
||||||
|
datetime GetTime()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
datetime result = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid() || !mBar.IsValid())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = mBar.time;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ENUM_TIMEFRAMES GetPeriod()
|
ENUM_TIMEFRAMES GetPeriod()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -3761,7 +3784,6 @@ struct XPOIState
|
|||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -4092,6 +4114,78 @@ struct XPVPivot
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Price in Premium or not ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsPriceInPremium()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double ask = GetAsk(symbol);
|
||||||
|
double bid = GetBid(symbol);
|
||||||
|
|
||||||
|
//
|
||||||
|
double mid = CalculateMid();
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
ask > mid &&
|
||||||
|
bid > mid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Price in Discount or not ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsPriceInDiscount()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double ask = GetAsk(symbol);
|
||||||
|
double bid = GetBid(symbol);
|
||||||
|
|
||||||
|
//
|
||||||
|
double mid = CalculateMid();
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
ask > mid &&
|
||||||
|
bid > mid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5512,6 +5606,9 @@ void DetectPivotPOIs(
|
|||||||
bool isInside = iBar.high <= pivot.upper;
|
bool isInside = iBar.high <= pivot.upper;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// iSwing.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iSwing,
|
iSwing,
|
||||||
@@ -5548,6 +5645,9 @@ void DetectPivotPOIs(
|
|||||||
bool isInside = iBar.low >= pivot.lower;
|
bool isInside = iBar.low >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// iSwing.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iSwing,
|
iSwing,
|
||||||
@@ -5581,6 +5681,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5611,6 +5714,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5644,6 +5750,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5674,6 +5783,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5707,6 +5819,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5737,6 +5852,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5770,6 +5888,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5800,6 +5921,9 @@ void DetectPivotPOIs(
|
|||||||
iZone.Lower() >= pivot.lower;
|
iZone.Lower() >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iZone.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iZone,
|
iZone,
|
||||||
@@ -5840,6 +5964,9 @@ void DetectPivotPOIs(
|
|||||||
iBar.low >= pivot.lower;
|
iBar.low >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iRejection.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iRejection,
|
iRejection,
|
||||||
@@ -5877,6 +6004,9 @@ void DetectPivotPOIs(
|
|||||||
iBar.high >= pivot.lower;
|
iBar.high >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iRejection.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iRejection,
|
iRejection,
|
||||||
@@ -5917,6 +6047,9 @@ void DetectPivotPOIs(
|
|||||||
iBar.low >= pivot.lower;
|
iBar.low >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iMomentum.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iMomentum,
|
iMomentum,
|
||||||
@@ -5954,6 +6087,9 @@ void DetectPivotPOIs(
|
|||||||
iBar.high >= pivot.lower;
|
iBar.high >= pivot.lower;
|
||||||
if (isInside)
|
if (isInside)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
iMomentum.To(pivot.to);
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
iMomentum,
|
iMomentum,
|
||||||
|
|||||||
@@ -5313,6 +5313,11 @@ string ToString(ENUM_X_SIGNAL_EXECUTION_RESULT value)
|
|||||||
result = "Spread more than Max Allowed";
|
result = "Spread more than Max Allowed";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_SIGNAL_EXECUTION_FAILED_NOT_ALLOWED:
|
||||||
|
result = "not Allowed";
|
||||||
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
case X_SIGNAL_EXECUTION_FAILED_NO_EQUITY:
|
case X_SIGNAL_EXECUTION_FAILED_NO_EQUITY:
|
||||||
result = "No Equity for Trade";
|
result = "No Equity for Trade";
|
||||||
@@ -5328,6 +5333,11 @@ string ToString(ENUM_X_SIGNAL_EXECUTION_RESULT value)
|
|||||||
result = "Max Allowed Positions Reached";
|
result = "Max Allowed Positions Reached";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_SIGNAL_EXECUTION_FAILED_DELAY_NOT_PASSED:
|
||||||
|
result = "Min Delay Between to Signal not Passed";
|
||||||
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
case X_SIGNAL_EXECUTION_FAILED_INVALID_PARAMS:
|
case X_SIGNAL_EXECUTION_FAILED_INVALID_PARAMS:
|
||||||
result = "Invalid Params";
|
result = "Invalid Params";
|
||||||
|
|||||||
@@ -773,13 +773,18 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
|||||||
iObj.SLColor(clrRed);
|
iObj.SLColor(clrRed);
|
||||||
iObj.SLWidth(STYLE_DOT);
|
iObj.SLWidth(STYLE_DOT);
|
||||||
|
|
||||||
|
//
|
||||||
|
iObj.TargetWidth(1);
|
||||||
|
iObj.TargetColor(clrLightBlue);
|
||||||
|
iObj.TargetWidth(STYLE_DOT);
|
||||||
|
|
||||||
//
|
//
|
||||||
iObj.EntryWidth(1);
|
iObj.EntryWidth(1);
|
||||||
iObj.EntryColor(clrYellow);
|
iObj.EntryColor(clrYellow);
|
||||||
iObj.EntryWidth(STYLE_DOT);
|
iObj.EntryWidth(STYLE_DOT);
|
||||||
|
|
||||||
//
|
//
|
||||||
mDrawnObjects.Add(iObj);
|
// mDrawnObjects.Add(iObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -622,6 +622,605 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate Specified Pivot's State ...
|
||||||
|
*
|
||||||
|
* @param pivot: XPVPivot instance Reference ...
|
||||||
|
* @param barIndex: Integer ...
|
||||||
|
*/
|
||||||
|
void ValidatePivotState(
|
||||||
|
XPVPivot &pivot,
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (!pivot.IsValid() ||
|
||||||
|
!pivot.state.IsValid() ||
|
||||||
|
!pivot.state.HasChild())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double upperr = pivot.upper;
|
||||||
|
double lower = pivot.lower;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
bool isInited = cBar.Init(
|
||||||
|
pivot.symbol,
|
||||||
|
pivot.period,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
double ask = GetAsk(pivot.symbol);
|
||||||
|
double bid = GetBid(pivot.symbol);
|
||||||
|
|
||||||
|
//
|
||||||
|
double pivotMid = pivot.CalculateMid();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try to Validate States ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isPriceInPremium =
|
||||||
|
//
|
||||||
|
ask > pivotMid &&
|
||||||
|
bid > pivotMid &&
|
||||||
|
cBar.low > pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isPriceInDiscount =
|
||||||
|
//
|
||||||
|
ask < pivotMid &&
|
||||||
|
bid < pivotMid &&
|
||||||
|
cBar.high < pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Swings ...
|
||||||
|
XCSwing *tmpSwings[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Swing Highs ...
|
||||||
|
Clean(tmpSwings);
|
||||||
|
count = pivot.state.CountSwingHighs();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInPremium)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSwing *iSwing = pivot.state.swingHighs[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iSwing.GetTime() >= pivot.from &&
|
||||||
|
iSwing.GetTime() <= pivot.to &&
|
||||||
|
iSwing.GetValue() > pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iSwing,
|
||||||
|
tmpSwings //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpSwings,
|
||||||
|
pivot.state.swingHighs //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Swing Lows ...
|
||||||
|
Clean(tmpSwings);
|
||||||
|
count = pivot.state.CountSwingLows();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInDiscount)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSwing *iSwing = pivot.state.swingLows[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iSwing.GetTime() >= pivot.from &&
|
||||||
|
iSwing.GetTime() <= pivot.to &&
|
||||||
|
iSwing.GetValue() < pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iSwing,
|
||||||
|
tmpSwings //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpSwings,
|
||||||
|
pivot.state.swingLows //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpSwings);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Rejection Bars ...
|
||||||
|
XCRejectionBar *tmpRejections[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
Clean(tmpRejections);
|
||||||
|
count = pivot.state.CountBullishRejectionBars();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInDiscount)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCRejectionBar *iRejection = pivot.state.bullishRejectionBars[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isFilled = iRejection.FillBar(iBar);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iRejection.BarTime() >= pivot.from &&
|
||||||
|
iBar.high < pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iRejection,
|
||||||
|
tmpRejections //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpRejections,
|
||||||
|
pivot.state.bullishRejectionBars //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
Clean(tmpRejections);
|
||||||
|
count = pivot.state.CountBearishRejectionBars();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInPremium)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCRejectionBar *iRejection = pivot.state.bearishRejectionBars[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isFilled = iRejection.FillBar(iBar);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iRejection.BarTime() >= pivot.from &&
|
||||||
|
iBar.low > pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iRejection,
|
||||||
|
tmpRejections //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpRejections,
|
||||||
|
pivot.state.bearishRejectionBars //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpRejections);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support Zone ...
|
||||||
|
XCSupportZone *tmpSupports[];
|
||||||
|
count = pivot.state.CountSupportZones();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInDiscount)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupportZone *iZone = pivot.state.supportZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Upper() < pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpSupports //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpSupports,
|
||||||
|
pivot.state.supportZones //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpSupports);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Resistance Zone ...
|
||||||
|
XCResistanceZone *tmpResistances[];
|
||||||
|
count = pivot.state.CountResistanceZones();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInPremium)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCResistanceZone *iZone = pivot.state.resistanceZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Lower() > pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpResistances //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpResistances,
|
||||||
|
pivot.state.resistanceZones //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpResistances);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply Zones ...
|
||||||
|
XCSupplyZone *tmpSupplies[];
|
||||||
|
count = pivot.state.CountSupplyZones();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInPremium)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupplyZone *iZone = pivot.state.supplyZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Lower() > pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpSupplies //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpSupplies,
|
||||||
|
pivot.state.supplyZones //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpSupplies);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Demand Zones ...
|
||||||
|
XCDemandZone *tmpDemands[];
|
||||||
|
count = pivot.state.CountDemandZones();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInDiscount)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCDemandZone *iZone = pivot.state.demandZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Upper() < pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpDemands //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpDemands,
|
||||||
|
pivot.state.demandZones //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpDemands);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Order Blocks ...
|
||||||
|
XCOrderBlock *tmpOrderBlocks[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
Clean(tmpOrderBlocks);
|
||||||
|
count = pivot.state.CountBullishOrderBlocks();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInDiscount)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCOrderBlock *iZone = pivot.state.bullishOrderBlocks[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Upper() < pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpOrderBlocks //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpOrderBlocks,
|
||||||
|
pivot.state.bullishOrderBlocks //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
Clean(tmpOrderBlocks);
|
||||||
|
count = pivot.state.CountBearishOrderBlocks();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInPremium)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCOrderBlock *iZone = pivot.state.bearishOrderBlocks[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Lower() > pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpOrderBlocks //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpOrderBlocks,
|
||||||
|
pivot.state.bearishOrderBlocks //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpOrderBlocks);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fair Value Gaps ...
|
||||||
|
XCFVG *tmpFVGs[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
Clean(tmpFVGs);
|
||||||
|
count = pivot.state.CountBullishFairValueGaps();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInDiscount)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCFVG *iZone = pivot.state.bullishFairValueGaps[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Upper() < pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpFVGs //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpFVGs,
|
||||||
|
pivot.state.bullishFairValueGaps //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
Clean(tmpFVGs);
|
||||||
|
count = pivot.state.CountBearishFairValueGaps();
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isPriceInPremium)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCFVG *iZone = pivot.state.bearishFairValueGaps[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid =
|
||||||
|
//
|
||||||
|
iZone.Lower() > pivotMid
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iZone,
|
||||||
|
tmpFVGs //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
tmpFVGs,
|
||||||
|
pivot.state.bearishFairValueGaps //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpFVGs);
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect Cycle Trend Based On Pivots ...
|
* Detect Cycle Trend Based On Pivots ...
|
||||||
*
|
*
|
||||||
@@ -1173,7 +1772,7 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
*
|
*
|
||||||
* @return ( int )
|
* @return ( int )
|
||||||
*/
|
*/
|
||||||
int FillPivotPointss(XPVPivotPoint &pivots[])
|
int FillPivotPoints(XPVPivotPoint &pivots[])
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@@ -2020,6 +2619,14 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
//
|
//
|
||||||
mActivePeakPivot.repetition++;
|
mActivePeakPivot.repetition++;
|
||||||
mActivePeakPivot.to = changeBar.time;
|
mActivePeakPivot.to = changeBar.time;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (mActivePeakPivot.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
FillPivotState(mActivePeakPivot);
|
||||||
|
ValidatePivotState(mActivePeakPivot, barIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (mActivePeakPivot.upper > 0 && mActivePeakPivot.upper != peak)
|
else if (mActivePeakPivot.upper > 0 && mActivePeakPivot.upper != peak)
|
||||||
{
|
{
|
||||||
@@ -2083,6 +2690,14 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
//
|
//
|
||||||
mActiveValePivot.repetition++;
|
mActiveValePivot.repetition++;
|
||||||
mActiveValePivot.to = changeBar.time;
|
mActiveValePivot.to = changeBar.time;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (mActiveValePivot.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
FillPivotState(mActiveValePivot);
|
||||||
|
ValidatePivotState(mActiveValePivot, barIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (mActiveValePivot.lower > 0 && mActiveValePivot.lower != vale)
|
else if (mActiveValePivot.lower > 0 && mActiveValePivot.lower != vale)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ struct X121SMCTradeData
|
|||||||
double commission; // Commission
|
double commission; // Commission
|
||||||
string conditions; // Signal Conditions
|
string conditions; // Signal Conditions
|
||||||
double maxDrawdown; // Max Position Drawdown
|
double maxDrawdown; // Max Position Drawdown
|
||||||
|
bool isTargeted; // Check Targetted Before Or Not
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor ...
|
// Constructor ...
|
||||||
@@ -110,6 +111,9 @@ struct X121SMCTradeData
|
|||||||
startTime = NULL;
|
startTime = NULL;
|
||||||
conditions = NULL;
|
conditions = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
isTargeted = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
signal.Clean();
|
signal.Clean();
|
||||||
}
|
}
|
||||||
@@ -2901,7 +2905,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
mTrader.GetPositions(
|
mTrader.GetPositions(
|
||||||
longs,
|
longs,
|
||||||
shorts,
|
shorts,
|
||||||
signal.symbol,
|
signal.symbol,
|
||||||
signal.provider //
|
signal.provider //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3099,6 +3103,13 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
);
|
);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
AlertSignalExecutionFailed(
|
||||||
|
signal,
|
||||||
|
state //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3141,17 +3152,11 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
//
|
//
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// Alert Signal Execution Failed ...
|
AlertSignalExecutionFailed(
|
||||||
string msg = "Failed To Execute " +
|
signal,
|
||||||
(signal.type == POSITION_TYPE_BUY ? "Long" : "Short") +
|
state //
|
||||||
" Signal Provided by: " + signal.provider +
|
);
|
||||||
(signal.pushers > 1 ? " Pushers: " + ToString(signal.pushers) : "") +
|
|
||||||
" on: " + signal.symbol +
|
|
||||||
" in: " + ToString(signal.period) +
|
|
||||||
" due Reason: " + ToString(state) + " ...";
|
|
||||||
Alert(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3411,13 +3416,20 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
//
|
//
|
||||||
// Handle RF On Target ...
|
// Handle RF On Target ...
|
||||||
double target = iData.Target();
|
double target = iData.Target();
|
||||||
|
double targetDelta = isLong
|
||||||
|
? target + (15 * points)
|
||||||
|
: target - (15 * points);
|
||||||
bool canRF =
|
bool canRF =
|
||||||
target > 0 &&
|
target > 0 &&
|
||||||
target > entry &&
|
!iData.isTargeted &&
|
||||||
|
(isLong ? target > entry
|
||||||
|
: target < entry) &&
|
||||||
(isLong
|
(isLong
|
||||||
? iPosition.sl < target
|
? iPosition.sl < target
|
||||||
: iPosition.sl > target) &&
|
: iPosition.sl > target) &&
|
||||||
iPosition.price > target + (10 * points);
|
(isLong
|
||||||
|
? iPosition.price > targetDelta
|
||||||
|
: iPosition.price < targetDelta);
|
||||||
if (canRF)
|
if (canRF)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -3432,6 +3444,9 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
);
|
);
|
||||||
if (isModified)
|
if (isModified)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
mData[i].isTargeted = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
string message = ToString(iData.Type()) +
|
string message = ToString(iData.Type()) +
|
||||||
" Position: " +
|
" Position: " +
|
||||||
@@ -3529,7 +3544,22 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
XSymbolLastPosition mLastExecutedSignals[]; // Last Executed Signals
|
XSymbolLastPosition mLastExecutedSignals[]; // Last Executed Signals
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hedge Related Functions ...
|
void AlertSignalExecutionFailed(
|
||||||
|
XSignal &signal,
|
||||||
|
ENUM_X_SIGNAL_EXECUTION_RESULT state //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Alert Signal Execution Failed ...
|
||||||
|
string msg = "Failed To Execute " +
|
||||||
|
(signal.type == POSITION_TYPE_BUY ? "Long" : "Short") +
|
||||||
|
" Signal Provided by: " + signal.provider +
|
||||||
|
(signal.pushers > 1 ? " Pushers: " + ToString(signal.pushers) : "") +
|
||||||
|
" on: " + signal.symbol +
|
||||||
|
" in: " + ToString(signal.period) +
|
||||||
|
" due Reason: " + ToString(state) + " ...";
|
||||||
|
Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private ...
|
// Private ...
|
||||||
|
|||||||
@@ -49,16 +49,8 @@ struct X121SMCStrategyXTWPVSignalConditions
|
|||||||
datetime triggerTime;
|
datetime triggerTime;
|
||||||
|
|
||||||
//
|
//
|
||||||
int peakRepeat;
|
double point;
|
||||||
double farPeak;
|
XPVPivot pivot;
|
||||||
double middlePeak;
|
|
||||||
double nearPeak;
|
|
||||||
|
|
||||||
//
|
|
||||||
int valeRepeat;
|
|
||||||
double farVale;
|
|
||||||
double middleVale;
|
|
||||||
double nearVale;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor ...
|
// Constructor ...
|
||||||
@@ -175,16 +167,13 @@ struct X121SMCStrategyXTWPVSignalConditions
|
|||||||
void ExtensionClean()
|
void ExtensionClean()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
peakRepeat = 0;
|
point = 0;
|
||||||
farPeak = 0;
|
pivot.Clean();
|
||||||
middlePeak = 0;
|
}
|
||||||
nearPeak = 0;
|
|
||||||
|
|
||||||
//
|
bool HasPivot()
|
||||||
valeRepeat = 0;
|
{
|
||||||
farVale = 0;
|
return pivot.IsValid();
|
||||||
middleVale = 0;
|
|
||||||
nearVale = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -409,7 +398,200 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Exists Valid Peaks or Vales ...
|
// Retrieve Active Pivots ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Select Source Cycle Helper ...
|
||||||
|
XC121SMCCycleHelper *helper = analyseCycleHelper;
|
||||||
|
X121SMCCycleConditions helperConditions = analyseConditions;
|
||||||
|
XPOIState helperState = analyseState;
|
||||||
|
XOHCL helperCBar;
|
||||||
|
result = helper.GetBar(
|
||||||
|
cBar,
|
||||||
|
helperCBar //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XPVPivot peakPivot;
|
||||||
|
bool hasPeakPivot = helper
|
||||||
|
.GetActivePeakPivot(peakPivot);
|
||||||
|
|
||||||
|
//
|
||||||
|
XPVPivot valePivot;
|
||||||
|
bool hasValePivot = helper
|
||||||
|
.GetActiveValePivot(valePivot);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Pivot ...
|
||||||
|
bool hasPivot = conditions.HasPivot();
|
||||||
|
if (!hasPivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (hasPeakPivot && !hasValePivot)
|
||||||
|
{
|
||||||
|
conditions.pivot = peakPivot;
|
||||||
|
}
|
||||||
|
else if (hasValePivot && !hasPeakPivot)
|
||||||
|
{
|
||||||
|
conditions.pivot = valePivot;
|
||||||
|
}
|
||||||
|
else if (hasPeakPivot && hasValePivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (peakPivot.from > valePivot.from)
|
||||||
|
{
|
||||||
|
conditions.pivot = peakPivot;
|
||||||
|
}
|
||||||
|
else if (valePivot.from > peakPivot.from)
|
||||||
|
{
|
||||||
|
conditions.pivot = valePivot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hasPivot = conditions.HasPivot();
|
||||||
|
result = hasPivot;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update Pivot States ...
|
||||||
|
if (hasPivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.pivot.to = cTime;
|
||||||
|
helper.FillPivotState(conditions.pivot);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool hasNewPivot =
|
||||||
|
//
|
||||||
|
(hasPeakPivot &&
|
||||||
|
peakPivot.from > conditions.pivot.from) ||
|
||||||
|
(hasValePivot &&
|
||||||
|
valePivot.from > conditions.pivot.from)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
result = !hasNewPivot;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
conditions.pivot.Clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Waits for new Peaks or Vales ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double peak = helperConditions.x121Conditions.peaksBuffer[1];
|
||||||
|
bool isNewPeak = helperConditions.x121Conditions.isNewPeak;
|
||||||
|
bool isNewPeakOverLast = helperConditions.x121Conditions.isNewPeakOverLast;
|
||||||
|
bool isNewPeakUnderLast = helperConditions.x121Conditions.isNewPeakUnderLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
double vale = helperConditions.x121Conditions.valesBuffer[1];
|
||||||
|
bool isNewVale = helperConditions.x121Conditions.isNewVale;
|
||||||
|
bool isNewValeOverLast = helperConditions.x121Conditions.isNewValeOverLast;
|
||||||
|
bool isNewValeUnderLast = helperConditions.x121Conditions.isNewValeUnderLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isNewPeak ||
|
||||||
|
isNewVale;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double bullishFib = GetFibonacciLevel(
|
||||||
|
helperCBar.high,
|
||||||
|
helperCBar.low,
|
||||||
|
GetFiboLevelValue(X_FIBO_LEVEL_382),
|
||||||
|
-1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
double bearishFib = GetFibonacciLevel(
|
||||||
|
helperCBar.high,
|
||||||
|
helperCBar.low,
|
||||||
|
GetFiboLevelValue(X_FIBO_LEVEL_382),
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBearishFiboPassed = bullishFib <= conditions.pivot.lower;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish Conditions 1 ...
|
||||||
|
bool bearishConditions1 =
|
||||||
|
//
|
||||||
|
isNewValeUnderLast &&
|
||||||
|
isBearishFiboPassed &&
|
||||||
|
helperCBar.IsBearish() &&
|
||||||
|
conditions.pivot.lower > vale &&
|
||||||
|
conditions.pivot.lower < helperCBar.GetUp() &&
|
||||||
|
conditions.pivot.lower > helperCBar.GetDown()
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (bearishConditions1)
|
||||||
|
{
|
||||||
|
conditions.point = conditions.pivot.lower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double donCloseUpper = helperConditions.x121Conditions.donCloseUpperBuffer[1];
|
||||||
|
double donCloseLower = helperConditions.x121Conditions.donCloseLowerBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
double donOpenUpper = helperConditions.x121Conditions.donOpenUpperBuffer[1];
|
||||||
|
double donOpenLower = helperConditions.x121Conditions.donOpenLowerBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool bearishConditions2 =
|
||||||
|
//
|
||||||
|
isNewPeakUnderLast &&
|
||||||
|
donCloseUpper > peak
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (bearishConditions2)
|
||||||
|
{
|
||||||
|
conditions.point = peak;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summary Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
false
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
bearishConditions1 ||
|
||||||
|
bearishConditions2
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = isBullish ||
|
result = isBullish ||
|
||||||
@@ -465,8 +647,8 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
|||||||
ENUM_X_DIRECTION setupDir = conditions.dir;
|
ENUM_X_DIRECTION setupDir = conditions.dir;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isBullish = false;
|
bool isBullish = IsBullish(setupDir);
|
||||||
bool isBearish = false;
|
bool isBearish = IsBearish(setupDir);
|
||||||
|
|
||||||
//
|
//
|
||||||
int zIndex = 0;
|
int zIndex = 0;
|
||||||
@@ -639,56 +821,15 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
|||||||
//
|
//
|
||||||
// Trigger Conditions ...
|
// Trigger Conditions ...
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Check VWap State ...
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// false;
|
||||||
|
|
||||||
//
|
// //
|
||||||
bool isVWapBullishState = triggerConditions.x121Conditions.isVWapBullishState;
|
// isBearish =
|
||||||
bool isVWapBearishState = triggerConditions.x121Conditions.isVWapBearishState;
|
// isBearish &&
|
||||||
|
// false;
|
||||||
//
|
|
||||||
isBullish =
|
|
||||||
IsBullish(setupDir) &&
|
|
||||||
isVWapBullishState;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBearish =
|
|
||||||
IsBearish(setupDir) &&
|
|
||||||
isVWapBearishState;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = isBullish ||
|
|
||||||
isBearish;
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Waitings For Sar Switched to Direction ...
|
|
||||||
|
|
||||||
//
|
|
||||||
double sar = triggerConditions.x121Conditions.sarBuffer[1];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isSarSwitchedToBullish = triggerConditions.x121Conditions.isSarSwitchedToBullish;
|
|
||||||
bool isSarSwitchedToBearish = triggerConditions.x121Conditions.isSarSwitchedToBearish;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBullish =
|
|
||||||
//
|
|
||||||
isBullish &&
|
|
||||||
isSarSwitchedToBullish
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBearish =
|
|
||||||
//
|
|
||||||
isBearish &&
|
|
||||||
isSarSwitchedToBearish
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
result = isBullish ||
|
result = isBullish ||
|
||||||
@@ -710,32 +851,181 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detect Nearest FVG or Supply Zone For Traget ...
|
// Detect Consolidation ...
|
||||||
|
XConsolidationZone consolidationZone;
|
||||||
|
bool hasConsolidationZone = triggerCycleHelper
|
||||||
|
.GetLastConsolidationZone(consolidationZone);
|
||||||
|
if (hasConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasConsolidationZone =
|
||||||
|
isBullish
|
||||||
|
? consolidationZone.upper <= conditions.point
|
||||||
|
: consolidationZone.lower >= conditions.point;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!hasConsolidationZone)
|
||||||
|
{
|
||||||
|
consolidationZone.Clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Select Source State ...
|
// Detect Nearest Pivot Point ...
|
||||||
XPOIState state = triggerState;
|
XPVPivotPoint pivotPoints[];
|
||||||
|
XPVPivotPoint nearestPivotPoint;
|
||||||
|
bool hasNearestPivotPoint = false;
|
||||||
|
int pivotPointsCount = triggerCycleHelper
|
||||||
|
.FillPivotPoints(pivotPoints);
|
||||||
|
if (IsValidSize(pivotPointsCount))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < pivotPointsCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPVPivotPoint iPoint = pivotPoints[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSet =
|
||||||
|
(isBullish
|
||||||
|
? iPoint.value < conditions.point
|
||||||
|
: iPoint.value > conditions.point)
|
||||||
|
//
|
||||||
|
&&
|
||||||
|
//
|
||||||
|
(!nearestPivotPoint.IsValid()
|
||||||
|
? true
|
||||||
|
: isBullish
|
||||||
|
? nearestPivotPoint.value > iPoint.value
|
||||||
|
: nearestPivotPoint.value < iPoint.value);
|
||||||
|
if (canSet)
|
||||||
|
{
|
||||||
|
nearestPivotPoint = iPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hasNearestPivotPoint = nearestPivotPoint.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Detect Target ...
|
||||||
double target = CalculateTarget(
|
double target = CalculateTarget(
|
||||||
cBar,
|
cBar,
|
||||||
state,
|
analyseState,
|
||||||
|
setupDir //
|
||||||
|
);
|
||||||
|
if (target == 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
target = CalculateTarget(
|
||||||
|
cBar,
|
||||||
|
verificationState,
|
||||||
|
setupDir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double oppositTarget = CalculateTarget(
|
||||||
|
cBar,
|
||||||
|
analyseState,
|
||||||
|
Opposit(setupDir) //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
double points = GetPoints(conditions.symbol);
|
||||||
|
|
||||||
|
//
|
||||||
|
double entry = GetEntry(
|
||||||
|
conditions.symbol,
|
||||||
setupDir //
|
setupDir //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
result = target > 0;
|
// Filling SL Candidates ...
|
||||||
if (!result)
|
double sls[];
|
||||||
|
if (hasConsolidationZone)
|
||||||
{
|
{
|
||||||
return result;
|
//
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
Add(
|
||||||
|
consolidationZone.lower,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Add(
|
||||||
|
consolidationZone.upper,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasNearestPivotPoint)
|
||||||
|
{
|
||||||
|
Add(
|
||||||
|
nearestPivotPoint.value,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (ArraySize(sls) == 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double pointsDiff = (10 * points);
|
||||||
|
double pointsPlus = conditions.point + pointsDiff;
|
||||||
|
double pointsMinus = conditions.point - pointsDiff;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Force SL ...
|
||||||
|
Add(
|
||||||
|
conditions.point,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
pointsPlus,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
pointsMinus,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
oppositTarget,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
double slsMin = GetMin(sls);
|
||||||
|
double slsMax = GetMax(sls);
|
||||||
|
|
||||||
|
//
|
||||||
|
double sl = isBullish
|
||||||
|
? slsMin
|
||||||
|
: slsMax;
|
||||||
|
double risk = MathAbs(entry - sl);
|
||||||
|
double targetDelta = 2 * (risk / 3);
|
||||||
|
if (target == 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Force Target On Half Risk ...
|
||||||
|
target =
|
||||||
|
isBullish
|
||||||
|
? entry + targetDelta
|
||||||
|
: entry - targetDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.sl = sl;
|
||||||
conditions.target = target;
|
conditions.target = target;
|
||||||
conditions.triggerTime = cTime;
|
conditions.triggerTime = cTime;
|
||||||
conditions.sl = isBullish
|
|
||||||
? sar
|
|
||||||
: sar;
|
|
||||||
conditions.type = isBullish
|
conditions.type = isBullish
|
||||||
? X_POSITION_TYPE_LONG
|
? X_POSITION_TYPE_LONG
|
||||||
: X_POSITION_TYPE_SHORT;
|
: X_POSITION_TYPE_SHORT;
|
||||||
|
|||||||
@@ -326,6 +326,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
signal.time = TimeCurrent();
|
signal.time = TimeCurrent();
|
||||||
signal.target = conditions.target;
|
signal.target = conditions.target;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canReplaceTarget =
|
||||||
|
hasLong
|
||||||
|
? signal.target > signal.tp
|
||||||
|
: signal.target < signal.tp;
|
||||||
|
if (canReplaceTarget)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
signal.tp = conditions.target;
|
||||||
|
signal.target = tp;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Signal Protecting ...
|
// Configure Signal Protecting ...
|
||||||
// if (hasXPVOBSignal ||
|
// if (hasXPVOBSignal ||
|
||||||
@@ -1180,6 +1192,38 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
//
|
//
|
||||||
setupDir = mXTWPVConditions.dir;
|
setupDir = mXTWPVConditions.dir;
|
||||||
setupTime = mXTWPVConditions.setupTime;
|
setupTime = mXTWPVConditions.setupTime;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// if (!isSetuped)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// bool hasParent = mXTWPVConditions.HasParentPivot();
|
||||||
|
// if (hasParent)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCBaseObject *objs[];
|
||||||
|
// mPOIDrawer.DrawPivot(
|
||||||
|
// mXTWPVConditions.parentPivot,
|
||||||
|
// objs,
|
||||||
|
// true, // Drawing State ...
|
||||||
|
// true // Drawing Ticks Zone ...
|
||||||
|
// );
|
||||||
|
// AddObjectsIfNotExists(objs);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool hasChild = mXTWPVConditions.HasChildPivot();
|
||||||
|
// if (hasChild)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCBaseObject *objs[];
|
||||||
|
// mPOIDrawer.DrawPivot(
|
||||||
|
// mXTWPVConditions.childPivot,
|
||||||
|
// objs //
|
||||||
|
// );
|
||||||
|
// AddObjectsIfNotExists(objs);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
result = isSetuped;
|
result = isSetuped;
|
||||||
if (!result)
|
if (!result)
|
||||||
@@ -1581,9 +1625,22 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
|
|
||||||
//
|
//
|
||||||
x121Inputs.showFibo2Levels = false;
|
x121Inputs.showFibo2Levels = false;
|
||||||
x121Inputs.showFibo3Levels = true;
|
x121Inputs.showFibo3Levels = false;
|
||||||
x121Inputs.showFibo4Levels = false;
|
x121Inputs.showFibo4Levels = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
x121Inputs.showSar = false;
|
||||||
|
x121Inputs.showPeaks = true;
|
||||||
|
x121Inputs.showVales = true;
|
||||||
|
x121Inputs.showVWap = false;
|
||||||
|
x121Inputs.showDonchain = true;
|
||||||
|
|
||||||
|
//
|
||||||
|
x121Inputs.showOpen = true;
|
||||||
|
x121Inputs.showHigh = true;
|
||||||
|
x121Inputs.showClose = true;
|
||||||
|
x121Inputs.showLow = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize Cycle Helpers ...
|
// Initialize Cycle Helpers ...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user