This commit is contained in:
2024-07-27 15:59:01 +03:30
parent c0c4714545
commit 37b9578ba1
6 changed files with 3525 additions and 1092 deletions
+38 -5
View File
@@ -43,23 +43,29 @@ double eaAllowLong = true; // Allow Long Positions
double eaAllowShort = true; // Allow Short Positions
//
int eaMaxAllowedLongs = 0; // Max Allowed Long Positions
int eaMaxAllowedShorts = 0; // Max Allowed Short Positions
int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
int eaMaxAllowedShorts = 1; // Max Allowed Short Positions
//
input double eaTPPoint = 200; // Static TP Point
input double eaTPPoint = 100; // Static TP Point
input double eaSLPoint = 100; // Static SL Point
//
bool eaIgnoreTP = false; // Ignore TP
bool eaIgnoreSL = false; // Ignore SL
//
int eaMaxAllowedSLsInDay = 2;
//
double eaR2R = 1.5; // Risk to Reward Ratio
//
// Variables ...
//
int mNumberOfSLs = 0;
//
// Bar Style nad Time Instances ...
XSCXCTHelper *mCTHelper;
@@ -73,6 +79,9 @@ XSCBaseStrategy *strategies[];
// Trader Instance Class ...
XSCTrade *eaTrader;
//
XTimeTracker eaTimeTracker;
//
// Alert Class ...
XSCAlert *eaAlert;
@@ -167,7 +176,14 @@ void OnTrade()
// On Timer ...
void OnTimer()
{
//
HandleTradeState();
//
if (eaTimeTracker.IsNewDay())
{
mNumberOfSLs = 0;
}
}
//
@@ -359,6 +375,7 @@ bool InitialEA()
eurusdXCHKMStrategy = new XSCXCHKMStrategy(
eurusdSymbol,
PERIOD_M5,
PERIOD_H1, // Analyzing Period
eaVolume,
eaR2R, // R2R ...
eaSlippage,
@@ -387,17 +404,18 @@ bool InitialEA()
xchmStrategy = new XSCXCHKMStrategy(
_Symbol,
_Period,
PERIOD_H1, // Analyzing Period
eaVolume,
eaR2R, // R2R ...
eaSlippage,
eaMagicNumber,
true, // Ignore Signal Execution
false, // Use TP SL Point
true, // Use TP SL Point
false, // Use Max
eaTPPoint, // TP
eaSLPoint, // SL
eaIgnoreTP,
false, // eaIgnoreSL,
true, // eaIgnoreSL,
eaAllowLong,
eaAllowShort,
eaMaxAllowedLongs, // Max Longs
@@ -503,6 +521,13 @@ void OnSignalRecieved(XSignal &signal)
return;
}
//
if (eaMaxAllowedSLsInDay > 0 &&
mNumberOfSLs >= eaMaxAllowedSLsInDay)
{
return;
}
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = eaTrader.ExecuteSignal(
@@ -564,13 +589,21 @@ void OnSignalRecieved(XSignal &signal)
//
void OnStopLossTriggered(const XDeal &deal)
{
//
// Finish ...
eaTradeHandler.Finish(deal);
//
if (deal.profit < 0)
{
mNumberOfSLs++;
}
}
//
void OnTakeProfitTriggered(const XDeal &deal)
{
//
// Finish ...
eaTradeHandler.Finish(deal);
}