Backup ...
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,650 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XSCX121SMCBaseStrategy
|
||||
// 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-alert.class.mq5"
|
||||
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||
#include "../../Classes/x-saherelm.x-poi.class.mq5"
|
||||
#include "../../Classes/x-saherelm.x-trade.class.mq5"
|
||||
#include "../Classes/x-121.smc.cobjects.class.mq5"
|
||||
#include "../Libraries/x-121.smc.lib.mq5"
|
||||
|
||||
//
|
||||
// Helper(s) ...
|
||||
|
||||
//
|
||||
// XStrategy Class Implementation(s) ...
|
||||
class XCX121SMCBaseStrategy : public XCBaseAlert
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
XCAccount mAccount;
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XCX121SMCBaseStrategy(
|
||||
//
|
||||
// Base ...
|
||||
string _symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES _period // Trading TimeFrame
|
||||
)
|
||||
{
|
||||
//
|
||||
mSymbol = _symbol;
|
||||
mPeriod = _period;
|
||||
|
||||
//
|
||||
Init();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCX121SMCBaseStrategy()
|
||||
{
|
||||
DeInit();
|
||||
}
|
||||
|
||||
//
|
||||
// Getter / Setter (s) ...
|
||||
|
||||
/**
|
||||
* Retrieve Symbol ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetSymbol()
|
||||
{
|
||||
return mSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve TimeFrame ...
|
||||
*
|
||||
* @return ( ENUM_TIMEFRAMES )
|
||||
*/
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Strategy is Disabled or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsDisabled()
|
||||
{
|
||||
return mForceDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Signal Volume ...
|
||||
*
|
||||
* @return ( double )
|
||||
*/
|
||||
double Volume()
|
||||
{
|
||||
return mVolume;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Signal Volume ...
|
||||
*
|
||||
* @param value: Double ...
|
||||
*/
|
||||
void Volume(double value)
|
||||
{
|
||||
//
|
||||
if (value < 0.01)
|
||||
{
|
||||
value = 0.01;
|
||||
}
|
||||
|
||||
//
|
||||
mVolume = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Risk/Reward Ratio ...
|
||||
*
|
||||
* @return ( double )
|
||||
*/
|
||||
double R2R()
|
||||
{
|
||||
return mR2R;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Risk/Reward Ratio ...
|
||||
*
|
||||
* @param value: Double ...
|
||||
*/
|
||||
void R2R(double value)
|
||||
{
|
||||
//
|
||||
if (value < 0)
|
||||
{
|
||||
value = 1.5;
|
||||
}
|
||||
|
||||
//
|
||||
mR2R = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Max Allowed Spread ...
|
||||
*
|
||||
* @return ( double )
|
||||
*/
|
||||
double MaxAllowedSpread()
|
||||
{
|
||||
return mMaxAllowedSpread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Max Allowed Spread ...
|
||||
*
|
||||
* @param value: Double ...
|
||||
*/
|
||||
void MaxAllowedSpread(double value)
|
||||
{
|
||||
mMaxAllowedSpread = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Long Signalling State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AllowLong()
|
||||
{
|
||||
return mAllowLong;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Long Signalling State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void AllowLong(bool value)
|
||||
{
|
||||
mAllowLong = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Short Signalling State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AllowShort()
|
||||
{
|
||||
return mAllowShort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Short Signalling State ...
|
||||
*
|
||||
* @param value: Argument 1
|
||||
*/
|
||||
void AllowShort(bool value)
|
||||
{
|
||||
mAllowShort = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Disable Strategy ...
|
||||
*/
|
||||
void Disable()
|
||||
{
|
||||
mForceDisabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Strategy ...
|
||||
*/
|
||||
void Enable()
|
||||
{
|
||||
mForceDisabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Signal Event Handler ...
|
||||
*
|
||||
* @param handler: an Instance of TOnXSignal ...
|
||||
*/
|
||||
void AddXSignalEventHandler(TOnX121SMCSignal handler)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
handler,
|
||||
mSignalEventHandlers //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Virtual Actions ...
|
||||
|
||||
/**
|
||||
* Destroy All Class Implementations ...
|
||||
*/
|
||||
virtual void Destroy()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Tick Processing ...
|
||||
*
|
||||
* @param positions: XPosition instance Collection ...
|
||||
*/
|
||||
virtual void HandleTick()
|
||||
{
|
||||
//
|
||||
DoUnwaitedTicksWork();
|
||||
|
||||
//
|
||||
// Check State ...
|
||||
if (IsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Signalling State ...
|
||||
if (!AllowLong() && !AllowShort())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar Tracker State ...
|
||||
if (!mBarTracker.CanProcessBar())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Current Tick and Check it's Time
|
||||
// by Last Issued Tick ...
|
||||
MqlTick cTick;
|
||||
bool hasTick = GetTick(
|
||||
mSymbol,
|
||||
cTick //
|
||||
);
|
||||
bool isSameAsLast = cTick.time == mLastTick.time;
|
||||
if (isSameAsLast)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Update Last Issued Tick ...
|
||||
mLastTick = cTick;
|
||||
|
||||
//
|
||||
// Check Current Processing Tick has Signal or not ...
|
||||
XSignal signal;
|
||||
X121SMCStrategyConditions conditions;
|
||||
bool hasSignal = HasSignal(
|
||||
signal,
|
||||
conditions //
|
||||
);
|
||||
if (!hasSignal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Waits Until Next Candle if Current Tick has Signal ...
|
||||
mBarTracker.Waits();
|
||||
|
||||
//
|
||||
// Notify Signal Event Handlers ...
|
||||
NotifyOnSignalEventHandlers(
|
||||
signal,
|
||||
conditions //
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for any Guards ...
|
||||
*
|
||||
* @param guards: X121SMCGuard instance Collection ...
|
||||
* @param positions: XPosition instance Collection ...
|
||||
*
|
||||
* @return ( virtual bool )
|
||||
*/
|
||||
virtual bool HandleGuard(
|
||||
X121SMCGuard &guards[],
|
||||
XPosition &positions[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Check State ...
|
||||
if (IsDisabled())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Signalling State ...
|
||||
if (!AllowLong() && !AllowShort())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar Tracker State ...
|
||||
if (!mGuardBarTracker.CanProcessBar())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check For Guards ...
|
||||
result = CheckGuard(
|
||||
guards,
|
||||
positions //
|
||||
);
|
||||
|
||||
//
|
||||
// Waits Until Next Candle if Current Tick has Guard ...
|
||||
mGuardBarTracker.Waits();
|
||||
|
||||
//
|
||||
Clean(positions);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check For Signal ...
|
||||
*
|
||||
* @param signal: XSignal instance ...
|
||||
* @param conditions: X121SMCStrategyConditions instance ...
|
||||
*
|
||||
* @return ( virtual bool )
|
||||
*/
|
||||
virtual bool HasSignal(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
signal.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for any Guard Actions ...
|
||||
*
|
||||
* @param guards: X121SMCGuard instance Collection ...
|
||||
*
|
||||
* @return ( virtual bool )
|
||||
*/
|
||||
virtual bool CheckGuard(
|
||||
X121SMCGuard &guards[],
|
||||
const XPosition &positions[] // Positions ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all Requirements without waiting ...
|
||||
*/
|
||||
virtual void DoUnwaitedTicksWork()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect SL Candidates based on Strategy and Conditions ...
|
||||
*
|
||||
* @param result: Double array reference ...
|
||||
* @param entry: Double, Position Entry Price ...
|
||||
* @param conditions: X121SMCStrategyConditions instance, Provides Configurations ...
|
||||
* @param type: ENUM_X_POSITION_TYPES member, Specified Position Type ...
|
||||
*/
|
||||
virtual void DetectSLCandidates(
|
||||
double &result[],
|
||||
double entry,
|
||||
X121SMCStrategyConditions &conditions,
|
||||
ENUM_X_POSITION_TYPES type //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Customize Strategy Identifier ...
|
||||
*
|
||||
* @return ( virtual string )
|
||||
*/
|
||||
virtual string GetTag()
|
||||
{
|
||||
return X121SMCStrategyToken;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
MqlTick mLastTick; // Last Issued Tick ...
|
||||
|
||||
//
|
||||
XBarTracker mBarTracker; // Strategy Bar Tracker ...
|
||||
XBarTracker mGuardBarTracker; // Strategy Guard Bar Tracker ...
|
||||
XCBarAnalyser *mBarAnalyser; // Bar Analyser Instance
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Prepare and Normalize Signal for Execution in Strategy ...
|
||||
*
|
||||
* @param signal: XSignal instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool PrepareSignal(XSignal &signal)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Check Strategy Is Enables ...
|
||||
result = !IsDisabled();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Signal ...
|
||||
result = signal.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isLong = IsLong(signal.type);
|
||||
|
||||
//
|
||||
// TODO: Implement Signal Preparation Mechanism here ...
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
* Notified Signal Event Handler(s) ...
|
||||
*
|
||||
* @param signal: XSignal instance ...
|
||||
* @param conditions: XStrategyConditions instance ...
|
||||
*/
|
||||
void NotifyOnSignalEventHandlers(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!signal.IsValid() || !conditions.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(mSignalEventHandlers);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
mSignalEventHandlers[i](
|
||||
signal,
|
||||
conditions //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mSymbol; // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod; // Trading TimeFrame ...
|
||||
bool mForceDisabled; // Force Disabled ...
|
||||
bool mAllowLong; // Allow Long Signals
|
||||
bool mAllowShort; // Allow Short Signals
|
||||
double mR2R; // Risk/Rewar Ratio ...
|
||||
double mVolume; // Static Volume Per Trades ...
|
||||
|
||||
//
|
||||
double mMaxAllowedSpread; // Max Allowed Spread ...
|
||||
|
||||
//
|
||||
// On X121 Signal Recieved Event Handler(s) ...
|
||||
TOnX121SMCSignal mSignalEventHandlers[];
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Install all Helpers and Prepare all Configurations for required Indicators ...
|
||||
*/
|
||||
void Init()
|
||||
{
|
||||
//
|
||||
mForceDisabled = false;
|
||||
|
||||
//
|
||||
R2R(1);
|
||||
Volume(0.01);
|
||||
|
||||
//
|
||||
string symbol = Symbol();
|
||||
ENUM_TIMEFRAMES period = Period();
|
||||
|
||||
//
|
||||
// Initialize Bar Tracker ...
|
||||
mBarTracker.Init(
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
|
||||
//
|
||||
// Initialize Guard Bar Tracker ...
|
||||
mGuardBarTracker.Init(
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
|
||||
//
|
||||
mBarAnalyser = new XCBarAnalyser();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* De Initialize all Tools ...
|
||||
*/
|
||||
void DeInit()
|
||||
{
|
||||
//
|
||||
ZeroMemory(mBarAnalyser);
|
||||
|
||||
//
|
||||
delete mBarAnalyser;
|
||||
|
||||
//
|
||||
Clean(mSignalEventHandlers);
|
||||
|
||||
//
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reste Bar Tracker ...
|
||||
*/
|
||||
void ResetBarTracker()
|
||||
{
|
||||
mBarTracker.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XChartObjects
|
||||
// Description: provides all require Chart Objects ...
|
||||
//
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../../Classes/x-saherelm.x-cobject.class.mq5"
|
||||
#include "../Libraries/x-121.smc.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
enum ENUM_X121SMC_CHARTOBJECTS
|
||||
{
|
||||
X_121_NONE_OBJ
|
||||
};
|
||||
|
||||
//
|
||||
// Implementations ...
|
||||
Binary file not shown.
@@ -0,0 +1,63 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XC121Panel
|
||||
// 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-app-dialog.class.mq5"
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
class X121CAppDialog : public XCAppDialog
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void X121CAppDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~X121CAppDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
void Configure()
|
||||
{
|
||||
//
|
||||
// Configure Dialog ...
|
||||
BackgroundColor(clrBlack);
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,802 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ...
|
||||
|
||||
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 ToString(ENUM_X_CYCLES value)
|
||||
{
|
||||
//
|
||||
string result = EnumToString(value);
|
||||
|
||||
//
|
||||
StringReplace(result, "X_CYCLE_", "");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
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) ...
|
||||
|
||||
//
|
||||
int CountConsolidationZones()
|
||||
{
|
||||
return ArraySize(mConsolidationZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasConsolidationZones()
|
||||
{
|
||||
return HasChild(mConsolidationZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetConsolidationZone(
|
||||
int idx,
|
||||
XConsolidationZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
zone.Clean();
|
||||
|
||||
//
|
||||
result = HasConsolidationZones();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = CountConsolidationZones();
|
||||
result = idx >= 0 &&
|
||||
idx < count;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
zone = mConsolidationZones[idx];
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool GetLastDirectionalConsolidationZone(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XConsolidationZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
zone.Clean();
|
||||
|
||||
//
|
||||
result = HasDirection(forDir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasZones = HasConsolidationZones();
|
||||
int zonesCount = CountConsolidationZones();
|
||||
result = hasZones;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = zonesCount - 1; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
XConsolidationZone iZone = mConsolidationZones[i];
|
||||
|
||||
//
|
||||
if (!iZone.IsBreaked())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (!HasDirection(iZone.breakDir))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (iZone.breakDir != forDir)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
zone = iZone;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool GetActiveConsolidationZone(
|
||||
XConsolidationZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
zone = mActiveConsolidationZone;
|
||||
result = zone.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int FillConsolidationZones(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XConsolidationZone &zones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(zones);
|
||||
|
||||
//
|
||||
bool hasZones = HasConsolidationZones();
|
||||
if (!hasZones)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = CountConsolidationZones();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XConsolidationZone iZone = mConsolidationZones[i];
|
||||
|
||||
//
|
||||
bool isDirPassed =
|
||||
(forDir == X_DIRECTION_ALL ||
|
||||
forDir == X_DIRECTION_NONE)
|
||||
? true
|
||||
: forDir == iZone.breakDir;
|
||||
if (isDirPassed)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iZone,
|
||||
zones //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(zones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 < 10)
|
||||
{
|
||||
requiredPOIS = 10;
|
||||
}
|
||||
|
||||
//
|
||||
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.MaxNumberOfPOIs(requiredPOIS);
|
||||
mPOIDetector.MaxNumberOfRequiredPOIs(requiredPOIS);
|
||||
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 ...
|
||||
void Update()
|
||||
{
|
||||
//
|
||||
int czRange = 50; // Consolidation min Range Points ...
|
||||
int czLoopback = 5;
|
||||
int maxAllowed = 20;
|
||||
bool isActiveConsolidationZoneBreaked = false;
|
||||
bool hasActiveConsolidationZone = mActiveConsolidationZone.IsValid();
|
||||
|
||||
//
|
||||
if (hasActiveConsolidationZone)
|
||||
{
|
||||
//
|
||||
isActiveConsolidationZoneBreaked = mActiveConsolidationZone.IsBreaked();
|
||||
|
||||
//
|
||||
if (isActiveConsolidationZoneBreaked)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
mActiveConsolidationZone,
|
||||
mConsolidationZones //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
mConsolidationZones,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
mActiveConsolidationZone.Clean();
|
||||
}
|
||||
else
|
||||
{
|
||||
mActiveConsolidationZone.Update();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
XOHCL mBar;
|
||||
bool hasBar = GetBar(
|
||||
mBar,
|
||||
0 //
|
||||
);
|
||||
if (hasBar)
|
||||
{
|
||||
//
|
||||
double upper = 0;
|
||||
double lower = 0;
|
||||
bool hasConsolidationZone =
|
||||
mBarAnalyser.IsConsolidate(
|
||||
mBar,
|
||||
upper,
|
||||
lower,
|
||||
czLoopback,
|
||||
czRange //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasConsolidationZone)
|
||||
{
|
||||
//
|
||||
mActiveConsolidationZone.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
upper,
|
||||
lower,
|
||||
czLoopback //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
mBar.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
/**
|
||||
* Set Default Properties Values ...
|
||||
*/
|
||||
virtual void Default()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
string mSymbol;
|
||||
ENUM_TIMEFRAMES mPeriod;
|
||||
|
||||
//
|
||||
// CArrayObj mConsolidationObjects;
|
||||
XConsolidationZone mActiveConsolidationZone;
|
||||
XConsolidationZone mConsolidationZones[];
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Release All Resources ...
|
||||
*/
|
||||
void DeInit()
|
||||
{
|
||||
//
|
||||
ZeroMemory(mX121Helper);
|
||||
ZeroMemory(mPOIDetector);
|
||||
ZeroMemory(mBarAnalyser);
|
||||
|
||||
//
|
||||
delete mX121Helper;
|
||||
delete mPOIDetector;
|
||||
delete mBarAnalyser;
|
||||
|
||||
//
|
||||
Clean(mConsolidationZones);
|
||||
mActiveConsolidationZone.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_MODE, mMode);
|
||||
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_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_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_CHART_LINE, mLineColor);
|
||||
ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,974 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 X121 SMC Signal Class
|
||||
// -------------------------------------------------
|
||||
// Name:
|
||||
// Description: provide all Global Guarding 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"
|
||||
|
||||
//
|
||||
XConsolidationZone x121SMCConsolidationZone;
|
||||
bool DetectX121SMCGuards(
|
||||
//
|
||||
string provider, // Provider ...
|
||||
X121SMCGuard &guards[],
|
||||
const XPosition &positions[],
|
||||
XC121SMCCycleHelper *decisionCycleHelper,
|
||||
XC121SMCCycleHelper *analyseCycleHelper,
|
||||
XC121SMCCycleHelper *consolidationCycleHelper,
|
||||
XC121SMCCycleHelper *visionCycleHelper,
|
||||
//
|
||||
// Guard Types ...
|
||||
ENUM_X_121_SMC_GUARD_ACTIONS &ignoreGuards[],
|
||||
//
|
||||
// Required Configurations ...
|
||||
double breakEvenTPLevel = 2.0
|
||||
//
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bool isCycleHelpersValid =
|
||||
//
|
||||
visionCycleHelper != NULL &&
|
||||
analyseCycleHelper != NULL &&
|
||||
decisionCycleHelper != NULL &&
|
||||
consolidationCycleHelper != NULL
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Ignore Guards ...
|
||||
bool hasIgnoreGuards = HasChild(ignoreGuards);
|
||||
bool isColseIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_CLOSE,
|
||||
ignoreGuards //
|
||||
);
|
||||
bool isColseAllIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_CLOSE_ALL,
|
||||
ignoreGuards //
|
||||
);
|
||||
bool isColseLongsIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_CLOSE_LONGS,
|
||||
ignoreGuards //
|
||||
);
|
||||
bool isColseShortsIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_CLOSE_SHORTS,
|
||||
ignoreGuards //
|
||||
);
|
||||
bool isPartialColseIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE,
|
||||
ignoreGuards //
|
||||
);
|
||||
bool isTrailStopIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_TRAIL_STOP,
|
||||
ignoreGuards //
|
||||
);
|
||||
bool isTrailTargetIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_TRAIL_TARGET,
|
||||
ignoreGuards //
|
||||
);
|
||||
bool isHedgeIgnored =
|
||||
hasIgnoreGuards &&
|
||||
Contains(
|
||||
X_121_SMC_GUARD_ACTION_HEDGE,
|
||||
ignoreGuards //
|
||||
);
|
||||
|
||||
//
|
||||
bool isAllIgnores =
|
||||
//
|
||||
isColseIgnored &&
|
||||
isHedgeIgnored &&
|
||||
isColseAllIgnored &&
|
||||
isTrailStopIgnored &&
|
||||
isColseLongsIgnored &&
|
||||
isColseShortsIgnored &&
|
||||
isTrailTargetIgnored &&
|
||||
isPartialColseIgnored
|
||||
//
|
||||
;
|
||||
result = !isAllIgnores &&
|
||||
isCycleHelpersValid;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(positions);
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbol = decisionCycleHelper.GetSymbol();
|
||||
ENUM_TIMEFRAMES period = decisionCycleHelper.GetPeriod();
|
||||
|
||||
//
|
||||
XPosition ownPositions[];
|
||||
XPosition ownLongPositions[];
|
||||
XPosition ownShortPositions[];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = positions[i];
|
||||
bool isOwn = iPosition
|
||||
.IsFiltersPassed(
|
||||
symbol,
|
||||
provider,
|
||||
NULL,
|
||||
X_POSITION_TYPE_ALL,
|
||||
iPosition.magic //
|
||||
);
|
||||
if (isOwn)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPosition,
|
||||
ownPositions //
|
||||
);
|
||||
|
||||
//
|
||||
bool isLong = IsLong(positions[i].type);
|
||||
if (isLong)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPosition,
|
||||
ownLongPositions //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPosition,
|
||||
ownShortPositions //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
count = ArraySize(ownPositions);
|
||||
|
||||
//
|
||||
int longsCount = ArraySize(ownLongPositions);
|
||||
bool hasLongs = IsValidSize(longsCount);
|
||||
|
||||
//
|
||||
int shortsCount = ArraySize(ownShortPositions);
|
||||
bool hasShorts = IsValidSize(shortsCount);
|
||||
|
||||
//
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(ownPositions);
|
||||
Clean(ownLongPositions);
|
||||
Clean(ownShortPositions);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Here we Are Sure there is Positions to Guard ...
|
||||
// based on Current Provider ...
|
||||
|
||||
//
|
||||
// Detect Required Data for Analyse Market to Guard Positions ...
|
||||
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
int loopback = 10;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
result = zBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
zIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
result = HasChild(guards);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
result = HasChild(guards);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
result = pBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
pIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
result = HasChild(guards);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL ppBar;
|
||||
result = ppBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
ppIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
ppBar.Clean();
|
||||
result = HasChild(guards);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double ask = GetAsk(symbol);
|
||||
double bid = GetBid(symbol);
|
||||
datetime cTime = TimeCurrent();
|
||||
double points = GetPoints(symbol);
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Cycles Conditions ...
|
||||
|
||||
//
|
||||
// Decision ...
|
||||
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
||||
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
||||
X121SMCCycleConditions decisionConditions;
|
||||
result = decisionCycleHelper.GetConditions(
|
||||
decisionCycleEvents,
|
||||
decisionPoiEvents,
|
||||
decisionConditions,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
ppBar.Clean();
|
||||
result = HasChild(guards);
|
||||
|
||||
//
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(decisionCycleEvents);
|
||||
|
||||
//
|
||||
decisionConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Analyse ...
|
||||
ENUM_XPOI_EVENTS analysePoiEvents[];
|
||||
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
||||
X121SMCCycleConditions analyseConditions;
|
||||
result = analyseCycleHelper.GetConditions(
|
||||
analyseCycleEvents,
|
||||
analysePoiEvents,
|
||||
analyseConditions,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
ppBar.Clean();
|
||||
|
||||
//
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(decisionCycleEvents);
|
||||
|
||||
//
|
||||
decisionConditions.Clean();
|
||||
|
||||
//
|
||||
Clean(analysePoiEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
|
||||
//
|
||||
analyseConditions.Clean();
|
||||
|
||||
//
|
||||
result = HasChild(guards);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Consolidation ...
|
||||
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
||||
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
||||
X121SMCCycleConditions consolidationConditions;
|
||||
result = consolidationCycleHelper.GetConditions(
|
||||
consolidationCycleEvents,
|
||||
consolidationPoiEvents,
|
||||
consolidationConditions,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
ppBar.Clean();
|
||||
|
||||
//
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(decisionCycleEvents);
|
||||
|
||||
//
|
||||
decisionConditions.Clean();
|
||||
|
||||
//
|
||||
Clean(analysePoiEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
|
||||
//
|
||||
analyseConditions.Clean();
|
||||
|
||||
//
|
||||
Clean(consolidationPoiEvents);
|
||||
Clean(consolidationCycleEvents);
|
||||
|
||||
//
|
||||
consolidationConditions.Clean();
|
||||
|
||||
//
|
||||
result = HasChild(guards);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Vision ...
|
||||
ENUM_XPOI_EVENTS visionPoiEvents[];
|
||||
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
||||
X121SMCCycleConditions visionConditions;
|
||||
result = visionCycleHelper.GetConditions(
|
||||
visionCycleEvents,
|
||||
visionPoiEvents,
|
||||
visionConditions,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
ppBar.Clean();
|
||||
|
||||
//
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(decisionCycleEvents);
|
||||
|
||||
//
|
||||
decisionConditions.Clean();
|
||||
|
||||
//
|
||||
Clean(analysePoiEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
|
||||
//
|
||||
analyseConditions.Clean();
|
||||
|
||||
//
|
||||
Clean(consolidationPoiEvents);
|
||||
Clean(consolidationCycleEvents);
|
||||
|
||||
//
|
||||
consolidationConditions.Clean();
|
||||
|
||||
//
|
||||
Clean(visionPoiEvents);
|
||||
Clean(visionCycleEvents);
|
||||
|
||||
//
|
||||
visionConditions.Clean();
|
||||
|
||||
//
|
||||
result = HasChild(guards);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Cycles POI States ...
|
||||
XPOIState decisionState = decisionConditions.state;
|
||||
XPOIState analyseState = analyseConditions.state;
|
||||
XPOIState consolidationState = consolidationConditions.state;
|
||||
XPOIState visionState = visionConditions.state;
|
||||
|
||||
//
|
||||
// Cycle X121Conditions ...
|
||||
X121Conditions decisionXConditions = decisionConditions.x121Conditions;
|
||||
X121Conditions analyseXConditions = analyseConditions.x121Conditions;
|
||||
X121Conditions consolidationXConditions = consolidationConditions.x121Conditions;
|
||||
X121Conditions visionXConditions = visionConditions.x121Conditions;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// Detect Consolidation Zone ...
|
||||
|
||||
//
|
||||
// Detect Consolidation Zones ...
|
||||
|
||||
//
|
||||
XBoxZone lastBullishBox;
|
||||
XBoxZone prevLastBullishBox;
|
||||
bool hasLastBullishBox = false;
|
||||
bool hasPrevLastBullishBox = false;
|
||||
XConsolidationZone lastBullishZone;
|
||||
bool isLastBullishAbovePrev = false;
|
||||
bool isLastBullishBelowPrev = false;
|
||||
XConsolidationZone prevLastBullishZone;
|
||||
|
||||
//
|
||||
XBoxZone lastBearishBox;
|
||||
XBoxZone prevLastBearishBox;
|
||||
bool hasLastBearishBox = false;
|
||||
bool hasPrevLastBearishBox = false;
|
||||
XConsolidationZone lastBearishZone;
|
||||
bool isLastBearishAbovePrev = false;
|
||||
bool isLastBearishBelowPrev = false;
|
||||
XConsolidationZone prevLastBearishZone;
|
||||
|
||||
//
|
||||
int bullishConsolidationZonesCount = 0;
|
||||
int bearishConsolidationZonesCount = 0;
|
||||
bool hasBullishConsolidationZones = false;
|
||||
bool hasBearishConsolidationZones = false;
|
||||
XConsolidationZone bullishConsolidationZones[];
|
||||
XConsolidationZone bearishConsolidationZones[];
|
||||
bool hasConsolidationZones = decisionCycleHelper.HasConsolidationZones();
|
||||
int consolidationZonesCount = decisionCycleHelper.CountConsolidationZones();
|
||||
if (hasConsolidationZones)
|
||||
{
|
||||
//
|
||||
bullishConsolidationZonesCount = decisionCycleHelper
|
||||
.FillConsolidationZones(
|
||||
X_DIRECTION_BULLISH,
|
||||
bullishConsolidationZones //
|
||||
);
|
||||
hasBullishConsolidationZones = IsValidSize(bullishConsolidationZonesCount);
|
||||
|
||||
//
|
||||
bearishConsolidationZonesCount = decisionCycleHelper
|
||||
.FillConsolidationZones(
|
||||
X_DIRECTION_BEARISH,
|
||||
bearishConsolidationZones //
|
||||
);
|
||||
hasBearishConsolidationZones = IsValidSize(bearishConsolidationZonesCount);
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
if (hasBullishConsolidationZones &&
|
||||
bullishConsolidationZonesCount >= 2)
|
||||
{
|
||||
//
|
||||
lastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 1];
|
||||
prevLastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 2];
|
||||
|
||||
//
|
||||
hasLastBullishBox = ToBox(
|
||||
lastBullishBox,
|
||||
lastBullishZone //
|
||||
);
|
||||
hasPrevLastBullishBox = ToBox(
|
||||
prevLastBullishBox,
|
||||
prevLastBullishZone //
|
||||
);
|
||||
|
||||
//
|
||||
isLastBullishAbovePrev = hasLastBullishBox &&
|
||||
hasPrevLastBullishBox &&
|
||||
IsBoxAbove(
|
||||
lastBullishBox,
|
||||
prevLastBullishBox //
|
||||
);
|
||||
|
||||
//
|
||||
isLastBullishBelowPrev = hasLastBullishBox &&
|
||||
hasPrevLastBullishBox &&
|
||||
IsBoxBelow(
|
||||
lastBullishBox,
|
||||
prevLastBullishBox //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (hasBearishConsolidationZones &&
|
||||
bearishConsolidationZonesCount >= 2)
|
||||
{
|
||||
//
|
||||
lastBearishZone = bearishConsolidationZones[bearishConsolidationZonesCount - 1];
|
||||
prevLastBearishZone = bearishConsolidationZones[bearishConsolidationZonesCount - 2];
|
||||
|
||||
//
|
||||
hasLastBearishBox = ToBox(
|
||||
lastBearishBox,
|
||||
lastBearishZone //
|
||||
);
|
||||
hasPrevLastBearishBox = ToBox(
|
||||
prevLastBearishBox,
|
||||
prevLastBearishZone //
|
||||
);
|
||||
|
||||
//
|
||||
isLastBearishAbovePrev = hasLastBearishBox &&
|
||||
hasPrevLastBearishBox &&
|
||||
IsBoxAbove(
|
||||
lastBearishBox,
|
||||
prevLastBearishBox //
|
||||
);
|
||||
|
||||
//
|
||||
isLastBearishBelowPrev = hasLastBearishBox &&
|
||||
hasPrevLastBearishBox &&
|
||||
IsBoxBelow(
|
||||
lastBearishBox,
|
||||
prevLastBearishBox //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Detect High Probability Swings ...
|
||||
bool isSwingLow =
|
||||
//
|
||||
cBar.low > pBar.low &&
|
||||
ppBar.low > pBar.low &&
|
||||
//
|
||||
zBar.low > pBar.low
|
||||
//
|
||||
;
|
||||
bool isSwingHigh =
|
||||
//
|
||||
cBar.high < pBar.high &&
|
||||
ppBar.high < pBar.high &&
|
||||
//
|
||||
zBar.high < pBar.high
|
||||
//
|
||||
;
|
||||
bool isStrongSwingLow =
|
||||
pBar.IsBullish() &&
|
||||
pBar.GetLowShadow() >= pBar.GetBody() * 2;
|
||||
bool isStrongSwingHigh =
|
||||
pBar.IsBearish() &&
|
||||
pBar.GetHighShadow() >= pBar.GetBody() * 2;
|
||||
|
||||
//
|
||||
bool isStrongSwingLowAboveLastBullishBox =
|
||||
isStrongSwingLow &&
|
||||
hasLastBullishBox &&
|
||||
pBar.low > lastBullishBox.upper;
|
||||
|
||||
//
|
||||
bool isStrongSwingHighBelowLastBearishBox =
|
||||
isStrongSwingHigh &&
|
||||
hasLastBearishBox &&
|
||||
pBar.high < lastBearishBox.lower;
|
||||
|
||||
//
|
||||
// Here We Have all Requirements for Guarding Positions ...
|
||||
|
||||
//
|
||||
// Available Guards:
|
||||
// X_121_SMC_GUARD_ACTION_NONE
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE_ALL
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE_LONGS
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE_SHORTS
|
||||
// X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE
|
||||
// X_121_SMC_GUARD_ACTION_TRAIL_STOP
|
||||
// X_121_SMC_GUARD_ACTION_TRAIL_TARGET
|
||||
// X_121_SMC_GUARD_ACTION_HEDGE
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE:
|
||||
// Close Specified Position on Specified Conditions ...
|
||||
if (!isColseIgnored)
|
||||
{
|
||||
//
|
||||
// TODO:
|
||||
// - [] Implement Close on Nearest on TP ...
|
||||
}
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE_ALL:
|
||||
// Close All Positions on Specified Conditions ...
|
||||
if (!isColseAllIgnored)
|
||||
{
|
||||
//
|
||||
// TODO:
|
||||
// - [] Implement Close All Positions on Weekend ...
|
||||
}
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE_LONGS:
|
||||
// Close All Long Positions on Specified Conditions ...
|
||||
if (!isColseLongsIgnored)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_CLOSE_SHORTS:
|
||||
// Close All Short Positions on Specified Conditions ...
|
||||
if (!isColseShortsIgnored)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE:
|
||||
// Partial Close Specified Position on Specified Conditions ...
|
||||
if (!isPartialColseIgnored)
|
||||
{
|
||||
//
|
||||
// Breake Even ...
|
||||
// Usually Break Even Works on TP2 Reached ...
|
||||
// when tp reached to required Level, we Close 50% of Entered Volume ...
|
||||
bool canBreakEven = breakEvenTPLevel >= 0;
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = ownPositions[i];
|
||||
|
||||
//
|
||||
bool isInProfit = iPosition.profit > 0;
|
||||
|
||||
//
|
||||
double reachedTPLevel = 0;
|
||||
double reachedTPPrice = 0;
|
||||
if (isInProfit)
|
||||
{
|
||||
//
|
||||
iPosition.CalculateReahedTP(
|
||||
reachedTPLevel,
|
||||
reachedTPPrice //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Break Event ...
|
||||
if (canBreakEven)
|
||||
{
|
||||
//
|
||||
// Position Must be In Profit ...
|
||||
if (!isInProfit)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool canDoBreakEven = reachedTPLevel == breakEvenTPLevel &&
|
||||
reachedTPPrice > 0;
|
||||
if (canDoBreakEven)
|
||||
{
|
||||
//
|
||||
X121SMCGuard iGuard;
|
||||
|
||||
//
|
||||
iGuard.time = cTime;
|
||||
iGuard.symbol = symbol;
|
||||
iGuard.provider = provider;
|
||||
iGuard.action = X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE;
|
||||
|
||||
//
|
||||
iGuard.ticket = iPosition.ticket;
|
||||
|
||||
//
|
||||
iGuard.volumeMultiplier = 0.5;
|
||||
|
||||
//
|
||||
AddGuard(
|
||||
iGuard,
|
||||
guards //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_TRAIL_STOP:
|
||||
// Trail Stop Specified Position on Specified Conditions ...
|
||||
if (!isTrailStopIgnored)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = ownPositions[i];
|
||||
|
||||
//
|
||||
bool isLong = IsLong(iPosition.type);
|
||||
bool isInProfit = iPosition.profit > 0;
|
||||
|
||||
//
|
||||
double reachedTPLevel = 0;
|
||||
double reachedTPPrice = 0;
|
||||
if (isInProfit)
|
||||
{
|
||||
//
|
||||
iPosition.CalculateReahedTP(
|
||||
reachedTPLevel,
|
||||
reachedTPPrice //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Trai Stop ...
|
||||
if (!isInProfit)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
double trailedStop = 0;
|
||||
|
||||
//
|
||||
// Trail Stop Senarios ...
|
||||
// - occures two same type consolidation zones in order of positions type;
|
||||
// - occures a swing in order of consolidation zones ...
|
||||
|
||||
//
|
||||
bool canTrailBasedOnTwoZone =
|
||||
isLong
|
||||
? isLastBullishAbovePrev
|
||||
: isLastBearishBelowPrev;
|
||||
if (canTrailBasedOnTwoZone)
|
||||
{
|
||||
//
|
||||
trailedStop =
|
||||
isLong
|
||||
? prevLastBullishBox.lower
|
||||
: prevLastBearishBox.upper;
|
||||
}
|
||||
|
||||
//
|
||||
bool canTrailBasedOnZoneSwing =
|
||||
trailedStop <= 0 &&
|
||||
(isLong
|
||||
? isStrongSwingLowAboveLastBullishBox
|
||||
: isStrongSwingHighBelowLastBearishBox);
|
||||
if (canTrailBasedOnZoneSwing)
|
||||
{
|
||||
//
|
||||
trailedStop =
|
||||
isLong
|
||||
? pBar.low
|
||||
: pBar.high;
|
||||
}
|
||||
|
||||
//
|
||||
bool canDoTrailStop =
|
||||
trailedStop > 0 &&
|
||||
(
|
||||
//
|
||||
iPosition.sl == 0
|
||||
? (isLong
|
||||
? trailedStop > iPosition.entry &&
|
||||
trailedStop < iPosition.price
|
||||
: trailedStop < iPosition.entry &&
|
||||
trailedStop > iPosition.price)
|
||||
: (isLong
|
||||
? trailedStop > iPosition.sl &&
|
||||
trailedStop > iPosition.entry &&
|
||||
trailedStop < iPosition.price
|
||||
: trailedStop < iPosition.sl &&
|
||||
trailedStop < iPosition.entry &&
|
||||
trailedStop > iPosition.price)
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (canDoTrailStop)
|
||||
{
|
||||
//
|
||||
X121SMCGuard iGuard;
|
||||
|
||||
//
|
||||
iGuard.time = cTime;
|
||||
iGuard.symbol = symbol;
|
||||
iGuard.provider = provider;
|
||||
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP;
|
||||
|
||||
//
|
||||
iGuard.ticket = iPosition.ticket;
|
||||
|
||||
//
|
||||
iGuard.sl = trailedStop;
|
||||
|
||||
//
|
||||
AddGuard(
|
||||
iGuard,
|
||||
guards //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_TRAIL_TARGET:
|
||||
// Trail Target Specified Position on Specified Conditions ...
|
||||
if (!isTrailTargetIgnored)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// X_121_SMC_GUARD_ACTION_HEDGE:
|
||||
// Hedge all Positions on Specified Conditions ...
|
||||
if (!isHedgeIgnored)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Collections ...
|
||||
|
||||
//
|
||||
Clean(ownPositions);
|
||||
Clean(ownLongPositions);
|
||||
Clean(ownShortPositions);
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
ppBar.Clean();
|
||||
|
||||
//
|
||||
Clean(visionPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(visionCycleEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
Clean(decisionCycleEvents);
|
||||
Clean(consolidationPoiEvents);
|
||||
Clean(consolidationCycleEvents);
|
||||
|
||||
//
|
||||
visionState.Clean();
|
||||
analyseState.Clean();
|
||||
decisionState.Clean();
|
||||
visionConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
visionXConditions.Clean();
|
||||
decisionConditions.Clean();
|
||||
consolidationState.Clean();
|
||||
analyseXConditions.Clean();
|
||||
decisionXConditions.Clean();
|
||||
consolidationConditions.Clean();
|
||||
consolidationXConditions.Clean();
|
||||
|
||||
//
|
||||
lastBullishBox.Clean();
|
||||
lastBearishBox.Clean();
|
||||
lastBullishZone.Clean();
|
||||
lastBearishZone.Clean();
|
||||
prevLastBullishBox.Clean();
|
||||
prevLastBearishBox.Clean();
|
||||
prevLastBullishZone.Clean();
|
||||
prevLastBearishZone.Clean();
|
||||
|
||||
//
|
||||
count = ArraySize(guards);
|
||||
result = IsValidSize(count);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,734 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Common Library
|
||||
// --------------------------------------
|
||||
// Name: X121SMCLib
|
||||
// Description: provide all commonly used 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-saherelm.base.class.mq5"
|
||||
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
||||
#include "../../Helpers/x-saherelm.x121.helper.mq5"
|
||||
#include "../../Libraries/x-saherelm.common.lib.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-poi.lib.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-trade.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
const string X121SMCStrategyToken = "X121SMC";
|
||||
|
||||
//
|
||||
const string X121SMCXWZToken = "X121XWZ";
|
||||
|
||||
//
|
||||
// X121 SMC Providers ...
|
||||
enum ENUM_X_121_SMC_PROVIDERS
|
||||
{
|
||||
//
|
||||
X_121_SMC_PROVIDER_NONE,
|
||||
X_121_SMC_PROVIDER_XWZ,
|
||||
};
|
||||
|
||||
//
|
||||
// Guard Actions ...
|
||||
enum ENUM_X_121_SMC_GUARD_ACTIONS
|
||||
{
|
||||
X_121_SMC_GUARD_ACTION_NONE, // Nothing to Do
|
||||
X_121_SMC_GUARD_ACTION_CLOSE, // Close Specified Position
|
||||
X_121_SMC_GUARD_ACTION_CLOSE_ALL, // Close All Positions
|
||||
X_121_SMC_GUARD_ACTION_CLOSE_LONGS, // Close All Long Positions
|
||||
X_121_SMC_GUARD_ACTION_CLOSE_SHORTS, // Close All Short Position
|
||||
X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE, // Partial Close Specified Position
|
||||
X_121_SMC_GUARD_ACTION_TRAIL_STOP, // Trail Stop of Specified Position
|
||||
X_121_SMC_GUARD_ACTION_TRAIL_TARGET, // Trail Target of Specified Position
|
||||
X_121_SMC_GUARD_ACTION_HEDGE, // Hedge Specified Positions
|
||||
};
|
||||
|
||||
//
|
||||
// Each Market Cycle (Time Frame) Conditions
|
||||
// Model as this Structure ...
|
||||
struct X121SMCCycleConditions
|
||||
{
|
||||
//
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
X121Conditions x121Conditions;
|
||||
|
||||
//
|
||||
void X121SMCStrategyConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
state.Clean();
|
||||
x121Conditions.Clean();
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsSpecifiedValid(symbol) &&
|
||||
IsSpecifiedValid(period) &&
|
||||
IsSpecifiedValid(time);
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reporter Functions ...
|
||||
|
||||
/**
|
||||
* Generate Provided Scores ...
|
||||
*
|
||||
* @param bullishScore: Integer, reference ...
|
||||
* @param bearishScore: Integer, referenceF ...
|
||||
*/
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double bullScore = 0;
|
||||
double bearScore = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Summary ...
|
||||
*
|
||||
* @param onlyCommons: Boolean ...
|
||||
* @param onlyConditions: Boolean ...
|
||||
* @param includeScores: Boolean ...
|
||||
* @param ignoreFalseConditions: Boolean ...
|
||||
* @param separator: String ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GenerateSummary(
|
||||
bool onlyCommons = false,
|
||||
bool onlyConditions = false,
|
||||
bool includeScores = true,
|
||||
bool ignoreFalseConditions = true,
|
||||
string separator = "\n" //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
|
||||
//
|
||||
string commonStr = GenerateSpecifiedCommonSummary(
|
||||
this,
|
||||
separator,
|
||||
includeScores,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
string conditionsStr =
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
"----------" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Unique Identifier ...
|
||||
*
|
||||
* @param forObject: Boolean ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetTag(
|
||||
bool forObject = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string typeName = GetTypeName(this);
|
||||
|
||||
//
|
||||
if (!forObject)
|
||||
{
|
||||
result = typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = typeName + "_" +
|
||||
symbol + "_" + ToString(period) + "_" +
|
||||
ToMD5(time);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Model Signalling Conditions ...
|
||||
struct X121SMCStrategyConditions
|
||||
{
|
||||
//
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
double sl;
|
||||
double tp;
|
||||
double target;
|
||||
string provider;
|
||||
ENUM_X_DIRECTION signalDir;
|
||||
|
||||
//
|
||||
void X121SMCStrategyConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
sl = 0;
|
||||
tp = 0;
|
||||
provider = NULL;
|
||||
signalDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsSpecifiedValid(symbol) &&
|
||||
IsSpecifiedValid(period) &&
|
||||
IsSpecifiedValid(time);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Conditions Has Valid Bullish Signal ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBullishSignal()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
(sl > 0 ||
|
||||
tp > 0) &&
|
||||
IsValid() &&
|
||||
HasDirection(signalDir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
IsBullish(signalDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Conditions Has Valid Bearish Signal ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBearishSignal()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
(sl > 0 ||
|
||||
tp > 0) &&
|
||||
IsValid() &&
|
||||
HasDirection(signalDir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
IsBearish(signalDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reporter Functions ...
|
||||
|
||||
/**
|
||||
* Generate Provided Scores ...
|
||||
*
|
||||
* @param bullishScore: Integer, reference ...
|
||||
* @param bearishScore: Integer, referenceF ...
|
||||
*/
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double bullScore = 0;
|
||||
double bearScore = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Summary ...
|
||||
*
|
||||
* @param onlyCommons: Boolean ...
|
||||
* @param onlyConditions: Boolean ...
|
||||
* @param includeScores: Boolean ...
|
||||
* @param ignoreFalseConditions: Boolean ...
|
||||
* @param separator: String ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GenerateSummary(
|
||||
bool onlyCommons = false,
|
||||
bool onlyConditions = false,
|
||||
bool includeScores = true,
|
||||
bool ignoreFalseConditions = true,
|
||||
string separator = "\n" //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
|
||||
//
|
||||
string commonStr = GenerateSpecifiedCommonSummary(
|
||||
this,
|
||||
separator,
|
||||
includeScores,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
string conditionsStr =
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
"----------" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Unique Identifier ...
|
||||
*
|
||||
* @param forObject: Boolean ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetTag(
|
||||
bool forObject = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string typeName = GetTypeName(this);
|
||||
|
||||
//
|
||||
if (!forObject)
|
||||
{
|
||||
result = typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = typeName + "_" +
|
||||
symbol + "_" + ToString(period) + "_" +
|
||||
ToMD5(time);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Model a Guard Action ...
|
||||
struct X121SMCGuard
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
ENUM_X_121_SMC_GUARD_ACTIONS action;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
string symbol;
|
||||
string provider;
|
||||
|
||||
//
|
||||
// Specified Position ...
|
||||
ulong ticket;
|
||||
|
||||
//
|
||||
// Partial Close ...
|
||||
double volumeMultiplier;
|
||||
|
||||
//
|
||||
// SL Trial ...
|
||||
double sl;
|
||||
|
||||
//
|
||||
// TP Trial ...
|
||||
double tp;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
X121SMCGuard()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
time = NULL;
|
||||
action = X_121_SMC_GUARD_ACTION_NONE;
|
||||
|
||||
//
|
||||
symbol = NULL;
|
||||
provider = NULL;
|
||||
|
||||
//
|
||||
ticket = 0;
|
||||
|
||||
//
|
||||
volumeMultiplier = 0;
|
||||
|
||||
//
|
||||
sl = 0;
|
||||
tp = 0;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValid(time) &&
|
||||
IsValid(symbol) &&
|
||||
IsValid(provider) &&
|
||||
action != X_121_SMC_GUARD_ACTION_NONE
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Model Based On Specified Guard Actions ...
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add Guard to Collection ...
|
||||
*
|
||||
* @param guard: X121SMCGuard instance ...
|
||||
* @param guards: X121SMCGuard instance Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int AddGuard(
|
||||
X121SMCGuard &guard,
|
||||
X121SMCGuard &guards[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!guard.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
guard,
|
||||
guards //
|
||||
);
|
||||
|
||||
//
|
||||
result = ArraySize(guards);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
typedef void (*TOnX121SMCSignal)(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
);
|
||||
|
||||
//
|
||||
// Extentions ...
|
||||
|
||||
/**
|
||||
* Validate a Signal Provider ...
|
||||
*
|
||||
* @param value: ENUM_X_121_SMC_PROVIDERS member ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid(ENUM_X_121_SMC_PROVIDERS value)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = value != X_121_SMC_PROVIDER_NONE;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Signal Provider to String ...
|
||||
*
|
||||
* @param value: ENUM_X_121_SMC_PROVIDERS member ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string ToString(ENUM_X_121_SMC_PROVIDERS value)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
if (!IsValid(value))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
switch (value)
|
||||
{
|
||||
//
|
||||
case X_121_SMC_PROVIDER_XWZ:
|
||||
result = X121SMCXWZToken;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Specified String as a Signal Provider ...
|
||||
*
|
||||
* @param value: String ...
|
||||
*
|
||||
* @return ( ENUM_X_121_SMC_PROVIDERS )
|
||||
*/
|
||||
ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
|
||||
{
|
||||
//
|
||||
ENUM_X_121_SMC_PROVIDERS result = X_121_SMC_PROVIDER_NONE;
|
||||
|
||||
//
|
||||
if (!IsValid(value))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (Contains(X121SMCXWZToken, value))
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_XWZ;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user