- 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:
@@ -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[];
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user