last workd ...
This commit is contained in:
@@ -2710,6 +2710,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mWaitsUntilNewBar = false;
|
||||
|
||||
//
|
||||
// Validate Enable Type of Signalling ...
|
||||
result = mIsLongEnable || mIsShortEnable;
|
||||
@@ -2779,11 +2782,14 @@ public:
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
mWaitsUntilNewBar = true;
|
||||
|
||||
//
|
||||
string mConditionsStr = mConditions.GenerateSummary(true);
|
||||
|
||||
//
|
||||
string providerTypeStr = provider + "(" + (hasLong ? "Long" : "Short") + ")" + "\n";
|
||||
string providerTypeStr = GetSymbol() + ", " + provider + "(" + (hasLong ? "Long" : "Short") + ")";
|
||||
mConditionsStr = providerTypeStr + "\n" + mConditionsStr;
|
||||
mConditionsCollector.Add(mConditionsStr);
|
||||
Print(mConditionsStr);
|
||||
@@ -95056,9 +95062,16 @@ struct X5ProviderDescriptor
|
||||
this.period = mPeriod;
|
||||
this.allowLong = mAllowLong;
|
||||
this.allowShort = mAllowShort;
|
||||
|
||||
//
|
||||
ENUM_X5_SIGNAL_PROVIDERS tmp[];
|
||||
Copy(
|
||||
this.signallers,
|
||||
mSignallers //
|
||||
mSignallers,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
this.signallers //
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
@@ -32,7 +32,7 @@ typedef void (*TX5OnSignal)(X5ProviderDescriptor &descriptor);
|
||||
//
|
||||
// Class Definition ...
|
||||
|
||||
class XSCX5EA : XSCBaseEA
|
||||
class XSCX5EA : public XSCBaseEA
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -178,8 +178,46 @@ public:
|
||||
) override
|
||||
{
|
||||
//
|
||||
// TODO: Implement this ...
|
||||
return 0;
|
||||
bool result = 0;
|
||||
|
||||
//
|
||||
Clean(signals);
|
||||
|
||||
//
|
||||
int descriptorsCount = CountDescriptors();
|
||||
if (descriptorsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < descriptorsCount; i++)
|
||||
{
|
||||
//
|
||||
X5ProviderDescriptor iDescriptor = mDescriptors[i];
|
||||
|
||||
//
|
||||
bool iHasSignal = iDescriptor.HasSignal();
|
||||
if (iHasSignal)
|
||||
{
|
||||
//
|
||||
// Here we Can double check Signals by Conditions
|
||||
// for Score Base Filtering ...
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iDescriptor.signal,
|
||||
signals
|
||||
//
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(signals);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -251,6 +289,12 @@ private:
|
||||
// a Collection of X5 Provider Descriptors ...
|
||||
X5ProviderDescriptor mDescriptors[];
|
||||
|
||||
//
|
||||
int CountDescriptors()
|
||||
{
|
||||
return ArraySize(mDescriptors);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
};
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.provider.class.mq5"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
long x5EAMagicNumber = 78692110; // Magic Number
|
||||
int x5EASlippage = 10; // Slippgae
|
||||
string x5EASymbols = "EURUSDb,USDCHFb,USDJPYb,XAUUSDb";
|
||||
|
||||
//
|
||||
double x5EAVolume = 0.01;
|
||||
|
||||
//
|
||||
// Vars ...
|
||||
string x5EASymbol;
|
||||
ENUM_TIMEFRAMES x5EAPeriod;
|
||||
|
||||
//
|
||||
MqlTick x5EATick;
|
||||
|
||||
//
|
||||
// X5Provider ...
|
||||
XSignal signal;
|
||||
|
||||
//
|
||||
X5ProviderDescriptor mProviderDescriptors[];
|
||||
|
||||
//
|
||||
// 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 Providers ...
|
||||
// if (!InitialProviders())
|
||||
// {
|
||||
// return INIT_PARAMETERS_INCORRECT;
|
||||
// }
|
||||
|
||||
//
|
||||
// Testing SymbolsTotal ...
|
||||
string symbols[];
|
||||
int symbolsCount = FilterUSDSymbols(
|
||||
symbols
|
||||
);
|
||||
if (symbolsCount > 0) {
|
||||
//
|
||||
ArrayPrint(symbols);
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
//
|
||||
ProcessProvidersTick();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
// Validate Variables nd Inputs ...
|
||||
bool X5EAValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
x5EASlippage > 0 &&
|
||||
x5EAMagicNumber > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Specific Providers ...
|
||||
bool InitialProviders()
|
||||
{
|
||||
//
|
||||
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);
|
||||
|
||||
//
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Define Structure ...
|
||||
X5ProviderDescriptor iDescriptor;
|
||||
|
||||
//
|
||||
// Set Inputs to Default ...
|
||||
iDescriptor.inputs.Default();
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool isInputsValid = iDescriptor.inputs.IsValid();
|
||||
if (!isInputsValid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Provider Class ...
|
||||
iDescriptor.provider = new XSCX5Provider(
|
||||
symbols[i],
|
||||
PERIOD_M5 //
|
||||
);
|
||||
|
||||
//
|
||||
// Enable Required Signallers and Types ...
|
||||
// TODO: add Support for TYPE Specifications ...
|
||||
iDescriptor.provider
|
||||
.SetSignalTypeState(
|
||||
POSITION_TYPE_BUY,
|
||||
true //
|
||||
);
|
||||
iDescriptor.provider
|
||||
.SetSignalTypeState(
|
||||
POSITION_TYPE_SELL,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
// Enable Required Signallers ...
|
||||
iDescriptor.provider
|
||||
.SetSignalProviderStates(signallers, true);
|
||||
|
||||
//
|
||||
// Try to Initialize Provider Instance ...
|
||||
bool isInitialized = iDescriptor.provider
|
||||
.Init(iDescriptor.inputs);
|
||||
if (!isInitialized)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Prepared Descriptor to Collection ...
|
||||
AddRef(
|
||||
iDescriptor,
|
||||
mProviderDescriptors
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Result ...
|
||||
result = ArraySize(mProviderDescriptors) == symbolsCount;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Providers Signals ...
|
||||
void ProcessProvidersTick()
|
||||
{
|
||||
//
|
||||
// Here We Have to Check 4 instance of X5Provider for Signals ...
|
||||
// - EURUSD/M5;
|
||||
// - USDCHF/M5;
|
||||
// - USDJPY/M5;
|
||||
// - XAUUSD/M5;
|
||||
|
||||
//
|
||||
int descriptorsCount = ArraySize(mProviderDescriptors);
|
||||
if (descriptorsCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int signalsCount = 0;
|
||||
for (int i = 0; i < descriptorsCount; i++)
|
||||
{
|
||||
//
|
||||
X5ProviderDescriptor iDescriptor = mProviderDescriptors[i];
|
||||
|
||||
//
|
||||
bool iHasSignal = iDescriptor.HasSignal(0);
|
||||
|
||||
//
|
||||
if (iHasSignal)
|
||||
{
|
||||
//
|
||||
signalsCount++;
|
||||
Print("Signal: " + iDescriptor.provider.GetSymbol() + ", " + ToString(iDescriptor.provider.GetPeriod()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
+50
-106
@@ -23,14 +23,25 @@
|
||||
#define ShortName "X5EA"
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.x5.provider.class.mq5"
|
||||
#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";
|
||||
|
||||
string x5EASymbols = "EURUSDb"; // 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 = 15; // 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.015; // Max Allowed Drawdown Factor
|
||||
//
|
||||
double x5EAVolume = 0.01;
|
||||
|
||||
@@ -43,11 +54,8 @@ ENUM_TIMEFRAMES x5EAPeriod;
|
||||
MqlTick x5EATick;
|
||||
|
||||
//
|
||||
// X5Provider ...
|
||||
XSignal signal;
|
||||
|
||||
//
|
||||
X5ProviderDescriptor mProviderDescriptors[];
|
||||
// X5EA ...
|
||||
XSCX5EA *mX5EA;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
@@ -75,22 +83,11 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
// //
|
||||
// // Initial Providers ...
|
||||
// if (!InitialProviders())
|
||||
// {
|
||||
// return INIT_PARAMETERS_INCORRECT;
|
||||
// }
|
||||
|
||||
//
|
||||
// Testing SymbolsTotal ...
|
||||
string symbols[];
|
||||
int symbolsCount = FilterUSDSymbols(
|
||||
symbols
|
||||
);
|
||||
if (symbolsCount > 0) {
|
||||
//
|
||||
ArrayPrint(symbols);
|
||||
// Initial EA ...
|
||||
if (!InitialEA())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -130,7 +127,7 @@ void OnTick()
|
||||
}
|
||||
|
||||
//
|
||||
ProcessProvidersTick();
|
||||
mX5EA.OnTick();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -157,7 +154,7 @@ bool X5EAValidateInputs()
|
||||
|
||||
//
|
||||
// Initialize Specific Providers ...
|
||||
bool InitialProviders()
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
@@ -193,12 +190,37 @@ bool InitialProviders()
|
||||
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.allowLong = x5EAAllowLong;
|
||||
iDescriptor.allowShort = x5EAAllowShort;
|
||||
Copy(
|
||||
signallers,
|
||||
iDescriptor.signallers);
|
||||
|
||||
//
|
||||
// Set Inputs to Default ...
|
||||
iDescriptor.inputs.Default();
|
||||
@@ -212,93 +234,15 @@ bool InitialProviders()
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Provider Class ...
|
||||
iDescriptor.provider = new XSCX5Provider(
|
||||
symbols[i],
|
||||
PERIOD_M5 //
|
||||
);
|
||||
|
||||
//
|
||||
// Enable Required Signallers and Types ...
|
||||
// TODO: add Support for TYPE Specifications ...
|
||||
iDescriptor.provider
|
||||
.SetSignalTypeState(
|
||||
POSITION_TYPE_BUY,
|
||||
true //
|
||||
);
|
||||
iDescriptor.provider
|
||||
.SetSignalTypeState(
|
||||
POSITION_TYPE_SELL,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
// Enable Required Signallers ...
|
||||
iDescriptor.provider
|
||||
.SetSignalProviderStates(signallers, true);
|
||||
|
||||
//
|
||||
// Try to Initialize Provider Instance ...
|
||||
bool isInitialized = iDescriptor.provider
|
||||
.Init(iDescriptor.inputs);
|
||||
if (!isInitialized)
|
||||
result = mX5EA.AddProvider(iDescriptor);
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Prepared Descriptor to Collection ...
|
||||
AddRef(
|
||||
iDescriptor,
|
||||
mProviderDescriptors
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Result ...
|
||||
result = ArraySize(mProviderDescriptors) == symbolsCount;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Providers Signals ...
|
||||
void ProcessProvidersTick()
|
||||
{
|
||||
//
|
||||
// Here We Have to Check 4 instance of X5Provider for Signals ...
|
||||
// - EURUSD/M5;
|
||||
// - USDCHF/M5;
|
||||
// - USDJPY/M5;
|
||||
// - XAUUSD/M5;
|
||||
|
||||
//
|
||||
int descriptorsCount = ArraySize(mProviderDescriptors);
|
||||
if (descriptorsCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int signalsCount = 0;
|
||||
for (int i = 0; i < descriptorsCount; i++)
|
||||
{
|
||||
//
|
||||
X5ProviderDescriptor iDescriptor = mProviderDescriptors[i];
|
||||
|
||||
//
|
||||
bool iHasSignal = iDescriptor.HasSignal(0);
|
||||
|
||||
//
|
||||
if (iHasSignal)
|
||||
{
|
||||
//
|
||||
signalsCount++;
|
||||
Print("Signal: " + iDescriptor.provider.GetSymbol() + ", " + ToString(iDescriptor.provider.GetPeriod()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user