last works on test ...

This commit is contained in:
2024-06-29 18:38:21 +03:30
parent 09c85a3794
commit a2c935eb5b
5 changed files with 3782 additions and 928 deletions
File diff suppressed because it is too large Load Diff
+304
View File
@@ -0,0 +1,304 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center XTest MQL5 Expert Advisor
// -------------------------------------------------
// Name: XTestEA
// Description: an Exper Advisor which used XTestSetup
// to Analyse Market ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////x
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XTestEA"
#property strict
//
#define ShortName "XTestEA"
//
// Imports ...
#include "../Test/x-saherelm.test.xea.mq5"
#include "../Helpers/x-saherelm.xct.helper.mq5"
#include "../Helpers/x-saherelm.xcc.helper.mq5"
//
// Inputs ...
long mMagicNumber = 78692110; // Magic Number
int mSlippage = 10; // Slippgae
//
double eaVolume = 0.01;
double eaAllowLong = true;
double eaAllowShort = true;
//
// Variables ...
XSCXTestSetupEA *mSetupEA;
XSCXCTHelper *mCTHelper;
XSCXCCHelper *mCCHelper;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitialEA())
{
return INIT_FAILED;
}
//
// Init Succeed ...
return INIT_SUCCEEDED;
}
//
// DeInitialization ...
void OnDeinit(const int reason)
{
//
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
// REASON_REMOVE 1 Program removed from a chart
// REASON_RECOMPILE 2 Program recompiled
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
// REASON_CHARTCLOSE 4 Chart closed
// REASON_PARAMETERS 5 Inputs changed by a user
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
// REASON_TEMPLATE 7 Another chart template applied
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
// REASON_CLOSE 9 Terminal closed
//
// De Initialize XSampleEA Providers ...
delete mSetupEA;
delete mCTHelper;
delete mCCHelper;
}
//
// On Tick Handler ...
void OnTick()
{
mSetupEA.OnTick();
}
//
// Custom Functions ...
//
bool ValidateInputs()
{
//
bool result = false;
//
result = true;
//
return result;
}
//
bool InitialEA()
{
//
bool result = false;
//
//
// Bar Timer ...
XCTInputs ctInputs;
ctInputs.Default();
mCTHelper = new XSCXCTHelper();
result = mCTHelper.Init(
_Symbol,
_Period,
ctInputs //
);
if (!result)
{
return result;
}
//
// Bar Styles ...
XCCInputs ccInputs;
ccInputs.Default();
mCCHelper = new XSCXCCHelper();
result = mCCHelper.Init(
_Symbol,
_Period,
ccInputs //
);
if (!result)
{
return result;
}
//
// Preparing EA Class ...
mSetupEA = new XSCXTestSetupEA(
mSlippage,
mMagicNumber //
);
//
// Configuring EA Class ...
mSetupEA.Volume(eaVolume);
mSetupEA.AllowLong(eaAllowLong);
mSetupEA.AllowShort(eaAllowShort);
//
// Configure Indicators ...
XTestInputs setupInputsDefault;
setupInputsDefault.Default();
PreConfigureStyles(setupInputsDefault);
//
// Instantiate Per Symbol ...
//
string iSymbol = _Symbol;
ENUM_TIMEFRAMES iPeriod = _Period;
//
XTestInputs iInputs;
iInputs = setupInputsDefault;
iInputs.tpPoint = 60;
iInputs.slPoint = 60;
iInputs.symbol = iSymbol;
iInputs.period = iPeriod;
iInputs.volume = eaVolume;
result = iInputs.IsValid();
if (!result)
{
return result;
}
//
XSCXTestSetup *iSetup = new XSCXTestSetup();
result = iSetup.Init(iInputs);
if (!result)
{
return result;
}
//
result = mSetupEA.AddSetup(iSetup);
//
return result;
}
//
void PreConfigureStyles(XTestInputs &inputs)
{
//
// XRL ...
inputs.rlInputs.showFast = true;
inputs.rlInputs.showSlow = true;
inputs.rlInputs.showVerifier = true;
//
// XHTD ...
inputs.htdInputs.show = false;
//
// XATSL ...
inputs.atslInputs.show = true;
//
// XSLN ...
inputs.slnInputs.show = false;
//
// XDMNT ...
inputs.dmntInputs.showBull = false;
inputs.dmntInputs.showBear = false;
//
// XSTR ...
inputs.strInputs.showTrends = false;
inputs.strInputs.fillTrends = false;
//
// XPV ...
inputs.pvInputs.showPeaksAndVales = true;
inputs.pvInputs.showLevels = false;
inputs.pvInputs.showConsolidations = false;
inputs.pvInputs.showFibo1Levels = false;
inputs.pvInputs.showFibo2Levels = false;
inputs.pvInputs.showFibo3Levels = true;
inputs.pvInputs.showFibo4Levels = false;
inputs.pvInputs.showFibo5Levels = false;
//
// XMC ...
inputs.mcInputs.showSar = false;
inputs.mcInputs.showFastMa = false;
inputs.mcInputs.showSlowMa = false;
inputs.mcInputs.showVerifierMa = false;
//
// XHK ...
inputs.hkInputs.drawHikenAshi = false;
inputs.hkInputs.drawSmoothedHikenAshi = false;
//
// XCHE ...
inputs.cheInputs.showLongExit1Line = false;
inputs.cheInputs.showShortExit1Line = false;
inputs.cheInputs.showLongExit2Line = false;
inputs.cheInputs.showShortExit2Line = false;
//
// XICH ...
inputs.ichInputs.showTenkanSen = false;
inputs.ichInputs.showKijunSen = false;
inputs.ichInputs.showKijunSenPlus = false;
inputs.ichInputs.showKijunSenNegative = false;
inputs.ichInputs.showChikouSpan = false;
inputs.ichInputs.showSenkouSpanA = false;
inputs.ichInputs.showSenkouSpanB = false;
inputs.ichInputs.showKumo = false;
//
// XMRB ...
inputs.mrbInputs.showFastMa = false;
inputs.mrbInputs.showSlowMa = false;
inputs.mrbInputs.showRibbon = false;
//
// XASCT ...
inputs.asctInputs.showLongs = false;
inputs.asctInputs.showShorts = false;
//
// XSSLC ...
inputs.sslcInputs.showUp = false;
inputs.sslcInputs.showDown = false;
//
// XHULL ...
inputs.hullInputs.showUpZone = false;
inputs.hullInputs.showDownZone = false;
}
//
+1 -1
View File
@@ -40,7 +40,7 @@ enum ENUM_XRL_BUFFERS
{ {
// //
XRL_FAST_LINE = 0, XRL_FAST_LINE = 0,
XRL_SLOW_LINE = 1, XRL_SLOW_LINE = 2,
XRL_VERIFIER_LINE = 2, XRL_VERIFIER_LINE = 2,
// //
XRL_FAST_STATE_LINE = 8, XRL_FAST_STATE_LINE = 8,
File diff suppressed because it is too large Load Diff
+354
View File
@@ -0,0 +1,354 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSCXTestSetupEA
// Description: provides implementation of XTest
// Setup EA ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// Imports ...
#include "../Test/x-saherelm.test.setup.mq5"
#include "../Classes/x-saherelm.xea.class.mq5"
//
class XSCXTestSetupEA : public XSCBaseEA
{
//
// Public ...
public:
//
// Constructors ...
XSCXTestSetupEA(
//
// XTrade Class Requirements ...
int slippage, // Specify Slippage
ulong magicNumber, // Specify Magic Number
//
// XSCTrade Event Handlers ...
TOnSignal onSignal = NULL, // On Signal Recieved Event Handler
TOnModify onModifyPosition = NULL, // On Modify Position Event Handler
TOnStopLoss onStopLossTriggered = NULL, // On StopLoass Triggered Event Handler
TOnTakeProfit onTakeProfitTriggered = NULL, // On TakeProfit Triggered Event Handler
TOnForceClose onForceClosePosition = NULL, // On Force Close Position Event Handler
TOnPartialClose onPartialClosePosition = NULL, // On Partial Close Position Event Handler
TOnDealsChanged onDealsChangedHandler = NULL, // On Deals Changed Event Handler
TOnOrdersChanged onOrdersChangedHandler = NULL, // On Orders Changed Event Handler
TOnPositionsChanged onPositionsChangedHandler = NULL, // On Positions Changed Event Handler
TOnTradeStateChanged onTradeStateChangedHandler = NULL // On Trade State Changed Event Handler
) : XSCBaseEA(slippage,
magicNumber,
onSignal,
onModifyPosition,
onStopLossTriggered,
onTakeProfitTriggered,
onForceClosePosition,
onPartialClosePosition,
onDealsChangedHandler,
onOrdersChangedHandler,
onPositionsChangedHandler,
onTradeStateChangedHandler //
)
{
//
DefaultConfig();
}
//
// Deconstructor ...
~XSCXTestSetupEA() {}
//
// Getter(s) / Setter(s) ...
//
double Volume()
{
return mVolume;
}
//
void Volume(double value)
{
//
if (value < 0.01)
{
value = 0.01;
}
//
mVolume = value;
}
//
bool AllowLong()
{
return mAllowLong;
}
//
void AllowLong(bool value)
{
mAllowLong = value;
}
//
bool AllowShort()
{
return mAllowShort;
}
//
void AllowShort(bool value)
{
mAllowShort = value;
}
//
// Add Setup ...
bool AddSetup(XSCXTestSetup *setup)
{
//
bool result = false;
//
result = setup != NULL;
if (!result)
{
return result;
}
//
Add(
setup,
setups //
);
//
return result;
}
//
// Overrides ...
//
// Customize Token ...
string GetToken() override
{
return GetSpecificToken(this);
}
//
string GetTag() override
{
return this.GetToken();
}
//
// Check Provider for any Guards ...
bool CheckForGuard(XGuard &guards[]) override
{
//
bool result = false;
//
return result;
}
//
// Request Fro Signals ...
int RequestForSignal(
XSignal &signals[] // Holds Signals ...
) override
{
//
int result = 0;
//
int count = CountSetups();
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XTestConditions iConditions;
bool iHasConditions = setups[i].GetConditions(
iConditions,
0,
5 //
);
if (!iHasConditions)
{
continue;
}
//
// Check iConditions Signal is Valid or not ...
bool hasSignal = iConditions.signal.IsValid();
if (!hasSignal)
{
continue;
}
//
bool isLong = IsLong(iConditions.signal.type);
//
// TODO: Implement Management ...
//
AddRef(
iConditions.signal,
signals //
);
}
//
result = ArraySize(signals);
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
//
bool mVolume;
bool mAllowLong;
bool mAllowShort;
//
void DefaultConfig()
{
//
Volume(0.01);
AllowLong(true);
AllowShort(true);
}
//
// Provider(s) ...
//
XSCXTestSetup *setups[];
//
int CountSetups()
{
return ArraySize(setups);
}
//
int FindSetupIndex(
string _symbol //
)
{
//
int result = -1;
//
if (!IsValid(_symbol))
{
return result;
}
//
int count = CountSetups();
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
bool isOwn = _symbol == setups[i].GetSymbol();
if (isOwn)
{
//
result = i;
break;
}
}
//
return result;
}
//
int FindSetupIndex(
string _symbol, //
ENUM_TIMEFRAMES _period //
)
{
//
int result = -1;
//
if (!IsValid(_symbol))
{
return result;
}
//
if (!IsValid(_period))
{
return result;
}
//
int count = CountSetups();
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
bool isOwn =
_symbol == setups[i].GetSymbol() &&
_period == setups[i].GetPeriod();
if (isOwn)
{
//
result = i;
break;
}
}
//
return result;
}
//
};
//