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

1740 lines
46 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center XTESTXXX MQL5 Expert Advisor
// -------------------------------------------------
// Name: XTESTXXX
// 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 XTESTXXX"
#property strict
//
// Imports ...
#include "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Classes/x-saherelm.xalert.class.mq5"
#include "../Classes/x-saherelm.xtrade.class.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.x121.setup.class.mq5"
//
// #include "../Helpers/x-saherelm.xtd.helper.mq5"
// #include "../Helpers/x-saherelm.xhk.helper.mq5"
// #include "../Helpers/x-saherelm.xstr.helper.mq5"
// #include "../Helpers/x-saherelm.xche.helper.mq5"
// #include "../Helpers/x-saherelm.xich.helper.mq5"
// #include "../Helpers/x-saherelm.xmrb.helper.mq5"
// #include "../Helpers/x-saherelm.xosc.helper.mq5"
// #include "../Helpers/x-saherelm.xasct.helper.mq5"
// #include "../Helpers/x-saherelm.xsslc.helper.mq5"
// #include "../Helpers/x-saherelm.xhull.helper.mq5"
// #include "../Helpers/x-saherelm.xmatd.helper.mq5"
// #include "../Helpers/x-saherelm.xadxtd.helper.mq5"
//
#define ShortName "XTESTXXX"
//
// Inputs ...
//
long eaMagicNumber = 78692110; // Magic Number
int eaSlippage = 10; // Slippgae
//
string eaSymbols = "EURUSDb"; // Symbols
//
bool eaAllowLong = true; // Allow Long Trades
bool eaAllowShort = true; // Allow Short Trades
double eaVolume = 0.05; // Static Volume
int eaReuiredVerifications = 1; // Required Verifications for Signals
//
// Definitions ...
//
// Local Variables ...
//
XSCAlert *mAlert;
XSCTrade *mTrader;
//
XSCX121Setup *mSetup;
X121SignalGenerator mSignalGenerator;
// //
// // Helpers ...
// XSCXTDHelper *tdHelper;
// XSCXHKHelper *hkHelper;
// XSCXCHEHelper *cheHelper;
// XSCXICHHelper *ichHelper;
// XSCXSTRHelper *strHelper;
// XSCXMRBHelper *mrbHelper;
// XSCXOSCHelper *oscHelper;
// XSCXMATDHelper *matdHelper;
// XSCXASCTHelper *asctHelper;
// XSCXSSLCHelper *sslcHelper;
// XSCXHULLHelper *hullHelper;
// XSCXADXTDHelper *adxtdHelper;
// //
// int rsiHandler = INVALID_HANDLE;
// int cciHandler = INVALID_HANDLE;
// int macdHandler = INVALID_HANDLE;
//
XBarTracker xBarTracker;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
drawPrefix = ShortName;
//
if (!InitialEA())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// 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 XSampleEA Providers ...
// //
// delete tdHelper;
// delete hkHelper;
// delete cheHelper;
// delete strHelper;
// delete ichHelper;
// delete mrbHelper;
// delete oscHelper;
// delete matdHelper;
// delete asctHelper;
// delete sslcHelper;
// delete hullHelper;
// delete adxtdHelper;
//
delete mSetup;
//
delete mAlert;
delete mTrader;
}
//
// On Tick Handler ...
void OnTick()
{
//
if (!xBarTracker.CanProcessBar())
{
return;
}
// //
// double bullishScore = 0;
// double bearishScore = 0;
// //
// double tempBullishScore = 0;
// double tempBearishScore = 0;
// //
// XMATDConditions matdConditions;
// matdHelper.GetConditions(matdConditions);
// string matdSummary = matdConditions.GenerateSummary(false, true, false);
// matdConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XADXTDConditions adxtdConditions;
// adxtdHelper.GetConditions(adxtdConditions);
// string adxtdSummary = adxtdConditions.GenerateSummary(false, true, false);
// adxtdConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XSTRConditions strConditions;
// strHelper.GetConditions(strConditions);
// string strSummary = strConditions.GenerateSummary(false, true, false);
// strConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XCHEConditions cheConditions;
// cheHelper.GetConditions(cheConditions);
// string cheSummary = cheConditions.GenerateSummary(false, true, false);
// cheConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XASCTConditions asctConditions;
// asctHelper.GetConditions(asctConditions);
// string asctSummary = asctConditions.GenerateSummary(false, true, false);
// asctConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XTDConditions tdConditions;
// tdHelper.GetConditions(tdConditions);
// string tdSummary = tdConditions.GenerateSummary(false, true, false);
// tdConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XICHConditions ichConditions;
// ichHelper.GetConditions(ichConditions);
// string ichSummary = ichConditions.GenerateSummary(false, true, false);
// ichConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XHKConditions hkConditions;
// hkHelper.GetConditions(hkConditions);
// string hkSummary = hkConditions.GenerateSummary(false, true, false);
// hkConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XMRBConditions mrbConditions;
// mrbHelper.GetConditions(mrbConditions);
// string mrbSummary = mrbConditions.GenerateSummary(false, true, false);
// mrbConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XSSLCConditions sslcConditions;
// sslcHelper.GetConditions(sslcConditions);
// string sslcSummary = sslcConditions.GenerateSummary(false, true, false);
// sslcConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// XHULLConditions hullConditions;
// hullHelper.GetConditions(hullConditions);
// string hullSummary = hullConditions.GenerateSummary(false, true, false);
// hullConditions.GenerateScore(
// tempBullishScore,
// tempBearishScore //
// );
// bullishScore += tempBullishScore;
// bearishScore += tempBearishScore;
// //
// // OSCS Verifications ...
// int zIndex = 0;
// int cIndex = zIndex + 1;
// int pIndex = cIndex + 1;
// //
// int loopback = 3;
// //
// double ccis[];
// ArraySetAsSeries(ccis, true);
// oscHelper.CopyCCI(
// zIndex,
// loopback,
// ccis //
// );
// //
// double rsis[];
// ArraySetAsSeries(rsis, true);
// oscHelper.CopyRSI(
// zIndex,
// loopback,
// rsis //
// );
// //
// double macdMains[];
// double macdSignals[];
// ArraySetAsSeries(macdMains, true);
// ArraySetAsSeries(macdSignals, true);
// oscHelper.CopyMACD(
// zIndex,
// loopback,
// macdMains //
// );
// oscHelper.CopyMACDSignal(
// zIndex,
// loopback,
// macdSignals //
// );
// //
// bool oscLongVerifications =
// //
// // CCI ...
// ccis[cIndex] < 96 &&
// ccis[cIndex] > ccis[pIndex]
// //
// &&
// //
// // RSI ...
// rsis[cIndex] < 70 &&
// rsis[cIndex] > rsis[pIndex]
// //
// &&
// //
// // MACD ...
// macdMains[cIndex] > 0 &&
// macdSignals[cIndex] > 0 &&
// macdMains[cIndex] > macdSignals[cIndex]
// //
// ;
// //
// bool oscShortVerifications =
// //
// // CCI ...
// ccis[cIndex] > -96 &&
// ccis[cIndex] < ccis[pIndex]
// //
// &&
// //
// // RSI ...
// rsis[cIndex] > 30 &&
// rsis[cIndex] < rsis[pIndex]
// //
// &&
// //
// // MACD ...
// macdMains[cIndex] < 0 &&
// macdSignals[cIndex] < 0 &&
// macdMains[cIndex] < macdSignals[cIndex]
// //
// ;
// //
// string separator = "\n";
// string summary =
// //
// matdSummary + separator +
// adxtdSummary + separator +
// strSummary + separator +
// cheSummary + separator +
// asctSummary + separator +
// tdSummary + separator +
// ichSummary + separator +
// hkSummary + separator +
// mrbSummary + separator +
// sslcSummary + separator +
// hullSummary + separator +
// ""
// //
// ;
// //
// string scoreSummary =
// //
// "Scores:" + separator +
// "----------" + separator +
// "Bullish: " + ToString(bullishScore) + separator +
// "Bearish: " + ToString(bearishScore) + separator +
// // "---------" + separator +
// // "OSC Long: " + ToString(oscLongVerifications) + separator +
// // "OSC Short: " + ToString(oscShortVerifications) + separator +
// ""
// //
// ;
// //
// Comment(scoreSummary);
// //
// int longPusher = 0;
// int shortPusher = 0;
// //
// // LONG ...
// bool hasLong = false;
// if (eaAllowLong)
// {
// //
// bool long1 =
// //
// // Starting Conditions ...
// matdConditions.isSwitchedToBullish &&
// //
// // Verifications ...
// matdConditions.isSARBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// tdConditions.isBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long1)
// {
// longPusher++;
// }
// //
// bool long2 =
// //
// // Starting Conditions ...
// matdConditions.isSARSwitchedToBullish &&
// //
// // Verifications ...
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// tdConditions.isBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long2)
// {
// longPusher++;
// }
// //
// bool long3 =
// //
// // Starting Conditions ...
// adxtdConditions.isStrongSwitchedToBullish &&
// //
// // Verifications ...
// matdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// tdConditions.isBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long3)
// {
// longPusher++;
// }
// //
// bool long4 =
// //
// // Starting Conditions ...
// strConditions.isTrendSwitchedToBullish &&
// //
// // Verifications ...
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// cheConditions.isStrongBullish &&
// tdConditions.isBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long4)
// {
// longPusher++;
// }
// //
// bool long5 =
// //
// // Starting Conditions ...
// cheConditions.isStrongSwitchedToBullish &&
// //
// // Verifications ...
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// tdConditions.isBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long5)
// {
// longPusher++;
// }
// //
// bool long6 =
// //
// // Starting Conditions ...
// tdConditions.isSwitchedToBullish &&
// //
// // Verifications ...
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long6)
// {
// longPusher++;
// }
// //
// bool long7 =
// //
// // Starting Conditions ...
// rsis[cIndex] > 30 &&
// rsis[pIndex] <= 30 &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long7)
// {
// longPusher++;
// }
// //
// bool long8 =
// //
// // Starting Conditions ...
// ccis[cIndex] > -100 &&
// ccis[pIndex] <= -100 &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long8)
// {
// longPusher++;
// }
// //
// bool long9 =
// //
// // Starting Conditions ...
// macdMains[cIndex] > 0 &&
// macdMains[cIndex] > macdSignals[cIndex] &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long9)
// {
// longPusher++;
// }
// //
// bool long10 =
// //
// // Starting Conditions ...
// ichConditions.HasLongConditions() &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long10)
// {
// longPusher++;
// }
// //
// bool long11 =
// //
// // Starting Conditions ...
// hkConditions.isHKSwitchedToBullish &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long11)
// {
// longPusher++;
// }
// //
// bool long12 =
// //
// // Starting Conditions ...
// hkConditions.isSMHKSwitchedToBullish &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long12)
// {
// longPusher++;
// }
// //
// bool long13 =
// //
// // Starting Conditions ...
// mrbConditions.isFastCrossedOverSlow &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// sslcConditions.isBullish &&
// hullConditions.isBullish
// //
// ;
// if (long13)
// {
// longPusher++;
// }
// //
// bool long14 =
// //
// // Starting Conditions ...
// sslcConditions.isSwitchedToBullish &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// hullConditions.isBullish
// //
// ;
// if (long14)
// {
// longPusher++;
// }
// //
// bool long15 =
// //
// // Starting Conditions ...
// hullConditions.isSwitchedToBullish &&
// //
// // Verifications ...
// tdConditions.isBullish &&
// matdConditions.isBullish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBullish &&
// strConditions.isTrendBullish &&
// cheConditions.isStrongBullish &&
// hkConditions.isHKBullish &&
// hkConditions.isSMHKBullish &&
// mrbConditions.isFastOverSlow &&
// sslcConditions.isBullish
// //
// ;
// if (long15)
// {
// longPusher++;
// }
// //
// hasLong =
// //
// longPusher >= 1 &&
// !oscShortVerifications &&
// asctConditions.isLongSignal &&
// bullishScore > bearishScore * 2 &&
// (
// //
// long1
// //
// ||
// //
// long2
// //
// ||
// //
// long3
// //
// ||
// //
// long4
// //
// ||
// //
// long5
// //
// ||
// //
// long6
// //
// ||
// //
// long7
// //
// ||
// //
// long8
// //
// ||
// //
// long9
// //
// ||
// //
// long10
// //
// ||
// //
// long11
// //
// ||
// //
// long12
// //
// ||
// //
// long13
// //
// ||
// //
// long14
// //
// ||
// //
// long15
// //
// )
// //
// ;
// }
// //
// // SHORT ...
// bool hasShort = false;
// if (eaAllowShort)
// {
// //
// bool short1 =
// //
// // Starting Conditions ...
// matdConditions.isSwitchedToBearish &&
// //
// // Verifications ...
// matdConditions.isSARBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// tdConditions.isBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short1)
// {
// shortPusher++;
// }
// //
// bool short2 =
// //
// // Starting Conditions ...
// matdConditions.isSARSwitchedToBearish &&
// //
// // Verifications ...
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// tdConditions.isBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short2)
// {
// shortPusher++;
// }
// //
// bool short3 =
// //
// // Starting Conditions ...
// adxtdConditions.isStrongSwitchedToBearish &&
// //
// // Verifications ...
// matdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// tdConditions.isBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short3)
// {
// shortPusher++;
// }
// //
// bool short4 =
// //
// // Starting Conditions ...
// strConditions.isTrendSwitchedToBearish &&
// //
// // Verifications ...
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// cheConditions.isStrongBearish &&
// tdConditions.isBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short4)
// {
// shortPusher++;
// }
// //
// bool short5 =
// //
// // Starting Conditions ...
// cheConditions.isStrongSwitchedToBearish &&
// //
// // Verifications ...
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// tdConditions.isBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short5)
// {
// shortPusher++;
// }
// //
// bool short6 =
// //
// // Starting Conditions ...
// tdConditions.isSwitchedToBearish &&
// //
// // Verifications ...
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short6)
// {
// shortPusher++;
// }
// //
// bool short7 =
// //
// // Starting Conditions ...
// rsis[cIndex] < 70 &&
// rsis[pIndex] >= 70 &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short7)
// {
// shortPusher++;
// }
// //
// bool short8 =
// //
// // Starting Conditions ...
// ccis[cIndex] < 100 &&
// ccis[pIndex] >= 100 &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short8)
// {
// shortPusher++;
// }
// //
// bool short9 =
// //
// // Starting Conditions ...
// macdMains[cIndex] < 0 &&
// macdMains[cIndex] < macdSignals[cIndex] &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short9)
// {
// shortPusher++;
// }
// //
// bool short10 =
// //
// // Starting Conditions ...
// ichConditions.HasShortConditions() &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short10)
// {
// shortPusher++;
// }
// //
// bool short11 =
// //
// // Starting Conditions ...
// hkConditions.isHKSwitchedToBearish &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short11)
// {
// shortPusher++;
// }
// //
// bool short12 =
// //
// // Starting Conditions ...
// hkConditions.isSMHKSwitchedToBearish &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short12)
// {
// shortPusher++;
// }
// //
// bool short13 =
// //
// // Starting Conditions ...
// mrbConditions.isFastCrossedUnderSlow &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// sslcConditions.isBearish &&
// hullConditions.isBearish
// //
// ;
// if (short13)
// {
// shortPusher++;
// }
// //
// bool short14 =
// //
// // Starting Conditions ...
// sslcConditions.isSwitchedToBearish &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// hullConditions.isBearish
// //
// ;
// if (short14)
// {
// shortPusher++;
// }
// //
// bool short15 =
// //
// // Starting Conditions ...
// hullConditions.isSwitchedToBearish &&
// //
// // Verifications ...
// tdConditions.isBearish &&
// matdConditions.isBearish &&
// adxtdConditions.isStrong &&
// adxtdConditions.isBearish &&
// strConditions.isTrendBearish &&
// cheConditions.isStrongBearish &&
// hkConditions.isHKBearish &&
// hkConditions.isSMHKBearish &&
// mrbConditions.isFastUnderSlow &&
// sslcConditions.isBearish
// //
// ;
// if (short15)
// {
// shortPusher++;
// }
// //
// hasShort =
// //
// shortPusher >= 1 &&
// !oscLongVerifications &&
// asctConditions.isShortSignal &&
// bearishScore > bullishScore * 2 &&
// (
// //
// short1
// //
// ||
// //
// short2
// //
// ||
// //
// short3
// //
// ||
// //
// short4
// //
// ||
// //
// short5
// //
// ||
// //
// short6
// //
// ||
// //
// short7
// //
// ||
// //
// short8
// //
// ||
// //
// short9
// //
// ||
// //
// short10
// //
// ||
// //
// short11
// //
// ||
// //
// short12
// //
// ||
// //
// short13
// //
// ||
// //
// short14
// //
// ||
// //
// short15
// //
// )
// //
// ;
// }
// //
// bool hasSignal = hasLong || hasShort;
// if (!hasSignal)
// {
// return;
// }
//
//
// Since we have a Signal in current Bar, ignore other ticks and
// waits for Next Bar ...
// xBarTracker.Waits();
// //
// int pusher = hasLong
// ? longPusher
// : shortPusher;
// //
// XSignal mSignal;
// bool isPrepared = mSignal.Prepare(
// _Symbol,
// "XXX_" + ToString(pusher),
// _Period,
// mType,
// X_ORDER_MODE_MARKET,
// mEntry,
// eaVolume,
// 0, // mSL,
// mTP //
// );
// if (!isPrepared)
// {
// return;
// }
//
// Get Consitions and Validate it ...
X121SetupConditions conditions;
bool hasConditions = mSetup.GetConditions(
conditions //
);
if (!hasConditions)
{
return;
}
//
string separator = "\n";
//
// Retrieve Scores ...
double bullishScore = 0;
double bearishScore = 0;
conditions.GenerateScore(
bullishScore,
bearishScore //
);
//
// Create Score Summary for Commenting on Chart ...
string scoreSummary =
//
"Scores:" + separator +
"----------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
Comment(scoreSummary);
//
// Check Conditions has Signal or not ...
int pusher = 0;
XSignal signal;
bool hasSignal = mSignalGenerator
.HasSignal(
conditions,
signal,
pusher,
eaAllowLong,
eaAllowShort,
eaVolume,
0, // SL Point ...
30 // TP Point ...
);
if (!hasSignal)
{
return;
}
//
// Since we have a Signal in current Bar, ignore other ticks and
// waits for Next Bar ...
xBarTracker.Waits();
//
// Generate Condition Summary for Logging ...
string summary = conditions.GenerateSummary(false, true, false);
//
Print(summary);
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
int isExecuted = mTrader.ExecuteSignal(
signal,
state //
);
if (isExecuted)
{
//
string message = "Signal Executed Successfully ...";
//
mAlert.Alert(message);
}
}
//
// Custom Functions ...
//
bool InitialEA()
{
//
bool result = false;
//
TesterHideIndicators(true);
//
mAlert = new XSCAlert();
mAlert.SetLogAlerts(true);
mAlert.SetPrefix(ShortName);
mAlert.SetEnableAlerts(true);
mAlert.SetPushAlerts(false);
mAlert.SetMailAlerts(false);
mAlert.SetTerminalAlerts(false);
//
mTrader = new XSCTrade(
eaSlippage,
eaMagicNumber,
0,
0,
0 //
);
//
result = xBarTracker.Init(
_Symbol,
_Period //
);
if (!result)
{
return result;
}
//
X121SetupInputs x121Inputs;
x121Inputs.symbol = _Symbol;
x121Inputs.period = _Period;
result = x121Inputs.Init();
if (!result)
{
return result;
}
mSetup = new XSCX121Setup();
result = mSetup.Init(
x121Inputs //
);
if (!result)
{
return result;
}
//
// Init Temp ...
// //
// // CCI ...
// cciHandler = iCCI(
// _Symbol,
// _Period,
// 14,
// PRICE_CLOSE //
// );
// result = cciHandler != INVALID_HANDLE;
// if (!result)
// {
// return result;
// }
// //
// // RSI ...
// rsiHandler = iRSI(
// _Symbol,
// _Period,
// 14,
// PRICE_CLOSE //
// );
// result = rsiHandler != INVALID_HANDLE;
// if (!result)
// {
// return result;
// }
// //
// // MACD ...
// macdHandler = iMACD(
// _Symbol,
// _Period,
// 12,
// 26,
// 9,
// PRICE_CLOSE //
// );
// result = macdHandler != INVALID_HANDLE;
// if (!result)
// {
// return result;
// }
//
// Init Indicators ...
// //
// // XMATD ...
// XMATDInputs matdInputs;
// matdInputs.Default();
// matdHelper = new XSCXMATDHelper(
// _Symbol,
// _Period //
// );
// result = matdHelper.Init(matdInputs);
// if (!result)
// {
// return result;
// }
// //
// // XADXTD ...
// XADXTDInputs adxtdInputs;
// adxtdInputs.Default();
// adxtdHelper = new XSCXADXTDHelper(
// _Symbol,
// _Period //
// );
// result = adxtdHelper.Init(adxtdInputs);
// if (!result)
// {
// return result;
// }
// //
// // XSTR ...
// XSTRInputs strInputs;
// strInputs.Default();
// strInputs.showTrends = true;
// strHelper = new XSCXSTRHelper();
// result = strHelper.Init(
// _Symbol,
// _Period,
// strInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XCHE ...
// XCHEInputs cheInputs;
// cheInputs.Default();
// cheInputs.showLongExit1Line = true;
// cheInputs.showShortExit1Line = true;
// cheInputs.showLongExit2Line = true;
// cheInputs.showShortExit2Line = true;
// cheHelper = new XSCXCHEHelper();
// result = cheHelper.Init(
// _Symbol,
// _Period,
// cheInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XASCT ...
// XASCTInputs asctInputs;
// asctInputs.Default();
// asctInputs.showLongs = false;
// asctInputs.showShorts = false;
// asctHelper = new XSCXASCTHelper();
// result = asctHelper.Init(
// _Symbol,
// _Period,
// asctInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XTD ...
// XTDInputs tdInputs;
// tdInputs.Default();
// tdHelper = new XSCXTDHelper();
// result = tdHelper.Init(
// _Symbol,
// _Period,
// tdInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XICH ...
// XICHInputs ichInputs;
// ichInputs.Default();
// ichHelper = new XSCXICHHelper();
// result = ichHelper.Init(
// _Symbol,
// _Period,
// ichInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XHK ...
// XHKInputs hkInputs;
// hkInputs.Default();
// hkHelper = new XSCXHKHelper();
// result = hkHelper.Init(
// _Symbol,
// _Period,
// hkInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XMRB ...
// XMRBInputs mrbInputs;
// mrbInputs.Default();
// mrbHelper = new XSCXMRBHelper();
// result = mrbHelper.Init(
// _Symbol,
// _Period,
// mrbInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XSSLC ...
// XSSLCInputs sslcInputs;
// sslcInputs.Default();
// sslcHelper = new XSCXSSLCHelper();
// result = sslcHelper.Init(
// _Symbol,
// _Period,
// sslcInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XHULL ...
// XHULLInputs hullInputs;
// hullInputs.Default();
// hullHelper = new XSCXHULLHelper();
// result = hullHelper.Init(
// _Symbol,
// _Period,
// hullInputs //
// );
// if (!result)
// {
// return result;
// }
// //
// // XOSC ...
// XOSCInputs oscInputs;
// oscInputs.Default();
// oscHelper = new XSCXOSCHelper();
// result = oscHelper.Init(
// _Symbol,
// _Period,
// oscInputs //
// );
// if (!result)
// {
// return result;
// }
//
return result;
}