last ...
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,953 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center X121EA MQL5 Expert Advisor
|
||||
// -------------------------------------------------
|
||||
// Name: X121EA
|
||||
// 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 X121EA"
|
||||
#property strict
|
||||
|
||||
//
|
||||
#define ShortName "X121EA"
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.x121.xea.class.mq5"
|
||||
|
||||
//
|
||||
// "EURUSDb,USDCHFb,USDJPYb,XAUUSDb"
|
||||
// "EURUSDb,USDCHFb,USDJPYb,GBPUSDb,XAUUSDb,AUDUSDb,USDCADb,NZDUSDb"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
long x121EAMagicNumber = 78692110; // Magic Number
|
||||
int x121EASlippage = 10; // Slippgae
|
||||
string x121EASymbols = "EURUSDb,USDCHFb,USDJPYb,GBPUSDb"; // Symbols
|
||||
//
|
||||
bool x121EAAllowLong = true; // Allow Long Trades
|
||||
bool x121EAAllowShort = true; // Allow Short Trades
|
||||
int x121EAManageInterval = 0; // Manager Check Intervals Seconds
|
||||
int x121EAMaxAllowedPositions = 5; // Max Allowed Positions
|
||||
double x121EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades
|
||||
double x121EAMinProfitPerTrade = 3; // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
double x121EAMinProfitPerVolumeFactor = 0.01; // Min Volume Factor for Calculating Profit (Hedge)
|
||||
double x121EAMaxAllowedDrawdownFactor = 0.002; // Max Allowed Drawdown Factor
|
||||
//
|
||||
double x121EAVolume = 0.01;
|
||||
|
||||
//
|
||||
// Vars ...
|
||||
string x121EASymbol;
|
||||
ENUM_TIMEFRAMES x121EAPeriod;
|
||||
|
||||
//
|
||||
MqlTick x121EATick;
|
||||
|
||||
//
|
||||
// X121EA ...
|
||||
XSCX121EA *mX121EA;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
if (x121EASymbol == NULL || StringLen(x121EASymbol) <= 0)
|
||||
{
|
||||
x121EASymbol = _Symbol;
|
||||
}
|
||||
|
||||
//
|
||||
if (x121EAPeriod == NULL)
|
||||
{
|
||||
x121EAPeriod = _Period;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!X121EAValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial EA ...
|
||||
if (!InitialEA())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// TesterHideIndicators(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 X121EA Providers ...
|
||||
}
|
||||
|
||||
//
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
// Reading Tick ...
|
||||
if (!SymbolInfoTick(x121EASymbol, x121EATick))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
mX121EA.OnTick();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
// Validate Variables nd Inputs ...
|
||||
bool X121EAValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
x121EASlippage > 0 &&
|
||||
x121EAMagicNumber > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Specific Providers ...
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Here We Have to Initial 4 instance of X5Provider ...
|
||||
// - EURUSD/M5;
|
||||
// - USDCHF/M5;
|
||||
// - USDJPY/M5;
|
||||
// - XAUUSD/M5;
|
||||
|
||||
//
|
||||
result = IsValid(x121EASymbols);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbols[];
|
||||
int symbolsCount = SplitContent(
|
||||
symbols,
|
||||
x121EASymbols);
|
||||
result = symbolsCount > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Signallers ...
|
||||
ENUM_X121_SIGNAL_PROVIDERS signallers[];
|
||||
Add(X786, signallers);
|
||||
Add(X110, signallers);
|
||||
Add(X121, signallers);
|
||||
Add(X128, signallers);
|
||||
Add(X92, signallers);
|
||||
// GetAllX121SignalProviders(signallers);
|
||||
|
||||
//
|
||||
// Instantiate X121EA Class ...
|
||||
mX121EA = new XSCX121EA(
|
||||
x121EASlippage, // Slippgae
|
||||
x121EAMagicNumber, // Magic Number
|
||||
x121EAManageInterval, // Manager Check Intervals Seconds
|
||||
x121EAMaxAllowedSpread, // Max Allowed Spred for Opening Trades
|
||||
x121EAMaxAllowedPositions, // Max Allowed Positions
|
||||
x121EAMaxAllowedDrawdownFactor, // Max Allowed Drawdown Factor
|
||||
x121EAVolume, // Static Volume for Positions
|
||||
x121EAAllowLong, // Allow Long Trades
|
||||
x121EAAllowShort, // Allow Short Trades
|
||||
x121EAMinProfitPerTrade, // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
x121EAMinProfitPerVolumeFactor // Min Volume Factor for Calculating Profit (Hedge)
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Providers and Add them into mX121EA class ...
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Requirements ...
|
||||
string iSymbol = symbols[i];
|
||||
ENUM_TIMEFRAMES iPeriod = PERIOD_M5;
|
||||
|
||||
//
|
||||
// Define Structure ...
|
||||
X121ProviderDescriptor iDescriptor;
|
||||
|
||||
//
|
||||
iDescriptor.symbol = iSymbol;
|
||||
iDescriptor.period = iPeriod;
|
||||
iDescriptor.staticVolume = x121EAVolume;
|
||||
iDescriptor.allowLong = x121EAAllowLong;
|
||||
iDescriptor.allowShort = x121EAAllowShort;
|
||||
Copy(
|
||||
signallers,
|
||||
iDescriptor.signallers);
|
||||
|
||||
//
|
||||
// Set Inputs to Default ...
|
||||
iDescriptor.inputs.Default();
|
||||
|
||||
//
|
||||
// Prepare Input Requirements ...
|
||||
|
||||
//
|
||||
iDescriptor.inputs.symbol = iSymbol;
|
||||
iDescriptor.inputs.period = iPeriod;
|
||||
|
||||
//
|
||||
ConfigureDescriptor(iDescriptor);
|
||||
|
||||
//
|
||||
// Init Inputs ...
|
||||
result = iDescriptor.inputs.Init();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool isInputsValid = iDescriptor.inputs.IsValid();
|
||||
if (!isInputsValid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
result = mX121EA.AddProvider(iDescriptor);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Configurators ...
|
||||
|
||||
//
|
||||
// Configuring Descriptors ...
|
||||
void ConfigureDescriptor(
|
||||
X121ProviderDescriptor &iDescriptor //
|
||||
)
|
||||
{
|
||||
//
|
||||
// XHK ...
|
||||
iDescriptor.inputs.hkInputs.drawHikenAshi = false;
|
||||
iDescriptor.inputs.hkInputs.drawSmoothedHikenAshi = false;
|
||||
|
||||
//
|
||||
// XMC ...
|
||||
iDescriptor.inputs.mcInputs.showFastMa = false;
|
||||
iDescriptor.inputs.mcInputs.showSlowMa = false;
|
||||
iDescriptor.inputs.mcInputs.showVerifierMa = false;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
iDescriptor.inputs.ichInputs.showKumo = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSen = false;
|
||||
iDescriptor.inputs.ichInputs.showTenkanSen = false;
|
||||
iDescriptor.inputs.ichInputs.showChikouSpan = false;
|
||||
iDescriptor.inputs.ichInputs.showSenkouSpanA = false;
|
||||
iDescriptor.inputs.ichInputs.showSenkouSpanB = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSenPlus = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSenNegative = false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
iDescriptor.inputs.cheInputs.showLongExit1Line = false;
|
||||
iDescriptor.inputs.cheInputs.showShortExit1Line = false;
|
||||
iDescriptor.inputs.cheInputs.showLongExit2Line = false;
|
||||
iDescriptor.inputs.cheInputs.showShortExit2Line = false;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
iDescriptor.inputs.pvInputs.showPeaksAndVales = true;
|
||||
iDescriptor.inputs.pvInputs.showLevels = false;
|
||||
iDescriptor.inputs.pvInputs.showConsolidations = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo1Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo2Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo3Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo4Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo5Levels = false;
|
||||
|
||||
//
|
||||
// XZG ...
|
||||
iDescriptor.inputs.zgInputs.showZigZag = true;
|
||||
iDescriptor.inputs.zgInputs.showPeaksAndVales = true;
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
iDescriptor.inputs.donInputs.showOpen = false;
|
||||
iDescriptor.inputs.donInputs.showHigh = false;
|
||||
iDescriptor.inputs.donInputs.showClose = false;
|
||||
iDescriptor.inputs.donInputs.showLow = false;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
iDescriptor.inputs.strInputs.showTrends = false;
|
||||
iDescriptor.inputs.strInputs.fillTrends = false;
|
||||
|
||||
//
|
||||
// Short MArket ...
|
||||
iDescriptor.inputs.sMarketPeriod = NULL;
|
||||
iDescriptor.inputs.sMarketMethod = X_PERIOD_AUTO;
|
||||
|
||||
//
|
||||
// Medium Market ...
|
||||
iDescriptor.inputs.mMarketPeriod = NULL;
|
||||
iDescriptor.inputs.mMarketMethod = X_PERIOD_AUTO;
|
||||
|
||||
//
|
||||
// Long Market ...
|
||||
iDescriptor.inputs.lMarketPeriod = NULL;
|
||||
iDescriptor.inputs.lMarketMethod = X_PERIOD_AUTO;
|
||||
|
||||
//
|
||||
int fontSize = 12;
|
||||
double fontAngel = 90;
|
||||
string fontName = "Arial";
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER;
|
||||
|
||||
//
|
||||
// Current Market ...
|
||||
ConfigureCurrentMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
"Current",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Short Market ...
|
||||
ConfigureShortMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.sMarketPeriod,
|
||||
iDescriptor.inputs.sMarketMethod,
|
||||
//
|
||||
"Short",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Medium Market ...
|
||||
ConfigureMediumMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.mMarketPeriod,
|
||||
iDescriptor.inputs.mMarketMethod,
|
||||
//
|
||||
"Medium",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Long Market ...
|
||||
ConfigureLongMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.lMarketPeriod,
|
||||
iDescriptor.inputs.lMarketMethod,
|
||||
//
|
||||
"Long",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Hind Market ...
|
||||
ConfigureHindMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.hMarketPeriod,
|
||||
iDescriptor.inputs.hMarketMethod,
|
||||
//
|
||||
"Hind",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Current ...
|
||||
void ConfigureCurrentMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
string prefix = "Current",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.cMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
void ConfigureShortMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Short",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Short Market ...
|
||||
iDescriptor.inputs.sMarketPeriod = period;
|
||||
iDescriptor.inputs.sMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.sMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
void ConfigureMediumMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Medium",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Medium Market ...
|
||||
iDescriptor.inputs.mMarketPeriod = period;
|
||||
iDescriptor.inputs.mMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.mMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Long ...
|
||||
void ConfigureLongMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Long",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Long Market ...
|
||||
iDescriptor.inputs.lMarketPeriod = period;
|
||||
iDescriptor.inputs.lMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.lMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
void ConfigureHindMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Hind",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Hind Market ...
|
||||
iDescriptor.inputs.hMarketPeriod = period;
|
||||
iDescriptor.inputs.hMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.hMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Market ...
|
||||
void ConfigureMarketDrawSpecs(
|
||||
X121MCycleInputs &inputs,
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string prefix = "",
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
inputs.drawLabels = drawLabels;
|
||||
inputs.drawCBar = drawCBar;
|
||||
inputs.drawPBar = drawPBar;
|
||||
inputs.drawCBarMid = drawCBarMid;
|
||||
inputs.drawPBarMid = drawPBarMid;
|
||||
inputs.cBarDrawSpecs.Default();
|
||||
inputs.pBarDrawSpecs.Default();
|
||||
|
||||
//
|
||||
if (drawCBarMid)
|
||||
{
|
||||
inputs.cBarMidDrawSpecs.clr = clrYellow;
|
||||
}
|
||||
|
||||
//
|
||||
if (drawPBarMid)
|
||||
{
|
||||
inputs.pBarMidDrawSpecs.clr = clrYellow;
|
||||
}
|
||||
|
||||
//
|
||||
if (drawLabels)
|
||||
{
|
||||
//
|
||||
string cBarStr = prefix + " " + cBarPrefix + " ";
|
||||
string pBarStr = prefix + " " + pBarPrefix + " ";
|
||||
|
||||
//
|
||||
if (drawCBar)
|
||||
{
|
||||
//
|
||||
inputs.cBarDrawSpecs.openStyle.Label(
|
||||
cBarStr + openLabel,
|
||||
inputs.cBarDrawSpecs.openStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.cBarDrawSpecs.highStyle.Label(
|
||||
cBarStr + highLabel,
|
||||
inputs.cBarDrawSpecs.highStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.cBarDrawSpecs.closeStyle.Label(
|
||||
cBarStr + closeLabel,
|
||||
inputs.cBarDrawSpecs.closeStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.cBarDrawSpecs.lowStyle.Label(
|
||||
cBarStr + lowLabel,
|
||||
inputs.cBarDrawSpecs.lowStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawPBar)
|
||||
{
|
||||
//
|
||||
inputs.pBarDrawSpecs.openStyle.Label(
|
||||
pBarStr + openLabel,
|
||||
inputs.pBarDrawSpecs.openStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.pBarDrawSpecs.highStyle.Label(
|
||||
pBarStr + highLabel,
|
||||
inputs.pBarDrawSpecs.highStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.pBarDrawSpecs.closeStyle.Label(
|
||||
pBarStr + closeLabel,
|
||||
inputs.pBarDrawSpecs.closeStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.pBarDrawSpecs.lowStyle.Label(
|
||||
pBarStr + lowLabel,
|
||||
inputs.pBarDrawSpecs.lowStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawCBarMid)
|
||||
{
|
||||
//
|
||||
inputs.cBarMidDrawSpecs.Label(
|
||||
cBarStr + midLineLabel,
|
||||
clrYellow,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawPBarMid)
|
||||
{
|
||||
//
|
||||
inputs.pBarMidDrawSpecs.Label(
|
||||
pBarStr + midLineLabel,
|
||||
clrYellow,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,252 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "../Classes/x-saherelm.x5.xea.class.mq5"
|
||||
|
||||
//
|
||||
// "EURUSDb,USDCHFb,USDJPYb,XAUUSDb"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
long x5EAMagicNumber = 78692110; // Magic Number
|
||||
int x5EASlippage = 10; // Slippgae
|
||||
string x5EASymbols = "EURUSDb,USDCHFb,USDJPYb,XAUUSDb"; // Symbols
|
||||
//
|
||||
bool x5EAAllowLong = true; // Allow Long Trades
|
||||
bool x5EAAllowShort = true; // Allow Short Trades
|
||||
int x5EAManageInterval = 5; // Manager Check Intervals Seconds
|
||||
int x5EAMaxAllowedPositions = 15; // Max Allowed Positions
|
||||
double x5EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades
|
||||
double x5EAMinProfitPerTrade = 0; // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
double x5EAMinProfitPerVolumeFactor = 0; // Min Volume Factor for Calculating Profit (Hedge)
|
||||
double x5EAMaxAllowedDrawdownFactor = 0; // Max Allowed Drawdown Factor
|
||||
//
|
||||
double x5EAVolume = 0.01;
|
||||
|
||||
//
|
||||
// Vars ...
|
||||
string x5EASymbol;
|
||||
ENUM_TIMEFRAMES x5EAPeriod;
|
||||
|
||||
//
|
||||
MqlTick x5EATick;
|
||||
|
||||
//
|
||||
// X5EA ...
|
||||
XSCX5EA *mX5EA;
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial EA ...
|
||||
if (!InitialEA())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
TesterHideIndicators(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;
|
||||
}
|
||||
|
||||
//
|
||||
mX5EA.OnTick();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
// Validate Variables nd Inputs ...
|
||||
bool X5EAValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
x5EASlippage > 0 &&
|
||||
x5EAMagicNumber > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Specific Providers ...
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Here We Have to Initial 4 instance of X5Provider ...
|
||||
// - EURUSD/M5;
|
||||
// - USDCHF/M5;
|
||||
// - USDJPY/M5;
|
||||
// - XAUUSD/M5;
|
||||
|
||||
//
|
||||
result = IsValid(x5EASymbols);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbols[];
|
||||
int symbolsCount = SplitContent(
|
||||
symbols,
|
||||
x5EASymbols);
|
||||
result = symbolsCount > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Signallers ...
|
||||
ENUM_X5_SIGNAL_PROVIDERS signallers[];
|
||||
GetAllX5SignalProviders(signallers);
|
||||
|
||||
//
|
||||
// Instantiate X5EA Class ...
|
||||
mX5EA = new XSCX5EA(
|
||||
x5EASlippage, // Slippgae
|
||||
x5EAMagicNumber, // Magic Number
|
||||
x5EAManageInterval, // Manager Check Intervals Seconds
|
||||
x5EAMaxAllowedSpread, // Max Allowed Spred for Opening Trades
|
||||
x5EAMaxAllowedPositions, // Max Allowed Positions
|
||||
x5EAMaxAllowedDrawdownFactor, // Max Allowed Drawdown Factor
|
||||
x5EAAllowLong, // Allow Long Trades
|
||||
x5EAAllowShort, // Allow Short Trades
|
||||
x5EAMinProfitPerTrade, // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
x5EAMinProfitPerVolumeFactor // Min Volume Factor for Calculating Profit (Hedge)
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Providers and Add them into mX5EA class ...
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Define Structure ...
|
||||
X5ProviderDescriptor iDescriptor;
|
||||
|
||||
//
|
||||
iDescriptor.symbol = symbols[i];
|
||||
iDescriptor.period = PERIOD_M5;
|
||||
iDescriptor.staticVolume = x5EAVolume;
|
||||
iDescriptor.allowLong = x5EAAllowLong;
|
||||
iDescriptor.allowShort = x5EAAllowShort;
|
||||
Copy(
|
||||
signallers,
|
||||
iDescriptor.signallers);
|
||||
|
||||
//
|
||||
// Set Inputs to Default ...
|
||||
iDescriptor.inputs.Default();
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool isInputsValid = iDescriptor.inputs.IsValid();
|
||||
if (!isInputsValid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
result = mX5EA.AddProvider(iDescriptor);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user