1791 lines
43 KiB
Plaintext
1791 lines
43 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// --------------------------------------
|
|
// Name: XC121SMCCycleHelper
|
|
// Description: provides all based classes for use ...
|
|
//
|
|
//
|
|
// 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-saherelm.x-bar.analyser.class.mq5"
|
|
#include "../../Classes/x-saherelm.x-poi.class.mq5"
|
|
#include "../Libraries/x-121.smc.lib.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Implementations ...
|
|
|
|
//
|
|
// Cycles Enumeration ...
|
|
enum ENUM_X_CYCLES
|
|
{
|
|
X_CYCLE_NONE,
|
|
X_CYCLE_TRIGGER,
|
|
X_CYCLE_DECISION,
|
|
X_CYCLE_ANALYSE,
|
|
X_CYCLE_VERIFICATION,
|
|
X_CYCLE_CONSOLIDATION,
|
|
X_CYCLE_VISION,
|
|
};
|
|
|
|
//
|
|
// String Representation of Cycles Enumeration ...
|
|
string ToString(ENUM_X_CYCLES value)
|
|
{
|
|
//
|
|
string result = EnumToString(value);
|
|
|
|
//
|
|
StringReplace(result, "X_CYCLE_", "");
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Validate a Cycle ...
|
|
bool IsValid(ENUM_X_CYCLES value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
value != X_CYCLE_NONE;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cycle Events Enumeration ...
|
|
enum ENUM_X_CYCLE_EVENTS
|
|
{
|
|
SAR_CHANGE_DETECTED,
|
|
NEW_PEAK_DETECTED,
|
|
NEW_VALE_DETECTED,
|
|
PIVOT_POINT_DETECTED,
|
|
VWAP_ORDER_CHANGE_ETECTED,
|
|
VWAP_STATE_CHANGE_DETCTED,
|
|
CONSOLIDATION_BREAKED_DETECTED,
|
|
PEAK_PIVOT_STARTED,
|
|
PEAK_PIVOT_ENDED,
|
|
VALE_PIVOT_STARTED,
|
|
VALE_PIVOT_ENDED,
|
|
};
|
|
|
|
//
|
|
// Cycle Helper ...
|
|
class XC121SMCCycleHelper : public XCBase
|
|
{
|
|
//
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// X121 ...
|
|
XCX121Helper *mX121Helper;
|
|
|
|
//
|
|
// POI Detector ...
|
|
XCPOIDrawer *mPOIDrawer;
|
|
XCPOIDetector *mPOIDetector;
|
|
|
|
//
|
|
// Bar Analyser
|
|
XCBarAnalyser *mBarAnalyser;
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
XC121SMCCycleHelper()
|
|
{
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XC121SMCCycleHelper()
|
|
{
|
|
DeInit();
|
|
}
|
|
|
|
//
|
|
// Getter/Setter(s) ...
|
|
|
|
//
|
|
// Actions ...
|
|
|
|
/**
|
|
* Initialize ...
|
|
*
|
|
* @param symbol: String ...
|
|
* @param period: ENUM_TIMEFRAMES member ...
|
|
* @param x121Inputs: X121Inputs instance ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool Init(
|
|
string symbol,
|
|
ENUM_TIMEFRAMES period,
|
|
X121Inputs &x121Inputs,
|
|
int requiredPOIs = 50 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (requiredPOIs < 0)
|
|
{
|
|
requiredPOIs = 0;
|
|
}
|
|
|
|
//
|
|
result = IsValid(symbol) &&
|
|
IsValid(period);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mSymbol = symbol;
|
|
mPeriod = period;
|
|
|
|
//
|
|
// X121 ...
|
|
mX121Helper = new XCX121Helper();
|
|
result = mX121Helper.Init(
|
|
symbol,
|
|
period,
|
|
x121Inputs //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mPOIDetector = new XCPOIDetector(
|
|
symbol,
|
|
period //
|
|
);
|
|
mPOIDetector.MaxRequiredPOIs(requiredPOIs);
|
|
|
|
//
|
|
int maxLoopbackBars = mPOIDetector.MaxAllowedLoopbackForInit();
|
|
int periodSeconds = PeriodSeconds(period);
|
|
if (periodSeconds > PeriodSeconds(PERIOD_M15))
|
|
{
|
|
//
|
|
int multiplier = periodSeconds / PeriodSeconds(PERIOD_M15);
|
|
|
|
//
|
|
if (multiplier >= 1)
|
|
{
|
|
maxLoopbackBars *= 2;
|
|
}
|
|
}
|
|
mPOIDetector.MaxAllowedLoopbackForInit(maxLoopbackBars);
|
|
mPOIDetector.Init();
|
|
|
|
//
|
|
// Initialize Bar Analyser Class Instance ...
|
|
mBarAnalyser = new XCBarAnalyser();
|
|
|
|
//
|
|
// Initial and Configure POI Drawer if Required ...
|
|
mPOIDrawer = new XCPOIDrawer();
|
|
mPOIDrawer.ChartIdentification(0);
|
|
mPOIDrawer.SubWindowIdentification(0);
|
|
|
|
//
|
|
mPOIDrawer.DemandZoneFill(false);
|
|
mPOIDrawer.SupplyZoneFill(false);
|
|
mPOIDrawer.BullishFVGFill(false);
|
|
mPOIDrawer.BearishFVGFill(false);
|
|
mPOIDrawer.SupportZoneFill(false);
|
|
mPOIDrawer.ResistanceZoneFill(false);
|
|
mPOIDrawer.BullishOrderBlockFill(false);
|
|
mPOIDrawer.BearishOrderBlockFill(false);
|
|
|
|
//
|
|
// Set Chart Style ...
|
|
ApplyChartStyle();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve Symbol ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string GetSymbol()
|
|
{
|
|
return mSymbol;
|
|
}
|
|
|
|
/**
|
|
* Retrieve TimeFrame (Period) ...
|
|
*
|
|
* @return ( ENUM_TIMEFRAMES )
|
|
*/
|
|
ENUM_TIMEFRAMES GetPeriod()
|
|
{
|
|
return mPeriod;
|
|
}
|
|
|
|
/**
|
|
* Get Specified Bar ...
|
|
*
|
|
* @param source: XOHCL instance, Source Bar ...
|
|
* @param bar: XOHCL instance, Dest Bar ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GetBar(
|
|
XOHCL &source,
|
|
XOHCL &bar //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
bar.Clean();
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
result =
|
|
IsValid(symbol) &&
|
|
IsValid(period) &&
|
|
source.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int index = iBarShift(
|
|
symbol,
|
|
period,
|
|
source.time //
|
|
);
|
|
result = bar.Init(
|
|
symbol,
|
|
period,
|
|
index //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
bar.Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve Specified Bar ...
|
|
*
|
|
* @param bar: XOHCL instance ...
|
|
* @param index: Integer ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GetBar(
|
|
XOHCL &bar,
|
|
int index = 0 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
bar.Clean();
|
|
|
|
//
|
|
if (index < 0)
|
|
{
|
|
index = 0;
|
|
}
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
result = bar.Init(
|
|
symbol,
|
|
period,
|
|
index //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve Specified Bar ...
|
|
*
|
|
* @param bar: XOHCL instance ...
|
|
* @param time: Datetime ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GetBar(
|
|
XOHCL &bar,
|
|
datetime time = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
int index = GetBarIndex(time);
|
|
result = GetBar(bar,
|
|
index //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve Specified Time Bar Index ...
|
|
*
|
|
* @param time: DateTime ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int GetBarIndex(datetime time = NULL)
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
time = NormalizeTime(time);
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
result = iBarShift(
|
|
symbol,
|
|
period,
|
|
time //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieve Cycle Conditions ...
|
|
*
|
|
* @param events: ENUM_X_CYCLE_EVENTS member, Array ...
|
|
* @param conditions: X121SMCCycleConditions instance ...
|
|
* @param barIndex: Integer ...
|
|
* @param loopback: Integer ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool GetConditions(
|
|
ENUM_X_CYCLE_EVENTS &events[],
|
|
ENUM_XPOI_EVENTS &poiEvents[],
|
|
X121SMCCycleConditions &conditions,
|
|
int barIndex = 0,
|
|
int loopback = 7 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
if (loopback < 5)
|
|
{
|
|
loopback = 5;
|
|
}
|
|
|
|
//
|
|
Clean(events);
|
|
Clean(poiEvents);
|
|
conditions.Clean();
|
|
|
|
//
|
|
result = mX121Helper.GetConditions(
|
|
conditions.x121Conditions,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
conditions.Clean();
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mPOIDetector.Update(poiEvents);
|
|
mPOIDetector.GetState(conditions.state);
|
|
|
|
//
|
|
conditions.symbol = GetSymbol();
|
|
conditions.period = GetPeriod();
|
|
conditions.time = TimeCurrent();
|
|
|
|
//
|
|
// Update();
|
|
|
|
//
|
|
result = conditions.IsValid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
bool GeneratePVBox(
|
|
XBoxZone &box,
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
box.Clean();
|
|
box.symbol = GetSymbol();
|
|
box.period = GetPeriod();
|
|
|
|
//
|
|
int index = barIndex;
|
|
|
|
//
|
|
// Peak ...
|
|
datetime peaksSameFrom = NULL;
|
|
double peak = mX121Helper.xpvHelper.GetPeak(index);
|
|
double prevPeak = mX121Helper.xpvHelper.GetPeak(index + 1);
|
|
bool startsByPeak = peak == prevPeak;
|
|
|
|
//
|
|
// Vale ...
|
|
datetime valesSameFrom = NULL;
|
|
double vale = mX121Helper.xpvHelper.GetVale(index);
|
|
double prevVale = mX121Helper.xpvHelper.GetVale(index + 1);
|
|
bool startsByVale =
|
|
!startsByPeak &&
|
|
vale == prevVale;
|
|
|
|
//
|
|
bool canBreak = false;
|
|
while (!canBreak)
|
|
{
|
|
//
|
|
index++;
|
|
|
|
//
|
|
datetime cTime = iTime(
|
|
box.symbol,
|
|
box.period,
|
|
index //
|
|
);
|
|
|
|
//
|
|
// Peak ...
|
|
double iPeak = mX121Helper.xpvHelper.GetPeak(index);
|
|
|
|
//
|
|
// Vale ...
|
|
double iVale = mX121Helper.xpvHelper.GetVale(index);
|
|
|
|
//
|
|
// Start By Peak or Value ...
|
|
bool isSame = false;
|
|
if (startsByPeak)
|
|
{
|
|
//
|
|
isSame = iPeak == peak;
|
|
bool canSetVale = vale == 0
|
|
? true
|
|
: iVale > vale;
|
|
if (canSetVale)
|
|
{
|
|
vale = iVale;
|
|
}
|
|
}
|
|
else if (startsByVale)
|
|
{
|
|
//
|
|
isSame = iVale == vale;
|
|
bool canSetPeak = peak == 0
|
|
? true
|
|
: iPeak < peak;
|
|
if (canSetPeak)
|
|
{
|
|
peak = iPeak;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (isSame)
|
|
{
|
|
//
|
|
box.from = cTime;
|
|
box.upper = peak;
|
|
box.lower = vale;
|
|
}
|
|
else if (IsValid(box.from))
|
|
{
|
|
//
|
|
// Complete Box ...
|
|
box.to = iTime(
|
|
box.symbol,
|
|
box.period,
|
|
barIndex //
|
|
);
|
|
|
|
//
|
|
box.type = "XPVBox";
|
|
box.dir = startsByPeak
|
|
? X_DIRECTION_BEARISH
|
|
: startsByVale
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_NONE;
|
|
}
|
|
|
|
//
|
|
canBreak = !isSame;
|
|
}
|
|
|
|
//
|
|
result = box.IsValid();
|
|
if (!result)
|
|
{
|
|
box.Clean();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int DetectRejections(
|
|
XBoxZone &rejections[],
|
|
int barIndex = 0,
|
|
bool forceBarType = true,
|
|
bool forceFiboPressure = true,
|
|
bool forceUnUsedRejections = true,
|
|
int maxAllowedLoopback = 587 //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize Args ...
|
|
Clean(rejections);
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
int idx = -1;
|
|
bool has = false;
|
|
for (int i = barIndex + 1; i < barIndex + maxAllowedLoopback; i++)
|
|
{
|
|
//
|
|
// Init Indexed Bar ...
|
|
XOHCL iBar;
|
|
XOHCL iCBar;
|
|
XOHCL iPBar;
|
|
has = GetBar(iBar, i);
|
|
has =
|
|
has &&
|
|
iBar.GetPreviousBar(iCBar);
|
|
has =
|
|
has &&
|
|
iCBar.GetPreviousBar(iPBar);
|
|
if (!has)
|
|
{
|
|
//
|
|
iBar.Clean();
|
|
iCBar.Clean();
|
|
iPBar.Clean();
|
|
break;
|
|
}
|
|
|
|
//
|
|
// Check CBar Bullish Fibo Pressure ...
|
|
bool cBarHasBullishFiboPressure =
|
|
mBarAnalyser
|
|
.HasFiboPressure(
|
|
iCBar,
|
|
X_DIRECTION_BULLISH,
|
|
X_FIBO_LEVEL_382 //
|
|
);
|
|
|
|
//
|
|
// Check CBar Bearish Fibo Pressure ...
|
|
bool cBarHasBearishFiboPressure =
|
|
mBarAnalyser
|
|
.HasFiboPressure(
|
|
iCBar,
|
|
X_DIRECTION_BEARISH,
|
|
X_FIBO_LEVEL_382 //
|
|
);
|
|
|
|
//
|
|
// Check Bar is Bullish Rejection Swing ...
|
|
bool isBullishRejection =
|
|
//
|
|
iCBar.low < iBar.low &&
|
|
iCBar.low < iPBar.low &&
|
|
//
|
|
iCBar.low < iCBar.GetDown() &&
|
|
iCBar.GetLowShadow() > iCBar.GetBody() &&
|
|
iCBar.GetLowShadow() > iCBar.GetHighShadow()
|
|
//
|
|
;
|
|
|
|
//
|
|
// Check Bar is Bearish Rejection Swing ...
|
|
bool isBearishRejection =
|
|
//
|
|
iCBar.high > iBar.high &&
|
|
iCBar.high > iPBar.high &&
|
|
//
|
|
iCBar.high > iCBar.GetUp() &&
|
|
iCBar.GetHighShadow() > iCBar.GetBody() &&
|
|
iCBar.GetHighShadow() > iCBar.GetLowShadow()
|
|
//
|
|
;
|
|
|
|
//
|
|
// Apply Fibo Pressure ...
|
|
if (forceFiboPressure)
|
|
{
|
|
//
|
|
isBullishRejection =
|
|
isBullishRejection &&
|
|
cBarHasBullishFiboPressure;
|
|
|
|
//
|
|
isBearishRejection =
|
|
isBearishRejection &&
|
|
cBarHasBearishFiboPressure;
|
|
}
|
|
|
|
//
|
|
// Apply Force Bar Type ...
|
|
if (forceBarType)
|
|
{
|
|
//
|
|
isBullishRejection =
|
|
isBullishRejection &&
|
|
iCBar.IsBullish();
|
|
|
|
//
|
|
isBearishRejection =
|
|
isBearishRejection &&
|
|
iCBar.IsBearish();
|
|
}
|
|
|
|
//
|
|
// Summarize Result ...
|
|
has = isBullishRejection ||
|
|
isBearishRejection;
|
|
if (has)
|
|
{
|
|
//
|
|
XBoxZone iBox;
|
|
|
|
//
|
|
iBox.to = iBar.time;
|
|
iBox.from = iCBar.time;
|
|
iBox.period = iBar.period;
|
|
iBox.symbol = iBar.symbol;
|
|
|
|
//
|
|
iBox.dir =
|
|
isBullishRejection
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
|
|
//
|
|
iBox.upper =
|
|
isBullishRejection
|
|
? iCBar.GetDown()
|
|
: iCBar.high;
|
|
|
|
//
|
|
iBox.lower =
|
|
isBullishRejection
|
|
? iCBar.low
|
|
: iCBar.GetUp();
|
|
|
|
//
|
|
iBox.type =
|
|
isBullishRejection
|
|
? "XSwingLow"
|
|
: "XSwingHigh";
|
|
|
|
//
|
|
// Validate Box ...
|
|
has = iBox.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
// Apply Force Unused Rejections ...
|
|
if (forceUnUsedRejections)
|
|
{
|
|
//
|
|
has = !IsBoxBreaked(
|
|
iBox,
|
|
iCBar.Index() + 1,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
if (has)
|
|
{
|
|
//
|
|
idx = FindIndex(
|
|
iBox,
|
|
rejections //
|
|
);
|
|
has = !IsValidIndex(idx);
|
|
if (has)
|
|
{
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
rejections //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
iCBar.Clean();
|
|
iPBar.Clean();
|
|
}
|
|
|
|
//
|
|
result = ArraySize(rejections);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
datetime DetectNearestCloseOverX3MAFast(
|
|
XOHCL &bar,
|
|
int maxAllowedBars = 20 //
|
|
)
|
|
{
|
|
//
|
|
datetime result = NULL;
|
|
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool has = false;
|
|
int idx = bar.Index();
|
|
int start = idx;
|
|
int end = start + maxAllowedBars;
|
|
bool canContinue = true;
|
|
while (canContinue)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
has = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
start //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
iBar.Clean();
|
|
break;
|
|
}
|
|
|
|
//
|
|
double iFast = mX121Helper
|
|
.x3maHelper
|
|
.GetX3MaFast(start);
|
|
|
|
//
|
|
has = iBar.close > iFast &&
|
|
iBar.open < iFast;
|
|
if (has)
|
|
{
|
|
result = iBar.time;
|
|
}
|
|
|
|
//
|
|
canContinue =
|
|
start < end &&
|
|
!IsValid(result);
|
|
|
|
//
|
|
start++;
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
datetime DetectNearestCloseUnderX3MAFast(
|
|
XOHCL &bar,
|
|
int maxAllowedBars = 20 //
|
|
)
|
|
{
|
|
//
|
|
datetime result = NULL;
|
|
|
|
//
|
|
if (!bar.IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool has = false;
|
|
int idx = bar.Index();
|
|
int start = idx;
|
|
int end = start + maxAllowedBars;
|
|
bool canContinue = true;
|
|
while (canContinue)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
has = iBar.Init(
|
|
bar.symbol,
|
|
bar.period,
|
|
start //
|
|
);
|
|
if (!has)
|
|
{
|
|
//
|
|
iBar.Clean();
|
|
break;
|
|
}
|
|
|
|
//
|
|
double iFast = mX121Helper
|
|
.x3maHelper
|
|
.GetX3MaFast(start);
|
|
|
|
//
|
|
has = iBar.close < iFast &&
|
|
iBar.open > iFast;
|
|
if (has)
|
|
{
|
|
result = iBar.time;
|
|
}
|
|
|
|
//
|
|
canContinue =
|
|
start < end &&
|
|
!IsValid(result);
|
|
|
|
//
|
|
start++;
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool DetectNearestStrSwitched(
|
|
XOHCL &bar,
|
|
ENUM_X_DIRECTION &dir,
|
|
int barIndex = 0,
|
|
int maxAllowedBars = 20 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
bar.Clean();
|
|
dir = X_DIRECTION_NONE;
|
|
barIndex = NormalizeInt(barIndex, 0);
|
|
maxAllowedBars = NormalizeInt(maxAllowedBars, 20);
|
|
|
|
//
|
|
// Looping Through LoopBack Period ...
|
|
// for Detecting Result ...
|
|
for (int i = barIndex; i < barIndex + maxAllowedBars; i++)
|
|
{
|
|
//
|
|
XOHCL iBar;
|
|
result = iBar.Init(
|
|
GetSymbol(),
|
|
GetPeriod(),
|
|
i //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
iBar.Clean();
|
|
break;
|
|
}
|
|
|
|
//
|
|
double iStrState = mX121Helper.xstrHelper.GetSTRState(i);
|
|
double iStrStateP = mX121Helper.xstrHelper.GetSTRState(i + 1);
|
|
|
|
//
|
|
bool isStrBullish = iStrState > 0;
|
|
bool isStrBullishP = iStrStateP > 0;
|
|
|
|
//
|
|
bool isStrBearish = iStrState < 0;
|
|
bool isStrBearishP = iStrStateP < 0;
|
|
|
|
//
|
|
bool isBullish = isStrBullish &&
|
|
!isStrBullishP;
|
|
|
|
//
|
|
bool isBearish = isStrBearish &&
|
|
!isStrBearishP;
|
|
|
|
//
|
|
result = isBullish ||
|
|
isBearish;
|
|
if (result)
|
|
{
|
|
//
|
|
bar = iBar;
|
|
|
|
//
|
|
dir = isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
|
|
//
|
|
iBar.Clean();
|
|
break;
|
|
}
|
|
|
|
//
|
|
iBar.Clean();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Virtuals ...
|
|
|
|
/**
|
|
* Set Default Properties Values ...
|
|
*/
|
|
virtual void Default()
|
|
{
|
|
}
|
|
|
|
//
|
|
protected:
|
|
//
|
|
|
|
//
|
|
private:
|
|
//
|
|
// Props ...
|
|
string mSymbol;
|
|
ENUM_TIMEFRAMES mPeriod;
|
|
|
|
//
|
|
// Actions ...
|
|
|
|
/**
|
|
* Release All Resources ...
|
|
*/
|
|
void DeInit()
|
|
{
|
|
//
|
|
ZeroMemory(mX121Helper);
|
|
ZeroMemory(mPOIDetector);
|
|
ZeroMemory(mBarAnalyser);
|
|
|
|
//
|
|
delete mX121Helper;
|
|
delete mPOIDetector;
|
|
delete mBarAnalyser;
|
|
}
|
|
|
|
/**
|
|
* Apply Chart Style ...
|
|
*/
|
|
void ApplyChartStyle()
|
|
{
|
|
//
|
|
// Retrieve Current Chart ID ...
|
|
long chartId = ChartID();
|
|
|
|
//
|
|
ENUM_CHART_MODE mMode = CHART_CANDLES; // chart's mMode
|
|
bool mShowBidLine = true; // show bid line
|
|
bool mShowAskLine = true; // show ask line
|
|
bool mShowGrid = false; // show grids on chart
|
|
bool mShowVolumes = false; // show volumes
|
|
bool mShowTradeLevels = true; // Displaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders)
|
|
bool mAutoScroll = true; // chart autoscroll
|
|
bool mQuickNavigation = true; // chart quick navigation state
|
|
color mForeGroundColor = clrWhite; // chart's foreground color
|
|
color mBackGroundColor = clrBlack; // chart's background color
|
|
color mUpColor = clrGreen; // Up Color
|
|
color mDownColor = clrRed; // Down Color
|
|
color mBullishColor = clrGreen; // Bullish color
|
|
color mBearishColor = clrRed; // Bearish color
|
|
color mGridColor = clrGray; // grid color
|
|
color mBidLineColor = clrGray; // bid line color
|
|
color mAskLineColor = clrRed; // ask line color
|
|
color mLineColor = clrLime; // line mMode and doji candlestick color
|
|
color mStopColor = clrGold; // Color of stop order levels (Stop Loss and Take Profit)
|
|
color mVolumesColor = clrGreen; // volumes color
|
|
|
|
//
|
|
ChartSetInteger(chartId, CHART_SHOW_BID_LINE, mShowBidLine);
|
|
ChartSetInteger(chartId, CHART_SHOW_ASK_LINE, mShowAskLine);
|
|
ChartSetInteger(chartId, CHART_SHOW_GRID, mShowGrid);
|
|
ChartSetInteger(chartId, CHART_SHOW_VOLUMES, mShowVolumes);
|
|
ChartSetInteger(chartId, CHART_SHOW_TRADE_LEVELS, mShowTradeLevels);
|
|
ChartSetInteger(chartId, CHART_AUTOSCROLL, mAutoScroll);
|
|
ChartSetInteger(chartId, CHART_QUICK_NAVIGATION, mQuickNavigation);
|
|
ChartSetInteger(chartId, CHART_COLOR_FOREGROUND, mForeGroundColor);
|
|
ChartSetInteger(chartId, CHART_COLOR_BACKGROUND, mBackGroundColor);
|
|
ChartSetInteger(chartId, CHART_COLOR_GRID, mGridColor);
|
|
ChartSetInteger(chartId, CHART_COLOR_BID, mBidLineColor);
|
|
ChartSetInteger(chartId, CHART_COLOR_ASK, mAskLineColor);
|
|
ChartSetInteger(chartId, CHART_COLOR_STOP_LEVEL, mStopColor);
|
|
ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor);
|
|
|
|
//
|
|
// For Enabling XCC ...
|
|
// ChartSetInteger(chartId, CHART_MODE, mMode);
|
|
// ChartSetInteger(chartId, CHART_COLOR_CHART_UP, mUpColor);
|
|
// ChartSetInteger(chartId, CHART_COLOR_CHART_DOWN, mDownColor);
|
|
// ChartSetInteger(chartId, CHART_COLOR_CANDLE_BULL, mBullishColor);
|
|
// ChartSetInteger(chartId, CHART_COLOR_CANDLE_BEAR, mBearishColor);
|
|
// ChartSetInteger(chartId, CHART_COLOR_CHART_LINE, mLineColor);
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Signal Provider Data ...
|
|
struct X121SMCStrategySignalProviderData
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Trigger ...
|
|
XPOIState triggerState;
|
|
double triggerBullishScore;
|
|
double triggerBearishScore;
|
|
X121Conditions triggerXConditions;
|
|
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
|
XC121SMCCycleHelper *triggerCycleHelper;
|
|
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
|
X121SMCCycleConditions triggerConditions;
|
|
|
|
//
|
|
// Decision ...
|
|
XPOIState decisionState;
|
|
double decisionBullishScore;
|
|
double decisionBearishScore;
|
|
X121Conditions decisionXConditions;
|
|
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
|
XC121SMCCycleHelper *decisionCycleHelper;
|
|
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
|
X121SMCCycleConditions decisionConditions;
|
|
|
|
//
|
|
// Analyse ...
|
|
XPOIState analyseState;
|
|
double analyseBullishScore;
|
|
double analyseBearishScore;
|
|
X121Conditions analyseXConditions;
|
|
ENUM_XPOI_EVENTS analysePoiEvents[];
|
|
XC121SMCCycleHelper *analyseCycleHelper;
|
|
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
|
X121SMCCycleConditions analyseConditions;
|
|
|
|
//
|
|
// Verification ...
|
|
XPOIState verificationState;
|
|
double verificationBullishScore;
|
|
double verificationBearishScore;
|
|
X121Conditions verificationXConditions;
|
|
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
|
XC121SMCCycleHelper *verificationCycleHelper;
|
|
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
|
X121SMCCycleConditions verificationConditions;
|
|
|
|
//
|
|
// Consolidation ...
|
|
XPOIState consolidationState;
|
|
double consolidationBullishScore;
|
|
double consolidationBearishScore;
|
|
X121Conditions consolidationXConditions;
|
|
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
|
XC121SMCCycleHelper *consolidationCycleHelper;
|
|
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
|
X121SMCCycleConditions consolidationConditions;
|
|
|
|
//
|
|
// Vision ...
|
|
XPOIState visionState;
|
|
double visionBullishScore;
|
|
double visionBearishScore;
|
|
X121Conditions visionXConditions;
|
|
ENUM_XPOI_EVENTS visionPoiEvents[];
|
|
XC121SMCCycleHelper *visionCycleHelper;
|
|
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
|
X121SMCCycleConditions visionConditions;
|
|
|
|
//
|
|
// Constructor ...
|
|
X121SMCStrategySignalProviderData()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean()
|
|
{
|
|
//
|
|
// Trigger ...
|
|
triggerState.Clean();
|
|
triggerBullishScore = 0;
|
|
triggerBearishScore = 0;
|
|
Clean(triggerPoiEvents);
|
|
Clean(triggerCycleEvents);
|
|
triggerConditions.Clean();
|
|
triggerXConditions.Clean();
|
|
|
|
//
|
|
// Decision ...
|
|
decisionState.Clean();
|
|
decisionBullishScore = 0;
|
|
decisionBearishScore = 0;
|
|
Clean(decisionPoiEvents);
|
|
Clean(decisionCycleEvents);
|
|
decisionConditions.Clean();
|
|
decisionXConditions.Clean();
|
|
|
|
//
|
|
// Analyse ...
|
|
analyseState.Clean();
|
|
analyseBullishScore = 0;
|
|
analyseBearishScore = 0;
|
|
Clean(analysePoiEvents);
|
|
Clean(analyseCycleEvents);
|
|
analyseConditions.Clean();
|
|
analyseXConditions.Clean();
|
|
|
|
//
|
|
// Verification ...
|
|
verificationState.Clean();
|
|
verificationBullishScore = 0;
|
|
verificationBearishScore = 0;
|
|
Clean(verificationPoiEvents);
|
|
Clean(verificationCycleEvents);
|
|
verificationConditions.Clean();
|
|
verificationXConditions.Clean();
|
|
|
|
//
|
|
// Consolidation ...
|
|
consolidationState.Clean();
|
|
consolidationBullishScore = 0;
|
|
consolidationBearishScore = 0;
|
|
Clean(consolidationPoiEvents);
|
|
Clean(consolidationCycleEvents);
|
|
consolidationConditions.Clean();
|
|
consolidationXConditions.Clean();
|
|
|
|
//
|
|
// Vision ...
|
|
visionState.Clean();
|
|
visionBullishScore = 0;
|
|
visionBearishScore = 0;
|
|
Clean(visionPoiEvents);
|
|
Clean(visionCycleEvents);
|
|
visionConditions.Clean();
|
|
visionXConditions.Clean();
|
|
}
|
|
|
|
//
|
|
void Destroy()
|
|
{
|
|
//
|
|
Clean();
|
|
|
|
//
|
|
ZeroMemory(visionCycleHelper);
|
|
ZeroMemory(triggerCycleHelper);
|
|
ZeroMemory(analyseCycleHelper);
|
|
ZeroMemory(decisionCycleHelper);
|
|
ZeroMemory(verificationCycleHelper);
|
|
ZeroMemory(consolidationCycleHelper);
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
//
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
visionCycleHelper != NULL &&
|
|
triggerCycleHelper != NULL &&
|
|
analyseCycleHelper != NULL &&
|
|
decisionCycleHelper != NULL &&
|
|
verificationCycleHelper != NULL &&
|
|
consolidationCycleHelper != NULL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Initialize ...
|
|
bool Init(
|
|
XC121SMCCycleHelper *_triggerCycleHelper,
|
|
XC121SMCCycleHelper *_decisionCycleHelper,
|
|
XC121SMCCycleHelper *_analyseCycleHelper,
|
|
XC121SMCCycleHelper *_verificationCycleHelper,
|
|
XC121SMCCycleHelper *_consolidationCycleHelper,
|
|
XC121SMCCycleHelper *_visionCycleHelper //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Cycle Helpers ...
|
|
result =
|
|
//
|
|
_visionCycleHelper != NULL &&
|
|
_triggerCycleHelper != NULL &&
|
|
_analyseCycleHelper != NULL &&
|
|
_decisionCycleHelper != NULL &&
|
|
_verificationCycleHelper != NULL &&
|
|
_consolidationCycleHelper != NULL
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
visionCycleHelper = _visionCycleHelper;
|
|
triggerCycleHelper = _triggerCycleHelper;
|
|
analyseCycleHelper = _analyseCycleHelper;
|
|
decisionCycleHelper = _decisionCycleHelper;
|
|
verificationCycleHelper = _verificationCycleHelper;
|
|
consolidationCycleHelper = _consolidationCycleHelper;
|
|
|
|
//
|
|
result = IsValid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Prepare all ...
|
|
bool Prepare(
|
|
int barIndex = 0,
|
|
int loopback = 10,
|
|
bool trigger = false,
|
|
bool decision = true,
|
|
bool analyse = true,
|
|
bool verification = false,
|
|
bool consolidation = true,
|
|
bool vision = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
if (loopback < 7)
|
|
{
|
|
loopback = 7;
|
|
}
|
|
|
|
//
|
|
result = IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Trigger ...
|
|
if (trigger)
|
|
{
|
|
//
|
|
result = triggerCycleHelper.GetConditions(
|
|
triggerCycleEvents,
|
|
triggerPoiEvents,
|
|
triggerConditions,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean(triggerPoiEvents);
|
|
Clean(triggerCycleEvents);
|
|
|
|
//
|
|
triggerConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Decision ...
|
|
if (decision)
|
|
{
|
|
//
|
|
result = decisionCycleHelper.GetConditions(
|
|
decisionCycleEvents,
|
|
decisionPoiEvents,
|
|
decisionConditions,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean(triggerPoiEvents);
|
|
Clean(decisionPoiEvents);
|
|
Clean(triggerCycleEvents);
|
|
triggerConditions.Clean();
|
|
Clean(decisionCycleEvents);
|
|
decisionConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Analyse ...
|
|
if (analyse)
|
|
{
|
|
//
|
|
result = analyseCycleHelper.GetConditions(
|
|
analyseCycleEvents,
|
|
analysePoiEvents,
|
|
analyseConditions,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean(triggerPoiEvents);
|
|
Clean(analysePoiEvents);
|
|
Clean(decisionPoiEvents);
|
|
Clean(triggerCycleEvents);
|
|
Clean(analyseCycleEvents);
|
|
triggerConditions.Clean();
|
|
analyseConditions.Clean();
|
|
Clean(decisionCycleEvents);
|
|
decisionConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Verification ...
|
|
if (verification)
|
|
{
|
|
//
|
|
result = verificationCycleHelper.GetConditions(
|
|
verificationCycleEvents,
|
|
verificationPoiEvents,
|
|
verificationConditions,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean(triggerPoiEvents);
|
|
Clean(analysePoiEvents);
|
|
Clean(decisionPoiEvents);
|
|
Clean(triggerCycleEvents);
|
|
Clean(analyseCycleEvents);
|
|
triggerConditions.Clean();
|
|
analyseConditions.Clean();
|
|
Clean(decisionCycleEvents);
|
|
decisionConditions.Clean();
|
|
Clean(verificationPoiEvents);
|
|
Clean(verificationCycleEvents);
|
|
verificationConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Consolidation ...
|
|
if (consolidation)
|
|
{
|
|
//
|
|
result = consolidationCycleHelper.GetConditions(
|
|
consolidationCycleEvents,
|
|
consolidationPoiEvents,
|
|
consolidationConditions,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean(triggerPoiEvents);
|
|
Clean(analysePoiEvents);
|
|
Clean(decisionPoiEvents);
|
|
Clean(triggerCycleEvents);
|
|
Clean(analyseCycleEvents);
|
|
triggerConditions.Clean();
|
|
analyseConditions.Clean();
|
|
Clean(decisionCycleEvents);
|
|
decisionConditions.Clean();
|
|
Clean(verificationPoiEvents);
|
|
Clean(consolidationPoiEvents);
|
|
Clean(verificationCycleEvents);
|
|
verificationConditions.Clean();
|
|
Clean(consolidationCycleEvents);
|
|
consolidationConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Vision ...
|
|
if (vision)
|
|
{
|
|
result = visionCycleHelper.GetConditions(
|
|
visionCycleEvents,
|
|
visionPoiEvents,
|
|
visionConditions,
|
|
barIndex,
|
|
loopback //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean(visionPoiEvents);
|
|
Clean(triggerPoiEvents);
|
|
Clean(analysePoiEvents);
|
|
Clean(visionCycleEvents);
|
|
visionConditions.Clean();
|
|
Clean(decisionPoiEvents);
|
|
Clean(triggerCycleEvents);
|
|
Clean(analyseCycleEvents);
|
|
triggerConditions.Clean();
|
|
analyseConditions.Clean();
|
|
Clean(decisionCycleEvents);
|
|
decisionConditions.Clean();
|
|
Clean(verificationPoiEvents);
|
|
Clean(consolidationPoiEvents);
|
|
Clean(verificationCycleEvents);
|
|
verificationConditions.Clean();
|
|
Clean(consolidationCycleEvents);
|
|
consolidationConditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cycles POI States ...
|
|
visionState = visionConditions.state;
|
|
triggerState = triggerConditions.state;
|
|
analyseState = analyseConditions.state;
|
|
decisionState = decisionConditions.state;
|
|
verificationState = verificationConditions.state;
|
|
consolidationState = consolidationConditions.state;
|
|
|
|
//
|
|
// Cycle X121Conditions ...
|
|
visionXConditions = visionConditions.x121Conditions;
|
|
triggerXConditions = triggerConditions.x121Conditions;
|
|
analyseXConditions = analyseConditions.x121Conditions;
|
|
decisionXConditions = decisionConditions.x121Conditions;
|
|
verificationXConditions = verificationConditions.x121Conditions;
|
|
consolidationXConditions = consolidationConditions.x121Conditions;
|
|
|
|
//
|
|
// Trigger ...
|
|
triggerXConditions.GenerateScore(
|
|
triggerBullishScore,
|
|
triggerBearishScore //
|
|
);
|
|
|
|
//
|
|
// Decision ...
|
|
decisionXConditions.GenerateScore(
|
|
decisionBullishScore,
|
|
decisionBearishScore //
|
|
);
|
|
|
|
//
|
|
// Analyse ...
|
|
analyseXConditions.GenerateScore(
|
|
analyseBullishScore,
|
|
analyseBearishScore //
|
|
);
|
|
|
|
//
|
|
// Verification ...
|
|
verificationXConditions.GenerateScore(
|
|
verificationBullishScore,
|
|
verificationBearishScore //
|
|
);
|
|
|
|
//
|
|
// Consolidation ...
|
|
consolidationXConditions.GenerateScore(
|
|
consolidationBullishScore,
|
|
consolidationBearishScore //
|
|
);
|
|
|
|
//
|
|
// Vision ...
|
|
visionXConditions.GenerateScore(
|
|
visionBullishScore,
|
|
visionBearishScore //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool SelectCycle(
|
|
ENUM_X_CYCLES cycle,
|
|
XPOIState &cState,
|
|
XPOIStateEvents &cStateEvents,
|
|
X121Conditions &cXConditions,
|
|
XC121SMCCycleHelper *&cHelper,
|
|
X121SMCCycleConditions &cConditions //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
cState.Clean();
|
|
ZeroMemory(cHelper);
|
|
cConditions.Clean();
|
|
cStateEvents.Clean();
|
|
cXConditions.Clean();
|
|
|
|
//
|
|
result = cycle != X_CYCLE_NONE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (cycle == X_CYCLE_TRIGGER)
|
|
{
|
|
//
|
|
cState = triggerState;
|
|
cHelper = triggerCycleHelper;
|
|
cConditions = triggerConditions;
|
|
cXConditions = triggerXConditions;
|
|
cStateEvents.Init(triggerPoiEvents);
|
|
}
|
|
else if (cycle == X_CYCLE_DECISION)
|
|
{
|
|
//
|
|
cState = decisionState;
|
|
cHelper = decisionCycleHelper;
|
|
cConditions = decisionConditions;
|
|
cXConditions = decisionXConditions;
|
|
cStateEvents.Init(decisionPoiEvents);
|
|
}
|
|
else if (cycle == X_CYCLE_ANALYSE)
|
|
{
|
|
//
|
|
cState = analyseState;
|
|
cHelper = analyseCycleHelper;
|
|
cConditions = analyseConditions;
|
|
cXConditions = analyseXConditions;
|
|
cStateEvents.Init(analysePoiEvents);
|
|
}
|
|
else if (cycle == X_CYCLE_VERIFICATION)
|
|
{
|
|
//
|
|
cState = verificationState;
|
|
cHelper = verificationCycleHelper;
|
|
cConditions = verificationConditions;
|
|
cXConditions = verificationXConditions;
|
|
cStateEvents.Init(verificationPoiEvents);
|
|
}
|
|
else if (cycle == X_CYCLE_CONSOLIDATION)
|
|
{
|
|
//
|
|
cState = consolidationState;
|
|
cHelper = consolidationCycleHelper;
|
|
cConditions = consolidationConditions;
|
|
cXConditions = consolidationXConditions;
|
|
cStateEvents.Init(consolidationPoiEvents);
|
|
}
|
|
else if (cycle == X_CYCLE_VISION)
|
|
{
|
|
//
|
|
cState = visionState;
|
|
cHelper = visionCycleHelper;
|
|
cConditions = visionConditions;
|
|
cXConditions = visionXConditions;
|
|
cStateEvents.Init(visionPoiEvents);
|
|
}
|
|
|
|
//
|
|
result = cState.IsValid() &&
|
|
cHelper != NULL;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void MaxRequiredPOIs(int value)
|
|
{
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
visionCycleHelper.mPOIDetector.MaxRequiredPOIs(value);
|
|
analyseCycleHelper.mPOIDetector.MaxRequiredPOIs(value);
|
|
decisionCycleHelper.mPOIDetector.MaxRequiredPOIs(value);
|
|
consolidationCycleHelper.mPOIDetector.MaxRequiredPOIs(value);
|
|
}
|
|
|
|
//
|
|
void MaxAllowedLoopbackForInit(int value)
|
|
{
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
visionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value);
|
|
analyseCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value);
|
|
decisionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value);
|
|
consolidationCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value);
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|