Last Works ...
This commit is contained in:
@@ -369,21 +369,39 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Trigger ...
|
||||
ENUM_XPOI_EVENTS triggerPOIEvents[];
|
||||
mTriggerPOIDetector.Update(triggerPOIEvents);
|
||||
mTriggerPOIDetector.GetState(mTriggerPOIState);
|
||||
ENUM_XPOI_EVENTS mTriggerEvents[];
|
||||
mTriggerDetector.Update(mTriggerEvents);
|
||||
mTriggerDetector.GetState(mTriggerState);
|
||||
|
||||
//
|
||||
// Decision ...
|
||||
ENUM_XPOI_EVENTS mDecisionEvents[];
|
||||
mDecisionDetector.Update(mDecisionEvents);
|
||||
mDecisionDetector.GetState(mDecisionState);
|
||||
|
||||
//
|
||||
// Analyse ...
|
||||
ENUM_XPOI_EVENTS analysePOIEvents[];
|
||||
mAnalysePOIDetector.Update(analysePOIEvents);
|
||||
mAnalysePOIDetector.GetState(mAnalysePOIState);
|
||||
ENUM_XPOI_EVENTS mAnalyseEvents[];
|
||||
mAnalyseDetector.Update(mAnalyseEvents);
|
||||
mAnalyseDetector.GetState(mAnalyseState);
|
||||
|
||||
//
|
||||
// Trigger ...
|
||||
ENUM_XPOI_EVENTS visionPOIEvents[];
|
||||
mVisionPOIDetector.Update(visionPOIEvents);
|
||||
mVisionPOIDetector.GetState(mVisionPOIState);
|
||||
// Verification ...
|
||||
ENUM_XPOI_EVENTS mVerificationEvents[];
|
||||
mVerificationDetector.Update(mVerificationEvents);
|
||||
mVerificationDetector.GetState(mVerificationState);
|
||||
|
||||
//
|
||||
// Consolidation ...
|
||||
ENUM_XPOI_EVENTS mConsolidationEvents[];
|
||||
mConsolidationDetector.Update(mConsolidationEvents);
|
||||
mConsolidationDetector.GetState(mConsolidationState);
|
||||
|
||||
//
|
||||
// Vision ...
|
||||
ENUM_XPOI_EVENTS mVisionEvents[];
|
||||
mVisionDetector.Update(mVisionEvents);
|
||||
mVisionDetector.GetState(mVisionState);
|
||||
|
||||
//
|
||||
// Check Current Processing Tick has Signal or not ...
|
||||
@@ -474,14 +492,20 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Point Of Interests ...
|
||||
XCPOIDetector *mTriggerPOIDetector;
|
||||
XCPOIDetector *mAnalysePOIDetector;
|
||||
XCPOIDetector *mVisionPOIDetector;
|
||||
XCPOIDetector *mVisionDetector;
|
||||
XCPOIDetector *mConsolidationDetector;
|
||||
XCPOIDetector *mVerificationDetector;
|
||||
XCPOIDetector *mAnalyseDetector;
|
||||
XCPOIDetector *mDecisionDetector;
|
||||
XCPOIDetector *mTriggerDetector;
|
||||
|
||||
//
|
||||
XPOIState mTriggerPOIState;
|
||||
XPOIState mAnalysePOIState;
|
||||
XPOIState mVisionPOIState;
|
||||
XPOIState mVisionState;
|
||||
XPOIState mConsolidationState;
|
||||
XPOIState mVerificationState;
|
||||
XPOIState mAnalyseState;
|
||||
XPOIState mDecisionState;
|
||||
XPOIState mTriggerState;
|
||||
|
||||
//
|
||||
XCPOIDrawer *mPOIDrawer; // POI Drawer Class ...
|
||||
@@ -1522,32 +1546,58 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Trigger ...
|
||||
mTriggerPOIDetector = new XCPOIDetector(
|
||||
mTriggerDetector = new XCPOIDetector(
|
||||
symbol,
|
||||
period //
|
||||
PERIOD_M1 //
|
||||
);
|
||||
mTriggerPOIDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mTriggerPOIDetector.Init();
|
||||
mTriggerDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mTriggerDetector.Init();
|
||||
|
||||
//
|
||||
// Decision ...
|
||||
mDecisionDetector = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_M5 //
|
||||
);
|
||||
mDecisionDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mDecisionDetector.Init();
|
||||
|
||||
//
|
||||
// Analyse ...
|
||||
ENUM_TIMEFRAMES analysePeriod = GetAnalysePeriod(period);
|
||||
mAnalysePOIDetector = new XCPOIDetector(
|
||||
mAnalyseDetector = new XCPOIDetector(
|
||||
symbol,
|
||||
analysePeriod //
|
||||
PERIOD_M15 //
|
||||
);
|
||||
mAnalysePOIDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mAnalysePOIDetector.Init();
|
||||
mAnalyseDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mAnalyseDetector.Init();
|
||||
|
||||
//
|
||||
// Verification ...
|
||||
mVerificationDetector = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_M30 //
|
||||
);
|
||||
mVerificationDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mVerificationDetector.Init();
|
||||
|
||||
//
|
||||
// Consolidation ...
|
||||
mConsolidationDetector = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_H1 //
|
||||
);
|
||||
mConsolidationDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mConsolidationDetector.Init();
|
||||
|
||||
//
|
||||
// Vision ...
|
||||
ENUM_TIMEFRAMES visionPeriod = GetVisionPeriod(period);
|
||||
mVisionPOIDetector = new XCPOIDetector(
|
||||
mVisionDetector = new XCPOIDetector(
|
||||
symbol,
|
||||
visionPeriod //
|
||||
PERIOD_H4 //
|
||||
);
|
||||
mVisionPOIDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mVisionPOIDetector.Init();
|
||||
mVisionDetector.MaxNumberOfRequiredPOIs(poiRequired);
|
||||
mVisionDetector.Init();
|
||||
|
||||
|
||||
//
|
||||
}
|
||||
@@ -1558,9 +1608,12 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
||||
void DeInit()
|
||||
{
|
||||
//
|
||||
delete mTriggerPOIDetector;
|
||||
delete mAnalysePOIDetector;
|
||||
delete mVisionPOIDetector;
|
||||
delete mVisionDetector;
|
||||
delete mConsolidationDetector;
|
||||
delete mVerificationDetector;
|
||||
delete mAnalyseDetector;
|
||||
delete mDecisionDetector;
|
||||
delete mTriggerDetector;
|
||||
|
||||
//
|
||||
delete mPOIDrawer;
|
||||
|
||||
@@ -0,0 +1,468 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "../Libraries/x-121.smc.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementations ...
|
||||
|
||||
class XC121SMCCycleHelper : public XCBase
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XCXPVHelper *mXPVHelper;
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
XCX3MAHelper *mX3MAHelper;
|
||||
|
||||
//
|
||||
// X3VWAP ...
|
||||
XCX3VWAPHelper *mX3VWAPHelper;
|
||||
|
||||
//
|
||||
// XCHSAR ...
|
||||
XCXCHSARHelper *mXCHSARHelper;
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XC121SMCCycleHelper()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XC121SMCCycleHelper()
|
||||
{
|
||||
DeInit();
|
||||
}
|
||||
|
||||
//
|
||||
// Getter/Setter(s) ...
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Initialize ...
|
||||
*
|
||||
* @param symbol: String ...
|
||||
* @param period: ENUM_TIMEFRAMES member ...
|
||||
* @param xpvInputs: XPVInputs instance ...
|
||||
* @param x3maInputs: X3MAInputs instance ...
|
||||
* @param x3vwapInputs: X3VWAPInputs instance ...
|
||||
* @param xchsarInputs: XCHSARInputs instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Init(
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period,
|
||||
XPVInputs &xpvInputs,
|
||||
X3MAInputs &x3maInputs,
|
||||
X3VWAPInputs &x3vwapInputs,
|
||||
XCHSARInputs &xchsarInputs //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(symbol) &&
|
||||
IsValid(period);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
|
||||
//
|
||||
result = xpvInputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mXPVHelper = new XCXPVHelper();
|
||||
result = mXPVHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
xpvInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
|
||||
//
|
||||
result = x3maInputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mX3MAHelper = new XCX3MAHelper();
|
||||
result = mX3MAHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
x3maInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// X3VWAP ...
|
||||
|
||||
//
|
||||
result = x3vwapInputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mX3VWAPHelper = new XCX3VWAPHelper();
|
||||
result = mX3VWAPHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
x3vwapInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XCHSAR ...
|
||||
|
||||
//
|
||||
result = xchsarInputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mXCHSARHelper = new XCXCHSARHelper();
|
||||
result = mXCHSARHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
xchsarInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Chart Style ...
|
||||
ApplyChartStyle();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Cycle Conditions ...
|
||||
*
|
||||
* @param conditions: X121SMCCycleConditions instance ...
|
||||
* @param barIndex: Integer ...
|
||||
* @param loopback: Integer ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetConditions(
|
||||
X121SMCCycleConditions &conditions,
|
||||
int barIndex = 0,
|
||||
int loopback = 7 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
if (loopback < 5)
|
||||
{
|
||||
loopback = 5;
|
||||
}
|
||||
|
||||
//
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
result = mXPVHelper.GetConditions(
|
||||
conditions.xpvConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = mX3MAHelper.GetConditions(
|
||||
conditions.x3maConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = mX3VWAPHelper.GetConditions(
|
||||
conditions.x3vwapConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = mXCHSARHelper.GetConditions(
|
||||
conditions.xchsarConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
conditions.symbol = conditions.xpvConditions.symbol;
|
||||
conditions.period = conditions.xpvConditions.period;
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
result = conditions.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// POI Tools ...
|
||||
|
||||
/**
|
||||
* Detect Nearest Current SAR Change ...
|
||||
*
|
||||
* @param changeBar: XOHCL instance, Holds Nearest Change Bar ...
|
||||
* @param bar: XOHCL instance, represents Current Bar for Loopback ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectNearestCSARChange(
|
||||
XOHCL &changeBar,
|
||||
XOHCL &bar //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
changeBar.Clean();
|
||||
|
||||
//
|
||||
result =
|
||||
bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int barIndex = bar.Index();
|
||||
double sar = mXCHSARHelper.GetC(barIndex);
|
||||
bool isBullish = sar > 0 &&
|
||||
sar < bar.low;
|
||||
bool isBearish = sar > 0 &&
|
||||
sar > bar.high;
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Back to Find Nearest Sar Change ...
|
||||
bool canContinue = true;
|
||||
while (canContinue)
|
||||
{
|
||||
//
|
||||
barIndex++;
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
canContinue = iBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
barIndex //
|
||||
);
|
||||
if (!canContinue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
double iSar = mXCHSARHelper.GetC(barIndex);
|
||||
bool isISarBullish =
|
||||
iSar > 0 &&
|
||||
iSar < iBar.low;
|
||||
bool isISarBearish =
|
||||
iSar > 0 &&
|
||||
iSar > iBar.high;
|
||||
bool isSarChanged =
|
||||
isBullish
|
||||
? !isISarBullish
|
||||
: !isISarBearish;
|
||||
|
||||
//
|
||||
if (isSarChanged)
|
||||
{
|
||||
//
|
||||
changeBar = iBar;
|
||||
canContinue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = changeBar.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Release All Resources ...
|
||||
*/
|
||||
void DeInit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user