Complete XPOi MomentumBar ...

This commit is contained in:
2024-10-19 17:25:28 +03:30
parent 41130e1872
commit 474dabbeb6
4 changed files with 3964 additions and 9 deletions
File diff suppressed because it is too large Load Diff
+178 -7
View File
@@ -28,6 +28,12 @@
#include "../Helpers/x-saherelm.xcc.helper.mq5"
#include "../Helpers/x-saherelm.xct.helper.mq5"
#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 ...
@@ -39,6 +45,12 @@ input long eaMagicNumber = 78692110; // Magic Number
input int eaSlippage = 10; // Slippgae
input string eaLogSuffix = ""; // Log Suffix
//
// Symbols ...
input group "Symbols";
input bool eaMultiSymbol = false; // Use Multi Symbol
input string eaSymbols = "EURUSDb,GBPUSDb,USDJPYb,USDCHFb,DowJones30,XAUUSDb"; // Trading Symbols
//
// Alert ...
// Here we Provider All Requirements for
@@ -62,13 +74,14 @@ input bool eaReportNewHours = false; // Report New Hours
// Define Local Variables ...
//
string eaLogTag; // EA Log Prefix ...
XSCAlert *eaAlert; // Alert Provider for Expert Adviser ...
XSCTrade *eaTrader; // Trader of Expert Adviser ...
XTimeTracker eaTimeTracker; // Time Tracker for Providing Reports ...
XSCXCTHelper *eaCTHelper; // Bar Timer Indicator Helper class ...
XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
X121CAppDialog eaMainWindow; // EA Main Dialog ...
string eaLogTag; // EA Log Prefix ...
XSCAlert *eaAlert; // Alert Provider for Expert Adviser ...
XSCTrade *eaTrader; // Trader of Expert Adviser ...
XTimeTracker eaTimeTracker; // Time Tracker for Providing Reports ...
XSCXCTHelper *eaCTHelper; // Bar Timer Indicator Helper class ...
XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
X121CAppDialog eaMainWindow; // EA Main Dialog ...
XCX121SMCStrategy *eaStrategies[]; // Registere Strategies in EA ...
//
// Event Handlers ...
@@ -159,6 +172,15 @@ void OnTick()
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 ...
}
@@ -241,6 +263,21 @@ void OnPositionForceClosed(
HandleReportBalance();
}
/**
* Do What we Want by Specific Signal ...
*
* @param signal: XSignal instance ...
* @param conditions: XStrategyConditions instance ...
*/
void OnSignalRecieved(
XSignal &signal,
XStrategyConditions &conditions //
)
{
//
// TODO: Implement this ...
}
//
// Custom Functions ...
@@ -387,6 +424,111 @@ bool InitEA()
eaTrader.AddOnTakeProfitEventHandler(OnTakeProfitTriggered);
eaTrader.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
//
// TEST ...
eaPOI = new XCPOI(
_Symbol,
_Period //
);
eaPOI.EnableDrawPOIs();
eaPOI.AllowDrawSwingHighs(false);
eaPOI.AllowDrawSwingLows(false);
eaPOI.Init();
// //
// // Symbols Parsing ...
// //
// // Parsers ...
// XSymbolParser _symbolParser;
// //
// // Single Symbol ...
// if (!eaMultiSymbol)
// {
// //
// // 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];
// //
// // 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);
// //
// // Check Symbol Can Register or not ...
// bool canRegisterStrategy = true;
// //
// 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);
// }
// }
// }
//
return result;
}
@@ -402,6 +544,10 @@ void DestroyEA()
//
delete eaAlert;
//
// TEST ...
delete eaPOI;
}
/**
@@ -566,3 +712,28 @@ void HandleReportTime()
}
//
/**
* Register an Strategy in EA ...
*
* @param strategy: XCX121SMCStrategy instance ...
*/
void RegisterStrategy(XCX121SMCStrategy *strategy)
{
//
if (strategy == NULL)
{
return;
}
//
ArrayResize(
eaStrategies,
ArraySize(eaStrategies) + 1 //
);
//
eaStrategies[ArraySize(eaStrategies) - 1] = strategy;
}
//
+157 -2
View File
@@ -1130,6 +1130,44 @@ struct XOHCL
return result;
}
//
bool GetNextBar(XOHCL &bar)
{
//
bool result = false;
//
result = IsValid();
if (!result)
{
return result;
}
//
int idx = Index();
result = idx > 0;
if (!result)
{
return result;
}
//
result = bar.Init(
this.symbol,
this.period,
idx - 1 //
);
//
if (!result)
{
bar.Clean();
}
//
return result;
}
//
bool GetPreviousBar(XOHCL &bar)
{
@@ -1196,7 +1234,7 @@ struct XOHCL
//
result =
IsStrong() && IsBullish();
IsStrong(percent) && IsBullish();
//
return result;
@@ -1212,7 +1250,7 @@ struct XOHCL
//
result =
IsStrong() && IsBearish();
IsStrong(percent) && IsBearish();
//
return result;
@@ -2822,6 +2860,57 @@ struct XOHCL
return result;
}
//
// Find Simple 3 Candle Based Swing High ...
bool IsSimpleSwingHigh(double thresholdInPoint = 1)
{
//
bool result = false;
//
int index = Index();
result = index > 0;
if (!result)
{
return result;
}
//
XOHCL nextBar;
result = GetNextBar(nextBar);
if (!result)
{
return result;
}
//
XOHCL prevBar;
result = GetPreviousBar(prevBar);
if (!result)
{
return result;
}
//
double point = GetPoints(symbol);
double requiredOffset = point * thresholdInPoint;
//
result =
high > nextBar.high &&
high > prevBar.high &&
(thresholdInPoint <= 0
? true
: MathAbs(
MathMax(
nextBar.high,
prevBar.high) -
high) >= requiredOffset);
//
return result;
}
//
// Find Last Swing High ...
bool FindLastSwingHigh(XOHCL &swing)
@@ -2947,6 +3036,57 @@ struct XOHCL
return result;
}
//
// Find Simple 3 Candle Based Swing Low ...
bool IsSimpleSwingLow(double thresholdInPoint = 1)
{
//
bool result = false;
//
int index = Index();
result = index > 0;
if (!result)
{
return result;
}
//
XOHCL nextBar;
result = GetNextBar(nextBar);
if (!result)
{
return result;
}
//
XOHCL prevBar;
result = GetPreviousBar(prevBar);
if (!result)
{
return result;
}
//
double point = GetPoints(symbol);
double requiredOffset = point * thresholdInPoint;
//
result =
low < nextBar.low &&
low < prevBar.low &&
(thresholdInPoint <= 0
? true
: MathAbs(
MathMax(
nextBar.low,
prevBar.low) -
low) >= requiredOffset);
//
return result;
}
//
// Find Last Swing Low ...
bool FindLastSwingLow(XOHCL &swing)
@@ -4147,6 +4287,21 @@ struct XOHCL
//
// Other ...
string GetTag(string prefix)
{
//
string result = NULL;
//
result =
(IsValid(prefix)
? prefix + "_"
: "") +
"XOHCL_" + symbol + "_" + ToString(period) + "_" + ToFormatString(time);
//
return result;
}
//
// Convert to String Representation ...
File diff suppressed because it is too large Load Diff