This commit is contained in:
2024-06-22 17:55:17 +03:30
parent fbe701f198
commit b88d74e57d
7 changed files with 2719 additions and 8 deletions
+363
View File
@@ -32,12 +32,16 @@
#include "../Helpers/x-saherelm.xpv.helper.mq5"
#include "../Helpers/x-saherelm.xtd.helper.mq5"
#include "../Helpers/x-saherelm.xhk.helper.mq5"
#include "../Helpers/x-saherelm.xsln.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.xvlm.helper.mq5"
#include "../Helpers/x-saherelm.xhtd.helper.mq5"
#include "../Helpers/x-saherelm.xatsl.helper.mq5"
#include "../Helpers/x-saherelm.xdmnt.helper.mq5"
#include "../Helpers/x-saherelm.xasct.helper.mq5"
#include "../Helpers/x-saherelm.xsslc.helper.mq5"
#include "../Helpers/x-saherelm.xhull.helper.mq5"
@@ -70,6 +74,7 @@ enum ENUM_X121_SIGNAL_PROVIDER
PROVIDER_XVLM = 17,
PROVIDER_XPVF = 18,
PROVIDER_XPVSAR = 19,
PROVIDER_XHTSRD = 20,
};
//
@@ -202,6 +207,10 @@ ENUM_X121_SIGNAL_PROVIDER FromString(string value)
{
result = PROVIDER_XPVSAR;
}
else if (Contains(value, (EnumToString(PROVIDER_XHTSRD))))
{
result = PROVIDER_XHTSRD;
}
//
return result;
@@ -222,12 +231,16 @@ struct X121SetupInputs
XPVInputs pvInputs; // XPV Inputs
XTDInputs tdInputs; // XTD Inputs
XHKInputs hkInputs; // XHK Inputs
XHTDInputs htdInputs; // XHTD Inputs
XCHEInputs cheInputs; // XCHE Inputs
XICHInputs ichInputs; // XICH Inputs
XSTRInputs strInputs; // XSTR Inputs
XMRBInputs mrbInputs; // XMRB Inputs
XOSCInputs oscInputs; // XOSC Inputs
XVLMInputs vlmInputs; // XVLM Inputs
XSLNInputs slnInputs; // XSLN Inputs
XATSLInputs atslInputs; // XATSL Inputs
XDMNTInputs dmntInputs; // XDMNT Inputs
XASCTInputs asctInputs; // XASCT Inputs
XSSLCInputs sslcInputs; // XSSLC Inputs
XHULLInputs hullInputs; // XHULL Inputs
@@ -259,12 +272,16 @@ struct X121SetupInputs
XPVInputs &_pvInputs, // XPV Inputs
XTDInputs &_tdInputs, // XTD Inputs
XHKInputs &_hkInputs, // XHK Inputs
XHTDInputs &_htdInputs, // XHTD Inputs
XCHEInputs &_cheInputs, // XCHE Inputs
XICHInputs &_ichInputs, // XICH Inputs
XSTRInputs &_strInputs, // XSTR Inputs
XMRBInputs &_mrbInputs, // XMRB Inputs
XOSCInputs &_oscInputs, // XOSC Inputs
XVLMInputs &_vlmInputs, // XVLM Inputs
XSLNInputs &_slnInputs, // XSLN Inputs
XATSLInputs &_atslInputs, // XATSL Inputs
XDMNTInputs &_dmntInputs, // XDMNT Inputs
XASCTInputs &_asctInputs, // XASCT Inputs
XSSLCInputs &_sslcInputs, // XSSLC Inputs
XHULLInputs &_hullInputs, // XHULL Inputs
@@ -281,12 +298,15 @@ struct X121SetupInputs
this.pvInputs = _pvInputs;
this.tdInputs = _tdInputs;
this.hkInputs = _hkInputs;
this.htdInputs = _htdInputs;
this.cheInputs = _cheInputs;
this.ichInputs = _ichInputs;
this.strInputs = _strInputs;
this.mrbInputs = _mrbInputs;
this.oscInputs = _oscInputs;
this.vlmInputs = _vlmInputs;
this.atslInputs = _atslInputs;
this.dmntInputs = _dmntInputs;
this.asctInputs = _asctInputs;
this.sslcInputs = _sslcInputs;
this.hullInputs = _hullInputs;
@@ -321,9 +341,13 @@ struct X121SetupInputs
mrbInputs.Clean();
oscInputs.Clean();
vlmInputs.Clean();
slnInputs.Clean();
htdInputs.Clean();
asctInputs.Clean();
sslcInputs.Clean();
hullInputs.Clean();
atslInputs.Clean();
dmntInputs.Clean();
adxtdInputs.Clean();
}
@@ -342,9 +366,13 @@ struct X121SetupInputs
mrbInputs.Default();
oscInputs.Default();
vlmInputs.Default();
slnInputs.Default();
htdInputs.Default();
asctInputs.Default();
sslcInputs.Default();
hullInputs.Default();
atslInputs.Default();
dmntInputs.Default();
adxtdInputs.Default();
}
@@ -374,6 +402,13 @@ struct X121SetupInputs
return result;
}
//
result = slnInputs.IsValid();
if (!result)
{
return result;
}
//
result = pvInputs.IsValid();
if (!result)
@@ -465,6 +500,27 @@ struct X121SetupInputs
return result;
}
//
result = htdInputs.IsValid();
if (!result)
{
return result;
}
//
result = atslInputs.IsValid();
if (!result)
{
return result;
}
//
result = dmntInputs.IsValid();
if (!result)
{
return result;
}
//
return result;
}
@@ -491,9 +547,13 @@ struct X121SetupConditions
XSTRConditions strConditions;
XMRBConditions mrbConditions;
XVLMConditions vlmConditions;
XHTDConditions htdConditions;
XSLNConditions slnConditions;
XATSLConditions atslConditions;
XASCTConditions asctConditions;
XSSLCConditions sslcConditions;
XHULLConditions hullConditions;
XDMNTConditions dmntConditions;
XADXTDConditions adxtdConditions;
//
@@ -530,9 +590,13 @@ struct X121SetupConditions
strConditions.Clean();
mrbConditions.Clean();
vlmConditions.Clean();
slnConditions.Clean();
htdConditions.Clean();
atslConditions.Clean();
asctConditions.Clean();
sslcConditions.Clean();
hullConditions.Clean();
dmntConditions.Clean();
adxtdConditions.Clean();
}
@@ -566,6 +630,14 @@ struct X121SetupConditions
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
slnConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
adxtdConditions.GenerateScore(
tempBullishScore,
@@ -653,6 +725,32 @@ struct X121SetupConditions
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
htdConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
atslConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
dmntConditions.GenerateScore(
tempBullishScore,
tempBearishScore //
);
bullishScore += tempBullishScore;
bearishScore += tempBearishScore;
//
}
//
@@ -703,9 +801,13 @@ struct X121SetupConditions
string ichSummary = ichConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string mrbSummary = mrbConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string vlmSummary = vlmConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string slnSummary = slnConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string htdSummary = htdConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string atsSummary = atslConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string asctSummary = asctConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string sslcSummary = sslcConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string hullSummary = hullConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string dmntSummary = dmntConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
string adxtdSummary = adxtdConditions.GenerateSummary(false, true, false, ignoreFalseConditions);
//
@@ -718,12 +820,16 @@ struct X121SetupConditions
ichSummary + separator +
mrbSummary + separator +
vlmSummary + separator +
slnSummary + separator +
strSummary + separator +
cheSummary + separator +
asctSummary + separator +
sslcSummary + separator +
hullSummary + separator +
adxtdSummary + separator +
htdSummary + separator +
atsSummary + separator +
dmntSummary + separator +
""
//
;
@@ -750,6 +856,115 @@ struct X121SetupConditions
return result;
}
//
// Add Combine Conditions ...
//
bool IsTrendBullish()
{
//
bool result = false;
//
result =
//
(strConditions.isTrendSwitchedToBullish &&
slnConditions.isBullish &&
htdConditions.isBullish &&
atslConditions.isBullish &&
cheConditions.isStrongBullish)
//
||
//
(slnConditions.isSwitchedToBullish &&
strConditions.isTrendBullish &&
htdConditions.isBullish &&
atslConditions.isBullish &&
cheConditions.isStrongBullish)
//
||
//
(htdConditions.isSwitchedToBullish &&
strConditions.isTrendBullish &&
slnConditions.isBullish &&
atslConditions.isBullish &&
cheConditions.isStrongBullish)
//
||
//
(atslConditions.isSwitchedToBullish &&
strConditions.isTrendBullish &&
htdConditions.isBullish &&
slnConditions.isBullish &&
cheConditions.isStrongBullish)
//
||
//
(cheConditions.isStrongSwitchedToBullish &&
strConditions.isTrendBullish &&
htdConditions.isBullish &&
slnConditions.isBullish &&
atslConditions.isBullish)
//
;
//
return result;
}
//
bool IsTrendBearish()
{
//
bool result = false;
//
result =
//
(strConditions.isTrendSwitchedToBearish &&
slnConditions.isBearish &&
htdConditions.isBearish &&
atslConditions.isBearish &&
cheConditions.isStrongBearish)
//
||
//
(slnConditions.isSwitchedToBearish &&
strConditions.isTrendBearish &&
htdConditions.isBearish &&
atslConditions.isBearish &&
cheConditions.isStrongBearish)
//
||
//
(htdConditions.isSwitchedToBearish &&
strConditions.isTrendBearish &&
slnConditions.isBearish &&
atslConditions.isBearish &&
cheConditions.isStrongBearish)
//
||
//
(atslConditions.isSwitchedToBearish &&
strConditions.isTrendBearish &&
htdConditions.isBearish &&
slnConditions.isBearish &&
cheConditions.isStrongBearish)
//
||
//
(cheConditions.isStrongSwitchedToBearish &&
strConditions.isTrendBearish &&
htdConditions.isBearish &&
slnConditions.isBearish &&
atslConditions.isBearish)
//
;
//
return result;
}
//
string GetTag()
{
@@ -827,6 +1042,7 @@ struct X121SignalGenerator
//
return result;
}
//
// Retrieve OSC Based Short Verifications ...
bool IsOSCShortVerified(
@@ -1400,6 +1616,8 @@ struct X121SignalGenerator
//
// XPVF ...
bool long18 =
//
false &&
//
// Starting Conditions ...
conditions.pvConditions.isFiboIncreased &&
@@ -1445,6 +1663,22 @@ struct X121SignalGenerator
provider = ToString(PROVIDER_XPVSAR);
}
//
// XHTSRD ...
bool long20 =
//
// Starting Conditions ...
conditions.IsTrendBullish() &&
conditions.dmntConditions.isBullish
//
;
if (long20)
{
//
pusher++;
provider = ToString(PROVIDER_XHTSRD);
}
//
result =
//
@@ -1527,6 +1761,10 @@ struct X121SignalGenerator
//
long19
//
||
//
long20
//
)
//
;
@@ -2068,6 +2306,8 @@ struct X121SignalGenerator
//
// XPVF ...
bool short18 =
//
false &&
//
// Starting Conditions ...
conditions.pvConditions.isFiboDecreased &&
@@ -2113,6 +2353,22 @@ struct X121SignalGenerator
provider = ToString(PROVIDER_XPVSAR);
}
//
// XHTSRD ...
bool short20 =
//
// Starting Conditions ...
conditions.IsTrendBearish() &&
conditions.dmntConditions.isBearish
//
;
if (short20)
{
//
pusher++;
provider = ToString(PROVIDER_XHTSRD);
}
//
result =
//
@@ -2195,6 +2451,10 @@ struct X121SignalGenerator
//
short19
//
||
//
short20
//
)
//
;
@@ -3477,9 +3737,13 @@ public:
XSCXMRBHelper *mrbHelper;
XSCXOSCHelper *oscHelper;
XSCXVLMHelper *vlmHelper;
XSCXSLNHelper *slnHelper;
XSCXHTDHelper *hdtHelper;
XSCXASCTHelper *asctHelper;
XSCXSSLCHelper *sslcHelper;
XSCXHULLHelper *hullHelper;
XSCXATSLHelper *atslHelper;
XSCXDMNTHelper *dmntHelper;
XSCXADXTDHelper *adxtdHelper;
//
@@ -3501,9 +3765,12 @@ public:
delete mrbHelper;
delete oscHelper;
delete vlmHelper;
delete hdtHelper;
delete asctHelper;
delete sslcHelper;
delete hullHelper;
delete atslHelper;
delete dmntHelper;
delete adxtdHelper;
}
@@ -3559,6 +3826,19 @@ public:
return result;
}
//
// XSLN ...
slnHelper = new XSCXSLNHelper();
result = slnHelper.Init(
inputs.symbol,
inputs.period,
inputs.slnInputs //
);
if (!result)
{
return result;
}
//
// XTD ...
tdHelper = new XSCXTDHelper();
@@ -3572,6 +3852,45 @@ public:
return result;
}
//
// XHTD ...
hdtHelper = new XSCXHTDHelper();
result = hdtHelper.Init(
inputs.symbol,
inputs.period,
inputs.htdInputs //
);
if (!result)
{
return result;
}
//
// XATSL ...
atslHelper = new XSCXATSLHelper();
result = atslHelper.Init(
inputs.symbol,
inputs.period,
inputs.atslInputs //
);
if (!result)
{
return result;
}
//
// XDMNT ...
dmntHelper = new XSCXDMNTHelper();
result = dmntHelper.Init(
inputs.symbol,
inputs.period,
inputs.dmntInputs //
);
if (!result)
{
return result;
}
//
// XHK ...
hkHelper = new XSCXHKHelper();
@@ -3764,6 +4083,50 @@ public:
conditions.period = GetPeriod();
conditions.time = TimeCurrent();
//
result = hdtHelper.GetConditions(
conditions.htdConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = slnHelper.GetConditions(
conditions.slnConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = atslHelper.GetConditions(
conditions.atslConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = dmntHelper.GetConditions(
conditions.dmntConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
//
result = pvHelper.GetConditions(
conditions.pvConditions,
+26 -8
View File
@@ -40,15 +40,16 @@ input int x121EASlippage = 10; // Slippgae
// EURUSDb,GBPUSDb,XAUUSDb,USDCHFb,USDJPYb
input group "Signals";
//,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD
input string x121EASymbols = "EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb"; // Symbols
input string x121EASymbols = "EURUSDb"; // Symbols
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
input bool x121EAAllowLong = true; // Allow Long Trades
input bool x121EAAllowShort = true; // Allow Short Trades
input int x121EADelayBetweenTwoSignal = 5; // Delay Between two Same Signals
input int x121EAReuiredSignalVerifications = 5; // Required Verifications for Signals
input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames
input int x121EAReuiredSignalVerifications = 1; // Required Verifications for Signals
input bool x121EAGetVerificationFromOtherTimeFrames = false; // Get Verifications from Other Time Frames
//
// Risk Management ...
@@ -383,6 +384,28 @@ bool InitialEA()
//
void X121PreConfigureStyles(X121SetupInputs &inputs)
{
//
// XHTD ...
inputs.htdInputs.show = true;
//
// XATSL ...
inputs.atslInputs.show = true;
//
// XSLN ...
inputs.slnInputs.show = true;
//
// XDMNT ...
inputs.dmntInputs.showBull = true;
inputs.dmntInputs.showBear = true;
//
// XSTR ...
inputs.strInputs.showTrends = true;
inputs.strInputs.fillTrends = false;
//
// XPV ...
inputs.pvInputs.showPeaksAndVales = false;
@@ -424,11 +447,6 @@ void X121PreConfigureStyles(X121SetupInputs &inputs)
inputs.ichInputs.showSenkouSpanB = false;
inputs.ichInputs.showKumo = false;
//
// XSTR ...
inputs.strInputs.showTrends = false;
inputs.strInputs.fillTrends = false;
//
// XMRB ...
inputs.mrbInputs.showFastMa = false;
+552
View File
@@ -0,0 +1,552 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXATSLHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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 "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XATSL_BUFFERS
{
XATSL_MAIN_LINE = 0,
};
//
// Input Models ...
struct XATSLInputs
{
//
// Props ...
//
// Market ...
int length; // Length
double coeff; // Coefficient
//
// Presentation ...
bool show; // Show
//
// Constructor(s) ...
XATSLInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
coeff = 0;
//
show = false;
}
//
// Default ...
void Default()
{
//
length = 14;
coeff = 2.0;
//
show = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 2 &&
coeff > 0
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, length);
//
return result;
}
};
//
// Define Conditions ...
struct XATSLConditions
{
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Buffers ...
double atsl[];
//
// Conditions ...
//
bool isBullish;
bool isBearish;
//
bool isSwitchedToBullish;
bool isSwitchedToBearish;
//
void Clean()
{
//
Clean(atsl);
//
ArraySetAsSeries(atsl, true);
//
isBullish = false;
isBearish = false;
isSwitchedToBullish = false;
isSwitchedToBearish = false;
}
//
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
if (isBullish)
{
bullishScore++;
}
if (isSwitchedToBullish)
{
bullishScore++;
}
if (isBearish)
{
bearishScore++;
}
if (isSwitchedToBearish)
{
bearishScore++;
}
}
//
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
ToString("isBullish", isBullish, ignoreFalseConditions, separator) +
ToString("isBearish", isBearish, ignoreFalseConditions, separator) +
ToString("isSwitchedToBullish", isSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSwitchedToBearish", isSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
//
string GetTag()
{
return "XATSL";
}
};
//
// Class ...
class XSCXATSLHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXATSLHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXATSLHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XATSLInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(atslBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xatsl",
//
// Inputs ...
//
// Market ...
"",
mInputs.length,
mInputs.coeff,
//
// Presentation ...
"",
mInputs.show
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XATSLInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XATSLInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetATSL(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(atslBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return atslBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyATSL(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
atslBuffer,
buffer,
forceClean
//
);
}
//
bool GetConditions(
XATSLConditions &conditions, //
int barIndex = 0, //
int loopback = 3 //
)
{
//
bool result = true;
//
if (loopback < 3)
{
loopback = 3;
}
//
conditions.Clean();
//
conditions.symbol = mSymbol;
conditions.period = mPeriod;
conditions.time = TimeCurrent();
//
int zIndex = barIndex;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Buffers ...
//
CopyATSL(
zIndex,
loopback,
conditions.atsl //
);
//
// Conditions ...
//
XOHCL cBar;
result = cBar.Init(
mSymbol,
mPeriod,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
mSymbol,
mPeriod,
pIndex //
);
if (!result)
{
return result;
}
//
bool isBullish = conditions.atsl[cIndex] < cBar.close;
bool isBullishPrev = conditions.atsl[pIndex] < pBar.close;
//
bool isBearish = conditions.atsl[cIndex] > cBar.close;
bool isBearishPrev = conditions.atsl[pIndex] > pBar.close;
//
bool isSwitchedToBullish = isBullish &&
!isBullishPrev;
bool isSwitchedToBearish = isBearish &&
!isBearishPrev;
//
conditions.isBullish = isBullish;
conditions.isBearish = isBearish;
conditions.isSwitchedToBullish = isSwitchedToBullish;
conditions.isSwitchedToBearish = isSwitchedToBearish;
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XATSLInputs mInputs; // Inputs ...
//
// Buffers ...
double atslBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
if (totalBars > 1000)
{
totalBars = 1000;
}
//
// Longs Buffer ...
CopyBuffer(
mHandler,
XATSL_MAIN_LINE,
0,
totalBars,
atslBuffer
//
);
}
};
//
+568
View File
@@ -0,0 +1,568 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXDMNTHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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 "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XDMNT_BUFFERS
{
XDMNT_BULL_LINE = 0,
XDMNT_BEAR_LINE = 1,
};
//
// Input Models ...
struct XDMNTInputs
{
//
// Props ...
//
// Presentation ...
bool showBull; // Show Bull
bool showBear; // Show Bear
//
// Constructor(s) ...
XDMNTInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
showBull = false;
showBear = false;
}
//
// Default ...
void Default()
{
//
showBull = true;
showBear = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
true
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = 0;
//
return result;
}
};
//
// Define Conditions ...
struct XDMNTConditions
{
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Buffers ...
double bull[];
double bear[];
//
// Conditions ...
//
bool isBullish;
bool isBearish;
//
void Clean()
{
//
Clean(bull);
Clean(bear);
//
ArraySetAsSeries(bull, true);
ArraySetAsSeries(bear, true);
//
isBullish = false;
isBearish = false;
}
//
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
if (isBullish)
{
bullishScore++;
}
//
if (isBearish)
{
bearishScore++;
}
}
//
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
ToString("isBullish", isBullish, ignoreFalseConditions, separator) +
ToString("isBearish", isBearish, ignoreFalseConditions, separator) +
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
//
string GetTag()
{
return "XDMNT";
}
};
//
// Class ...
class XSCXDMNTHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXDMNTHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXDMNTHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XDMNTInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(bullBuffer, true);
ArraySetAsSeries(bearBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xdmnt",
//
// Inputs ...
//
// Presentation ...
"",
mInputs.showBull,
mInputs.showBear
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XDMNTInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XDMNTInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
// Bull ...
//
double GetBull(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(bullBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return bullBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyBull(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
bullBuffer,
buffer,
forceClean
//
);
}
//
// Bear ...
//
double GetBear(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(bearBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return bearBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyBear(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
bearBuffer,
buffer,
forceClean
//
);
}
//
bool GetConditions(
XDMNTConditions &conditions, //
int barIndex = 0, //
int loopback = 3 //
)
{
//
bool result = true;
//
if (loopback < 3)
{
loopback = 3;
}
//
conditions.Clean();
//
conditions.symbol = mSymbol;
conditions.period = mPeriod;
conditions.time = TimeCurrent();
//
int zIndex = barIndex;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Buffers ...
//
CopyBull(
zIndex,
loopback,
conditions.bull //
);
//
CopyBear(
zIndex,
loopback,
conditions.bear //
);
//
// Conditions ...
//
bool isBullish = conditions.bull[cIndex] != 0;
//
bool isBearish = conditions.bear[cIndex] != 0;
//
conditions.isBullish = isBullish;
conditions.isBearish = isBearish;
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XDMNTInputs mInputs; // Inputs ...
//
// Buffers ...
double bullBuffer[];
double bearBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
if (totalBars > 1000)
{
totalBars = 1000;
}
//
// Bull Buffer ...
CopyBuffer(
mHandler,
XDMNT_BULL_LINE,
0,
totalBars,
bullBuffer
//
);
//
// Bear Buffer ...
CopyBuffer(
mHandler,
XDMNT_BEAR_LINE,
0,
totalBars,
bearBuffer
//
);
}
};
//
+560
View File
@@ -0,0 +1,560 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXHTDHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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 "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XHTD_BUFFERS
{
XHTD_MAIN_LINE = 0,
};
//
// Input Models ...
struct XHTDInputs
{
//
// Props ...
//
// Market ...
int length; // Length
ENUM_APPLIED_PRICE appliedTo; // Applied To
double multiplier; // Multiplier
//
// Presentation ...
bool show; // Show
//
// Constructor(s) ...
XHTDInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
multiplier = 0;
//
appliedTo = PRICE_CLOSE;
//
show = false;
}
//
// Default ...
void Default()
{
//
length = 14;
multiplier = 0.66;
//
appliedTo = PRICE_CLOSE;
//
show = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 2 &&
multiplier > 0
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, length);
//
return result;
}
};
//
// Define Conditions ...
struct XHTDConditions
{
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Buffers ...
double htd[];
//
// Conditions ...
//
bool isBullish;
bool isBearish;
//
bool isSwitchedToBullish;
bool isSwitchedToBearish;
//
void Clean()
{
//
Clean(htd);
//
ArraySetAsSeries(htd, true);
//
isBullish = false;
isBearish = false;
isSwitchedToBullish = false;
isSwitchedToBearish = false;
}
//
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
if (isBullish)
{
bullishScore++;
}
if (isSwitchedToBullish)
{
bullishScore++;
}
if (isBearish)
{
bearishScore++;
}
if (isSwitchedToBearish)
{
bearishScore++;
}
}
//
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
ToString("isBullish", isBullish, ignoreFalseConditions, separator) +
ToString("isBearish", isBearish, ignoreFalseConditions, separator) +
ToString("isSwitchedToBullish", isSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSwitchedToBearish", isSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
//
string GetTag()
{
return "XHTD";
}
};
//
// Class ...
class XSCXHTDHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXHTDHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXHTDHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XHTDInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(htdBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xhtd",
//
// Inputs ...
//
// Market ...
"",
mInputs.length,
mInputs.appliedTo,
mInputs.multiplier,
//
// Presentation ...
"",
mInputs.show
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XHTDInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XHTDInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetHTD(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(htdBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return htdBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyHTD(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
htdBuffer,
buffer,
forceClean
//
);
}
//
bool GetConditions(
XHTDConditions &conditions, //
int barIndex = 0, //
int loopback = 3 //
)
{
//
bool result = true;
//
if (loopback < 3)
{
loopback = 3;
}
//
conditions.Clean();
//
conditions.symbol = mSymbol;
conditions.period = mPeriod;
conditions.time = TimeCurrent();
//
int zIndex = barIndex;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Buffers ...
//
CopyHTD(
zIndex,
loopback,
conditions.htd //
);
//
// Conditions ...
//
XOHCL cBar;
result = cBar.Init(
mSymbol,
mPeriod,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
mSymbol,
mPeriod,
pIndex //
);
if (!result)
{
return result;
}
//
bool isBullish = conditions.htd[cIndex] < cBar.close;
bool isBullishPrev = conditions.htd[pIndex] < pBar.close;
//
bool isBearish = conditions.htd[cIndex] > cBar.close;
bool isBearishPrev = conditions.htd[pIndex] > pBar.close;
//
bool isSwitchedToBullish = isBullish &&
!isBullishPrev;
bool isSwitchedToBearish = isBearish &&
!isBearishPrev;
//
conditions.isBullish = isBullish;
conditions.isBearish = isBearish;
conditions.isSwitchedToBullish = isSwitchedToBullish;
conditions.isSwitchedToBearish = isSwitchedToBearish;
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XHTDInputs mInputs; // Inputs ...
//
// Buffers ...
double htdBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
if (totalBars > 1000)
{
totalBars = 1000;
}
//
// Longs Buffer ...
CopyBuffer(
mHandler,
XHTD_MAIN_LINE,
0,
totalBars,
htdBuffer
//
);
}
};
//
+638
View File
@@ -0,0 +1,638 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXSLNHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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 "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XSLN_STATE
{
XSLN_STATE_BULLISH = 1,
XSLN_STATE_BEARISH = -1,
};
//
enum ENUM_XSLN_BUFFERS
{
XSLN_MAIN_LINE = 0,
XSLN_STATE_LINE = 2,
};
//
// Input Models ...
struct XSLNInputs
{
//
// Props ...
//
// Presentation ...
bool show; // Show
//
// Constructor(s) ...
XSLNInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
show = false;
}
//
// Default ...
void Default()
{
//
show = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
true
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = 0;
//
return result;
}
};
//
// Define Conditions ...
struct XSLNConditions
{
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Buffers ...
double sln[];
double state[];
//
// Conditions ...
//
bool isBullish;
bool isBearish;
//
bool isSwitchedToBullish;
bool isSwitchedToBearish;
//
void Clean()
{
//
Clean(sln);
Clean(state);
//
ArraySetAsSeries(sln, true);
ArraySetAsSeries(state, true);
//
isBullish = false;
isBearish = false;
isSwitchedToBullish = false;
isSwitchedToBearish = false;
}
//
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
if (isBullish)
{
bullishScore++;
}
if (isSwitchedToBullish)
{
bullishScore++;
}
if (isBearish)
{
bearishScore++;
}
if (isSwitchedToBearish)
{
bearishScore++;
}
}
//
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
ToString("isBullish", isBullish, ignoreFalseConditions, separator) +
ToString("isBearish", isBearish, ignoreFalseConditions, separator) +
ToString("isSwitchedToBullish", isSwitchedToBullish, ignoreFalseConditions, separator) +
ToString("isSwitchedToBearish", isSwitchedToBearish, ignoreFalseConditions, separator) +
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
//
string GetTag()
{
return "XSLN";
}
};
//
// Class ...
class XSCXSLNHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXSLNHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXSLNHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XSLNInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(slnBuffer, true);
ArraySetAsSeries(stateBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xsln",
//
// Inputs ...
//
// Presentation ...
"",
mInputs.show
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XSLNInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XSLNInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetSLN(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(slnBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return slnBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySLN(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
slnBuffer,
buffer,
forceClean
//
);
}
//
double GetState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(stateBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return stateBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyState(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
stateBuffer,
buffer,
forceClean
//
);
}
//
ENUM_XSLN_STATE ToState(double value)
{
return (ENUM_XSLN_STATE)value;
}
//
bool IsBullish(double state)
{
//
bool result = false;
//
result = state == 1 || state == -1;
if (!result)
{
return result;
}
//
ENUM_XSLN_STATE eState = ToState(state);
result = eState == XSLN_STATE_BULLISH;
//
return result;
}
//
bool IsBearish(double state)
{
//
bool result = false;
//
result = state == 1 || state == -1;
if (!result)
{
return result;
}
//
ENUM_XSLN_STATE eState = ToState(state);
result = eState == XSLN_STATE_BEARISH;
//
return result;
}
//
bool GetConditions(
XSLNConditions &conditions, //
int barIndex = 0, //
int loopback = 3 //
)
{
//
bool result = true;
//
if (loopback < 3)
{
loopback = 3;
}
//
conditions.Clean();
//
conditions.symbol = mSymbol;
conditions.period = mPeriod;
conditions.time = TimeCurrent();
//
int zIndex = barIndex;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Buffers ...
//
CopySLN(
zIndex,
loopback,
conditions.sln //
);
//
CopyState(
zIndex,
loopback,
conditions.state //
);
//
// Conditions ...
//
bool isBullish = IsBullish(conditions.state[cIndex]);
bool isBullishPrev = IsBullish(conditions.state[pIndex]);
//
bool isBearish = IsBearish(conditions.state[cIndex]);
bool isBearishPrev = IsBearish(conditions.state[pIndex]);
//
bool isSwitchedToBullish = isBullish &&
!isBullishPrev;
bool isSwitchedToBearish = isBearish &&
!isBearishPrev;
//
conditions.isBullish = isBullish;
conditions.isBearish = isBearish;
conditions.isSwitchedToBullish = isSwitchedToBullish;
conditions.isSwitchedToBearish = isSwitchedToBearish;
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XSLNInputs mInputs; // Inputs ...
//
// Buffers ...
double slnBuffer[];
double stateBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
if (totalBars > 1000)
{
totalBars = 1000;
}
//
// Longs Buffer ...
CopyBuffer(
mHandler,
XSLN_MAIN_LINE,
0,
totalBars,
slnBuffer
//
);
//
// Longs Buffer ...
CopyBuffer(
mHandler,
XSLN_STATE_LINE,
0,
totalBars,
stateBuffer
//
);
}
};
//
+12
View File
@@ -49,6 +49,10 @@ double mainBuffer[];
#define mainBufferColorIndex 1
double mainBufferColor[];
//
#define stateBufferIndex 2
double stateBuffer[];
//
#define hideColorIDX 0
#define bullColorIDX 1
@@ -204,17 +208,22 @@ int OnCalculate(
}
//
stateBuffer[i] = stateBuffer[i - 1];
mainBufferColor[i] = mainBufferColor[i - 1];
//
if (work[i][trend] == 1)
{
//
stateBuffer[i] = 1;
mainBufferColor[i] = bullColorIDX;
}
//
if (work[i][trend] == -1)
{
//
stateBuffer[i] = -1;
mainBufferColor[i] = bearColorIDX;
}
}
@@ -259,6 +268,9 @@ void DefineBuffers()
SetIndexBuffer(mainBufferIndex, mainBuffer, INDICATOR_DATA);
PlotIndexSetInteger(mainBufferIndex, PLOT_DRAW_TYPE, mainDrawType);
SetIndexBuffer(mainBufferColorIndex, mainBufferColor, INDICATOR_COLOR_INDEX);
//
SetIndexBuffer(stateBufferIndex, stateBuffer, INDICATOR_CALCULATIONS);
}
//