- Create a Data Collector Class;

- Add Support for Save Logs in Alert Class;
- Add Propper inputs for Handle Saving Logs in EA and Expert Class;
- remove x-trade.manager Class Data Collector and use General Developed Data Collector;
- Add Support for Reading Fles in Data Collector Class for Support Configuration Parsing;
- Remove XCBaseAlert class and add Support for get XCAlert instance reference pointer as Dependency Injection in all used classed and Refactor all Changes;
- Apply Fix some UnImplemented Event Handlers on Ea Expert Class of XCATBEA and also change Event Handler Binding to Collection Based Model;
- Test all Functionalities ...
- Apply Some Fixes on Prevent Double Saing Same Log Messages ...
This commit is contained in:
2025-06-05 05:35:47 +03:30
parent 4e941f3a65
commit e46cac2ab1
12 changed files with 2107 additions and 927 deletions
+324 -58
View File
@@ -107,12 +107,12 @@ class XCXCATBEAExpert : public XCBase
bool eaAllowSignallingBasedOnTriggerBlocksInsideOther; // Signalling Based on Trigger Blocks Seccond inputs
bool eaSecondsTriggersSLUsingFirstTriggerBlock; // Use First Trigger Block for SL of Seconds Trigger Block Signalss
bool eaApplyValidateAndFilterOnSelectInsideOthers; // Select Trigger Blocks by Applying Validations and Filterss
bool eaAllowSignallingConditions1; // Allow Market Conditions Signaller to Using Sar Starter Signals
bool eaAllowSignallingConditions2; // Allow Market Conditions Signaller to Using Trend Starter Signals
bool eaAllowSignallingConditions3; // Allow Market Conditions Signaller to Using Delta Starter Signals
bool eaAllowSignallingConditions4; // Allow Market Conditions Signaller to Using Volume Starter Signals
bool eaAllowSignallingConditions5; // Allow Market Conditions Signaller to Using Signal Bar Starter Signals
bool eaAllowSignallingConditions6; // Allow Market Conditions Signaller to Using HK Signal Bar Starter Signals
bool eaAllowSignallingConditions1; // Allow Market Conditions Signaller to Using Sar Starter Signals
bool eaAllowSignallingConditions2; // Allow Market Conditions Signaller to Using Trend Starter Signals
bool eaAllowSignallingConditions3; // Allow Market Conditions Signaller to Using Delta Starter Signals
bool eaAllowSignallingConditions4; // Allow Market Conditions Signaller to Using Volume Starter Signals
bool eaAllowSignallingConditions5; // Allow Market Conditions Signaller to Using Signal Bar Starter Signals
bool eaAllowSignallingConditions6; // Allow Market Conditions Signaller to Using HK Signal Bar Starter Signals
//
// Volume ...
@@ -144,6 +144,7 @@ class XCXCATBEAExpert : public XCBase
//
// Alert ...
bool eaEnableAlerts; // Enable Alerts
bool eaSaveAlerts; // Save Alerts
bool eaLogAlerts; // Log Alerts
bool eaMailAlerts; // Mail Alerts
bool eaPushAlerts; // Push Alerts
@@ -169,18 +170,6 @@ class XCXCATBEAExpert : public XCBase
bool eaSaveLosts; // Save Lost Conditions
bool eaSaveRestrictions; // Save Restriction Reports
//
// Trade Event Handlers ...
TOnModify OnModifyEventHandler;
TOnStopLoss OnStopLossEventHandler;
TOnForceClose OnForceCloseEventHandler;
TOnTakeProfit OnTakeProfitEventHandler;
TOnPartialClose OnPartialCloseEventHandler;
TOnDealsChanged OnDealsChangedEventHandler;
TOnOrdersChanged OnOrdersChangedEventHandler;
TOnPositionsChanged OnPositionsChangedEventHandler;
TOnTradeStateChanged OnTradeStateChangedEventHandler;
//
// Requirements ...
@@ -196,6 +185,162 @@ class XCXCATBEAExpert : public XCBase
//
// Tools / Actions / Handlers ...
//
// Trade Event Handlers ...
//
void AddOnStopLossEventHandler(TOnStopLoss handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mStopLossEventHandlers
//
);
}
//
void AddOnTakeProfitEventHandler(TOnTakeProfit handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mTakeProfitEventHandlers
//
);
}
//
void AddOnDealsChangedEventHandler(TOnDealsChanged handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mDealsChangedEventHandlers
//
);
}
//
void AddOnOrdersChangedEventHandler(TOnOrdersChanged handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mOrdersChangedEventHandlers
//
);
}
//
void AddOnModifyPositionEventHandler(TOnModify handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mOnModifyEventHandlers
//
);
}
//
void AddOnPositionsChangedEventHandler(TOnPositionsChanged handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mPositionsChangedEventHandlers
//
);
}
//
void AddOnTradeStateChangedEventHandler(TOnTradeStateChanged handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mTradeStateChangedEventHandlers
//
);
}
//
void AddOnForceClosePositionEventHandler(TOnForceClose handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mOnForceCloseEventHandlers
//
);
}
//
void AddOnPartialClosePositionEventHandler(TOnPartialClose handler)
{
//
if (handler == NULL)
{
return;
}
//
Add(
handler,
mOnPartialCloseEventHandlers
//
);
}
//
// Validators ...
@@ -239,6 +384,10 @@ class XCXCATBEAExpert : public XCBase
return result;
}
//
bool has = false;
int count = -1;
//
// Initialize Alert Handler ...
eaAlert = new XCAlert();
@@ -246,6 +395,7 @@ class XCXCATBEAExpert : public XCBase
eaAlert.SetLogAlerts(eaLogAlerts);
eaAlert.SetMailAlerts(eaMailAlerts);
eaAlert.SetPushAlerts(eaPushAlerts);
eaAlert.SetSaveAlerts(eaSaveAlerts);
eaAlert.SetEnableAlerts(eaEnableAlerts);
eaAlert.SetTerminalAlerts(eaTerminalAlerts);
@@ -275,44 +425,139 @@ class XCXCATBEAExpert : public XCBase
eaMaxAllowedPositions,
eaMaxAllowedDrawdownFactor //
);
eaTrade.AddOnStopLossEventHandler(OnStopLossEventHandler);
eaTrade.AddOnTakeProfitEventHandler(OnTakeProfitEventHandler);
eaTrade.AddOnModifyPositionEventHandler(OnModifyEventHandler);
eaTrade.AddOnDealsChangedEventHandler(OnDealsChangedEventHandler);
eaTrade.AddOnOrdersChangedEventHandler(OnOrdersChangedEventHandler);
eaTrade.AddOnForceClosePositionEventHandler(OnForceCloseEventHandler);
eaTrade.AddOnPartialClosePositionEventHandler(OnPartialCloseEventHandler);
eaTrade.AddOnPositionsChangedEventHandler(OnPositionsChangedEventHandler);
eaTrade.AddOnTradeStateChangedEventHandler(OnTradeStateChangedEventHandler);
//
// Trade Handler Attachments ...
//
// Position Modifiy Event Handlers ...
count = ArraySize(mOnModifyEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnModifyPositionEventHandler(mOnModifyEventHandlers[i]);
}
}
//
// Position Stop Loss Event Handlers ...
if (has)
{
//
count = ArraySize(mStopLossEventHandlers);
has = IsValidSize(count);
for (int i = 0; i < count; i++)
{
eaTrade.AddOnStopLossEventHandler(mStopLossEventHandlers[i]);
}
}
//
// Position Take Profit Event Handlers ...
count = ArraySize(mTakeProfitEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnTakeProfitEventHandler(mTakeProfitEventHandlers[i]);
}
}
//
// Position Force Close Event Handlers ...
count = ArraySize(mOnForceCloseEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnForceClosePositionEventHandler(mOnForceCloseEventHandlers[i]);
}
}
//
// Deals Changed Event Handlers ...
count = ArraySize(mDealsChangedEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnDealsChangedEventHandler(mDealsChangedEventHandlers[i]);
}
}
//
// Orders Changed Event Handlers ...
count = ArraySize(mOrdersChangedEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnOrdersChangedEventHandler(mOrdersChangedEventHandlers[i]);
}
}
//
// Positions Changed Event Handlers ...
count = ArraySize(mPositionsChangedEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnPositionsChangedEventHandler(mPositionsChangedEventHandlers[i]);
}
}
//
// Trade Changed Event Handlers ...
count = ArraySize(mTradeStateChangedEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnTradeStateChangedEventHandler(mTradeStateChangedEventHandlers[i]);
}
}
//
// Postion Partially Close Event Handlers ...
count = ArraySize(mOnPartialCloseEventHandlers);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
eaTrade.AddOnPartialClosePositionEventHandler(mOnPartialCloseEventHandlers[i]);
}
}
//
// Initialize Guard Handler ...
eaGuard = new XCGuard(
eaAlert,
eaTrade //
);
//
eaGuard.SetAlertPrefix(eaLogSuffix);
eaGuard.SetAlertLogAlerts(eaLogAlerts);
eaGuard.SetAlertMailAlerts(eaMailAlerts);
eaGuard.SetAlertPushAlerts(eaPushAlerts);
eaGuard.SetAlertEnableAlerts(eaEnableAlerts);
eaGuard.SetAlertTerminalAlerts(eaTerminalAlerts);
//
// Initialize Trae Manager ...
eaTradeManager = new XCXCATBEATradeManager(
eaAlert,
eaTrade //
);
//
eaTradeManager.SetAlertPrefix(eaLogSuffix);
eaTradeManager.SetAlertLogAlerts(eaLogAlerts);
eaTradeManager.SetAlertMailAlerts(eaMailAlerts);
eaTradeManager.SetAlertPushAlerts(eaPushAlerts);
eaTradeManager.SetAlertEnableAlerts(eaEnableAlerts);
eaTradeManager.SetAlertTerminalAlerts(eaTerminalAlerts);
//
eaTradeManager.SaveWins(eaSaveWins);
eaTradeManager.SaveLosts(eaSaveLosts);
@@ -804,6 +1049,7 @@ class XCXCATBEAExpert : public XCBase
*/
void HandleOnTrade()
{
eaTrade.HandleOnTrade();
}
/**
@@ -840,6 +1086,7 @@ class XCXCATBEAExpert : public XCBase
*/
void HandleOnStopLossTriggered(const XDeal &deal)
{
eaTradeManager.HandleSL(deal);
}
/**
@@ -849,6 +1096,7 @@ class XCXCATBEAExpert : public XCBase
*/
void HandleOnTakeProfitTriggered(const XDeal &deal)
{
eaTradeManager.HandleTP(deal);
}
/**
@@ -864,21 +1112,7 @@ class XCXCATBEAExpert : public XCBase
const string comment //
)
{
}
/**
* Handle Position Modified Event ...
*
* @param ticket: ulong, triggered Positions ticket ...
* @param profit: double, Position Profit ...
* @param comment: string, Comment ...
*/
void HandleOnPositionModified(
const ulong ticket,
const double profit,
const string comment //
)
{
eaTradeManager.HandleForceClose(position);
}
/**
@@ -894,6 +1128,12 @@ class XCXCATBEAExpert : public XCBase
const string comment //
)
{
//
eaTradeManager.HandlePartiallyClosed(
ticket,
profit,
comment //
);
}
/**
@@ -929,6 +1169,21 @@ class XCXCATBEAExpert : public XCBase
{
}
/**
* Handle Position Modified Event ...
*
* @param ticket: ulong, triggered Positions ticket ...
* @param profit: double, Position Profit ...
* @param comment: string, Comment ...
*/
void HandleOnPositionModified(
const ulong ticket,
const double profit,
const string comment //
)
{
}
/**
* Handle all Trades States Changed Event ...
*
@@ -1149,6 +1404,17 @@ class XCXCATBEAExpert : public XCBase
private:
//
//
TOnModify mOnModifyEventHandlers[];
TOnStopLoss mStopLossEventHandlers[];
TOnTakeProfit mTakeProfitEventHandlers[];
TOnForceClose mOnForceCloseEventHandlers[];
TOnDealsChanged mDealsChangedEventHandlers[];
TOnOrdersChanged mOrdersChangedEventHandlers[];
TOnPartialClose mOnPartialCloseEventHandlers[];
TOnPositionsChanged mPositionsChangedEventHandlers[];
TOnTradeStateChanged mTradeStateChangedEventHandlers[];
//
};
@@ -1,209 +0,0 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------------
// Name: XCXCATBEADataCollector ...
// Description: Class for XCATBEA Data Collector ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm Class for XCATBEA Data Collector"
#property strict
//
// Imports ...
#include "../../Classes/x-saherelm.base.class.mq5"
//
// Definitions ...
//
// Implementation ...
class XCXCATBEADataCollector : public XCBase
{
//
// Public ...
public:
//
// Constructors ...
XCXCATBEADataCollector()
{
}
//
// Deconstructor ...
~XCXCATBEADataCollector()
{
}
//
// Properties ...
//
string Path()
{
return mPath;
}
//
void Path(string value)
{
//
// Normalizing Collector Path ...
if (IsValid(value))
{
mPath = value;
}
else
{
mPath = "XCXCATBEADataCollector";
}
}
//
// Tools ...
//
string GetFilePath(string fileName)
{
//
string result = "";
//
result =
//
mPath + "\\" + fileName + ".x121.log"
//
;
//
return result;
}
//
int GetFileHandlerForWrite(string filePath)
{
//
int result = INVALID_HANDLE;
//
if (!IsValid(filePath))
{
return result;
}
//
result = FileOpen(
filePath,
FILE_READ | FILE_WRITE | FILE_TXT //
);
//
return result;
}
/**
* Save Specified Content into Specified File Name ...
*
* @param fileName: string, file name ...
* @param content: string, content ...
*
* @return ( bool )
*/
bool Save(
string fileName,
string content //
)
{
//
bool result = false;
//
result = IsValid(content);
if (!result)
{
return result;
}
//
//
int mHandler = GetFileHandlerForWrite(fileName);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
FileWrite(mHandler, content);
FileFlush(mHandler);
FileClose(mHandler);
//
return result;
}
/**
* Append Specified Content into Specified File Name ...
*
* @param fileName: string, file name ...
* @param content: string, content ...
*
* @return ( bool )
*/
bool Append(
string fileName,
string content //
)
{
//
bool result = false;
//
result = IsValid(content);
if (!result)
{
return result;
}
//
//
int mHandler = GetFileHandlerForWrite(fileName);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
FileSeek(mHandler, 0, SEEK_END);
FileWrite(mHandler, content);
FileFlush(mHandler);
FileClose(mHandler);
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
//
string mPath; // Base Collector Path ...
};
@@ -22,10 +22,10 @@
//
// Imports ...
#include "../../Classes/x-saherelm.x-alert.class.mq5"
#include "../../Classes/x-saherelm.x-data.collector.class.mq5"
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
#include "../../Classes/x-saherelm.x-trade.class.mq5"
#include "../../Libraries/x-saherelm.x-poi.lib.mq5"
#include "../Classes/xcatbea.x-data.collector.class.mq5"
#include "../Libraries/xcatbea.lib.mq5"
#include "../Libraries/xcatbea.signaller.lib.mq5"
@@ -1594,27 +1594,29 @@ struct XCATBEATrade
//
// Implementations ...
class XCXCATBEATradeManager : public XCBaseAlert
class XCXCATBEATradeManager : public XCBase
{
//
// Public ...
public:
//
// Props ...
XCAlert *alert;
XCTrade *trader;
bool drawSignal;
XCPOIDrawer *drawer;
XTimeTracker timeTracker;
XCXCATBEADataCollector *collector;
XCDataCollector *collector;
//
// Constructors ...
XCXCATBEATradeManager(
XCTrade *&_trader,
string _path = NULL // Base Path
XCAlert *_alert,
XCTrade *_trader //
)
{
//
alert = _alert;
trader = _trader;
drawSignal = true;
drawer = new XCPOIDrawer();
@@ -1644,15 +1646,12 @@ class XCXCATBEATradeManager : public XCBaseAlert
SaveTrades(false);
//
// Normalizing Collector Path ...
if (!IsValid(_path))
{
_path = "X121XCATBEATradeManager" + "\\" + trader.mAccount.GetCompany();
}
collector = new XCDataCollector();
//
collector = new XCXCATBEADataCollector();
collector.Path(_path);
// Setting Collector Path ...
string mPath = alert.GetPrefix() + "\\" + trader.mAccount.GetCompany();
collector.Path(mPath);
}
//
@@ -1666,8 +1665,15 @@ class XCXCATBEATradeManager : public XCBaseAlert
timeTracker.Clean();
//
ZeroMemory(alert);
ZeroMemory(trader);
//
delete drawer;
ZeroMemory(drawer);
//
delete collector;
ZeroMemory(collector);
}
@@ -2283,7 +2289,7 @@ class XCXCATBEATradeManager : public XCBaseAlert
{
//
string message = signal.GetMessage("Provided");
SendAlert(message);
alert.SendAlert(message);
}
//
@@ -2474,7 +2480,7 @@ class XCXCATBEATradeManager : public XCBaseAlert
}
//
SendAlert(message);
alert.SendAlert(message);
}
//
@@ -3183,10 +3189,10 @@ class XCXCATBEATradeManager : public XCBaseAlert
//
string message =
(IsValid(prefix)
? prefix + "\n"
? prefix + " | "
: "") +
"Account Balance: " + ToString(balance) + currency;
SendAlert(message);
alert.SendAlert(message);
}
//
@@ -3199,7 +3205,7 @@ class XCXCATBEATradeManager : public XCBaseAlert
}
//
SendAlert(message);
alert.SendAlert(message);
}
//
@@ -3595,7 +3601,7 @@ class XCXCATBEATradeManager : public XCBaseAlert
{
//
string message = iInfo.GetRestrictionDescription(restrictionsPeriod);
SendAlert(message);
alert.SendAlert(message);
}
SaveRestrictions(iInfo);
-611
View File
@@ -2678,617 +2678,6 @@ void ValidateTriggerBlockLiquidities(
// TODO: Implement Liquidity Validation ...
}
//
bool DetectSignalZone(
XCPOIDrawer *&drawer,
XCX121XCatbHelper *helper,
XCBarAnalyser *barAnalyser,
XBoxZone &signalZone,
X121XCatbConditions &conditions,
int barIndex = 0,
int loopback = 10 //
)
{
//
bool result = false;
//
// Checking Conditions ...
//
// Normalize Args ...
signalZone.Clean();
conditions.Clean();
barIndex = NormalizeInt(barIndex, 0);
loopback = NormalizeInt(loopback, 0);
//
// Validate Args ...
result = helper != NULL &&
barAnalyser != NULL;
if (!result)
{
return result;
}
//
// Reading Market Conditions ...
result = helper.GetConditions(
conditions,
barIndex,
loopback //
);
if (!result)
{
//
signalZone.Clean();
conditions.Clean();
//
return result;
}
//
int zIDX = 0;
int cIDX = zIDX + 1;
int pIDX = cIDX + 1;
int p2IDX = pIDX + 1;
int p3IDX = p2IDX + 1;
int p4IDX = p3IDX + 1;
//
double sl = 0;
double tp = 0;
double upper = 0;
double lower = 0;
datetime to = NULL;
datetime from = NULL;
string signalProvider = NULL;
//
// Checking Conditions ...
//
// Detect Bar Verifications ...
//
ENUM_X_DIRECTION iDir;
//
// Rejected ...
bool isRejected =
barAnalyser
.IsRejected(
conditions.bars[cIDX],
iDir //
);
bool isBullishRejected =
isRejected &&
IsBullish(iDir);
bool isBearishRejected =
isRejected &&
IsBearish(iDir);
//
// Engulfed ...
bool isEngulfed =
barAnalyser
.IsEngulfed(
conditions.bars[cIDX],
iDir //
);
bool isBullishEngulfed =
isEngulfed &&
IsBullish(iDir);
bool isBearishEngulfed =
isEngulfed &&
IsBearish(iDir);
//
// Momentum ...
bool isMomentum =
barAnalyser
.IsMomentum(
conditions.bars[cIDX],
iDir //
);
bool isBullishMomentum =
isMomentum &&
IsBullish(iDir);
bool isBearishMomentum =
isMomentum &&
IsBearish(iDir);
//
bool isBarBullishPressured =
isBullishRejected ||
isBullishEngulfed ||
isBullishMomentum;
//
bool isBarBearishPressured =
isBearishRejected ||
isBearishEngulfed ||
isBearishMomentum;
//
// Detect Indicator Base Start Directional Movement ...
//
// SAR ...
//
bool isSarBullishStart =
//
(
//
// Current SAR is Directional ...
conditions.isSarBullish &&
//
// Previous InDirectional Sar Exists ...
helper.lastSarBearish.IsValid() &&
//
// Current Close is Over previous Sar ...
conditions.bars[cIDX].close > helper.lastSarBearish.after &&
//
// Before Close is not Over previous Sar ...
conditions.bars[pIDX].close <= helper.lastSarBearish.after
//
)
//
;
//
bool isSarBearishStart =
//
(
//
// Current SAR is Directional ...
conditions.isSarBearish &&
//
// Previous InDirectional Sar Exists ...
helper.lastSarBullish.IsValid() &&
//
// Current Close is Under previous ...
conditions.bars[cIDX].close < helper.lastSarBullish.after &&
//
// Before Close is not Under previous ...
conditions.bars[pIDX].close >= helper.lastSarBullish.after
//
)
//
;
//
// TREND ...
//
bool isTrendBullishStart =
//
(
//
// Current Trend is Directional ...
conditions.isTrendBullish &&
//
// Previous InDirectiona; Trend Exists ...
helper.lastTrendBearish.IsValid() &&
//
// Current Close is Over previous ...
conditions.bars[cIDX].close > helper.lastTrendBearish.after &&
//
// Before close is not Over previous ...
conditions.bars[pIDX].close <= helper.lastTrendBearish.after
//
)
//
;
//
bool isTrendBearishStart =
//
(
//
// Current Trend is Directional ...
conditions.isTrendBearish &&
//
// Previous InDirectiona; Trend Exists ...
helper.lastTrendBullish.IsValid() &&
//
// Current Close is Under previous ...
conditions.bars[cIDX].close < helper.lastTrendBullish.after &&
//
// Before close is not Under previous ...
conditions.bars[pIDX].close >= helper.lastTrendBullish.after
//
)
//
;
//
// ADX ...
//
bool isADXBullishStart =
//
(
//
// ADX Value is Switched to Strong ...
conditions.adxBuffer[cIDX] > conditions.adxThreshold &&
conditions.adxBuffer[pIDX] <= conditions.adxThreshold &&
//
// ADX must Up ...
conditions.adxBuffer[cIDX] > conditions.adxBuffer[pIDX] &&
//
// ADX +DI is Bigger than -DI ...
conditions.adxpBuffer[cIDX] > conditions.adxnBuffer[cIDX] &&
//
// ADX +DI is Up ...
conditions.adxpBuffer[cIDX] > conditions.adxpBuffer[pIDX]
//
)
//
;
//
bool isADXBearishStart =
//
(
//
// ADX Value is Switched to Strong ...
conditions.adxBuffer[cIDX] > conditions.adxThreshold &&
conditions.adxBuffer[pIDX] <= conditions.adxThreshold &&
//
// ADX must Up ...
conditions.adxBuffer[cIDX] > conditions.adxBuffer[pIDX] &&
//
// ADX -DI is Bigger than +DI ...
conditions.adxnBuffer[cIDX] > conditions.adxpBuffer[cIDX] &&
//
// ADX -DI is Up ...
conditions.adxnBuffer[cIDX] > conditions.adxnBuffer[pIDX]
//
)
//
;
//
// DELTA ...
//
bool isDeltaBullishStart =
//
// Check State ...
(
//
// Delta is Up ...
conditions.deltaBuffer[cIDX] > conditions.deltaBuffer[pIDX] &&
//
// Delta Signal is Up ...
conditions.deltaSignalBuffer[cIDX] > conditions.deltaSignalBuffer[pIDX] &&
//
// Delta Crossed Over Delta Signal ...
conditions.deltaBuffer[cIDX] > conditions.deltaSignalBuffer[cIDX]
//
)
//
&&
//
// Check Last InDirectional Exists ...
helper.lastDeltaBearish.IsValid() &&
//
// Current Close is Over last ...
conditions.bars[cIDX].close > helper.lastDeltaBearish.after &&
//
// Before Close is not Over last ...
conditions.bars[pIDX].close <= helper.lastDeltaBearish.after
//
;
//
bool isDeltaBearishStart =
//
// Check State ...
(
//
// Delta is Down ...
conditions.deltaBuffer[cIDX] < conditions.deltaBuffer[pIDX] &&
//
// Delta Signal is Down ...
conditions.deltaSignalBuffer[cIDX] < conditions.deltaSignalBuffer[pIDX] &&
//
// Delta Crossed Under Delta Signal ...
conditions.deltaBuffer[cIDX] < conditions.deltaSignalBuffer[cIDX]
//
)
//
&&
//
// Check Last InDirectional Exists ...
helper.lastDeltaBullish.IsValid() &&
//
// Current Close is Under last ...
conditions.bars[cIDX].close < helper.lastDeltaBullish.after &&
//
// Before Close is not Under last ...
conditions.bars[pIDX].close >= helper.lastDeltaBullish.after
//
;
//
// VOLUME ...
//
bool isVolumeBullishStart =
//
(
//
//
// Volume is Up ...
conditions.bullishVolumeBuffer[1] > conditions.bullishVolumeBuffer[2] &&
//
// Volume Signal is Up ...
conditions.bullishVolumeSignalBuffer[1] > conditions.bullishVolumeSignalBuffer[2] &&
//
// Volume Signals Crossed Over ...
conditions.bullishVolumeSignalBuffer[1] > conditions.bearishVolumeSignalBuffer[1]
//
)
//
&&
//
// Check Last InDirectional Exists ...
helper.lastVolumeBearish.IsValid() &&
//
// Current Close is Over last ...
conditions.bars[cIDX].close > helper.lastVolumeBearish.after &&
//
// Before Close is not Over last ...
conditions.bars[pIDX].close <= helper.lastVolumeBearish.after
//
;
//
bool isVolumeBearishStart =
//
(
//
//
// Volume is Up ...
conditions.bearishVolumeBuffer[1] > conditions.bearishVolumeBuffer[2] &&
//
// Volume Signal is Up ...
conditions.bearishVolumeSignalBuffer[1] > conditions.bearishVolumeSignalBuffer[2] &&
//
// Volume Signals Crossed Over ...
conditions.bearishVolumeSignalBuffer[1] > conditions.bullishVolumeSignalBuffer[1]
//
)
//
&&
//
// Check Last InDirectional Exists ...
helper.lastVolumeBullish.IsValid() &&
//
// Current Close is Over last ...
conditions.bars[cIDX].close < helper.lastVolumeBullish.after &&
//
// Before Close is not Over last ...
conditions.bars[pIDX].close >= helper.lastVolumeBullish.after
//
;
//
// SIGNAL Bar ...
//
bool isSBarBullishStart =
//
(
//
// Check Direction ...
conditions.isSBarBullish &&
//
// Previous InDirectional Exists ...
helper.lastSignalBarBearish.IsValid() &&
//
// Current Signal Bar close over prev ...
conditions.sBarCloseBuffer[cIDX] > helper.lastSignalBarBearish.after &&
//
// Prev Signal Bar not close over prev ...
conditions.sBarCloseBuffer[pIDX] <= helper.lastSignalBarBearish.after
//
)
//
;
//
bool isSBarBearishStart =
//
(
//
// Check Direction ...
conditions.isSBarBearish &&
//
// Previous InDirectional Exists ...
helper.lastSignalBarBullish.IsValid() &&
//
// Current Signal Bar close over prev ...
conditions.sBarCloseBuffer[cIDX] < helper.lastSignalBarBullish.after &&
//
// Prev Signal Bar not close over prev ...
conditions.sBarCloseBuffer[pIDX] >= helper.lastSignalBarBullish.after
//
)
//
;
//
// HKSIGNAL Bar ...
//
bool isHKSBarBullishStart =
//
(
//
// Check Direction ...
conditions.isHKSBarBullish &&
//
// Previous InDirectional Exists ...
helper.lastHKSignalBarBearish.IsValid() &&
//
// Current Signal Bar close over prev ...
conditions.hkSBarCloseBuffer[cIDX] > helper.lastHKSignalBarBearish.after &&
//
// Prev Signal Bar not close over prev ...
conditions.hkSBarCloseBuffer[pIDX] <= helper.lastHKSignalBarBearish.after
//
)
//
;
//
bool isHKSBarBearishStart =
//
(
//
// Check Direction ...
conditions.isHKSBarBearish &&
//
// Previous InDirectional Exists ...
helper.lastHKSignalBarBullish.IsValid() &&
//
// Current Signal Bar close over prev ...
conditions.hkSBarCloseBuffer[cIDX] < helper.lastHKSignalBarBullish.after &&
//
// Prev Signal Bar not close over prev ...
conditions.hkSBarCloseBuffer[pIDX] >= helper.lastHKSignalBarBullish.after
//
)
//
;
//
// Check for Vale and Peak ...
//
bool isPeakOverLast =
//
(conditions.peakBuffer[cIDX] > conditions.peakBuffer[pIDX] &&
conditions.peakBuffer[pIDX] <= conditions.peakBuffer[p2IDX] &&
conditions.bars[cIDX].close > conditions.peakBuffer[pIDX])
//
;
//
bool isValeUnderLast =
//
(conditions.valeBuffer[cIDX] < conditions.valeBuffer[pIDX] &&
conditions.valeBuffer[pIDX] >= conditions.valeBuffer[p2IDX] &&
conditions.bars[cIDX].close < conditions.valeBuffer[pIDX])
//
;
//
// Start Different Conditions Implemntation ...
//
// Condition 1:
// ---------------------------
// Descriptions:
//
//
// ---------------------------
//
// Bullish ...
bool isCond1Bullish = false;
//
// Bearish ...
bool isCond1Bearish = false;
//
bool isCond1 =
isCond1Bullish ||
isCond1Bearish;
if (isCond1)
{
//
// Prepare Cond1 Based Requirements ...
//
to = NULL;
upper = 0;
lower = 0;
from = NULL;
//
// Provider Definition ...
signalProvider = "Cond1";
}
//
// Try to Summarize Conditions ...
//
bool isBullish =
//
isCond1Bullish
//
;
//
bool isBearish =
//
isCond1Bearish
//
;
//
// Summarize Result ...
result =
isBullish ||
isBearish;
if (result)
{
//
// Prepare Signal Zone ...
//
signalZone.to = to;
signalZone.from = from;
signalZone.upper = upper;
signalZone.lower = lower;
signalZone.type = signalProvider;
signalZone.symbol = conditions.symbol;
signalZone.period = conditions.period;
//
signalZone.dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
// Validate Signal Zone ...
result = signalZone.IsValid();
}
//
// Cleanup Resources ...
//
if (!result)
{
//
signalZone.Clean();
conditions.Clean();
}
//
return result;
}
//
// Draw Specific Trigger Block ...
bool DrawTriggerBlock(