Last ...
This commit is contained in:
@@ -49,7 +49,8 @@ enum ENUM_X_CYCLE_EVENTS
|
||||
PIVOT_POINT_DETECTED,
|
||||
VWAP_ORDER_CHANGE_ETECTED,
|
||||
VWAP_STATE_CHANGE_DETCTED,
|
||||
CONSOLIDATION_BREAKED_DETECTED
|
||||
CONSOLIDATION_BREAKED_DETECTED,
|
||||
PIVOT_DETECTED,
|
||||
};
|
||||
|
||||
class XC121SMCCycleHelper : public XCBase
|
||||
@@ -401,6 +402,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
*/
|
||||
bool GetConditions(
|
||||
ENUM_X_CYCLE_EVENTS &events[],
|
||||
ENUM_XPOI_EVENTS &poiEvents[],
|
||||
X121SMCCycleConditions &conditions,
|
||||
int barIndex = 0,
|
||||
int loopback = 7 //
|
||||
@@ -422,6 +424,8 @@ class XC121SMCCycleHelper : public XCBase
|
||||
}
|
||||
|
||||
//
|
||||
Clean(events);
|
||||
Clean(poiEvents);
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
@@ -437,6 +441,10 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mPOIDetector.Update(poiEvents);
|
||||
mPOIDetector.GetState(conditions.state);
|
||||
|
||||
//
|
||||
conditions.symbol = conditions.x121Conditions.symbol;
|
||||
conditions.period = conditions.x121Conditions.period;
|
||||
@@ -463,6 +471,106 @@ class XC121SMCCycleHelper : public XCBase
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Get POI State of Specified Pivot ...
|
||||
*
|
||||
* @param pivot: XPVPivot instance Reference ...
|
||||
* @param lookupSwingHighs: Boolean ...
|
||||
* @param lookupSwingLows: Boolean ...
|
||||
* @param lookupSupportZones: Boolean ...
|
||||
* @param lookupResistanceZones: Boolean ...
|
||||
* @param lookupSupplyZones: Boolean ...
|
||||
* @param lookupDemandZones: Boolean ...
|
||||
* @param lookupBullishOrderBlocks: Boolean ...
|
||||
* @param lookupBearishOrderBlocks: Boolean ...
|
||||
* @param lookupBullishFairValueGaps: Boolean ...
|
||||
* @param lookupBearishFairValueGaps: Boolean ...
|
||||
* @param lookupBullishRejectionBars: Boolean ...
|
||||
* @param lookupBearishRejectionBars: Boolean ...
|
||||
* @param lookupBullishMomentumBars: Boolean ...
|
||||
* @param lookupBearishMomentumBars: Boolean ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool FillPivotState(
|
||||
XPVPivot &pivot,
|
||||
bool lookupSwingHighs = true,
|
||||
bool lookupSwingLows = true,
|
||||
bool lookupSupportZones = true,
|
||||
bool lookupResistanceZones = true,
|
||||
bool lookupSupplyZones = true,
|
||||
bool lookupDemandZones = true,
|
||||
bool lookupBullishOrderBlocks = true,
|
||||
bool lookupBearishOrderBlocks = true,
|
||||
bool lookupBullishFairValueGaps = true,
|
||||
bool lookupBearishFairValueGaps = true,
|
||||
bool lookupBullishRejectionBars = true,
|
||||
bool lookupBearishRejectionBars = true,
|
||||
bool lookupBullishMomentumBars = true,
|
||||
bool lookupBearishMomentumBars = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
state.Clean();
|
||||
|
||||
//
|
||||
result = pivot.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XPOIState _state;
|
||||
mPOIDetector.GetState(_state);
|
||||
result = _state.IsValid() &&
|
||||
_state.HasChild();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
DetectPivotPOIs(
|
||||
pivot,
|
||||
_state,
|
||||
state,
|
||||
lookupSwingHighs,
|
||||
lookupSwingLows,
|
||||
lookupSupportZones,
|
||||
lookupResistanceZones,
|
||||
lookupSupplyZones,
|
||||
lookupDemandZones,
|
||||
lookupBullishOrderBlocks,
|
||||
lookupBearishOrderBlocks,
|
||||
lookupBullishFairValueGaps,
|
||||
lookupBearishFairValueGaps,
|
||||
lookupBullishRejectionBars,
|
||||
lookupBearishRejectionBars,
|
||||
lookupBullishMomentumBars,
|
||||
lookupBearishMomentumBars //
|
||||
);
|
||||
|
||||
//
|
||||
result = state.IsValid() &&
|
||||
state.HasChild();
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
pivot.state = state;
|
||||
|
||||
//
|
||||
CalculatePivotTickZone(pivot);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect XPV Based POI(s) ...
|
||||
*
|
||||
@@ -814,9 +922,9 @@ class XC121SMCCycleHelper : public XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Last Sar Changes ...
|
||||
*
|
||||
*
|
||||
* @param change: XValueChange instance ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetLastSarChange(XValueChange &change)
|
||||
@@ -873,9 +981,9 @@ class XC121SMCCycleHelper : public XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Last Peak Changes ...
|
||||
*
|
||||
*
|
||||
* @param change: XValueChange instance ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetLastPeakChange(XValueChange &change)
|
||||
@@ -932,9 +1040,9 @@ class XC121SMCCycleHelper : public XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Last Vale Changes ...
|
||||
*
|
||||
*
|
||||
* @param change: XValueChange instance ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetLastValeChange(XValueChange &change)
|
||||
@@ -991,9 +1099,9 @@ class XC121SMCCycleHelper : public XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Last VWap Order Changes ...
|
||||
*
|
||||
*
|
||||
* @param change: XValueChange instance ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetLastVWapOrderChange(XValueChange &change)
|
||||
@@ -1050,9 +1158,9 @@ class XC121SMCCycleHelper : public XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Last VWap State Changes ...
|
||||
*
|
||||
*
|
||||
* @param change: XValueChange instance ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetLastVWapStateChange(XValueChange &change)
|
||||
@@ -1109,9 +1217,9 @@ class XC121SMCCycleHelper : public XCBase
|
||||
|
||||
/**
|
||||
* Retrieve Last Consolidation Breaks ...
|
||||
*
|
||||
*
|
||||
* @param change: XValueChange instance ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetLastConsolidationZone(XConsolidationZone &zone)
|
||||
@@ -1268,6 +1376,14 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void GetActivePivot(XPVPivot &pivot)
|
||||
{
|
||||
//
|
||||
mActivePivot.to = TimeCurrent();
|
||||
pivot = mActivePivot;
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
@@ -1303,6 +1419,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
datetime cTime = TimeCurrent();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
@@ -1778,6 +1895,107 @@ class XC121SMCCycleHelper : public XCBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Pivots ...
|
||||
if (isNewPeak || isNewVale)
|
||||
{
|
||||
//
|
||||
mActivePivot.symbol = symbol;
|
||||
mActivePivot.period = period;
|
||||
|
||||
//
|
||||
if (!IsValid(mActivePivot.from))
|
||||
{
|
||||
mActivePivot.from = cTime;
|
||||
}
|
||||
mActivePivot.to = cTime;
|
||||
|
||||
//
|
||||
if (mActivePivot.upper <= 0)
|
||||
{
|
||||
//
|
||||
if (isNewPeakUnderLast)
|
||||
{
|
||||
mActivePivot.upper = conditions.x121Conditions.peaksBuffer[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
mActivePivot.upper = conditions.x121Conditions.peaksBuffer[1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (mActivePivot.lower <= 0)
|
||||
{
|
||||
//
|
||||
if (isNewValeOverLast)
|
||||
{
|
||||
mActivePivot.lower = conditions.x121Conditions.valesBuffer[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
mActivePivot.lower = conditions.x121Conditions.valesBuffer[1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
mActivePivot.type =
|
||||
isNewPeak
|
||||
? XPV_VALE
|
||||
: XPV_PEAK;
|
||||
mActivePivot.repetition++;
|
||||
|
||||
//
|
||||
if (mActivePivot.to > mActivePivot.from)
|
||||
{
|
||||
//
|
||||
FillPivotState(mActivePivot);
|
||||
|
||||
//
|
||||
// Check Active Pivot has State and Ticks Zone ...
|
||||
if (mActivePivot.state.IsValid() &&
|
||||
mActivePivot.state.ticksZone != NULL &&
|
||||
mActivePivot.state.ticksZone.IsValid())
|
||||
{
|
||||
//
|
||||
// Here We Have to Calculate Ticks Level Volume and Percents ...
|
||||
// Liquidity ...
|
||||
|
||||
//
|
||||
// Select Current TickZone which Price is Inside ...
|
||||
int cTZoneIDX = -1;
|
||||
int count = mActivePivot.state.ticksZone.Count();
|
||||
if (IsValidSize(count))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCTickZone *iTZ = mActivePivot.state.ticksZone.GetZone(i);
|
||||
|
||||
//
|
||||
bool isBarInside =
|
||||
changeBar.low >= iTZ.low &&
|
||||
changeBar.high <= iTZ.high;
|
||||
if (isBarInside)
|
||||
{
|
||||
//
|
||||
cTZoneIDX = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidIndex(cTZoneIDX))
|
||||
{
|
||||
//
|
||||
Print("ZoneIndex: ", cTZoneIDX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1802,6 +2020,11 @@ class XC121SMCCycleHelper : public XCBase
|
||||
//
|
||||
XPVPivotPoint mPivotPoints[]; // Holds Pivots ...
|
||||
|
||||
//
|
||||
XCXPVPivotObject mActivePivotObject;
|
||||
XPVPivot mActivePivot;
|
||||
XPVPivot mPivots[];
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
@@ -1871,6 +2094,92 @@ class XC121SMCCycleHelper : public XCBase
|
||||
ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Pivot Tick Zone ...
|
||||
*
|
||||
* @param pivot: XPVPivot instance Reference ...
|
||||
*/
|
||||
void CalculatePivotTickZone(
|
||||
XPVPivot &pivot //
|
||||
)
|
||||
{
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
bool isInited = false;
|
||||
|
||||
//
|
||||
datetime from = pivot.from;
|
||||
XOHCL iFromBar;
|
||||
int iFromBarIndex = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
from //
|
||||
);
|
||||
isInited = iFromBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
iFromBarIndex //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
datetime to = pivot.to;
|
||||
XOHCL iToBar;
|
||||
int iToBarIndex = iBarShift(
|
||||
symbol,
|
||||
period,
|
||||
to //
|
||||
);
|
||||
isInited = iToBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
iToBarIndex //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if (iFromBarIndex <= iToBarIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XCTicksZone *iZone;
|
||||
iZone = new XCTicksZone();
|
||||
|
||||
//
|
||||
int ticksLevels = mPOIDetector.TicksRangeZoneLevel();
|
||||
int ticksRange = mPOIDetector.TicksRangeZoneRange();
|
||||
isInited = ticksLevels > 0 &&
|
||||
ticksRange > 0;
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
isInited = iZone.Init(
|
||||
iFromBar,
|
||||
iToBar //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
pivot.state.ticksZone = iZone;
|
||||
}
|
||||
|
||||
//
|
||||
// Change Values Actions ...
|
||||
|
||||
|
||||
@@ -563,7 +563,7 @@ class XC121SMCExpert : public XCBaseExpert
|
||||
|
||||
//
|
||||
mTradeHandler.MaxAllowedSLToPause(0);
|
||||
mTradeHandler.DelayBarBetweenTwoSignal(60);
|
||||
mTradeHandler.DelayBarBetweenTwoSignal(7);
|
||||
mTradeHandler.MaxAllowedSLReachedPauseDelay(HoursToSeconds(24));
|
||||
|
||||
//
|
||||
|
||||
@@ -2028,14 +2028,6 @@ struct XSMCStrategySetupConditions
|
||||
//
|
||||
datetime setupTime;
|
||||
datetime triggerTime;
|
||||
XConsolidationZone zone;
|
||||
XConsolidationZone consolidation;
|
||||
|
||||
//
|
||||
double peak;
|
||||
double vale;
|
||||
XPVPivotPoint validPeak;
|
||||
XPVPivotPoint validVale;
|
||||
|
||||
//
|
||||
// Trigger Props ...
|
||||
@@ -2059,8 +2051,6 @@ struct XSMCStrategySetupConditions
|
||||
sl = 0;
|
||||
|
||||
//
|
||||
zone.Clean();
|
||||
consolidation.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
type = X_POSITION_TYPE_NONE;
|
||||
|
||||
@@ -2069,12 +2059,6 @@ struct XSMCStrategySetupConditions
|
||||
period = NULL;
|
||||
setupTime = NULL;
|
||||
triggerTime = NULL;
|
||||
|
||||
//
|
||||
peak = 0;
|
||||
vale = 0;
|
||||
validPeak.Clean();
|
||||
validVale.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2127,33 +2111,6 @@ struct XSMCStrategySetupConditions
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Helpers ...
|
||||
|
||||
void UpdateZone()
|
||||
{
|
||||
//
|
||||
if (!zone.IsValid() ||
|
||||
!validPeak.IsValid() ||
|
||||
!validVale.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
zone.upper = validPeak.value;
|
||||
zone.lower = validVale.value;
|
||||
|
||||
//
|
||||
zone.Update();
|
||||
|
||||
//
|
||||
if (consolidation.IsValid())
|
||||
{
|
||||
consolidation.Update();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,787 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 X121SMCStrategyTestSignalConditions
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
|
||||
//
|
||||
double sl;
|
||||
ENUM_X_DIRECTION dir;
|
||||
ENUM_X_POSITION_TYPES type;
|
||||
|
||||
//
|
||||
// Setup Props ...
|
||||
|
||||
//
|
||||
datetime setupTime;
|
||||
datetime triggerTime;
|
||||
|
||||
//
|
||||
XPVPivot pivot;
|
||||
|
||||
//
|
||||
// Trigger Props ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
X121SMCStrategyTestSignalConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleaning Up ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
sl = 0;
|
||||
|
||||
//
|
||||
dir = X_DIRECTION_NONE;
|
||||
type = X_POSITION_TYPE_NONE;
|
||||
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
setupTime = NULL;
|
||||
triggerTime = NULL;
|
||||
|
||||
//
|
||||
pivot.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ...
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Extension Functions ...
|
||||
|
||||
//
|
||||
// Detect Setup Conditions ...
|
||||
bool DetectX121SMCTestSiganlSetup(
|
||||
string _symbol,
|
||||
ENUM_TIMEFRAMES _period,
|
||||
//
|
||||
X121SMCStrategyTestSignalConditions &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;
|
||||
|
||||
//
|
||||
// Check Order Block ...
|
||||
// TODO: Later ...
|
||||
// bool hasOrderBlock = conditions.HasOrderBlock();
|
||||
// if (hasOrderBlock)
|
||||
// {
|
||||
// //
|
||||
// DetectX121SMCTestSiganlOrderBlock(
|
||||
// zBar,
|
||||
// consolidationState,
|
||||
// conditions //
|
||||
// );
|
||||
// }
|
||||
|
||||
//
|
||||
bool isMarketBullish =
|
||||
//
|
||||
// VWap State ...
|
||||
decisionConditions.x121Conditions.isVWapBullishState &&
|
||||
analyseConditions.x121Conditions.isVWapBullishState &&
|
||||
verificationConditions.x121Conditions.isVWapBullishState
|
||||
//
|
||||
&&
|
||||
//
|
||||
// VWap Order ...
|
||||
decisionConditions.x121Conditions.isVWapBullishOrdered &&
|
||||
analyseConditions.x121Conditions.isVWapBullishOrdered &&
|
||||
verificationConditions.x121Conditions.isVWapBullishOrdered
|
||||
//
|
||||
&&
|
||||
//
|
||||
// Sar ...
|
||||
decisionConditions.x121Conditions.isSarBullish &&
|
||||
analyseConditions.x121Conditions.isSarBullish &&
|
||||
verificationConditions.x121Conditions.isSarBullish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isMarketBearish =
|
||||
//
|
||||
// VWap State ...
|
||||
decisionConditions.x121Conditions.isVWapBearishState &&
|
||||
analyseConditions.x121Conditions.isVWapBearishState &&
|
||||
verificationConditions.x121Conditions.isVWapBearishState
|
||||
//
|
||||
&&
|
||||
//
|
||||
// VWap Order ...
|
||||
decisionConditions.x121Conditions.isVWapBearishOrdered &&
|
||||
analyseConditions.x121Conditions.isVWapBearishOrdered &&
|
||||
verificationConditions.x121Conditions.isVWapBearishOrdered
|
||||
//
|
||||
&&
|
||||
//
|
||||
// Sar ...
|
||||
decisionConditions.x121Conditions.isSarBearish &&
|
||||
analyseConditions.x121Conditions.isSarBearish &&
|
||||
verificationConditions.x121Conditions.isSarBearish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Step 1
|
||||
// Detect Market Direction ...
|
||||
isBullish = isMarketBullish;
|
||||
isBearish = isMarketBearish;
|
||||
|
||||
//
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Step 2
|
||||
// VWap Switches or Sar Switches ...
|
||||
|
||||
//
|
||||
bool isSarBullish = triggerConditions.x121Conditions.isSarBullish;
|
||||
bool isSarBearish = triggerConditions.x121Conditions.isSarBearish;
|
||||
|
||||
//
|
||||
bool isSarSwitchedToBullish = triggerConditions.x121Conditions.isSarSwitchedToBullish;
|
||||
bool isSarSwitchedToBearish = triggerConditions.x121Conditions.isSarSwitchedToBearish;
|
||||
|
||||
//
|
||||
bool isVWapBullishState = triggerConditions.x121Conditions.isVWapBullishState;
|
||||
bool isVWapBearishState = triggerConditions.x121Conditions.isVWapBearishState;
|
||||
|
||||
//
|
||||
bool isVWapSwitchedToBullishState = triggerConditions.x121Conditions.isVWapSwitchedToBullishState;
|
||||
bool isVWapSwitchedToBearishState = triggerConditions.x121Conditions.isVWapSwitchedToBearishState;
|
||||
|
||||
//
|
||||
bool isVWapBullishOrdered = triggerConditions.x121Conditions.isVWapBullishOrdered;
|
||||
bool isVWapBearishOrdered = triggerConditions.x121Conditions.isVWapBearishOrdered;
|
||||
|
||||
//
|
||||
bool isVWapSwitchedToBullishOrdered = triggerConditions.x121Conditions.isVWapSwitchedToBullishOrdered;
|
||||
bool isVWapSwitchedToBearishOrdered = triggerConditions.x121Conditions.isVWapSwitchedToBearishOrdered;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
bool isSarStartedBullishStructure =
|
||||
//
|
||||
isSarSwitchedToBullish &&
|
||||
isVWapBullishState &&
|
||||
isVWapBullishOrdered
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isSarStartedBearishStructure =
|
||||
//
|
||||
isSarSwitchedToBearish &&
|
||||
isVWapBearishState &&
|
||||
isVWapBearishOrdered
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
bool isVWapStateStartedBullishStructure =
|
||||
//
|
||||
isVWapSwitchedToBullishState &&
|
||||
isSarBullish &&
|
||||
isVWapBullishOrdered
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isVWapStateStartedBearishStructure =
|
||||
//
|
||||
isVWapSwitchedToBearishState &&
|
||||
isSarBearish &&
|
||||
isVWapBearishOrdered
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
bool isVWapOrderStartedBullishStructure =
|
||||
//
|
||||
isVWapSwitchedToBullishOrdered &&
|
||||
isSarBullish &&
|
||||
isVWapBullishState
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isVWapOrderStartedBearishStructure =
|
||||
//
|
||||
isVWapSwitchedToBearishOrdered &&
|
||||
isSarBearish &&
|
||||
isVWapBearishState
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
isBullish
|
||||
//
|
||||
&&
|
||||
//
|
||||
(
|
||||
//
|
||||
isSarStartedBullishStructure ||
|
||||
isVWapStateStartedBullishStructure ||
|
||||
isVWapOrderStartedBullishStructure
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
isBearish
|
||||
//
|
||||
&&
|
||||
//
|
||||
(
|
||||
//
|
||||
isSarStartedBearishStructure ||
|
||||
isVWapStateStartedBearishStructure ||
|
||||
isVWapOrderStartedBearishStructure
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
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 DetectX121SMCTestSiganlTrigger(
|
||||
//
|
||||
X121SMCStrategyTestSignalConditions &conditions,
|
||||
//
|
||||
string _symbol,
|
||||
ENUM_TIMEFRAMES _period,
|
||||
//
|
||||
XC121SMCCycleHelper *triggerCycleHelper,
|
||||
XC121SMCCycleHelper *decisionCycleHelper,
|
||||
XC121SMCCycleHelper *analyseCycleHelper,
|
||||
XC121SMCCycleHelper *verificationCycleHelper,
|
||||
XC121SMCCycleHelper *consolidationCycleHelper,
|
||||
XC121SMCCycleHelper *visionCycleHelper
|
||||
//
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = conditions.IsSetuped();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_SMPV;
|
||||
string providerStr = ToString(provider);
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
result = false;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools Functions ...
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user