last ...
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -495,6 +495,35 @@ public:
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
|
||||
//
|
||||
if (cheConditions.long1[pIndex] > 0 &&
|
||||
cheConditions.long2[pIndex] > 0 &&
|
||||
cheConditions.long1[pIndex] != EMPTY_VALUE &&
|
||||
cheConditions.long2[pIndex] != EMPTY_VALUE &&
|
||||
!cheConditions.isStrongBullish)
|
||||
{
|
||||
//
|
||||
cheLastLongExitTime = pBar.time;
|
||||
cheLastLongExit1 = cheConditions.long1[pIndex];
|
||||
cheLastLongExit2 = cheConditions.long2[pIndex];
|
||||
}
|
||||
|
||||
//
|
||||
if (cheConditions.short1[pIndex] > 0 &&
|
||||
cheConditions.short2[pIndex] > 0 &&
|
||||
cheConditions.short1[pIndex] != EMPTY_VALUE &&
|
||||
cheConditions.short2[pIndex] != EMPTY_VALUE &&
|
||||
!cheConditions.isStrongBearish)
|
||||
{
|
||||
//
|
||||
cheLastShortExitTime = pBar.time;
|
||||
cheLastShortExit1 = cheConditions.short1[pIndex];
|
||||
cheLastShortExit2 = cheConditions.short2[pIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// XCHM ...
|
||||
// Detect XCHMbased Conditions ...
|
||||
@@ -1807,8 +1836,8 @@ private:
|
||||
chmInputs.hcPeriod = hcPeriod;
|
||||
|
||||
//
|
||||
chmInputs.showFast = true;
|
||||
chmInputs.showSlow = true;
|
||||
chmInputs.showFast = false;
|
||||
chmInputs.showSlow = false;
|
||||
chmInputs.showCCFast = false;
|
||||
chmInputs.showCCSlow = false;
|
||||
chmInputs.showSCFast = false;
|
||||
@@ -1817,8 +1846,8 @@ private:
|
||||
chmInputs.showMCSlow = false;
|
||||
chmInputs.showLCFast = false;
|
||||
chmInputs.showLCSlow = false;
|
||||
chmInputs.showHCFast = false;
|
||||
chmInputs.showHCSlow = false;
|
||||
chmInputs.showHCFast = true;
|
||||
chmInputs.showHCSlow = true;
|
||||
|
||||
//
|
||||
chmHelper = new XSCXCHMHelper();
|
||||
@@ -2092,6 +2121,71 @@ private:
|
||||
bearishFVG.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XCHE Custom Data ...
|
||||
|
||||
//
|
||||
double cheLastLongExit1;
|
||||
double cheLastLongExit2;
|
||||
datetime cheLastLongExitTime;
|
||||
double GetMaxCHELastLong()
|
||||
{
|
||||
//
|
||||
return MathMax(
|
||||
cheLastLongExit1,
|
||||
cheLastLongExit2 //
|
||||
);
|
||||
}
|
||||
double GetMinCHELastLong()
|
||||
{
|
||||
//
|
||||
return MathMin(
|
||||
cheLastLongExit1,
|
||||
cheLastLongExit2 //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double cheLastShortExit1;
|
||||
double cheLastShortExit2;
|
||||
datetime cheLastShortExitTime;
|
||||
double GetMaxCHELastShort()
|
||||
{
|
||||
//
|
||||
return MathMax(
|
||||
cheLastShortExit1,
|
||||
cheLastShortExit2 //
|
||||
);
|
||||
}
|
||||
double GetMinCHELastShort()
|
||||
{
|
||||
//
|
||||
return MathMin(
|
||||
cheLastShortExit1,
|
||||
cheLastShortExit2 //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetMaxCHELast()
|
||||
{
|
||||
//
|
||||
return MathMax(
|
||||
GetMaxCHELastLong(),
|
||||
GetMaxCHELastShort() //
|
||||
);
|
||||
}
|
||||
double GetMinCHELast()
|
||||
{
|
||||
//
|
||||
return MathMin(
|
||||
GetMinCHELastLong(),
|
||||
GetMinCHELastShort() //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user