Fix all Refactors issues on X121SMC for start Implementing Strategy ...
This commit is contained in:
@@ -23,11 +23,11 @@
|
||||
// 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.xalert.class.mq5"
|
||||
#include "../../Classes/x-saherelm.xtrade.class.mq5"
|
||||
#include "../../Classes/z-saherelm.x-bar.analyser.class.mq5"
|
||||
#include "../Classes/x-121.smc.chart.objects.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"
|
||||
|
||||
//
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
//
|
||||
// XStrategy Class Implementation(s) ...
|
||||
class XCX121SMCBaseStrategy : public XSCBaseAlert
|
||||
class XCX121SMCBaseStrategy : public XCBaseAlert
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -311,6 +311,13 @@ class XCX121SMCBaseStrategy : public XSCBaseAlert
|
||||
//
|
||||
// Virtual Actions ...
|
||||
|
||||
/**
|
||||
* Destroy All Class Implementations ...
|
||||
*/
|
||||
virtual void Destroy()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Tick Processing ...
|
||||
*/
|
||||
@@ -486,6 +493,23 @@ class XCX121SMCBaseStrategy : public XSCBaseAlert
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ...
|
||||
*
|
||||
@@ -506,13 +530,13 @@ class XCX121SMCBaseStrategy : public XSCBaseAlert
|
||||
|
||||
//
|
||||
// Point Of Interests ...
|
||||
XCPOI *m1DPOI;
|
||||
XCPOI *m4HPOI;
|
||||
XCPOI *m2HPOI;
|
||||
XCPOI *m1HPOI;
|
||||
XCPOI *m15MPOI;
|
||||
XCPOI *m5MPOI;
|
||||
XCPOI *m1MPOI;
|
||||
XCPOIDetector *m1DPOI;
|
||||
XCPOIDetector *m4HPOI;
|
||||
XCPOIDetector *m2HPOI;
|
||||
XCPOIDetector *m1HPOI;
|
||||
XCPOIDetector *m15MPOI;
|
||||
XCPOIDetector *m5MPOI;
|
||||
XCPOIDetector *m1MPOI;
|
||||
|
||||
//
|
||||
XPOIState _1DState;
|
||||
@@ -1024,128 +1048,77 @@ class XCX121SMCBaseStrategy : public XSCBaseAlert
|
||||
//
|
||||
// 1D Period ...
|
||||
// POI Detector ...
|
||||
m1DPOI = new XCPOI(
|
||||
m1DPOI = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_D1 //
|
||||
);
|
||||
|
||||
//
|
||||
m1DPOI.DisableDrawPOIs();
|
||||
m1DPOI.SupplyZonePeriod(PERIOD_W1);
|
||||
m1DPOI.DemandZonePeriod(PERIOD_W1);
|
||||
m1DPOI.SubWindowIdentification(0);
|
||||
m1DPOI.ChartIdentification(ChartID());
|
||||
|
||||
//
|
||||
m1DPOI.Init();
|
||||
|
||||
//
|
||||
// 4H Period ...
|
||||
// POI Detector ...
|
||||
m4HPOI = new XCPOI(
|
||||
m4HPOI = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_H4 //
|
||||
);
|
||||
|
||||
//
|
||||
m4HPOI.DisableDrawPOIs();
|
||||
m4HPOI.SupplyZonePeriod(PERIOD_D1);
|
||||
m4HPOI.DemandZonePeriod(PERIOD_D1);
|
||||
m4HPOI.SubWindowIdentification(0);
|
||||
m4HPOI.ChartIdentification(ChartID());
|
||||
|
||||
//
|
||||
m4HPOI.Init();
|
||||
|
||||
//
|
||||
// 2H Period ...
|
||||
// POI Detector ...
|
||||
m2HPOI = new XCPOI(
|
||||
m2HPOI = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_H2 //
|
||||
);
|
||||
|
||||
//
|
||||
m2HPOI.DisableDrawPOIs();
|
||||
m2HPOI.SupplyZonePeriod(PERIOD_H12);
|
||||
m2HPOI.DemandZonePeriod(PERIOD_H12);
|
||||
m2HPOI.SubWindowIdentification(0);
|
||||
m2HPOI.ChartIdentification(ChartID());
|
||||
|
||||
//
|
||||
m2HPOI.Init();
|
||||
|
||||
//
|
||||
// 1H Period ...
|
||||
// POI Detector ...
|
||||
m1HPOI = new XCPOI(
|
||||
m1HPOI = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_H1 //
|
||||
);
|
||||
|
||||
//
|
||||
m1HPOI.DisableDrawPOIs();
|
||||
m1HPOI.SupplyZonePeriod(PERIOD_H6);
|
||||
m1HPOI.DemandZonePeriod(PERIOD_H6);
|
||||
m1HPOI.SubWindowIdentification(0);
|
||||
m1HPOI.ChartIdentification(ChartID());
|
||||
|
||||
//
|
||||
m1HPOI.Init();
|
||||
|
||||
//
|
||||
// 15M Period ...
|
||||
// POI Detector ...
|
||||
m15MPOI = new XCPOI(
|
||||
m15MPOI = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_M15 //
|
||||
);
|
||||
|
||||
//
|
||||
m15MPOI.DisableDrawPOIs();
|
||||
m15MPOI.MaxNumberOfRequiredPOIs(2);
|
||||
m15MPOI.SupplyZonePeriod(PERIOD_H4);
|
||||
m15MPOI.DemandZonePeriod(PERIOD_H4);
|
||||
m15MPOI.SubWindowIdentification(0);
|
||||
m15MPOI.ChartIdentification(ChartID());
|
||||
|
||||
//
|
||||
m15MPOI.Init();
|
||||
|
||||
//
|
||||
// 5M Period ...
|
||||
// POI Detector ...
|
||||
m5MPOI = new XCPOI(
|
||||
m5MPOI = new XCPOIDetector(
|
||||
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(
|
||||
m1MPOI = new XCPOIDetector(
|
||||
symbol,
|
||||
PERIOD_M1 //
|
||||
);
|
||||
|
||||
//
|
||||
m1MPOI.DisableDrawPOIs();
|
||||
m1MPOI.SupplyZonePeriod(PERIOD_M5);
|
||||
m1MPOI.DemandZonePeriod(PERIOD_M5);
|
||||
m1MPOI.SubWindowIdentification(0);
|
||||
m1MPOI.ChartIdentification(ChartID());
|
||||
|
||||
//
|
||||
m1MPOI.Init();
|
||||
|
||||
@@ -1168,7 +1141,7 @@ class XCX121SMCBaseStrategy : public XSCBaseAlert
|
||||
delete mPOIDrawer;
|
||||
|
||||
//
|
||||
// ClearDraws();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+8
-47
@@ -24,6 +24,7 @@
|
||||
|
||||
//
|
||||
#include "../../Classes/x-saherelm.x-alert.class.mq5"
|
||||
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||
#include "../../Classes/x-saherelm.x-trade.class.mq5"
|
||||
|
||||
//
|
||||
@@ -1301,7 +1302,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
return mMaxAllowedSLReachedPauseDelay;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
void MaxAllowedSLReachedPauseDelay(int value)
|
||||
{
|
||||
//
|
||||
@@ -2742,7 +2743,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
XCTrade *mTrader; // Instance of Trader Class
|
||||
XCTrade *mTrader; // Instance of Trader Class
|
||||
X121SMCTradeCollector *mCollector; // Instance of Trade Collector Class
|
||||
|
||||
//
|
||||
@@ -3180,63 +3181,22 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
//
|
||||
// Common Conditions For Bullish and Bearish Powers ...
|
||||
|
||||
//
|
||||
// For Trend ...
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
// Detect Bullish/Bearish Patterns and Trends ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool hasBullishPower = cBar.HasBullishPower();
|
||||
bool hasBullishPattern = HasBullishPattern(cBar);
|
||||
bool hasBullishPattern = mBarAnalyser.HasBullishPattern(cBar);
|
||||
bool hasBullishPressure = cBar.HasBullishPressure();
|
||||
bool isBullishTrend = cBar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
bool isBullishTrend1 = cBar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
bool hasBullishTrend =
|
||||
//
|
||||
isBullishTrend
|
||||
//
|
||||
||
|
||||
//
|
||||
isBullishTrend1
|
||||
//
|
||||
;
|
||||
bool hasBullishTrend = mBarAnalyser.HasBullishTrend(cBar, true);
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool hasBearishPower = cBar.HasBearishPower();
|
||||
bool hasBearishPattern = HasBearishPattern(cBar);
|
||||
bool hasBearishPattern = mBarAnalyser.HasBearishPattern(cBar);
|
||||
bool hasBearishPressure = cBar.HasBearishPressure();
|
||||
bool isBearishTrend = cBar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
bool isBearishTrend1 = cBar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
bool hasBearishTrend =
|
||||
//
|
||||
isBearishTrend
|
||||
//
|
||||
||
|
||||
//
|
||||
isBearishTrend1
|
||||
//
|
||||
;
|
||||
bool hasBearishTrend = mBarAnalyser.HasBearishTrend(cBar, true);
|
||||
|
||||
//
|
||||
// Define Conditions ...
|
||||
@@ -3810,6 +3770,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
double mHedgeBEMinProfitPerVolumeStep; // Minimum Required Profit For BE Hedge Per Volume Step
|
||||
|
||||
//
|
||||
XCBarAnalyser mBarAnalyser;
|
||||
X121SMCSymbolPositionInfo mSymbolInfos[];
|
||||
|
||||
/**
|
||||
@@ -21,8 +21,9 @@
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.xexpert.class.mq5"
|
||||
#include "../Classes/x-121.smc.xtradehandler.class.mq5"
|
||||
#include "../Libraries/x-121.smc.lib.mq5"
|
||||
#include "../../Classes/x-saherelm.x-expert.class.mq5"
|
||||
#include "../Classes/x-121.smc.x-tradehandler.class.mq5"
|
||||
#include "../Strategy/x-121.smc.test.strategy.class.mq5"
|
||||
|
||||
//
|
||||
@@ -400,7 +401,7 @@ class XC121SMCExpert : public XCBaseExpert
|
||||
// Bar Timer ...
|
||||
XCTInputs ctInputs;
|
||||
ctInputs.Default(); // Default Configurations ...
|
||||
mCTHelper = new XSCXCTHelper();
|
||||
mCTHelper = new XCXCTHelper();
|
||||
result = mCTHelper.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
@@ -415,7 +416,7 @@ class XC121SMCExpert : public XCBaseExpert
|
||||
// Bar Styles ...
|
||||
XCCInputs ccInputs;
|
||||
ccInputs.Default(); // Default Configurations ...
|
||||
mCCHelper = new XSCXCCHelper();
|
||||
mCCHelper = new XCXCCHelper();
|
||||
result = mCCHelper.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
@@ -428,7 +429,7 @@ class XC121SMCExpert : public XCBaseExpert
|
||||
|
||||
//
|
||||
// Create Trader Instance and Configure it ...
|
||||
mTrader = new XSCTrade(
|
||||
mTrader = new XCTrade(
|
||||
Slippage(),
|
||||
MagicNumber() //
|
||||
);
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "../../Libraries/x-saherelm.common.lib.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-poi.lib.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-trade.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
const string X121SMCStrategyToken = "X121SMC";
|
||||
|
||||
struct X121SMCStrategyConditions
|
||||
{
|
||||
//
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
void X121SMCStrategyConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsSpecifiedValid(symbol) &&
|
||||
IsSpecifiedValid(period) &&
|
||||
IsSpecifiedValid(time);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// //
|
||||
// // XPV ...
|
||||
// pvConditions.GenerateScore(
|
||||
// bullScore,
|
||||
// bearScore //
|
||||
// );
|
||||
// bullishScore += bullScore;
|
||||
// bearishScore += bearScore;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 //
|
||||
);
|
||||
|
||||
// //
|
||||
// // XPV ...
|
||||
// string pvStr = pvConditions.GenerateSummary(
|
||||
// false,
|
||||
// true,
|
||||
// false,
|
||||
// ignoreFalseConditions //
|
||||
// );
|
||||
|
||||
//
|
||||
string conditionsStr =
|
||||
//
|
||||
// pvStr + separator +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
if (!forObject)
|
||||
{
|
||||
result = X121SMCStrategyToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = X121SMCStrategyToken + "_" +
|
||||
symbol + "_" + ToString(period) + "_" +
|
||||
ToMD5(time);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
typedef void (*TOnX121SMCSignal)(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
);
|
||||
|
||||
//
|
||||
@@ -0,0 +1,407 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCX121SMCTestStrategy
|
||||
// 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 "../../Helpers/x-saherelm.x3ma.helper.mq5"
|
||||
#include "../../Helpers/x-saherelm.x3vwap.helper.mq5"
|
||||
#include "../../Helpers/x-saherelm.xpv.helper.mq5"
|
||||
#include "../Classes/x-121.smc.base.strategy.class.mq5"
|
||||
|
||||
//
|
||||
// Helper(s) ...
|
||||
|
||||
//
|
||||
// XStrategy Class Implementation(s) ...
|
||||
class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCX121SMCTestStrategy(
|
||||
//
|
||||
// Base ...
|
||||
string _symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES _period // Trading TimeFrame
|
||||
)
|
||||
: XCX121SMCBaseStrategy(_symbol, _period)
|
||||
{
|
||||
InitialHelpers();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructur ...
|
||||
void ~XCX121SMCTestStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides Actions ...
|
||||
|
||||
/**
|
||||
* Destroy All Class Implementations ...
|
||||
*/
|
||||
void Destroy() override
|
||||
{
|
||||
//
|
||||
delete xpvHelper;
|
||||
delete x3maHelper;
|
||||
delete x3vwapHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Conditions For Signal ...
|
||||
*/
|
||||
bool HasSignal(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
) override
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
signal.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
int pushers = 0;
|
||||
|
||||
//
|
||||
double sl = 0;
|
||||
double tp = 0;
|
||||
double risk = 0;
|
||||
double entry = 0;
|
||||
double reward = 0;
|
||||
double r2r = R2R();
|
||||
double volume = Volume();
|
||||
ENUM_POSITION_TYPE type = POSITION_TYPE_BUY;
|
||||
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
|
||||
|
||||
//
|
||||
bool hasLong = false;
|
||||
bool hasShort = false;
|
||||
|
||||
//
|
||||
// Start Calculations ...
|
||||
|
||||
//
|
||||
string _symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES _period = GetPeriod();
|
||||
|
||||
//
|
||||
double points = GetPoints(_symbol);
|
||||
double pip = GetPipPrice(_symbol);
|
||||
double pip2 = 2 * pip;
|
||||
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
// Retrieve Bars ...
|
||||
|
||||
//
|
||||
// Zero Bar ...
|
||||
XOHCL zBar;
|
||||
result = zBar.Init(
|
||||
_symbol,
|
||||
_period,
|
||||
zIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Last Bar ...
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
_symbol,
|
||||
_period,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous Bar ...
|
||||
XOHCL pBar;
|
||||
result = pBar.Init(
|
||||
_symbol,
|
||||
_period,
|
||||
pIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isSpreadPassed = IsSpreadPass();
|
||||
result = isSpreadPassed;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to Implement SMC Based Conditions ...
|
||||
|
||||
//
|
||||
result = hasLong ||
|
||||
hasShort;
|
||||
|
||||
//
|
||||
// Rmove Signal Condition ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// TYPE ...
|
||||
type =
|
||||
hasLong
|
||||
? POSITION_TYPE_BUY
|
||||
: POSITION_TYPE_SELL;
|
||||
ENUM_X_POSITION_TYPES xType =
|
||||
hasLong
|
||||
? X_POSITION_TYPE_LONG
|
||||
: X_POSITION_TYPE_SHORT;
|
||||
|
||||
//
|
||||
entry = GetEntry(
|
||||
conditions.symbol,
|
||||
type //
|
||||
);
|
||||
|
||||
//
|
||||
double candidates[];
|
||||
DetectSLCandidates(
|
||||
candidates,
|
||||
entry,
|
||||
conditions,
|
||||
xType //
|
||||
);
|
||||
double selectedSL =
|
||||
hasLong
|
||||
? GetMax(candidates)
|
||||
: GetMin(candidates);
|
||||
sl =
|
||||
hasLong
|
||||
? selectedSL - pip2
|
||||
: selectedSL + pip2;
|
||||
|
||||
//
|
||||
// RISK Reward ...
|
||||
risk =
|
||||
hasLong
|
||||
? entry - sl
|
||||
: sl - entry;
|
||||
reward = risk * r2r;
|
||||
tp =
|
||||
hasLong
|
||||
? entry + reward
|
||||
: entry - reward;
|
||||
|
||||
//
|
||||
ClearDraws();
|
||||
|
||||
//
|
||||
signal.sl = sl;
|
||||
signal.tp = tp;
|
||||
signal.type = type;
|
||||
signal.mode = mode;
|
||||
signal.entry = entry;
|
||||
signal.volume = volume;
|
||||
signal.symbol = _symbol;
|
||||
signal.pushers = pushers;
|
||||
signal.provider = GetTag();
|
||||
signal.time = TimeCurrent();
|
||||
signal.period = _5MState.period;
|
||||
|
||||
//
|
||||
result = PrepareSignal(signal);
|
||||
|
||||
//
|
||||
hasLong = false;
|
||||
hasShort = false;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ...
|
||||
*/
|
||||
void DetectSLCandidates(
|
||||
double &result[],
|
||||
double entry,
|
||||
X121SMCStrategyConditions &conditions,
|
||||
ENUM_X_POSITION_TYPES type //
|
||||
) override
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Customize Strategy Identifier ...
|
||||
*/
|
||||
string GetTag() override
|
||||
{
|
||||
return X121SMCStrategyToken;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XPVInputs xpvInputs;
|
||||
XCXPVHelper *xpvHelper;
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
X3MAInputs x3maInputs;
|
||||
XCX3MAHelper *x3maHelper;
|
||||
|
||||
//
|
||||
// X3VWAP ...
|
||||
X3VWAPInputs x3vwapInputs;
|
||||
XCX3VWAPHelper *x3vwapHelper;
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
/**
|
||||
* Initial Required Indicators Helper ...
|
||||
*/
|
||||
void InitialHelpers()
|
||||
{
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
// Short ...
|
||||
ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
|
||||
ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
|
||||
ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
|
||||
|
||||
//
|
||||
// Long ...
|
||||
ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
|
||||
ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
|
||||
ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
|
||||
//
|
||||
xpvInputs.Default();
|
||||
|
||||
//
|
||||
xpvInputs.scMethod = scMethod;
|
||||
xpvInputs.scPeriod = scPeriod;
|
||||
xpvInputs.mcMethod = mcMethod;
|
||||
xpvInputs.mcPeriod = mcPeriod;
|
||||
xpvInputs.lcMethod = lcMethod;
|
||||
xpvInputs.lcPeriod = lcPeriod;
|
||||
xpvInputs.hcMethod = hcMethod;
|
||||
xpvInputs.hcPeriod = hcPeriod;
|
||||
|
||||
//
|
||||
xpvInputs.showPeaksAndVales = true;
|
||||
xpvInputs.showLevels = false;
|
||||
xpvInputs.showConsolidations = false;
|
||||
xpvInputs.showFibo1Levels = false;
|
||||
xpvInputs.showFibo2Levels = false;
|
||||
xpvInputs.showFibo3Levels = true;
|
||||
xpvInputs.showFibo4Levels = false;
|
||||
xpvInputs.showFibo5Levels = false;
|
||||
|
||||
//
|
||||
xpvHelper = new XCXPVHelper();
|
||||
xpvHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
xpvInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
|
||||
//
|
||||
x3maInputs.Default();
|
||||
x3maHelper = new XCX3MAHelper();
|
||||
x3maHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
x3maInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// X3VWAP ...
|
||||
|
||||
//
|
||||
x3vwapInputs.Default();
|
||||
x3vwapHelper = new XCX3VWAPHelper();
|
||||
x3vwapHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
x3vwapInputs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user