Files
MQL5Data/Documents/BKP/Parsers/AMarkets/x-saherelm.xch.che.amarkets.parser.mq5
T

707 lines
20 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Strategy Parser Library
// ------------------------------------------------
// Name: XCHCHEStartegyConditionsParser
// Description: provide all conditions parsing
// for XCH Strategy ...
//
//
// 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 "../../Strategies/x-saherelm.xch.che.strategy.mq5"
//
//
#include "./Brent/x-saherelm.xch.che.amarkets.brent.long.parser.mq5"
#include "./Brent/x-saherelm.xch.che.amarkets.brent.short.parser.mq5"
#include "./DowJones/x-saherelm.xch.che.amarkets.us30.long.parser.mq5"
#include "./DowJones/x-saherelm.xch.che.amarkets.us30.short.parser.mq5"
#include "./EURGBP/x-saherelm.xch.che.amarkets.eurgbp.long.parser.mq5"
#include "./EURGBP/x-saherelm.xch.che.amarkets.eurgbp.short.parser.mq5"
#include "./EURJPY/x-saherelm.xch.che.amarkets.eurjpy.long.parser.mq5"
#include "./EURJPY/x-saherelm.xch.che.amarkets.eurjpy.short.parser.mq5"
#include "./EURCHF/x-saherelm.xch.che.amarkets.eurchf.long.parser.mq5"
#include "./EURCHF/x-saherelm.xch.che.amarkets.eurchf.short.parser.mq5"
#include "./AUDUSD/x-saherelm.xch.che.amarkets.audusd.long.parser.mq5"
#include "./AUDUSD/x-saherelm.xch.che.amarkets.audusd.short.parser.mq5"
#include "./EURAUD/x-saherelm.xch.che.amarkets.euraud.long.parser.mq5"
#include "./EURAUD/x-saherelm.xch.che.amarkets.euraud.short.parser.mq5"
#include "./NZDUSD/x-saherelm.xch.che.amarkets.nzdusd.long.parser.mq5"
#include "./NZDUSD/x-saherelm.xch.che.amarkets.nzdusd.short.parser.mq5"
#include "./EURNZD/x-saherelm.xch.che.amarkets.eurnzd.long.parser.mq5"
#include "./EURNZD/x-saherelm.xch.che.amarkets.eurnzd.short.parser.mq5"
#include "./USDCAD/x-saherelm.xch.che.amarkets.usdcad.long.parser.mq5"
#include "./USDCAD/x-saherelm.xch.che.amarkets.usdcad.short.parser.mq5"
#include "./EURCAD/x-saherelm.xch.che.amarkets.eurcad.long.parser.mq5"
#include "./EURCAD/x-saherelm.xch.che.amarkets.eurcad.short.parser.mq5"
#include "./EURUSD/x-saherelm.xch.che.amarkets.eurusd.long.parser.mq5"
#include "./EURUSD/x-saherelm.xch.che.amarkets.eurusd.short.parser.mq5"
#include "./USDJPY/x-saherelm.xch.che.amarkets.usdjpy.long.parser.mq5"
#include "./USDJPY/x-saherelm.xch.che.amarkets.usdjpy.short.parser.mq5"
#include "./USDCHF/x-saherelm.xch.che.amarkets.usdchf.long.parser.mq5"
#include "./USDCHF/x-saherelm.xch.che.amarkets.usdchf.short.parser.mq5"
#include "./GBPUSD/x-saherelm.xch.che.amarkets.gbpusd.long.parser.mq5"
#include "./GBPUSD/x-saherelm.xch.che.amarkets.gbpusd.short.parser.mq5"
#include "./XAUUSD/x-saherelm.xch.che.amarkets.xauusd.long.parser.mq5"
#include "./XAUUSD/x-saherelm.xch.che.amarkets.xauusd.short.parser.mq5"
#include "./XAGUSD/x-saherelm.xch.che.amarkets.xagusd.long.parser.mq5"
#include "./XAGUSD/x-saherelm.xch.che.amarkets.xagusd.short.parser.mq5"
//
// Conditions Parser ...
struct XCHCHEStartegyAMarketsConditionsParser
{
//
string _version;
//
// Parsers ...
XSymbolParser _symbolParser;
//
// EURUSD ...
XCHCHEStartegyAMarketsEURUSDLongConditionsParser _eurusdLongParser;
XCHCHEStartegyAMarketsEURUSDShortConditionsParser _eurusdShortParser;
//
// GBPUSD ...
XCHCHEStartegyAMarketsGBPUSDLongConditionsParser _gbpusdLongParser;
XCHCHEStartegyAMarketsGBPUSDShortConditionsParser _gbpusdShortParser;
//
// EURGBP ...
XCHCHEStartegyAMarketsEURGBPLongConditionsParser _eurgbpLongParser;
XCHCHEStartegyAMarketsEURGBPShortConditionsParser _eurgbpShortParser;
//
// USDJPY ...
XCHCHEStartegyAMarketsUSDJPYLongConditionsParser _usdjpyLongParser;
XCHCHEStartegyAMarketsUSDJPYShortConditionsParser _usdjpyShortParser;
//
// EURJPY ...
XCHCHEStartegyAMarketsEURJPYLongConditionsParser _eurjpyLongParser;
XCHCHEStartegyAMarketsEURJPYShortConditionsParser _eurjpyShortParser;
//
// USDCHF ...
XCHCHEStartegyAMarketsUSDCHFLongConditionsParser _usdchfLongParser;
XCHCHEStartegyAMarketsUSDCHFShortConditionsParser _usdchfShortParser;
//
// EURCHF ...
XCHCHEStartegyAMarketsEURCHFLongConditionsParser _eurchfLongParser;
XCHCHEStartegyAMarketsEURCHFShortConditionsParser _eurchfShortParser;
//
// XAUUSD ...
XCHCHEStartegyAMarketsXAUUSDLongConditionsParser _xauusdLongParser;
XCHCHEStartegyAMarketsXAUUSDShortConditionsParser _xauusdShortParser;
//
// XAGUSD ...
XCHCHEStartegyAMarketsXAGUSDLongConditionsParser _xagusdLongParser;
XCHCHEStartegyAMarketsXAGUSDShortConditionsParser _xagusdShortParser;
//
// AUDUSD ...
XCHCHEStartegyAMarketsAUDUSDLongConditionsParser _audusdLongParser;
XCHCHEStartegyAMarketsAUDUSDShortConditionsParser _audusdShortParser;
//
// EURAUD ...
XCHCHEStartegyAMarketsEURAUDLongConditionsParser _euraudLongParser;
XCHCHEStartegyAMarketsEURAUDShortConditionsParser _euraudShortParser;
//
// NZDUSD ...
XCHCHEStartegyAMarketsNZDUSDLongConditionsParser _nzdusdLongParser;
XCHCHEStartegyAMarketsNZDUSDShortConditionsParser _nzdusdShortParser;
//
// EURNZD ...
XCHCHEStartegyAMarketsEURNZDLongConditionsParser _eurnzdLongParser;
XCHCHEStartegyAMarketsEURNZDShortConditionsParser _eurnzdShortParser;
//
// USDCAD ...
XCHCHEStartegyAMarketsUSDCADLongConditionsParser _usdcadLongParser;
XCHCHEStartegyAMarketsUSDCADShortConditionsParser _usdcadShortParser;
//
// EURCAD ...
XCHCHEStartegyAMarketsEURCADLongConditionsParser _eurcadLongParser;
XCHCHEStartegyAMarketsEURCADShortConditionsParser _eurcadShortParser;
//
// DOWJONES ...
XCHCHEStartegyAMarketsUS30LongConditionsParser _dowjonesLongParser;
XCHCHEStartegyAMarketsUS30ShortConditionsParser _dowjonesShortParser;
//
// BRENT ...
XCHCHEStartegyAMarketsBRENTLongConditionsParser _brentLongParser;
XCHCHEStartegyAMarketsBRENTShortConditionsParser _brentShortParser;
//
bool IsFiltered(
XSignal &signal, // Provided Signal
XCHStrategyConditions &conditions, // Market Conditions
bool force = false //
)
{
//
bool result = false;
//
// Validate Args ...
if (!signal.IsValid() || !conditions.IsValid())
{
//
result = true;
return result;
}
//
bool isLong = IsLong(signal.type);
//
result =
//
isLong
? IsLongFiltered(
signal,
conditions,
force //
)
: IsShortFiltered(
signal,
conditions,
force //
)
//
;
//
return result;
}
//
// Filter Long Signals ...
bool IsLongFiltered(
XSignal &signal,
XCHStrategyConditions &conditions,
bool force = false //
)
{
//
bool result = false;
//
bool isEURUSD = _symbolParser.IsEURUSD(signal.symbol);
bool isGBPUSD = _symbolParser.IsGBPUSD(signal.symbol);
bool isEURGBP = _symbolParser.IsEURGBP(signal.symbol);
bool isXAUUSD = _symbolParser.IsXAUUSD(signal.symbol);
bool isXAGUSD = _symbolParser.IsXAGUSD(signal.symbol);
bool isUSDJPY = _symbolParser.IsUSDJPY(signal.symbol);
bool isEURJPY = _symbolParser.IsEURJPY(signal.symbol);
bool isUSDCHF = _symbolParser.IsUSDCHF(signal.symbol);
bool isEURCHF = _symbolParser.IsEURCHF(signal.symbol);
bool isAUDUSD = _symbolParser.IsAUDUSD(signal.symbol);
bool isEURAUD = _symbolParser.IsEURAUD(signal.symbol);
bool isNZDUSD = _symbolParser.IsNZDUSD(signal.symbol);
bool isEURNZD = _symbolParser.IsEURNZD(signal.symbol);
bool isUSDCAD = _symbolParser.IsUSDCAD(signal.symbol);
bool isEURCAD = _symbolParser.IsEURCAD(signal.symbol);
bool isBrent = _symbolParser.IsBrent(signal.symbol);
bool isDowJones = _symbolParser.IsDowJones(signal.symbol);
//
bool isEURUSDFiltered = _eurusdLongParser.IsFiltered(
signal,
conditions //
);
bool isGBPUSDFiltered = _gbpusdLongParser.IsFiltered(
signal,
conditions //
);
bool isEURGBPFiltered = _eurgbpLongParser.IsFiltered(
signal,
conditions //
);
bool isUSDJPYFiltered = _usdjpyLongParser.IsFiltered(
signal,
conditions //
);
bool isEURJPYFiltered = _eurjpyLongParser.IsFiltered(
signal,
conditions //
);
bool isUSDCHFFiltered = _usdchfLongParser.IsFiltered(
signal,
conditions //
);
bool isEURCHFFiltered = _eurchfLongParser.IsFiltered(
signal,
conditions //
);
bool isXAUUSDFiltered = _xauusdLongParser.IsFiltered(
signal,
conditions //
);
bool isXAGUSDFiltered = _xagusdLongParser.IsFiltered(
signal,
conditions //
);
bool isAUDUSDFiltered = _audusdLongParser.IsFiltered(
signal,
conditions //
);
bool isEURAUDFiltered = _euraudLongParser.IsFiltered(
signal,
conditions //
);
bool isNZDUSDFiltered = _nzdusdLongParser.IsFiltered(
signal,
conditions //
);
bool isEURNZDFiltered = _eurnzdLongParser.IsFiltered(
signal,
conditions //
);
bool isUSDCADFiltered = _usdcadLongParser.IsFiltered(
signal,
conditions //
);
bool isEURCADFiltered = _eurcadLongParser.IsFiltered(
signal,
conditions //
);
bool isDowJonesFiltered = _dowjonesLongParser.IsFiltered(
signal,
conditions //
);
bool isBrentFiltered = _brentLongParser.IsFiltered(
signal,
conditions //
);
//
if (!force)
{
//
if (isEURUSD)
{
result = isEURUSDFiltered;
}
else if (isGBPUSD)
{
result = isGBPUSDFiltered;
}
else if (isEURGBP)
{
result = isEURGBPFiltered;
}
else if (isUSDJPY)
{
result = isUSDJPYFiltered;
}
else if (isEURJPY)
{
result = isEURJPYFiltered;
}
else if (isUSDCHF)
{
result = isUSDCHFFiltered;
}
else if (isEURCHF)
{
result = isEURCHFFiltered;
}
else if (isXAUUSD)
{
result = isXAUUSDFiltered;
}
else if (isXAGUSD)
{
result = isXAGUSDFiltered;
}
else if (isAUDUSD)
{
result = isAUDUSDFiltered;
}
else if (isEURAUD)
{
result = isEURAUDFiltered;
}
else if (isNZDUSD)
{
result = isNZDUSDFiltered;
}
else if (isEURNZD)
{
result = isEURNZDFiltered;
}
else if (isUSDCAD)
{
result = isUSDCADFiltered;
}
else if (isEURCAD)
{
result = isEURCADFiltered;
}
else if (isBrent)
{
result = isBrentFiltered;
}
else if (isDowJones)
{
result = isDowJonesFiltered;
}
}
else
{
//
result =
//
isEURUSDFiltered
//
||
//
isGBPUSDFiltered
//
||
//
isEURGBPFiltered
//
||
//
isUSDJPYFiltered
//
||
//
isEURJPYFiltered
//
||
//
isUSDCHFFiltered
//
||
//
isEURCHFFiltered
//
||
//
isXAUUSDFiltered
//
||
//
isXAGUSDFiltered
//
||
//
isAUDUSDFiltered
//
||
//
isEURAUDFiltered
//
||
//
isNZDUSDFiltered
//
||
//
isEURNZDFiltered
//
||
//
isUSDCADFiltered
//
||
//
isEURCADFiltered
//
||
//
isBrentFiltered
//
||
//
isDowJonesFiltered
//
;
}
//
return result;
}
//
// Filter Short Signals ...
bool IsShortFiltered(
XSignal &signal,
XCHStrategyConditions &conditions,
bool force = false //
)
{
//
bool result = false;
//
bool isEURUSD = _symbolParser.IsEURUSD(signal.symbol);
bool isGBPUSD = _symbolParser.IsGBPUSD(signal.symbol);
bool isEURGBP = _symbolParser.IsEURGBP(signal.symbol);
bool isXAUUSD = _symbolParser.IsXAUUSD(signal.symbol);
bool isXAGUSD = _symbolParser.IsXAGUSD(signal.symbol);
bool isUSDJPY = _symbolParser.IsUSDJPY(signal.symbol);
bool isEURJPY = _symbolParser.IsEURJPY(signal.symbol);
bool isUSDCHF = _symbolParser.IsUSDCHF(signal.symbol);
bool isEURCHF = _symbolParser.IsEURCHF(signal.symbol);
bool isAUDUSD = _symbolParser.IsAUDUSD(signal.symbol);
bool isEURAUD = _symbolParser.IsEURAUD(signal.symbol);
bool isNZDUSD = _symbolParser.IsNZDUSD(signal.symbol);
bool isEURNZD = _symbolParser.IsEURNZD(signal.symbol);
bool isUSDCAD = _symbolParser.IsUSDCAD(signal.symbol);
bool isEURCAD = _symbolParser.IsEURCAD(signal.symbol);
bool isBrent = _symbolParser.IsBrent(signal.symbol);
bool isDowJones = _symbolParser.IsDowJones(signal.symbol);
//
bool isEURUSDFiltered = _eurusdShortParser.IsFiltered(
signal,
conditions //
);
bool isGBPUSDFiltered = _gbpusdShortParser.IsFiltered(
signal,
conditions //
);
bool isEURGBPFiltered = _eurgbpShortParser.IsFiltered(
signal,
conditions //
);
bool isUSDJPYFiltered = _usdjpyShortParser.IsFiltered(
signal,
conditions //
);
bool isEURJPYFiltered = _eurjpyShortParser.IsFiltered(
signal,
conditions //
);
bool isUSDCHFFiltered = _usdchfShortParser.IsFiltered(
signal,
conditions //
);
bool isEURCHFFiltered = _eurchfShortParser.IsFiltered(
signal,
conditions //
);
bool isXAUUSDFiltered = _xauusdShortParser.IsFiltered(
signal,
conditions //
);
bool isXAGUSDFiltered = _xagusdShortParser.IsFiltered(
signal,
conditions //
);
bool isAUDUSDFiltered = _audusdShortParser.IsFiltered(
signal,
conditions //
);
bool isEURAUDFiltered = _euraudShortParser.IsFiltered(
signal,
conditions //
);
bool isNZDUSDFiltered = _nzdusdShortParser.IsFiltered(
signal,
conditions //
);
bool isEURNZDFiltered = _eurnzdShortParser.IsFiltered(
signal,
conditions //
);
bool isUSDCADFiltered = _usdcadShortParser.IsFiltered(
signal,
conditions //
);
bool isEURCADFiltered = _eurcadShortParser.IsFiltered(
signal,
conditions //
);
bool isBrentFiltered = _brentShortParser.IsFiltered(
signal,
conditions //
);
bool isDowJonesFiltered = _dowjonesShortParser.IsFiltered(
signal,
conditions //
);
//
if (!force)
{
//
if (isEURUSD)
{
result = isEURUSDFiltered;
}
else if (isGBPUSD)
{
result = isGBPUSDFiltered;
}
else if (isEURGBP)
{
result = isEURGBPFiltered;
}
else if (isUSDJPY)
{
result = isUSDJPYFiltered;
}
else if (isEURJPY)
{
result = isEURJPYFiltered;
}
else if (isUSDCHF)
{
result = isUSDCHFFiltered;
}
else if (isEURCHF)
{
result = isEURCHFFiltered;
}
else if (isXAUUSD)
{
result = isXAUUSDFiltered;
}
else if (isXAGUSD)
{
result = isXAGUSDFiltered;
}
else if (isAUDUSD)
{
result = isAUDUSDFiltered;
}
else if (isEURAUD)
{
result = isEURAUDFiltered;
}
else if (isNZDUSD)
{
result = isNZDUSDFiltered;
}
else if (isEURNZD)
{
result = isEURNZDFiltered;
}
else if (isUSDCAD)
{
result = isUSDCADFiltered;
}
else if (isEURCAD)
{
result = isEURCADFiltered;
}
else if (isBrent)
{
result = isBrentFiltered;
}
else if (isDowJones)
{
result = isDowJonesFiltered;
}
}
else
{
//
result =
//
isEURUSDFiltered
//
||
//
isGBPUSDFiltered
//
||
//
isEURGBPFiltered
//
||
//
isUSDJPYFiltered
//
||
//
isEURJPYFiltered
//
||
//
isUSDCHFFiltered
//
||
//
isEURCHFFiltered
//
||
//
isXAUUSDFiltered
//
||
//
isXAGUSDFiltered
//
||
//
isAUDUSDFiltered
//
||
//
isEURAUDFiltered
//
||
//
isNZDUSDFiltered
//
||
//
isEURNZDFiltered
//
||
//
isUSDCADFiltered
//
||
//
isEURCADFiltered
//
||
//
isBrentFiltered
//
||
//
isDowJonesFiltered
//
;
}
//
return result;
}
};
//