last ...
This commit is contained in:
@@ -7823,6 +7823,71 @@ double iGetPrice(
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates Price Change Percentage based on
|
||||||
|
* Several Params ...
|
||||||
|
*
|
||||||
|
* @param _symbol: Symbol ...
|
||||||
|
* @param _period: Time Frame ...
|
||||||
|
* @param _from: start Bar Index ...
|
||||||
|
* @param _length: Length of Bars ...
|
||||||
|
*
|
||||||
|
* @return ( double )
|
||||||
|
*/
|
||||||
|
double GetPriceChanged(
|
||||||
|
string _symbol = NULL,
|
||||||
|
ENUM_TIMEFRAMES _period = NULL,
|
||||||
|
int _from = 0,
|
||||||
|
int _length = 3 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
NormalizeSymbol(_symbol);
|
||||||
|
NormalizePeriod(_period);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (_from < 0)
|
||||||
|
{
|
||||||
|
_from = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (_length < 2)
|
||||||
|
{
|
||||||
|
_length = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (_factor < 0.01)
|
||||||
|
{
|
||||||
|
_factor = 0.01;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double closes[];
|
||||||
|
int copiedCloses = CopyClose(
|
||||||
|
_symbol,
|
||||||
|
_period,
|
||||||
|
_from,
|
||||||
|
_length,
|
||||||
|
closes //
|
||||||
|
);
|
||||||
|
if (copiedCloses < _length)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double change = (closes[0] - close[5]) / close[5] * 100;
|
||||||
|
result = change;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate TP/SL for Specified Type of Positions ...
|
// Calculate TP/SL for Specified Type of Positions ...
|
||||||
void CalculateTPSL(
|
void CalculateTPSL(
|
||||||
|
|||||||
@@ -357,6 +357,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
//
|
//
|
||||||
// Update POIs ...
|
// Update POIs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_XPOI_EVENTS _1DStates[];
|
||||||
|
m1DPOI.Update(_1DStates);
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_XPOI_EVENTS _4HStates[];
|
ENUM_XPOI_EVENTS _4HStates[];
|
||||||
m4HPOI.Update(_4HStates);
|
m4HPOI.Update(_4HStates);
|
||||||
@@ -373,6 +377,10 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
ENUM_XPOI_EVENTS _5MStates[];
|
ENUM_XPOI_EVENTS _5MStates[];
|
||||||
m5MPOI.Update(_5MStates);
|
m5MPOI.Update(_5MStates);
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_XPOI_EVENTS _1MStates[];
|
||||||
|
m1MPOI.Update(_1MStates);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Current Processing Tick has Signal or not ...
|
// Check Current Processing Tick has Signal or not ...
|
||||||
XSignal signal;
|
XSignal signal;
|
||||||
@@ -492,6 +500,11 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
//
|
//
|
||||||
// Reading POI(s) ...
|
// Reading POI(s) ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1D ...
|
||||||
|
XPOIState _1DState;
|
||||||
|
m1DPOI.GetState(_1DState);
|
||||||
|
|
||||||
//
|
//
|
||||||
XPOIState _4HSupDemState;
|
XPOIState _4HSupDemState;
|
||||||
m4HSupDemPOI.GetState(_4HSupDemState);
|
m4HSupDemPOI.GetState(_4HSupDemState);
|
||||||
@@ -511,6 +524,11 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
XPOIState _5MState;
|
XPOIState _5MState;
|
||||||
m5MPOI.GetState(_5MState);
|
m5MPOI.GetState(_5MState);
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1M ...
|
||||||
|
XPOIState _1MState;
|
||||||
|
m1MPOI.GetState(_1MState);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to Implement SMC Based Conditions ...
|
// Try to Implement SMC Based Conditions ...
|
||||||
|
|
||||||
@@ -687,73 +705,7 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
// Props ...
|
// Props ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private ...
|
// Actions ...
|
||||||
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 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XTick mTicks[]; // Hold Ticks Data ...
|
|
||||||
MqlTick mLastTick; // Last Issued Tick ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleanup Ticks Size ...
|
|
||||||
*/
|
|
||||||
void CleanupTicks()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
int maxRequiredTicks = 50;
|
|
||||||
int ticksCount = ArraySize(mTicks);
|
|
||||||
if (!IsValidSize(ticksCount) ||
|
|
||||||
ticksCount <= maxRequiredTicks)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int removeCount = ticksCount - maxRequiredTicks;
|
|
||||||
if (!IsValidSize(removeCount))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
ArrayRemove(
|
|
||||||
mTicks,
|
|
||||||
0,
|
|
||||||
removeCount //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add new Tick Data to Collection ...
|
|
||||||
*/
|
|
||||||
void SaveTickData()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XTick tick;
|
|
||||||
bool isInited = tick.Init(mSymbol);
|
|
||||||
if (!isInited)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
AddRef(
|
|
||||||
tick,
|
|
||||||
mTicks //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Spread Passed for Positions...
|
* Check Spread Passed for Positions...
|
||||||
@@ -818,41 +770,6 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate Ticks Param for Looping through Last n items ...
|
|
||||||
*
|
|
||||||
* @param start: Integer Reference to Start ...
|
|
||||||
* @param end: Integer Reference to End ...
|
|
||||||
* @param numOfLastTicks: Integer Max Number of Required N Last Ticks ...
|
|
||||||
*/
|
|
||||||
void CalculateTicksParams(
|
|
||||||
int &start,
|
|
||||||
int &end,
|
|
||||||
int numOfLastTicks = 5 //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
start = -1;
|
|
||||||
end = -1;
|
|
||||||
|
|
||||||
//
|
|
||||||
int count = ArraySize(mTicks);
|
|
||||||
|
|
||||||
//
|
|
||||||
start = count - numOfLastTicks;
|
|
||||||
if (start < 0)
|
|
||||||
{
|
|
||||||
start = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
end = start + numOfLastTicks;
|
|
||||||
if (end > count)
|
|
||||||
{
|
|
||||||
end = count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Ticks is Bullish or not ...
|
* Check Ticks is Bullish or not ...
|
||||||
*
|
*
|
||||||
@@ -992,257 +909,6 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
XBarTracker mBarTracker; // Strategy Time Tracker ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Point Of Interests ...
|
|
||||||
XCPOI *m4HPOI;
|
|
||||||
XCPOI *m4HSupDemPOI;
|
|
||||||
XCPOI *m15MPOI;
|
|
||||||
XCPOI *m5MPOI;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Collect all Drawn Objects ...
|
|
||||||
CArrayObj mDrawnObjects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear all Drawn Objects ...
|
|
||||||
*/
|
|
||||||
void ClearDraws()
|
|
||||||
{
|
|
||||||
mDrawnObjects.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove Specified Drawn Object ...
|
|
||||||
*
|
|
||||||
* @param name: Object name ...
|
|
||||||
*/
|
|
||||||
void RemoveObject(string name)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
if (!IsValid(name))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int count = mDrawnObjects.Total();
|
|
||||||
if (!IsValidSize(count))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int idx = -1;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
string iName = ((CChartObject *)mDrawnObjects.At(i)).Name();
|
|
||||||
string iObjName = NULL;
|
|
||||||
if (!IsValid(iName))
|
|
||||||
{
|
|
||||||
iObjName = ((XCBaseObject *)mDrawnObjects.At(i)).ObjName();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if ((IsValid(iName) &&
|
|
||||||
iName == name) ||
|
|
||||||
(IsValid(iObjName) &&
|
|
||||||
iObjName == name))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (IsValidIndex(idx))
|
|
||||||
{
|
|
||||||
mDrawnObjects.Delete(idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL mSwingHigh;
|
|
||||||
CChartObjectHLine *mSwingHighObject;
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL mSwingLow;
|
|
||||||
CChartObjectHLine *mSwingLowObject;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Holding Supply and Demand Zones ...
|
|
||||||
// XZone mSupplyZones[];
|
|
||||||
// XZone mDemandZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
// XZone mBearishOrderBlocks[];
|
|
||||||
// XZone mBullishOrderBlocks[];
|
|
||||||
|
|
||||||
//
|
|
||||||
// XZone mBearishFVGs[];
|
|
||||||
// XZone mBullishFVGs[];
|
|
||||||
|
|
||||||
//
|
|
||||||
X121SMCStrategyConditions mConditions[];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Actions ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install all Helpers and Prepare all Configurations for required Indicators ...
|
|
||||||
*/
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
mForceDisabled = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
R2R(2);
|
|
||||||
Volume(0.01);
|
|
||||||
|
|
||||||
//
|
|
||||||
ChartIdentification(0);
|
|
||||||
SubWindowIdentification(0);
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
//
|
|
||||||
string symbol = Symbol();
|
|
||||||
ENUM_TIMEFRAMES period = Period();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize Bar Tracker ...
|
|
||||||
mBarTracker.Init(
|
|
||||||
symbol,
|
|
||||||
period //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize POIs ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// this used only for Supply and
|
|
||||||
// Demand Zone for H4 Time Frame ..,
|
|
||||||
// POI Detector ...
|
|
||||||
m4HSupDemPOI = new XCPOI(
|
|
||||||
symbol,
|
|
||||||
PERIOD_M15 //
|
|
||||||
);
|
|
||||||
m4HSupDemPOI.DisablePOIs();
|
|
||||||
m4HSupDemPOI.DisableDrawPOIs();
|
|
||||||
m4HSupDemPOI.AllowSupplyZones(true);
|
|
||||||
m4HSupDemPOI.AllowDemandZones(true);
|
|
||||||
m4HSupDemPOI.SupplyZonePeriod(PERIOD_H4);
|
|
||||||
m4HSupDemPOI.DemandZonePeriod(PERIOD_H4);
|
|
||||||
m4HSupDemPOI.SubWindowIdentification(0);
|
|
||||||
m4HSupDemPOI.ChartIdentification(ChartID());
|
|
||||||
|
|
||||||
//
|
|
||||||
m4HSupDemPOI.Init();
|
|
||||||
|
|
||||||
//
|
|
||||||
// 4H Period ...
|
|
||||||
// POI Detector ...
|
|
||||||
m4HPOI = new XCPOI(
|
|
||||||
symbol,
|
|
||||||
PERIOD_H4 //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
m4HPOI.DisableDrawPOIs();
|
|
||||||
m4HPOI.SupplyZonePeriod(PERIOD_H4);
|
|
||||||
m4HPOI.DemandZonePeriod(PERIOD_H4);
|
|
||||||
m4HPOI.SubWindowIdentification(0);
|
|
||||||
m4HPOI.ChartIdentification(ChartID());
|
|
||||||
|
|
||||||
//
|
|
||||||
m4HPOI.Init();
|
|
||||||
|
|
||||||
//
|
|
||||||
// 15M Period ...
|
|
||||||
// POI Detector ...
|
|
||||||
m15MPOI = new XCPOI(
|
|
||||||
symbol,
|
|
||||||
PERIOD_M15 //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
m15MPOI.DisableDrawPOIs();
|
|
||||||
m15MPOI.MaxNumberOfRequiredPOIs(2);
|
|
||||||
m15MPOI.SupplyZonePeriod(PERIOD_M15);
|
|
||||||
m15MPOI.DemandZonePeriod(PERIOD_M15);
|
|
||||||
m15MPOI.SubWindowIdentification(0);
|
|
||||||
m15MPOI.ChartIdentification(ChartID());
|
|
||||||
|
|
||||||
//
|
|
||||||
m15MPOI.Init();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Trigger Period ...
|
|
||||||
// POI Detector ...
|
|
||||||
m5MPOI = new XCPOI(
|
|
||||||
symbol,
|
|
||||||
PERIOD_M5 //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
m5MPOI.DisableDrawPOIs();
|
|
||||||
m5MPOI.MaxNumberOfRequiredPOIs(2);
|
|
||||||
m5MPOI.SupplyZonePeriod(PERIOD_M5);
|
|
||||||
m5MPOI.DemandZonePeriod(PERIOD_M5);
|
|
||||||
m5MPOI.SubWindowIdentification(0);
|
|
||||||
m5MPOI.ChartIdentification(ChartID());
|
|
||||||
|
|
||||||
//
|
|
||||||
m5MPOI.Init();
|
|
||||||
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* De Initialize all Tools ...
|
|
||||||
*/
|
|
||||||
void DeInit()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
delete m4HPOI;
|
|
||||||
delete m5MPOI;
|
|
||||||
delete m15MPOI;
|
|
||||||
delete m4HSupDemPOI;
|
|
||||||
|
|
||||||
//
|
|
||||||
delete mPOIDrawer;
|
|
||||||
|
|
||||||
//
|
|
||||||
ClearDraws();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reste Bar Tracker ...
|
|
||||||
*/
|
|
||||||
void ResetBarTracker()
|
|
||||||
{
|
|
||||||
mBarTracker.Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare and Normalize Signal for Execution in Strategy ...
|
* Prepare and Normalize Signal for Execution in Strategy ...
|
||||||
*
|
*
|
||||||
@@ -1880,10 +1546,6 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// On X121 Signal Recieved Event Handler(s) ...
|
|
||||||
TOnX121SMCSignal mSignalEventHandlers[];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
/**
|
/**
|
||||||
* Notified Signal Event Handler(s) ...
|
* Notified Signal Event Handler(s) ...
|
||||||
@@ -1923,10 +1585,64 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
//
|
//
|
||||||
// Draw Functions ...
|
// Draw Functions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all Drawn Objects ...
|
||||||
|
*/
|
||||||
|
void ClearDraws()
|
||||||
|
{
|
||||||
|
mDrawnObjects.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove Specified Drawn Object ...
|
||||||
|
*
|
||||||
|
* @param name: Object name ...
|
||||||
|
*/
|
||||||
|
void RemoveObject(string name)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
long mChartID; // Chart ID ...
|
if (!IsValid(name))
|
||||||
int mSubWindow; // Sub Window ID ...
|
{
|
||||||
XCPOIDrawer *mPOIDrawer; // POI Drawer Class ...
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = mDrawnObjects.Total();
|
||||||
|
if (!IsValidSize(count))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string iName = ((CChartObject *)mDrawnObjects.At(i)).Name();
|
||||||
|
string iObjName = NULL;
|
||||||
|
if (!IsValid(iName))
|
||||||
|
{
|
||||||
|
iObjName = ((XCBaseObject *)mDrawnObjects.At(i)).ObjName();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if ((IsValid(iName) &&
|
||||||
|
iName == name) ||
|
||||||
|
(IsValid(iObjName) &&
|
||||||
|
iObjName == name))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (IsValidIndex(idx))
|
||||||
|
{
|
||||||
|
mDrawnObjects.Delete(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw Specific Condition ...
|
* Draw Specific Condition ...
|
||||||
@@ -2353,6 +2069,338 @@ class XCX121SMCStrategy : public XSCBaseAlert
|
|||||||
mDrawnObjects.Add(iObj);
|
mDrawnObjects.Add(iObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
long mChartID; // Chart ID ...
|
||||||
|
int mSubWindow; // Sub Window ID ...
|
||||||
|
XCPOIDrawer *mPOIDrawer; // POI Drawer Class ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XTick mTicks[]; // Hold Ticks Data ...
|
||||||
|
MqlTick mLastTick; // Last Issued Tick ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XBarTracker mBarTracker; // Strategy Time Tracker ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Point Of Interests ...
|
||||||
|
XCPOI *m1DPOI;
|
||||||
|
XCPOI *m4HPOI;
|
||||||
|
XCPOI *m4HSupDemPOI;
|
||||||
|
XCPOI *m15MPOI;
|
||||||
|
XCPOI *m5MPOI;
|
||||||
|
XCPOI *m1MPOI;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collect all Drawn Objects ...
|
||||||
|
CArrayObj mDrawnObjects;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL mSwingHigh;
|
||||||
|
CChartObjectHLine *mSwingHighObject;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL mSwingLow;
|
||||||
|
CChartObjectHLine *mSwingLowObject;
|
||||||
|
|
||||||
|
//
|
||||||
|
X121SMCStrategyConditions mConditions[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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(2);
|
||||||
|
Volume(0.01);
|
||||||
|
|
||||||
|
//
|
||||||
|
ChartIdentification(0);
|
||||||
|
SubWindowIdentification(0);
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = Symbol();
|
||||||
|
ENUM_TIMEFRAMES period = Period();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Bar Tracker ...
|
||||||
|
mBarTracker.Init(
|
||||||
|
symbol,
|
||||||
|
period //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize POIs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1D Period ...
|
||||||
|
// POI Detector ...
|
||||||
|
m1DPOI = new XCPOI(
|
||||||
|
symbol,
|
||||||
|
PERIOD_D1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
m1DPOI.DisableDrawPOIs();
|
||||||
|
m1DPOI.SupplyZonePeriod(PERIOD_W1);
|
||||||
|
m1DPOI.DemandZonePeriod(PERIOD_W1);
|
||||||
|
m1DPOI.SubWindowIdentification(0);
|
||||||
|
m1DPOI.ChartIdentification(ChartID());
|
||||||
|
|
||||||
|
//
|
||||||
|
m1DPOI.Init();
|
||||||
|
|
||||||
|
//
|
||||||
|
// this used only for Supply and
|
||||||
|
// Demand Zone for H4 Time Frame ..,
|
||||||
|
// POI Detector ...
|
||||||
|
m4HSupDemPOI = new XCPOI(
|
||||||
|
symbol,
|
||||||
|
PERIOD_M15 //
|
||||||
|
);
|
||||||
|
m4HSupDemPOI.DisablePOIs();
|
||||||
|
m4HSupDemPOI.DisableDrawPOIs();
|
||||||
|
m4HSupDemPOI.AllowSupplyZones(true);
|
||||||
|
m4HSupDemPOI.AllowDemandZones(true);
|
||||||
|
m4HSupDemPOI.SupplyZonePeriod(PERIOD_H4);
|
||||||
|
m4HSupDemPOI.DemandZonePeriod(PERIOD_H4);
|
||||||
|
m4HSupDemPOI.SubWindowIdentification(0);
|
||||||
|
m4HSupDemPOI.ChartIdentification(ChartID());
|
||||||
|
|
||||||
|
//
|
||||||
|
m4HSupDemPOI.Init();
|
||||||
|
|
||||||
|
//
|
||||||
|
// 4H Period ...
|
||||||
|
// POI Detector ...
|
||||||
|
m4HPOI = new XCPOI(
|
||||||
|
symbol,
|
||||||
|
PERIOD_H4 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
m4HPOI.DisableDrawPOIs();
|
||||||
|
m4HPOI.SupplyZonePeriod(PERIOD_H4);
|
||||||
|
m4HPOI.DemandZonePeriod(PERIOD_H4);
|
||||||
|
m4HPOI.SubWindowIdentification(0);
|
||||||
|
m4HPOI.ChartIdentification(ChartID());
|
||||||
|
|
||||||
|
//
|
||||||
|
m4HPOI.Init();
|
||||||
|
|
||||||
|
//
|
||||||
|
// 15M Period ...
|
||||||
|
// POI Detector ...
|
||||||
|
m15MPOI = new XCPOI(
|
||||||
|
symbol,
|
||||||
|
PERIOD_M15 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
m15MPOI.DisableDrawPOIs();
|
||||||
|
m15MPOI.MaxNumberOfRequiredPOIs(2);
|
||||||
|
m15MPOI.SupplyZonePeriod(PERIOD_H4);
|
||||||
|
m15MPOI.DemandZonePeriod(PERIOD_H4);
|
||||||
|
m15MPOI.SubWindowIdentification(0);
|
||||||
|
m15MPOI.ChartIdentification(ChartID());
|
||||||
|
|
||||||
|
//
|
||||||
|
m15MPOI.Init();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger Period ...
|
||||||
|
// POI Detector ...
|
||||||
|
m5MPOI = new XCPOI(
|
||||||
|
symbol,
|
||||||
|
PERIOD_M5 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
m5MPOI.DisableDrawPOIs();
|
||||||
|
m5MPOI.MaxNumberOfRequiredPOIs(2);
|
||||||
|
m5MPOI.SupplyZonePeriod(PERIOD_M15);
|
||||||
|
m5MPOI.DemandZonePeriod(PERIOD_M15);
|
||||||
|
m5MPOI.SubWindowIdentification(0);
|
||||||
|
m5MPOI.ChartIdentification(ChartID());
|
||||||
|
|
||||||
|
//
|
||||||
|
m5MPOI.Init();
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1M Period ...
|
||||||
|
// POI Detector ...
|
||||||
|
m1MPOI = new XCPOI(
|
||||||
|
symbol,
|
||||||
|
PERIOD_M1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
m1MPOI.DisableDrawPOIs();
|
||||||
|
m1MPOI.SupplyZonePeriod(PERIOD_M5);
|
||||||
|
m1MPOI.DemandZonePeriod(PERIOD_M5);
|
||||||
|
m1MPOI.SubWindowIdentification(0);
|
||||||
|
m1MPOI.ChartIdentification(ChartID());
|
||||||
|
|
||||||
|
//
|
||||||
|
m1MPOI.Init();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De Initialize all Tools ...
|
||||||
|
*/
|
||||||
|
void DeInit()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
delete m1DPOI;
|
||||||
|
delete m4HPOI;
|
||||||
|
delete m5MPOI;
|
||||||
|
delete m1MPOI;
|
||||||
|
delete m15MPOI;
|
||||||
|
delete m4HSupDemPOI;
|
||||||
|
|
||||||
|
//
|
||||||
|
delete mPOIDrawer;
|
||||||
|
|
||||||
|
//
|
||||||
|
ClearDraws();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reste Bar Tracker ...
|
||||||
|
*/
|
||||||
|
void ResetBarTracker()
|
||||||
|
{
|
||||||
|
mBarTracker.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup Ticks Size ...
|
||||||
|
*/
|
||||||
|
void CleanupTicks()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int maxRequiredTicks = 50;
|
||||||
|
int ticksCount = ArraySize(mTicks);
|
||||||
|
if (!IsValidSize(ticksCount) ||
|
||||||
|
ticksCount <= maxRequiredTicks)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int removeCount = ticksCount - maxRequiredTicks;
|
||||||
|
if (!IsValidSize(removeCount))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ArrayRemove(
|
||||||
|
mTicks,
|
||||||
|
0,
|
||||||
|
removeCount //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new Tick Data to Collection ...
|
||||||
|
*/
|
||||||
|
void SaveTickData()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XTick tick;
|
||||||
|
bool isInited = tick.Init(mSymbol);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
tick,
|
||||||
|
mTicks //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Ticks Param for Looping through Last n items ...
|
||||||
|
*
|
||||||
|
* @param start: Integer Reference to Start ...
|
||||||
|
* @param end: Integer Reference to End ...
|
||||||
|
* @param numOfLastTicks: Integer Max Number of Required N Last Ticks ...
|
||||||
|
*/
|
||||||
|
void CalculateTicksParams(
|
||||||
|
int &start,
|
||||||
|
int &end,
|
||||||
|
int numOfLastTicks = 5 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
start = -1;
|
||||||
|
end = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(mTicks);
|
||||||
|
|
||||||
|
//
|
||||||
|
start = count - numOfLastTicks;
|
||||||
|
if (start < 0)
|
||||||
|
{
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
end = start + numOfLastTicks;
|
||||||
|
if (end > count)
|
||||||
|
{
|
||||||
|
end = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user