last works ...

adding some tools to ch helper classes ...
This commit is contained in:
2024-07-26 03:36:40 +03:30
parent 35d814fc9c
commit fc9bca9c37
6 changed files with 1878 additions and 77 deletions
+41 -31
View File
@@ -43,8 +43,8 @@ double eaAllowLong = true; // Allow Long Positions
double eaAllowShort = true; // Allow Short Positions
//
int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
int eaMaxAllowedShorts = 1; // Max Allowed Short Positions
int eaMaxAllowedLongs = 0; // Max Allowed Long Positions
int eaMaxAllowedShorts = 0; // Max Allowed Short Positions
//
input double eaTPPoint = 200; // Static TP Point
@@ -250,13 +250,14 @@ bool InitialEA()
// Configure Hedging ...
eaTradeHandler.AllowHedging(false);
eaTradeHandler.HedgeVolumeFactor(eaVolume);
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.2);
eaTradeHandler.OnlyHedgeSupportedPositions(false);
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.3);
//
// Configure Trailing ...
eaTradeHandler.AllowTrailStops(false);
eaTradeHandler.TrailStepInPoint(25);
eaTradeHandler.TrailStartInPoint(50);
eaTradeHandler.TrailStepInPoint(10);
eaTradeHandler.TrailStartInPoint(20);
eaTradeHandler.IgnoreTPOnTrail(true);
eaTradeHandler.TrailBasedOnProfit(true);
@@ -267,7 +268,7 @@ bool InitialEA()
bool drawAreas = false;
//
bool useEURUSD = true;
bool useEURUSD = false;
bool useUSDCHF = false;
bool useUSDJPY = false;
bool useGBPUSD = false;
@@ -276,7 +277,7 @@ bool InitialEA()
//
bool useXTest = false;
bool useXDTD = false;
bool useXCHKM = true;
bool useXCHKM = false;
//
// EURUSD ...
@@ -382,30 +383,30 @@ bool InitialEA()
}
//
// XSCXDTDStrategy *xTDTStrategy;
// xTDTStrategy = new XSCXDTDStrategy(
// _Symbol,
// _Period,
// eaVolume,
// eaR2R, // R2R ...
// eaSlippage,
// eaMagicNumber,
// true, // Ignore Signal Execution
// true, // Use TP SL Point
// false, // Use Max
// eaTPPoint, // TP
// eaSLPoint, // SL
// eaIgnoreTP,
// eaIgnoreSL,
// eaAllowLong,
// eaAllowShort,
// eaMaxAllowedLongs, // Max Longs
// eaMaxAllowedShorts // Max Shorts
// );
// xTDTStrategy.SetAlertLogAlerts(true);
// xTDTStrategy.SetAlertEnableAlerts(true);
// xTDTStrategy.AddSignalEventHandler(OnSignalRecieved);
// RegisterStrategy(xTDTStrategy);
XSCXCHKMStrategy *xchmStrategy;
xchmStrategy = new XSCXCHKMStrategy(
_Symbol,
_Period,
eaVolume,
eaR2R, // R2R ...
eaSlippage,
eaMagicNumber,
true, // Ignore Signal Execution
false, // Use TP SL Point
false, // Use Max
eaTPPoint, // TP
eaSLPoint, // SL
eaIgnoreTP,
false, // eaIgnoreSL,
eaAllowLong,
eaAllowShort,
eaMaxAllowedLongs, // Max Longs
eaMaxAllowedShorts // Max Shorts
);
xchmStrategy.SetAlertLogAlerts(true);
xchmStrategy.SetAlertEnableAlerts(true);
xchmStrategy.AddSignalEventHandler(OnSignalRecieved);
RegisterStrategy(xchmStrategy);
//
return result;
@@ -470,6 +471,7 @@ void HandleTradeState()
void OnSignalRecieved(XSignal &signal)
{
//
// Check Max Allowed ...
if (eaMaxAllowedLongs > 0 || eaMaxAllowedShorts > 0)
{
//
@@ -493,6 +495,14 @@ void OnSignalRecieved(XSignal &signal)
}
}
//
// Check Signal Can Execute or not ...
bool canExecute = eaTradeHandler.CanExecute(signal);
if (!canExecute)
{
return;
}
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = eaTrader.ExecuteSignal(