Files
MQL5Data/Experts/x-test.x5ea.mq5
T

181 lines
3.7 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center X5EA MQL5 Expert Advisor
// -------------------------------------------------
// Name: X5EA
// Description: an Exper Advisor which used RSI and MA
// 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 X5EA"
#property strict
//
#define ShortName "X5EA"
//
#include "../Libraries/x-saherelm.log.lib.mq5"
#include "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xtrade.class.mq5"
#include "../Classes/x-saherelm.x5.provider.class.mq5"
//
// Inputs ...
long x5EAMagicNumber = 78692110; // Magic Number
int x5EASlippage = 10; // Slippgae
//
double x5EAVolume = 0.01;
//
// Vars ...
string x5EASymbol;
ENUM_TIMEFRAMES x5EAPeriod;
//
MqlTick x5EATick;
//
// X5Provider ...
XSignal signal;
X5ProviderInputs x5Inputs;
XSCX5Provider *x5Provider;
X5MarketConditions conditions;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
if (x5EASymbol == NULL || StringLen(x5EASymbol) <= 0)
{
x5EASymbol = _Symbol;
}
//
if (x5EAPeriod == NULL)
{
x5EAPeriod = _Period;
}
//
// Validate Inputs ...
if (!X5EAValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
logTag = ShortName;
drawPrefix = ShortName;
//
// Set Default and Validate X5Provider Inputs ...
x5Inputs.Default();
if (!x5Inputs.IsValid())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Init X5Provider Class ...
x5Provider = new XSCX5Provider(
x5EASymbol,
x5EAPeriod
//
);
if (!x5Provider.Init(x5Inputs))
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Enable Required Signallers and Types ...
x5Provider.SetSignalTypeState(
POSITION_TYPE_BUY,
true);
x5Provider.SetSignalTypeState(
POSITION_TYPE_SELL,
true);
//
ENUM_X5_SIGNAL_PROVIDERS providers[];
GetAllX5SignalProviders(providers);
x5Provider.SetSignalProviderStates(providers, true);
//
// 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 X5EA Providers ...
}
//
// On Tick Handler ...
void OnTick()
{
//
// Reading Tick ...
if (!SymbolInfoTick(x5EASymbol, x5EATick))
{
return;
}
//
signal.Clean();
conditions.Clear();
x5Provider.HasSignal(1, signal, conditions);
}
//
// Custom Functions ...
//
// Validate Variables nd Inputs ...
bool X5EAValidateInputs()
{
//
bool result = false;
//
result =
//
x5EASlippage > 0 &&
x5EAMagicNumber > 0
//
;
//
return result;
}