last works ...

This commit is contained in:
2024-06-11 18:54:39 +03:30
parent 53cfae7f99
commit 79b12c390d
5 changed files with 1443 additions and 134 deletions
+58 -131
View File
@@ -90,109 +90,14 @@ void OnDeinit(const int reason)
//
// De Initialize XSampleEA Providers ...
//
delete mSetup;
//
delete mAlert;
delete mTrader;
delete mEA;
}
//
// On Tick Handler ...
void OnTick()
{
//
if (!xBarTracker.CanProcessBar())
{
return;
}
//
// Get Consitions and Validate it ...
X121SetupConditions conditions;
bool hasConditions = mSetup.GetConditions(
conditions //
);
if (!hasConditions)
{
return;
}
//
string separator = "\n";
//
// Retrieve Scores ...
double bullishScore = 0;
double bearishScore = 0;
conditions.GenerateScore(
bullishScore,
bearishScore //
);
//
// Create Score Summary for Commenting on Chart ...
string scoreSummary =
//
"Scores:" + separator +
"----------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
Comment(scoreSummary);
//
// Check Conditions has Signal or not ...
int pusher = 0;
XSignal signal;
bool hasSignal = mSignalGenerator
.HasSignal(
conditions,
signal,
pusher,
eaAllowLong,
eaAllowShort,
eaVolume,
0, // SL Point ...
30 // TP Point ...
);
if (!hasSignal)
{
return;
}
//
// Since we have a Signal in current Bar, ignore other ticks and
// waits for Next Bar ...
xBarTracker.Waits();
//
// Generate Condition Summary for Logging ...
string summary = conditions.GenerateSummary(false, true, false);
//
Print(summary);
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
int isExecuted = mTrader.ExecuteSignal(
signal,
state //
);
if (isExecuted)
{
//
string message = "Signal Executed Successfully ...";
//
mAlert.Alert(message);
}
mEA.OnTick();
}
//
@@ -207,49 +112,71 @@ bool InitialEA()
//
TesterHideIndicators(true);
//
SetLogAlerts(true);
SetPrefix(ShortName);
SetEnableAlerts(true);
SetPushAlerts(false);
SetMailAlerts(false);
SetTerminalAlerts(false);
//
result = IsValid(eaSymbols);
if (!result)
{
return result;
}
//
mTrader = new XSCTrade(
string symbols[];
int symbolsCount = SplitContent(
symbols,
eaSymbols //
);
result = symbolsCount > 0;
if (!result)
{
return result;
}
//
mEA = new XSCX121SetupEA(
eaSlippage,
eaMagicNumber,
0,
0,
0 //
eaMagicNumber //
);
//
result = xBarTracker.Init(
_Symbol,
_Period //
);
if (!result)
{
return result;
}
// Allow Signals ...
mEA.AllowLong(true);
mEA.AllowShort(true);
//
X121SetupInputs x121Inputs;
x121Inputs.symbol = _Symbol;
x121Inputs.period = _Period;
result = x121Inputs.Init();
if (!result)
mEA.SetAlertPrefix(ShortName);
//
X121SetupInputs setupInputsDefault;
setupInputsDefault.Default();
//
// Prepare Providers and Add them into mX121EA class ...
for (int i = 0; i < symbolsCount; i++)
{
return result;
}
mSetup = new XSCX121Setup();
result = mSetup.Init(
x121Inputs //
);
if (!result)
{
return result;
//
// Requirements ...
string iSymbol = symbols[i];
ENUM_TIMEFRAMES iHostPeriod = _Period;
//
XSCX121SetupCycles *iSetupCycle;
iSetupCycle = new XSCX121SetupCycles();
result = iSetupCycle.Init(
setupInputsDefault,
iSymbol,
iHostPeriod //
);
if (!result)
{
break;
}
//
result = mEA.AddSetup(iSetupCycle);
if (!result)
{
break;
}
}
//