573 lines
16 KiB
Plaintext
573 lines
16 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 "./DowJones/x-saherelm.xch.che.alpari.us30.long.parser.mq5"
|
|
#include "./DowJones/x-saherelm.xch.che.alpari.us30.short.parser.mq5"
|
|
#include "./EURGBP/x-saherelm.xch.che.alpari.eurgbp.long.parser.mq5"
|
|
#include "./EURGBP/x-saherelm.xch.che.alpari.eurgbp.short.parser.mq5"
|
|
#include "./EURJPY/x-saherelm.xch.che.alpari.eurjpy.long.parser.mq5"
|
|
#include "./EURJPY/x-saherelm.xch.che.alpari.eurjpy.short.parser.mq5"
|
|
#include "./EURCHF/x-saherelm.xch.che.alpari.eurchf.long.parser.mq5"
|
|
#include "./EURCHF/x-saherelm.xch.che.alpari.eurchf.short.parser.mq5"
|
|
#include "./AUDUSD/x-saherelm.xch.che.alpari.audusd.long.parser.mq5"
|
|
#include "./AUDUSD/x-saherelm.xch.che.alpari.audusd.short.parser.mq5"
|
|
#include "./NZDUSD/x-saherelm.xch.che.alpari.nzdusd.long.parser.mq5"
|
|
#include "./NZDUSD/x-saherelm.xch.che.alpari.nzdusd.short.parser.mq5"
|
|
#include "./USDCAD/x-saherelm.xch.che.alpari.usdcad.long.parser.mq5"
|
|
#include "./USDCAD/x-saherelm.xch.che.alpari.usdcad.short.parser.mq5"
|
|
#include "./EURCAD/x-saherelm.xch.che.alpari.eurcad.long.parser.mq5"
|
|
#include "./EURCAD/x-saherelm.xch.che.alpari.eurcad.short.parser.mq5"
|
|
#include "./EURUSD/x-saherelm.xch.che.alpari.eurusd.long.parser.mq5"
|
|
#include "./EURUSD/x-saherelm.xch.che.alpari.eurusd.short.parser.mq5"
|
|
#include "./USDJPY/x-saherelm.xch.che.alpari.usdjpy.long.parser.mq5"
|
|
#include "./USDJPY/x-saherelm.xch.che.alpari.usdjpy.short.parser.mq5"
|
|
#include "./USDCHF/x-saherelm.xch.che.alpari.usdchf.long.parser.mq5"
|
|
#include "./USDCHF/x-saherelm.xch.che.alpari.usdchf.short.parser.mq5"
|
|
#include "./GBPUSD/x-saherelm.xch.che.alpari.gbpusd.long.parser.mq5"
|
|
#include "./GBPUSD/x-saherelm.xch.che.alpari.gbpusd.short.parser.mq5"
|
|
#include "./XAUUSD/x-saherelm.xch.che.alpari.xauusd.long.parser.mq5"
|
|
#include "./XAUUSD/x-saherelm.xch.che.alpari.xauusd.short.parser.mq5"
|
|
|
|
//
|
|
// Conditions Parser ...
|
|
struct XCHCHEStartegyAlpariConditionsParser
|
|
{
|
|
//
|
|
string _version;
|
|
|
|
//
|
|
// Parsers ...
|
|
XSymbolParser _symbolParser;
|
|
|
|
//
|
|
// EURUSD ...
|
|
XCHCHEStartegyAlpariEURUSDLongConditionsParser _eurusdLongParser;
|
|
XCHCHEStartegyAlpariEURUSDShortConditionsParser _eurusdShortParser;
|
|
|
|
//
|
|
// GBPUSD ...
|
|
XCHCHEStartegyAlpariGBPUSDLongConditionsParser _gbpusdLongParser;
|
|
XCHCHEStartegyAlpariGBPUSDShortConditionsParser _gbpusdShortParser;
|
|
|
|
//
|
|
// EURGBP ...
|
|
XCHCHEStartegyAlpariEURGBPLongConditionsParser _eurgbpLongParser;
|
|
XCHCHEStartegyAlpariEURGBPShortConditionsParser _eurgbpShortParser;
|
|
|
|
//
|
|
// USDJPY ...
|
|
XCHCHEStartegyAlpariUSDJPYLongConditionsParser _usdjpyLongParser;
|
|
XCHCHEStartegyAlpariUSDJPYShortConditionsParser _usdjpyShortParser;
|
|
|
|
//
|
|
// EURJPY ...
|
|
XCHCHEStartegyAlpariEURJPYLongConditionsParser _eurjpyLongParser;
|
|
XCHCHEStartegyAlpariEURJPYShortConditionsParser _eurjpyShortParser;
|
|
|
|
//
|
|
// USDCHF ...
|
|
XCHCHEStartegyAlpariUSDCHFLongConditionsParser _usdchfLongParser;
|
|
XCHCHEStartegyAlpariUSDCHFShortConditionsParser _usdchfShortParser;
|
|
|
|
//
|
|
// EURCHF ...
|
|
XCHCHEStartegyAlpariEURCHFLongConditionsParser _eurchfLongParser;
|
|
XCHCHEStartegyAlpariEURCHFShortConditionsParser _eurchfShortParser;
|
|
|
|
//
|
|
// XAUUSD ...
|
|
XCHCHEStartegyAlpariXAUUSDLongConditionsParser _xauusdLongParser;
|
|
XCHCHEStartegyAlpariXAUUSDShortConditionsParser _xauusdShortParser;
|
|
|
|
//
|
|
// DOWJONES ...
|
|
XCHCHEStartegyAlpariUS30LongConditionsParser _dowjonesLongParser;
|
|
XCHCHEStartegyAlpariUS30ShortConditionsParser _dowjonesShortParser;
|
|
|
|
//
|
|
// AUDUSD ...
|
|
XCHCHEStartegyAlpariAUDUSDLongConditionsParser _audusdLongParser;
|
|
XCHCHEStartegyAlpariAUDUSDShortConditionsParser _audusdShortParser;
|
|
|
|
//
|
|
// NZDUSD ...
|
|
XCHCHEStartegyAlpariNZDUSDLongConditionsParser _nzdusdLongParser;
|
|
XCHCHEStartegyAlpariNZDUSDShortConditionsParser _nzdusdShortParser;
|
|
|
|
//
|
|
// USDCAD ...
|
|
XCHCHEStartegyAlpariUSDCADLongConditionsParser _usdcadLongParser;
|
|
XCHCHEStartegyAlpariUSDCADShortConditionsParser _usdcadShortParser;
|
|
|
|
//
|
|
// EURCAD ...
|
|
XCHCHEStartegyAlpariEURCADLongConditionsParser _eurcadLongParser;
|
|
XCHCHEStartegyAlpariEURCADShortConditionsParser _eurcadShortParser;
|
|
|
|
//
|
|
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 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 isNZDUSD = _symbolParser.IsNZDUSD(signal.symbol);
|
|
bool isUSDCAD = _symbolParser.IsUSDCAD(signal.symbol);
|
|
bool isEURCAD = _symbolParser.IsEURCAD(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 isAUDUSDFiltered = _audusdLongParser.IsFiltered(
|
|
signal,
|
|
conditions //
|
|
);
|
|
bool isNZDUSDFiltered = _nzdusdLongParser.IsFiltered(
|
|
signal,
|
|
conditions //
|
|
);
|
|
bool isUSDCADFiltered = _usdcadLongParser.IsFiltered(
|
|
signal,
|
|
conditions //
|
|
);
|
|
bool isEURCADFiltered = _eurcadLongParser.IsFiltered(
|
|
signal,
|
|
conditions //
|
|
);
|
|
bool isDowJonesFiltered = _dowjonesLongParser.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 (isAUDUSD)
|
|
{
|
|
result = isAUDUSDFiltered;
|
|
}
|
|
else if (isNZDUSD)
|
|
{
|
|
result = isNZDUSDFiltered;
|
|
}
|
|
else if (isUSDCAD)
|
|
{
|
|
result = isUSDCADFiltered;
|
|
}
|
|
else if (isEURCAD)
|
|
{
|
|
result = isEURCADFiltered;
|
|
}
|
|
else if (isDowJones)
|
|
{
|
|
result = isDowJonesFiltered;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
result =
|
|
//
|
|
isEURUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isGBPUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURGBPFiltered
|
|
//
|
|
||
|
|
//
|
|
isUSDJPYFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURJPYFiltered
|
|
//
|
|
||
|
|
//
|
|
isUSDCHFFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURCHFFiltered
|
|
//
|
|
||
|
|
//
|
|
isXAUUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isAUDUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isNZDUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isUSDCADFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURCADFiltered
|
|
//
|
|
||
|
|
//
|
|
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 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 isNZDUSD = _symbolParser.IsNZDUSD(signal.symbol);
|
|
bool isUSDCAD = _symbolParser.IsUSDCAD(signal.symbol);
|
|
bool isEURCAD = _symbolParser.IsEURCAD(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 isAUDUSDFiltered = _audusdShortParser.IsFiltered(
|
|
signal,
|
|
conditions //
|
|
);
|
|
bool isNZDUSDFiltered = _nzdusdShortParser.IsFiltered(
|
|
signal,
|
|
conditions //
|
|
);
|
|
bool isUSDCADFiltered = _usdcadShortParser.IsFiltered(
|
|
signal,
|
|
conditions //
|
|
);
|
|
bool isEURCADFiltered = _eurcadShortParser.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 (isAUDUSD)
|
|
{
|
|
result = isAUDUSDFiltered;
|
|
}
|
|
else if (isNZDUSD)
|
|
{
|
|
result = isNZDUSDFiltered;
|
|
}
|
|
else if (isUSDCAD)
|
|
{
|
|
result = isUSDCADFiltered;
|
|
}
|
|
else if (isEURCAD)
|
|
{
|
|
result = isEURCADFiltered;
|
|
}
|
|
else if (isDowJones)
|
|
{
|
|
result = isDowJonesFiltered;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
result =
|
|
//
|
|
isEURUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isGBPUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURGBPFiltered
|
|
//
|
|
||
|
|
//
|
|
isUSDJPYFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURJPYFiltered
|
|
//
|
|
||
|
|
//
|
|
isUSDCHFFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURCHFFiltered
|
|
//
|
|
||
|
|
//
|
|
isXAUUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isAUDUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isNZDUSDFiltered
|
|
//
|
|
||
|
|
//
|
|
isUSDCADFiltered
|
|
//
|
|
||
|
|
//
|
|
isEURCADFiltered
|
|
//
|
|
||
|
|
//
|
|
isDowJonesFiltered
|
|
//
|
|
;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
// |