This commit is contained in:
2024-07-26 00:14:36 +03:30
parent 0ad2770634
commit 35d814fc9c
2 changed files with 129 additions and 11 deletions
+31 -7
View File
@@ -43,8 +43,8 @@ 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
@@ -55,7 +55,7 @@ bool eaIgnoreTP = false; // Ignore TP
bool eaIgnoreSL = false; // Ignore SL
//
double eaR2R = 2; // Risk to Reward Ratio
double eaR2R = 1.5; // Risk to Reward Ratio
//
// Variables ...
@@ -243,8 +243,8 @@ bool InitialEA()
// Initialize Trade Handler ...
eaTradeHandler = new XSCXTradeHandler(eaTrader);
eaTradeHandler.SetAlertPrefix(ShortName + "> TradeHandler");
eaTradeHandler.SaveTrades(true);
eaTradeHandler.SaveSignals(true);
eaTradeHandler.SaveTrades(false);
eaTradeHandler.SaveSignals(false);
//
// Configure Hedging ...
@@ -359,7 +359,7 @@ bool InitialEA()
eurusdSymbol,
PERIOD_M5,
eaVolume,
1, // eaR2R, // R2R ...
eaR2R, // R2R ...
eaSlippage,
magicNumber,
true, // Ignore Signal Execution
@@ -368,7 +368,7 @@ bool InitialEA()
eaTPPoint, // TP
eaSLPoint, // SL
eaIgnoreTP,
eaIgnoreSL,
false, // eaIgnoreSL,
eaAllowLong,
eaAllowShort,
eaMaxAllowedLongs, // Max Longs
@@ -469,6 +469,30 @@ void HandleTradeState()
// Analyzing ...
void OnSignalRecieved(XSignal &signal)
{
//
if (eaMaxAllowedLongs > 0 || eaMaxAllowedShorts > 0)
{
//
XPosition longs[];
XPosition shorts[];
eaTrader.GetPositions(
longs,
shorts,
signal.symbol //
);
//
int longsCount = ArraySize(longs);
int shortsCount = ArraySize(shorts);
//
if ((eaMaxAllowedLongs > 0 && longsCount >= eaMaxAllowedLongs) ||
(eaMaxAllowedShorts > 0 && shortsCount >= eaMaxAllowedShorts))
{
return;
}
}
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = eaTrader.ExecuteSignal(