last works on XBackTester and Complete it ...

This commit is contained in:
2025-09-16 00:44:27 +03:30
parent 53898b2e4e
commit 011a82bf1e
5 changed files with 882 additions and 37 deletions
+8
View File
@@ -121,6 +121,14 @@ int OnInit()
eaExpert.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
eaExpert.AddOnPartialClosePositionEventHandler(OnPositionPartialClosed);
//
// Configure Other Requirements ...
// eaExpert.volume = 0;
// eaExpert.riskInPoint = 0;
// eaExpert.allowedTPSLStep = 0;
// eaExpert.riskToRewardRatio = 0;
// eaExpert.minAllowedRiskInPoint = 0;
//
// Try to Initialize eaExpert ...
bool isInited = eaExpert.HandleOnInit();
+137 -1
View File
@@ -50,6 +50,64 @@ input bool eaMailAlerts = false; // Mail Alerts
input bool eaPushAlerts = false; // Push Alerts
input bool eaTerminalAlerts = false; // Terminal Alerts
//
// Indicator Inputs ...
//
input group "Calculation";
//
// Short ...
input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Short Period
input ENUM_TIMEFRAMES scPeriod = NULL; // Short Period
//
// Medium ...
input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Medium Period
input ENUM_TIMEFRAMES mcPeriod = NULL; // Medium Period
//
// Long ...
input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Long Period
input ENUM_TIMEFRAMES lcPeriod = NULL; // Long Period
//
// Hind ...
input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Hind Period
input ENUM_TIMEFRAMES hcPeriod = NULL; // Hind Period
//
// PV ...
input ENUM_SERIESMODE upperMode = MODE_HIGH; // Peak Method
input ENUM_SERIESMODE lowerMode = MODE_LOW; // Vale Method
//
// Others ...
input ENUM_X_FIBO_LEVELS upperZoneLevel = X_FIBO_LEVEL_618; // Upper Zone Level
input ENUM_X_FIBO_LEVELS lowerZoneLevel = X_FIBO_LEVEL_382; // Lower Zone Level
input double sarStep = 0.02; // SAR Step
input double sarMax = 0.2; // SAR Maximum
input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
input int maFastLength = 7; // Fast MA Length
input int maSlowLength = 20; // Slow MA Length
//
// Presentation ...
input group "Presentation";
input bool showPV = true; // Show PV
input bool showSAR = true; // Show Sar
input bool showMAFast = true; // Show MA Fast
input bool showMASlow = true; // Show MA Slow
input bool showFiboZone = false; // Show Fibo Zone
//
input int startCalculationForLastBars = 1500; // Calculate Last n Bars
//
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
input int peakArrowCode = 159; // Peaks Arrow Code
input int valeArrowCode = 159; // Vales Arrow Code
//
// Define Local Variables ...
@@ -57,6 +115,9 @@ input bool eaTerminalAlerts = false; // Terminal Alerts
string eaLogTag; // EA Log Prefix ...
XCBackTesterEA *eaExpert; // EA Expert ...
//
int eaHandler = INVALID_HANDLE; // Indicator Handler ...
//
// Define Indicators Here ...
@@ -125,6 +186,14 @@ int OnInit()
eaExpert.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
eaExpert.AddOnPartialClosePositionEventHandler(OnPositionPartialClosed);
//
// Configure Other Requirements ...
eaExpert.volume = 0.01;
eaExpert.riskInPoint = 200;
eaExpert.allowedTPSLStep = 10;
eaExpert.riskToRewardRatio = 2;
eaExpert.minAllowedRiskInPoint = 20;
//
// Try to Initialize eaExpert ...
bool isInited = eaExpert.HandleOnInit();
@@ -135,6 +204,51 @@ int OnInit()
return INIT_FAILED;
}
//
// Initial Indicator Handler ...
eaHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xom1",
"", // Calculation ...
scMethod,
scPeriod,
mcMethod,
mcPeriod,
lcMethod,
lcPeriod,
hcMethod,
hcPeriod,
upperMode,
lowerMode,
upperZoneLevel,
lowerZoneLevel,
sarStep,
sarMax,
maMethod,
maAppliedTo,
maFastLength,
maSlowLength,
"", // Presentation ...
showPV,
showSAR,
showMAFast,
showMASlow,
showFiboZone,
startCalculationForLastBars,
sarArrowCode,
peakArrowCode,
valeArrowCode
//
);
isInited = eaHandler != INVALID_HANDLE;
if (!isInited)
{
//
Print(ShortName, ": Initialization Failed ...");
return INIT_FAILED;
}
//
Print(ShortName, ": Initialized Successfully ...");
return INIT_SUCCEEDED;
@@ -160,6 +274,10 @@ void OnDeinit(const int reason)
// Destroy Timer ...
eaExpert.HandleOnDeInit();
//
// De Init Indicator ...
IndicatorRelease(eaHandler);
//
delete eaExpert;
ZeroMemory(eaExpert);
@@ -218,7 +336,25 @@ bool ValidateInputs()
bool isCommonValid = (
//
eaSlippage > 0 &&
eaMagicNumber > 0
eaMagicNumber > 0 &&
//
// Indicator Inputs ...
//
// MA ...
maFastLength >= 2 &&
maSlowLength >= 2 &&
maSlowLength > maFastLength &&
//
// SAR ...
sarMax > 0 &&
sarStep > 0 &&
sarMax > sarStep &&
//
// CYCLES ...
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
);
if (!isCommonValid)