last works on implementing SMC Strategy based on POIs ...
This commit is contained in:
+193
-127
@@ -30,11 +30,6 @@
|
||||
#include "../X121SMCEA/Classes/x-121.smc.ea.panel.class.mq5"
|
||||
#include "../X121SMCEA/Strategy/x-121.smc.strategy.class.mq5"
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
#include "../Classes/x-saherelm.x-poi.class.mq5"
|
||||
XCPOI *eaPOI;
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
@@ -51,6 +46,12 @@ input group "Symbols";
|
||||
input bool eaMultiSymbol = false; // Use Multi Symbol
|
||||
input string eaSymbols = "EURUSDb,GBPUSDb,USDJPYb,USDCHFb,DowJones30,XAUUSDb"; // Trading Symbols
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
input group "Signalling";
|
||||
input bool eaAllowLong = true; // Allow Long Signals
|
||||
input bool eaAllowShort = true; // Allow Short Signals
|
||||
|
||||
//
|
||||
// Alert ...
|
||||
// Here we Provider All Requirements for
|
||||
@@ -83,6 +84,12 @@ XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
|
||||
X121CAppDialog eaMainWindow; // EA Main Dialog ...
|
||||
XCX121SMCStrategy *eaStrategies[]; // Registere Strategies in EA ...
|
||||
|
||||
//
|
||||
// Signalling Controller Conditions ...
|
||||
bool eaDisableSignalling;
|
||||
bool eaAllowLongSignalling;
|
||||
bool eaAllowShortSignalling;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
@@ -105,6 +112,10 @@ int OnInit()
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial Controller Conditions ...
|
||||
InitControllerConditions();
|
||||
|
||||
//
|
||||
// Initialize all Requirements ...
|
||||
if (!InitEA())
|
||||
@@ -171,18 +182,7 @@ void OnTick()
|
||||
UpdateGUI();
|
||||
HandleReportTime();
|
||||
UpdatePositionsState();
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
ENUM_XPOI_EVENTS states[];
|
||||
int statesCount = eaPOI.Update(states);
|
||||
if (IsValidSize(statesCount))
|
||||
{
|
||||
eaAlert.Log("POI Events Happens: " + ToString(statesCount));
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Implemetn Tick Processors Algorithm ...
|
||||
HandleStrategiesOnTick();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -271,7 +271,7 @@ void OnPositionForceClosed(
|
||||
*/
|
||||
void OnSignalRecieved(
|
||||
XSignal &signal,
|
||||
XStrategyConditions &conditions //
|
||||
X121SMCStrategyConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -425,122 +425,96 @@ bool InitEA()
|
||||
eaTrader.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
eaPOI = new XCPOI(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
eaPOI.EnableDrawPOIs();
|
||||
// eaPOI.AllowDrawSwingLows(false);
|
||||
// eaPOI.AllowDrawSwingHighs(false);
|
||||
// eaPOI.AllowDrawBullishFVGs(false);
|
||||
// eaPOI.AllowDrawBearishFVGs(false);
|
||||
// eaPOI.AllowDrawSupplyZones(false);
|
||||
// eaPOI.AllowDrawDemandZones(false);
|
||||
// eaPOI.AllowDrawMomentumBars(false);
|
||||
// eaPOI.AllowDrawSupportZones(false);
|
||||
// eaPOI.AllowDrawRejectionBars(false);
|
||||
// eaPOI.AllowDrawMarketSessions(false);
|
||||
// eaPOI.AllowDrawResistanceZones(false);
|
||||
// eaPOI.AllowDrawBullishOrderBlocks(false);
|
||||
// eaPOI.AllowDrawBearishOrderBlocks(false);
|
||||
// Symbols Parsing ...
|
||||
|
||||
//
|
||||
eaPOI.Init();
|
||||
// Parsers ...
|
||||
XSymbolParser _symbolParser;
|
||||
|
||||
// //
|
||||
// // Symbols Parsing ...
|
||||
//
|
||||
// Single Symbol ...
|
||||
if (!eaMultiSymbol)
|
||||
{
|
||||
//
|
||||
// Register Strategy ...
|
||||
|
||||
// //
|
||||
// // Parsers ...
|
||||
// XSymbolParser _symbolParser;
|
||||
//
|
||||
// Create Class Instance ...
|
||||
XCX121SMCStrategy *iX121SMCStrategy;
|
||||
iX121SMCStrategy = new XCX121SMCStrategy(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
// //
|
||||
// // Single Symbol ...
|
||||
// if (!eaMultiSymbol)
|
||||
// {
|
||||
//
|
||||
ConfigureStrategy(iX121SMCStrategy);
|
||||
RegisterStrategy(iX121SMCStrategy);
|
||||
}
|
||||
//
|
||||
// Multi Symbol ...
|
||||
else
|
||||
{
|
||||
//
|
||||
// Parse Symbols ...
|
||||
string symbols[];
|
||||
int symbolsCount = SplitContent(
|
||||
symbols,
|
||||
eaSymbols //
|
||||
);
|
||||
result = IsValidSize(symbolsCount);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// //
|
||||
// // Register Strategy ...
|
||||
// }
|
||||
// //
|
||||
// // Multi Symbol ...
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// // Parse Symbols ...
|
||||
// string symbols[];
|
||||
// int symbolsCount = SplitContent(
|
||||
// symbols,
|
||||
// eaSymbols //
|
||||
// );
|
||||
// result = IsValidSize(symbolsCount);
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Select Symbol ...
|
||||
string iSymbol = symbols[i];
|
||||
|
||||
// //
|
||||
// for (int i = 0; i < symbolsCount; i++)
|
||||
// {
|
||||
// //
|
||||
// // Select Symbol ...
|
||||
// string iSymbol = symbols[i];
|
||||
//
|
||||
// Register Strategy Based On Symbol ...
|
||||
|
||||
// //
|
||||
// // Register Strategy Based On Symbol ...
|
||||
//
|
||||
// Parse Symbol ...
|
||||
bool isEURUSD = _symbolParser.IsEURUSD(_Symbol);
|
||||
bool isGBPUSD = _symbolParser.IsGBPUSD(_Symbol);
|
||||
bool isEURGBP = _symbolParser.IsEURGBP(_Symbol);
|
||||
bool isUSDCHF = _symbolParser.IsUSDCHF(_Symbol);
|
||||
bool isEURCHF = _symbolParser.IsEURCHF(_Symbol);
|
||||
bool isUSDJPY = _symbolParser.IsUSDJPY(_Symbol);
|
||||
bool isEURJPY = _symbolParser.IsEURJPY(_Symbol);
|
||||
bool isUSDCAD = _symbolParser.IsUSDCAD(_Symbol);
|
||||
bool isEURCAD = _symbolParser.IsEURCAD(_Symbol);
|
||||
bool isAUDUSD = _symbolParser.IsAUDUSD(_Symbol);
|
||||
bool isEURAUD = _symbolParser.IsEURAUD(_Symbol);
|
||||
bool isNZDUSD = _symbolParser.IsNZDUSD(_Symbol);
|
||||
bool isEURNZD = _symbolParser.IsEURNZD(_Symbol);
|
||||
|
||||
// //
|
||||
// // Parse Symbol ...
|
||||
// bool isEURUSD = _symbolParser.IsEURUSD(_Symbol);
|
||||
// bool isGBPUSD = _symbolParser.IsGBPUSD(_Symbol);
|
||||
// bool isEURGBP = _symbolParser.IsEURGBP(_Symbol);
|
||||
// bool isUSDCHF = _symbolParser.IsUSDCHF(_Symbol);
|
||||
// bool isEURCHF = _symbolParser.IsEURCHF(_Symbol);
|
||||
// bool isUSDJPY = _symbolParser.IsUSDJPY(_Symbol);
|
||||
// bool isEURJPY = _symbolParser.IsEURJPY(_Symbol);
|
||||
// bool isUSDCAD = _symbolParser.IsUSDCAD(_Symbol);
|
||||
// bool isEURCAD = _symbolParser.IsEURCAD(_Symbol);
|
||||
// bool isAUDUSD = _symbolParser.IsAUDUSD(_Symbol);
|
||||
// bool isEURAUD = _symbolParser.IsEURAUD(_Symbol);
|
||||
// bool isNZDUSD = _symbolParser.IsNZDUSD(_Symbol);
|
||||
// bool isEURNZD = _symbolParser.IsEURNZD(_Symbol);
|
||||
//
|
||||
// Check Symbol Can Register or not ...
|
||||
bool canRegisterStrategy = true;
|
||||
|
||||
// //
|
||||
// // Check Symbol Can Register or not ...
|
||||
// bool canRegisterStrategy = true;
|
||||
//
|
||||
if (canRegisterStrategy)
|
||||
{
|
||||
//
|
||||
// Create Class Instance ...
|
||||
XCX121SMCStrategy *iX121SMCStrategy;
|
||||
iX121SMCStrategy = new XCX121SMCStrategy(
|
||||
iSymbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
// //
|
||||
// if (canRegisterStrategy)
|
||||
// {
|
||||
// //
|
||||
// // Create Class Instance ...
|
||||
// XCX121SMCStrategy *iX121SMCStrategy;
|
||||
// iX121SMCStrategy = new XCX121SMCStrategy(
|
||||
// iSymbol,
|
||||
// _Period //
|
||||
// );
|
||||
|
||||
// //
|
||||
// // Configuere Strategy ...
|
||||
// // iX121SMCStrategy.DrawImportantAreas(false);
|
||||
// // iX121SMCStrategy.AddXSignalEventHandler(OnSignalRecieved);
|
||||
|
||||
// // //
|
||||
// // // Configure Alerts ...
|
||||
// // iX121SMCStrategy.SetAlertPrefix(eaLogTag);
|
||||
// // iX121SMCStrategy.SetAlertEnableAlerts(eAEnableAlerts);
|
||||
// // iX121SMCStrategy.SetAlertLogAlerts(eALogAlerts);
|
||||
// // iX121SMCStrategy.SetAlertMailAlerts(eAMailAlerts);
|
||||
// // iX121SMCStrategy.SetAlertPushAlerts(eAPushAlerts);
|
||||
// // iX121SMCStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
|
||||
|
||||
// //
|
||||
// // Register Strategy ...
|
||||
// RegisterStrategy(iX121SMCStrategy);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Register Strategy ...
|
||||
ConfigureStrategy(iX121SMCStrategy);
|
||||
RegisterStrategy(iX121SMCStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -557,10 +531,6 @@ void DestroyEA()
|
||||
|
||||
//
|
||||
delete eaAlert;
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
delete eaPOI;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,8 +694,63 @@ void HandleReportTime()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial EA Controller Conditions ...
|
||||
*/
|
||||
void InitControllerConditions()
|
||||
{
|
||||
//
|
||||
// Signalling Conditions ...
|
||||
eaAllowLongSignalling = eaAllowLong;
|
||||
eaAllowShortSignalling = eaAllowShort;
|
||||
|
||||
//
|
||||
eaDisableSignalling = !eaAllowLongSignalling &&
|
||||
!eaAllowShortSignalling;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
* Configure Startegy ...
|
||||
*/
|
||||
void ConfigureStrategy(XCX121SMCStrategy *&strategy)
|
||||
{
|
||||
//
|
||||
if (strategy == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Alerts ...
|
||||
strategy.SetAlertPrefix(eaLogTag);
|
||||
strategy.SetAlertLogAlerts(eALogAlerts);
|
||||
strategy.SetAlertMailAlerts(eAMailAlerts);
|
||||
strategy.SetAlertPushAlerts(eAPushAlerts);
|
||||
strategy.SetAlertEnableAlerts(eAEnableAlerts);
|
||||
strategy.SetAlertTerminalAlerts(eATerminalAlerts);
|
||||
|
||||
//
|
||||
// Confiugre Signalling ...
|
||||
|
||||
//
|
||||
strategy.AllowLong(eaAllowLongSignalling);
|
||||
strategy.AllowShort(eaAllowShortSignalling);
|
||||
|
||||
//
|
||||
if (eaDisableSignalling)
|
||||
{
|
||||
strategy.Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.Enable();
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an Strategy in EA ...
|
||||
*
|
||||
@@ -749,4 +774,45 @@ void RegisterStrategy(XCX121SMCStrategy *strategy)
|
||||
eaStrategies[ArraySize(eaStrategies) - 1] = strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re Configure All Registered Strategies ...
|
||||
*/
|
||||
void ReConfigureAllStrategies()
|
||||
{
|
||||
//
|
||||
int count = ArraySize(eaStrategies);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
ConfigureStrategy(eaStrategies[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call all Registered Strategies On Tick ...
|
||||
*/
|
||||
void HandleStrategiesOnTick()
|
||||
{
|
||||
//
|
||||
int count = ArraySize(eaStrategies);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Call Tick Handler Function ...
|
||||
eaStrategies[i].HandleTick();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user