prepare all indicators for working by new structures of libraries and models and compile them successfully ...
This commit is contained in:
@@ -0,0 +1,441 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCMD5
|
||||
// Description: Provides MD5 Hashing 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
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
static uchar _md5_PADDING[64] =
|
||||
{
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
//
|
||||
#define _md5_F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
#define _md5_G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
||||
#define _md5_H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define _md5_I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
#define _md5_ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
|
||||
//
|
||||
#define _md5_FF(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_F((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_GG(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_G((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_HH(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_H((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_II(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_I((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_INIT_STATE_0 0x67452301
|
||||
#define _md5_INIT_STATE_1 0xefcdab89
|
||||
#define _md5_INIT_STATE_2 0x98badcfe
|
||||
#define _md5_INIT_STATE_3 0x10325476
|
||||
|
||||
//
|
||||
#define _md5_S11 7
|
||||
#define _md5_S12 12
|
||||
#define _md5_S13 17
|
||||
#define _md5_S14 22
|
||||
|
||||
//
|
||||
#define _md5_S21 5
|
||||
#define _md5_S22 9
|
||||
#define _md5_S23 14
|
||||
#define _md5_S24 20
|
||||
|
||||
//
|
||||
#define _md5_S31 4
|
||||
#define _md5_S32 11
|
||||
#define _md5_S33 16
|
||||
#define _md5_S34 23
|
||||
|
||||
//
|
||||
#define _md5_S41 6
|
||||
#define _md5_S42 10
|
||||
#define _md5_S43 15
|
||||
#define _md5_S44 21
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// XCMD5 a library for Hashing ...
|
||||
class XSCMD5
|
||||
{
|
||||
//
|
||||
// Public Provides ...
|
||||
public:
|
||||
//
|
||||
// Protected Provides ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XSCMD5(void) {}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCMD5(void) {}
|
||||
|
||||
//
|
||||
// Hash Specified Char Array ...
|
||||
string Hash(
|
||||
uchar &mSource[], // Specify Char Array to Hash
|
||||
int mLength = 0 // Specify Length of Char Array which required to hash
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
int sourceCount = ArraySize(mSource);
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
sourceCount <= 0 ||
|
||||
(sourceCount > 0 && mLength > sourceCount))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
if (mLength == 0)
|
||||
{
|
||||
mLength = sourceCount;
|
||||
}
|
||||
|
||||
//
|
||||
// Init MD5 ...
|
||||
MD5Init();
|
||||
|
||||
//
|
||||
// Update Buffer ...
|
||||
MD5Update(mSource, mLength);
|
||||
|
||||
//
|
||||
// Calculate Result ...
|
||||
result = MD5Final();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Hash Specified String ...
|
||||
string Hash(
|
||||
string mSource // Specified String
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
// Converts String to Char Array ...
|
||||
uchar bytes[];
|
||||
StringToCharArray(
|
||||
mSource,
|
||||
bytes,
|
||||
0,
|
||||
StringLen(mSource));
|
||||
|
||||
//
|
||||
result = Hash(
|
||||
bytes,
|
||||
ArraySize(bytes));
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
//
|
||||
// Private Provides ...
|
||||
private:
|
||||
//
|
||||
uint m_lMD5[4];
|
||||
uint m_nCount[2];
|
||||
uchar m_lpszBuffer[64];
|
||||
|
||||
//
|
||||
// Convert Byte to DWord ...
|
||||
void ByteToDWord(int &out[], uint &in[], uint len)
|
||||
{
|
||||
//
|
||||
uint i = 0;
|
||||
uint j = 0;
|
||||
|
||||
//
|
||||
for (; j < len; i++, j += 4)
|
||||
{
|
||||
out[i] = (int)in[j] | (int)in[j + 1] << 8 | (int)in[j + 2] << 16 | (int)in[j + 3] << 24;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Convert DWord to Byte ...
|
||||
void DWordToByte(uchar &out[], int &in[], uint len)
|
||||
{
|
||||
//
|
||||
uint i = 0;
|
||||
uint j = 0;
|
||||
|
||||
//
|
||||
for (; j < len; i++, j += 4)
|
||||
{
|
||||
//
|
||||
out[j] = (uchar)(in[i] & 0xff);
|
||||
out[j + 1] = (uchar)((in[i] >> 8) & 0xff);
|
||||
out[j + 2] = (uchar)((in[i] >> 16) & 0xff);
|
||||
out[j + 3] = (uchar)((in[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Init MD5 Array ...
|
||||
void MD5Init()
|
||||
{
|
||||
//
|
||||
ArrayInitialize(m_lpszBuffer, 64);
|
||||
|
||||
//
|
||||
m_nCount[0] = m_nCount[1] = 0;
|
||||
m_lMD5[0] = _md5_INIT_STATE_0;
|
||||
m_lMD5[1] = _md5_INIT_STATE_1;
|
||||
m_lMD5[2] = _md5_INIT_STATE_2;
|
||||
m_lMD5[3] = _md5_INIT_STATE_3;
|
||||
}
|
||||
|
||||
//
|
||||
// Update MD5 ...
|
||||
void MD5Update(uchar &inBuf[], uint inLen)
|
||||
{
|
||||
//
|
||||
int i, ii;
|
||||
int mdi;
|
||||
|
||||
//
|
||||
uint in[16];
|
||||
int i0 = 0;
|
||||
|
||||
//
|
||||
mdi = (int)((m_nCount[0] >> 3) & 0x3F);
|
||||
|
||||
//
|
||||
if ((m_nCount[0] + ((uint)inLen << 3)) < m_nCount[0])
|
||||
{
|
||||
m_nCount[1]++;
|
||||
}
|
||||
|
||||
//
|
||||
m_nCount[0] += ((uint)inLen << 3);
|
||||
m_nCount[1] += ((uint)inLen >> 29);
|
||||
|
||||
//
|
||||
while ((inLen--) > 0)
|
||||
{
|
||||
//
|
||||
m_lpszBuffer[mdi++] = inBuf[i0++];
|
||||
if (mdi == 0x40)
|
||||
{
|
||||
//
|
||||
for (i = 0, ii = 0; i < 16; i++, ii += 4)
|
||||
{
|
||||
in[i] = (((uint)m_lpszBuffer[ii + 3]) << 24) | (((uint)m_lpszBuffer[ii + 2]) << 16) | (((uint)m_lpszBuffer[ii + 1]) << 8) | ((uint)m_lpszBuffer[ii]);
|
||||
}
|
||||
|
||||
//
|
||||
Transform(m_lMD5, in);
|
||||
|
||||
//
|
||||
mdi = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Finalize an MD5 Expression ...
|
||||
string MD5Final()
|
||||
{
|
||||
//
|
||||
uchar bits[8];
|
||||
int nIndex;
|
||||
uint nPadLen;
|
||||
const int nMD5Size = 16;
|
||||
uchar lpszMD5[16];
|
||||
string temp;
|
||||
string out = "";
|
||||
int i;
|
||||
|
||||
//
|
||||
DWordToByte(bits, m_nCount, 8);
|
||||
nIndex = (int)((m_nCount[0] >> 3) & 0x3f);
|
||||
nPadLen = (nIndex < 56) ? (56 - nIndex) : (120 - nIndex);
|
||||
MD5Update(_md5_PADDING, nPadLen);
|
||||
MD5Update(bits, 8);
|
||||
DWordToByte(lpszMD5, m_lMD5, nMD5Size);
|
||||
|
||||
//
|
||||
for (i = 0; i < nMD5Size; i++)
|
||||
{
|
||||
//
|
||||
if (lpszMD5[i] == 0)
|
||||
{
|
||||
temp = "00";
|
||||
}
|
||||
else if (lpszMD5[i] <= 15)
|
||||
{
|
||||
temp = StringFormat("0%x", lpszMD5[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = StringFormat("%x", lpszMD5[i]);
|
||||
}
|
||||
|
||||
//
|
||||
out += temp;
|
||||
}
|
||||
|
||||
//
|
||||
lpszMD5[0] = '\0';
|
||||
|
||||
//
|
||||
return (out);
|
||||
}
|
||||
|
||||
//
|
||||
// Transform Buffers ...
|
||||
void Transform(uint &buf[], uint &in[])
|
||||
{
|
||||
//
|
||||
uint a = buf[0], b = buf[1], c = buf[2], d = buf[3];
|
||||
|
||||
//
|
||||
_md5_FF(a, b, c, d, in[0], _md5_S11, 0xD76AA478);
|
||||
_md5_FF(d, a, b, c, in[1], _md5_S12, 0xE8C7B756);
|
||||
_md5_FF(c, d, a, b, in[2], _md5_S13, 0x242070DB);
|
||||
_md5_FF(b, c, d, a, in[3], _md5_S14, 0xC1BDCEEE);
|
||||
_md5_FF(a, b, c, d, in[4], _md5_S11, 0xF57C0FAF);
|
||||
_md5_FF(d, a, b, c, in[5], _md5_S12, 0x4787C62A);
|
||||
_md5_FF(c, d, a, b, in[6], _md5_S13, 0xA8304613);
|
||||
_md5_FF(b, c, d, a, in[7], _md5_S14, 0xFD469501);
|
||||
_md5_FF(a, b, c, d, in[8], _md5_S11, 0x698098D8);
|
||||
_md5_FF(d, a, b, c, in[9], _md5_S12, 0x8B44F7AF);
|
||||
_md5_FF(c, d, a, b, in[10], _md5_S13, 0xFFFF5BB1);
|
||||
_md5_FF(b, c, d, a, in[11], _md5_S14, 0x895CD7BE);
|
||||
_md5_FF(a, b, c, d, in[12], _md5_S11, 0x6B901122);
|
||||
_md5_FF(d, a, b, c, in[13], _md5_S12, 0xFD987193);
|
||||
_md5_FF(c, d, a, b, in[14], _md5_S13, 0xA679438E);
|
||||
_md5_FF(b, c, d, a, in[15], _md5_S14, 0x49B40821);
|
||||
|
||||
//
|
||||
_md5_GG(a, b, c, d, in[1], _md5_S21, 0xF61E2562);
|
||||
_md5_GG(d, a, b, c, in[6], _md5_S22, 0xC040B340);
|
||||
_md5_GG(c, d, a, b, in[11], _md5_S23, 0x265E5A51);
|
||||
_md5_GG(b, c, d, a, in[0], _md5_S24, 0xE9B6C7AA);
|
||||
_md5_GG(a, b, c, d, in[5], _md5_S21, 0xD62F105D);
|
||||
_md5_GG(d, a, b, c, in[10], _md5_S22, 0x02441453);
|
||||
_md5_GG(c, d, a, b, in[15], _md5_S23, 0xD8A1E681);
|
||||
_md5_GG(b, c, d, a, in[4], _md5_S24, 0xE7D3FBC8);
|
||||
_md5_GG(a, b, c, d, in[9], _md5_S21, 0x21E1CDE6);
|
||||
_md5_GG(d, a, b, c, in[14], _md5_S22, 0xC33707D6);
|
||||
_md5_GG(c, d, a, b, in[3], _md5_S23, 0xF4D50D87);
|
||||
_md5_GG(b, c, d, a, in[8], _md5_S24, 0x455A14ED);
|
||||
_md5_GG(a, b, c, d, in[13], _md5_S21, 0xA9E3E905);
|
||||
_md5_GG(d, a, b, c, in[2], _md5_S22, 0xFCEFA3F8);
|
||||
_md5_GG(c, d, a, b, in[7], _md5_S23, 0x676F02D9);
|
||||
_md5_GG(b, c, d, a, in[12], _md5_S24, 0x8D2A4C8A);
|
||||
|
||||
//
|
||||
_md5_HH(a, b, c, d, in[5], _md5_S31, 0xFFFA3942);
|
||||
_md5_HH(d, a, b, c, in[8], _md5_S32, 0x8771F681);
|
||||
_md5_HH(c, d, a, b, in[11], _md5_S33, 0x6D9D6122);
|
||||
_md5_HH(b, c, d, a, in[14], _md5_S34, 0xFDE5380C);
|
||||
_md5_HH(a, b, c, d, in[1], _md5_S31, 0xA4BEEA44);
|
||||
_md5_HH(d, a, b, c, in[4], _md5_S32, 0x4BDECFA9);
|
||||
_md5_HH(c, d, a, b, in[7], _md5_S33, 0xF6BB4B60);
|
||||
_md5_HH(b, c, d, a, in[10], _md5_S34, 0xBEBFBC70);
|
||||
_md5_HH(a, b, c, d, in[13], _md5_S31, 0x289B7EC6);
|
||||
_md5_HH(d, a, b, c, in[0], _md5_S32, 0xEAA127FA);
|
||||
_md5_HH(c, d, a, b, in[3], _md5_S33, 0xD4EF3085);
|
||||
_md5_HH(b, c, d, a, in[6], _md5_S34, 0x04881D05);
|
||||
_md5_HH(a, b, c, d, in[9], _md5_S31, 0xD9D4D039);
|
||||
_md5_HH(d, a, b, c, in[12], _md5_S32, 0xE6DB99E5);
|
||||
_md5_HH(c, d, a, b, in[15], _md5_S33, 0x1FA27CF8);
|
||||
_md5_HH(b, c, d, a, in[2], _md5_S34, 0xC4AC5665);
|
||||
|
||||
//
|
||||
_md5_II(a, b, c, d, in[0], _md5_S41, 0xF4292244);
|
||||
_md5_II(d, a, b, c, in[7], _md5_S42, 0x432AFF97);
|
||||
_md5_II(c, d, a, b, in[14], _md5_S43, 0xAB9423A7);
|
||||
_md5_II(b, c, d, a, in[5], _md5_S44, 0xFC93A039);
|
||||
_md5_II(a, b, c, d, in[12], _md5_S41, 0x655B59C3);
|
||||
_md5_II(d, a, b, c, in[3], _md5_S42, 0x8F0CCC92);
|
||||
_md5_II(c, d, a, b, in[10], _md5_S43, 0xFFEFF47D);
|
||||
_md5_II(b, c, d, a, in[1], _md5_S44, 0x85845DD1);
|
||||
_md5_II(a, b, c, d, in[8], _md5_S41, 0x6FA87E4F);
|
||||
_md5_II(d, a, b, c, in[15], _md5_S42, 0xFE2CE6E0);
|
||||
_md5_II(c, d, a, b, in[6], _md5_S43, 0xA3014314);
|
||||
_md5_II(b, c, d, a, in[13], _md5_S44, 0x4E0811A1);
|
||||
_md5_II(a, b, c, d, in[4], _md5_S41, 0xF7537E82);
|
||||
_md5_II(d, a, b, c, in[11], _md5_S42, 0xBD3AF235);
|
||||
_md5_II(c, d, a, b, in[2], _md5_S43, 0x2AD7D2BB);
|
||||
_md5_II(b, c, d, a, in[9], _md5_S44, 0xEB86D391);
|
||||
|
||||
//
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
};
|
||||
@@ -48,10 +48,6 @@ input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Applied To
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
@@ -106,9 +102,6 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
|
||||
//
|
||||
// Initializing MA Handler ...
|
||||
maHandler = iAMA(
|
||||
@@ -121,10 +114,6 @@ int OnInit()
|
||||
appliedTo);
|
||||
if (maHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
string message = "Error Initializing Ma Handler ...";
|
||||
LogMessage(message);
|
||||
|
||||
//
|
||||
return INIT_FAILED;
|
||||
}
|
||||
@@ -320,7 +309,12 @@ void CalculateBuffers(int bar_index)
|
||||
{
|
||||
//
|
||||
// Requirements ...
|
||||
XOHCL candle = GetCandle(bar_index);
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index
|
||||
);
|
||||
|
||||
//
|
||||
double maValue = maBuffer[bar_index];
|
||||
|
||||
@@ -33,9 +33,6 @@ enum ENUM_X_XCHLH_HOT_STATES
|
||||
X_XCHLH_HOT_LL = -1,
|
||||
};
|
||||
|
||||
//
|
||||
// Including Models Library ...
|
||||
#include "../Libraries/x-saherelm.models.lib.mq5"
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
@@ -190,7 +187,6 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
@@ -229,10 +225,6 @@ void OnDeinit(const int reason)
|
||||
// ReDraw Chart ...
|
||||
ChartRedraw();
|
||||
|
||||
//
|
||||
// De Init Draw Library ...
|
||||
OnDeinitDrawLibrary();
|
||||
|
||||
//
|
||||
Comment("");
|
||||
}
|
||||
@@ -529,15 +521,35 @@ void LCCalculateBuffers(
|
||||
ENUM_SERIESMODE hhMode = lcHHMode;
|
||||
ENUM_SERIESMODE llMode = lcLLMode;
|
||||
double threshold = PipsToPrice(lcThresholdInPips);
|
||||
double hh = GetHighestHigh(
|
||||
|
||||
//
|
||||
int hhIdx = iHighest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index,
|
||||
hhMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double hh = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIdx);
|
||||
double hhValue = hh + threshold;
|
||||
double ll = GetLowestLow(
|
||||
|
||||
//
|
||||
int llIdx = iLowest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index,
|
||||
llMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double ll = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIdx);
|
||||
double llValue = ll - threshold;
|
||||
|
||||
//
|
||||
@@ -557,15 +569,35 @@ void MCCalculateBuffers(
|
||||
ENUM_SERIESMODE hhMode = mcHHMode;
|
||||
ENUM_SERIESMODE llMode = mcLLMode;
|
||||
double threshold = PipsToPrice(mcThresholdInPips);
|
||||
double hh = GetHighestHigh(
|
||||
|
||||
//
|
||||
int hhIdx = iHighest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index,
|
||||
hhMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double hh = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIdx);
|
||||
double hhValue = hh + threshold;
|
||||
double ll = GetLowestLow(
|
||||
|
||||
//
|
||||
int llIdx = iLowest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index,
|
||||
llMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double ll = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIdx);
|
||||
double llValue = ll - threshold;
|
||||
|
||||
//
|
||||
@@ -585,15 +617,35 @@ void SCCalculateBuffers(
|
||||
ENUM_SERIESMODE hhMode = scHHMode;
|
||||
ENUM_SERIESMODE llMode = scLLMode;
|
||||
double threshold = PipsToPrice(scThresholdInPips);
|
||||
double hh = GetHighestHigh(
|
||||
|
||||
//
|
||||
int hhIdx = iHighest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index,
|
||||
hhMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double hh = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIdx);
|
||||
double hhValue = hh + threshold;
|
||||
double ll = GetLowestLow(
|
||||
|
||||
//
|
||||
int llIdx = iLowest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index,
|
||||
llMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double ll = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIdx);
|
||||
double llValue = ll - threshold;
|
||||
|
||||
//
|
||||
@@ -710,7 +762,13 @@ void DrawBuffers(
|
||||
|
||||
//
|
||||
// Retrieve Candle Model ...
|
||||
XOHCL candle = GetCandle(bar_index);
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
datetime time = iTime(_Symbol, _Period, bar_index);
|
||||
|
||||
//
|
||||
|
||||
@@ -110,10 +110,6 @@ input bool scDrawCrosses = false; // Draw Cross Lines
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
@@ -205,7 +201,6 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
@@ -251,10 +246,6 @@ void OnDeinit(const int reason)
|
||||
// ReDraw Chart ...
|
||||
ChartRedraw();
|
||||
|
||||
//
|
||||
// De Init Draw Library ...
|
||||
OnDeinitDrawLibrary();
|
||||
|
||||
//
|
||||
Comment("");
|
||||
}
|
||||
@@ -640,10 +631,6 @@ bool LCInitHandlers()
|
||||
lcAppliedTo);
|
||||
if (lcFastHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("LC Fast Indicator initialization failed: " + (string)GetLastError());
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -658,10 +645,6 @@ bool LCInitHandlers()
|
||||
lcAppliedTo);
|
||||
if (lcSlowHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("LC Slow Indicator initialization failed: " + (string)GetLastError());
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -687,10 +670,6 @@ bool MCInitHandlers()
|
||||
mcAppliedTo);
|
||||
if (mcFastHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("MC Fast Indicator initialization failed: " + (string)GetLastError());
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -705,10 +684,6 @@ bool MCInitHandlers()
|
||||
mcAppliedTo);
|
||||
if (mcSlowHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("MC Slow Indicator initialization failed: " + (string)GetLastError());
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -734,10 +709,6 @@ bool SCInitHandlers()
|
||||
scAppliedTo);
|
||||
if (scFastHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("SC Fast Indicator initialization failed: " + (string)GetLastError());
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -752,10 +723,6 @@ bool SCInitHandlers()
|
||||
scAppliedTo);
|
||||
if (scSlowHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("SC Slow Indicator initialization failed: " + (string)GetLastError());
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -771,7 +738,7 @@ double GetLCState(
|
||||
{
|
||||
//
|
||||
// Fast Cross Over Slow Detection ...
|
||||
bool isFastCrossedOverSlow = IsCrossOver(
|
||||
bool isFastCrossedOverSlow = IsCrossedOver(
|
||||
lcFastBuffer,
|
||||
lcSlowBuffer,
|
||||
bar_index);
|
||||
@@ -785,7 +752,7 @@ double GetLCState(
|
||||
|
||||
//
|
||||
// Fast Cross Under Slow Detection ...
|
||||
bool isFastCrossedUnderSlow = IsCrossUnder(
|
||||
bool isFastCrossedUnderSlow = IsCrossedUnder(
|
||||
lcFastBuffer,
|
||||
lcSlowBuffer,
|
||||
bar_index);
|
||||
@@ -833,7 +800,7 @@ double GetMCState(
|
||||
{
|
||||
//
|
||||
// Fast Cross Over Slow Detection ...
|
||||
bool isFastCrossedOverSlow = IsCrossOver(
|
||||
bool isFastCrossedOverSlow = IsCrossedOver(
|
||||
mcFastBuffer,
|
||||
mcSlowBuffer,
|
||||
bar_index);
|
||||
@@ -847,7 +814,7 @@ double GetMCState(
|
||||
|
||||
//
|
||||
// Fast Cross Under Slow Detection ...
|
||||
bool isFastCrossedUnderSlow = IsCrossUnder(
|
||||
bool isFastCrossedUnderSlow = IsCrossedUnder(
|
||||
mcFastBuffer,
|
||||
mcSlowBuffer,
|
||||
bar_index);
|
||||
@@ -895,7 +862,7 @@ double GetSCState(
|
||||
{
|
||||
//
|
||||
// Fast Cross Over Slow Detection ...
|
||||
bool isFastCrossedOverSlow = IsCrossOver(
|
||||
bool isFastCrossedOverSlow = IsCrossedOver(
|
||||
scFastBuffer,
|
||||
scSlowBuffer,
|
||||
bar_index);
|
||||
@@ -909,7 +876,7 @@ double GetSCState(
|
||||
|
||||
//
|
||||
// Fast Cross Under Slow Detection ...
|
||||
bool isFastCrossedUnderSlow = IsCrossUnder(
|
||||
bool isFastCrossedUnderSlow = IsCrossedUnder(
|
||||
scFastBuffer,
|
||||
scSlowBuffer,
|
||||
bar_index);
|
||||
@@ -1031,7 +998,13 @@ void DrawBuffers(
|
||||
|
||||
//
|
||||
// Retrieve Candle Model ...
|
||||
XOHCL candle = GetCandle(bar_index);
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
datetime time = iTime(_Symbol, _Period, bar_index);
|
||||
|
||||
//
|
||||
|
||||
@@ -39,6 +39,14 @@ input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER;
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 0
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
@@ -38,10 +38,6 @@ input ENUM_APPLIED_VOLUME appliedTo = VOLUME_TICK; // Applied To
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
@@ -96,9 +92,6 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
|
||||
//
|
||||
fiHandler = iForce(
|
||||
_Symbol,
|
||||
@@ -108,11 +101,6 @@ int OnInit()
|
||||
appliedTo);
|
||||
if (fiHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
string message = "Error Initializing Handler ...";
|
||||
LogMessage(message);
|
||||
|
||||
//
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,6 @@ input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
@@ -121,9 +117,6 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
|
||||
//
|
||||
// Define Index Buffers ...
|
||||
DefineBuffers();
|
||||
@@ -310,10 +303,17 @@ void CalculateBuffers(
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index);
|
||||
double hhValue = GetAppliedPrice(
|
||||
hhIndex,
|
||||
hhMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
XOHCL hhBar;
|
||||
hhBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIndex
|
||||
//
|
||||
);
|
||||
double hhValue = hhBar.GetPrice(hhMode);
|
||||
|
||||
//
|
||||
hhBuffer[bar_index] = hhValue;
|
||||
@@ -325,16 +325,22 @@ void CalculateBuffers(
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index);
|
||||
double llValue = GetAppliedPrice(
|
||||
llIndex,
|
||||
llMode);
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
XOHCL llBar;
|
||||
llBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIndex
|
||||
//
|
||||
);
|
||||
double llValue = llBar.GetPrice(llMode);
|
||||
|
||||
//
|
||||
llBuffer[bar_index] = llValue;
|
||||
|
||||
//
|
||||
XOHCL c = GetCandle(bar_index);
|
||||
double lhDiff = hhValue - llValue;
|
||||
double signalValue = (lhDiff / 2);
|
||||
|
||||
|
||||
@@ -44,10 +44,6 @@ input color swingLowArrowColor = clrAqua; // Swing Low Arrow Color
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Include Common and Models Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
@@ -94,7 +90,6 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
@@ -125,10 +120,6 @@ void OnDeinit(const int reason)
|
||||
// REASON_TEMPLATE 7 Another chart template applied
|
||||
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
||||
// REASON_CLOSE 9 Terminal closed
|
||||
|
||||
//
|
||||
// Here we can handle De Initialization Reasons ...
|
||||
OnDeinitDrawLibrary();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -264,32 +255,30 @@ void CalculateBuffers(int bar_index)
|
||||
|
||||
//
|
||||
// Reading Candles Data ...
|
||||
XOHCL candles[];
|
||||
for (int i = bar_index; i < bar_index + ((length * 2) + 2); i++)
|
||||
{
|
||||
int start = bar_index;
|
||||
int count = (length * 2) + 2;
|
||||
int end = start + count;
|
||||
XOHCL bars[];
|
||||
GetBars(
|
||||
bars,
|
||||
_Symbol,
|
||||
_Period,
|
||||
start,
|
||||
count
|
||||
//
|
||||
XOHCL iCandle = GetCandle(
|
||||
_Symbol,
|
||||
_Period,
|
||||
i);
|
||||
|
||||
//
|
||||
Add(
|
||||
iCandle,
|
||||
candles);
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
// Swing Low ...
|
||||
isSwingLow =
|
||||
//
|
||||
candles[1].close > candles[2].close &&
|
||||
candles[2].close > candles[3].close &&
|
||||
bars[1].close > bars[2].close &&
|
||||
bars[2].close > bars[3].close &&
|
||||
//
|
||||
candles[3].close < candles[4].close &&
|
||||
bars[3].close < bars[4].close &&
|
||||
//
|
||||
candles[5].close > candles[4].close &&
|
||||
candles[6].close > candles[5].close
|
||||
bars[5].close > bars[4].close &&
|
||||
bars[6].close > bars[5].close
|
||||
//
|
||||
;
|
||||
|
||||
@@ -306,13 +295,13 @@ void CalculateBuffers(int bar_index)
|
||||
// Swing High ...
|
||||
isSwingHigh =
|
||||
//
|
||||
candles[1].close < candles[2].close &&
|
||||
candles[2].close < candles[3].close &&
|
||||
bars[1].close < bars[2].close &&
|
||||
bars[2].close < bars[3].close &&
|
||||
//
|
||||
candles[3].close > candles[4].close &&
|
||||
bars[3].close > bars[4].close &&
|
||||
//
|
||||
candles[5].close < candles[4].close &&
|
||||
candles[6].close < candles[5].close
|
||||
bars[5].close < bars[4].close &&
|
||||
bars[6].close < bars[5].close
|
||||
//
|
||||
;
|
||||
|
||||
@@ -355,12 +344,17 @@ void CalculateBuffers(int bar_index)
|
||||
//
|
||||
// Draw a Swing Arrow Shape ...
|
||||
void DrawSwingArrow(
|
||||
int type, // Swing Type: 0 - Low / 1 - High ...
|
||||
int bar_index)
|
||||
int type, // Swing Type: 0 - Low / 1 - High ...
|
||||
int bar_index //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool isSwingHigh = type == 1;
|
||||
XOHCL candle = GetCandle(bar_index + 3);
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index + 3);
|
||||
double arrowDistanceInPoint = 0;
|
||||
|
||||
//
|
||||
|
||||
@@ -66,10 +66,6 @@ input ENUM_LINE_STYLE longExitLineStyle = STYLE_DOT; // Long Exit Style
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Include Common and Models Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
@@ -127,9 +123,6 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
|
||||
//
|
||||
rsiHandler = iRSI(
|
||||
_Symbol,
|
||||
|
||||
@@ -38,10 +38,6 @@ enum ENUM_X_XTD_STATES
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// Include Models Library ...
|
||||
#include "../Libraries/x-saherelm.models.lib.mq5"
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
@@ -61,10 +57,6 @@ input color bearishArrowColor = clrMagenta; // Cross Under Arrow Color
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5";
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5";
|
||||
@@ -141,7 +133,6 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
@@ -175,10 +166,6 @@ void OnDeinit(const int reason)
|
||||
|
||||
//
|
||||
// Here we can handle De Initialization Reasons ...
|
||||
|
||||
//
|
||||
// De Init Draw Library ...
|
||||
OnDeinitDrawLibrary();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -383,11 +370,11 @@ double GetState(
|
||||
// bullishCrossedUnderBearish = -2;
|
||||
// bullishUnderBearish = -1;
|
||||
// OtherWise = 0;
|
||||
bool isBullishCrossedOverBearish = IsCrossOver(
|
||||
bool isBullishCrossedOverBearish = IsCrossedOver(
|
||||
bullishBuffer,
|
||||
bearishBuffer,
|
||||
bar_index);
|
||||
bool isBullishCrossedUnderBearish = IsCrossUnder(
|
||||
bool isBullishCrossedUnderBearish = IsCrossedUnder(
|
||||
bullishBuffer,
|
||||
bearishBuffer,
|
||||
bar_index);
|
||||
|
||||
@@ -47,10 +47,6 @@ input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // Applied To
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
@@ -105,9 +101,6 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
|
||||
//
|
||||
// Initializing MA Handler ...
|
||||
maHandler = iMA(
|
||||
@@ -119,11 +112,6 @@ int OnInit()
|
||||
maAppliedTo);
|
||||
if (maHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
string message = "Error Initializing Ma Handler ...";
|
||||
LogMessage(message);
|
||||
|
||||
//
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
@@ -316,7 +304,13 @@ void CalculateBuffers(int bar_index)
|
||||
{
|
||||
//
|
||||
// Requirements ...
|
||||
XOHCL candle = GetCandle(bar_index);
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double maValue = maBuffer[bar_index];
|
||||
|
||||
@@ -23,20 +23,16 @@
|
||||
// START Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
#define ShortName "XTS"
|
||||
|
||||
enum ENUM_X_PERIOD_METHOD
|
||||
{
|
||||
//
|
||||
X_PERIOD_NOTHING,
|
||||
//
|
||||
X_PERIOD_AUTO,
|
||||
//
|
||||
X_PERIOD_MANUALLY
|
||||
};
|
||||
//
|
||||
// Includes Draw Library ...
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// XTS Oscillator States ...
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
@@ -63,18 +59,6 @@ input ENUM_X_PERIOD_METHOD farestMethod = X_PERIOD_AUTO; // How to Find Farest P
|
||||
input ENUM_TIMEFRAMES farestPeriod = NULL; // Farest Time Frame
|
||||
input ENUM_APPLIED_PRICE farestAppliedTo = PRICE_CLOSE; // Farest Applied To
|
||||
|
||||
//
|
||||
// Includes Logging Library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Draw Library ...
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
@@ -165,7 +149,6 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
logTag = ShortName;
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
@@ -185,10 +168,6 @@ int OnInit()
|
||||
// DeInitialization ...
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
OnDeinitDrawLibrary();
|
||||
|
||||
//
|
||||
Comment("");
|
||||
}
|
||||
|
||||
@@ -368,15 +347,16 @@ void CalculateCurrent(int bar_index)
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c = GetCandle(
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex);
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = GetAppliedPrice(
|
||||
c,
|
||||
currentAppliedTo);
|
||||
double value = c.GetPrice(currentAppliedTo);
|
||||
|
||||
//
|
||||
currentBuffer[bar_index] = value;
|
||||
@@ -394,7 +374,7 @@ void CalculateNearest(int bar_index)
|
||||
{
|
||||
//
|
||||
case X_PERIOD_AUTO:
|
||||
mNearestPeriod = GetNearestTimeFrame(_Period);
|
||||
mNearestPeriod = GetNearestPeriod(_Period);
|
||||
break;
|
||||
|
||||
//
|
||||
@@ -420,15 +400,16 @@ void CalculateNearest(int bar_index)
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c = GetCandle(
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex);
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = GetAppliedPrice(
|
||||
c,
|
||||
nearestAppliedTo);
|
||||
double value = c.GetPrice(nearestAppliedTo);
|
||||
|
||||
//
|
||||
nearestBuffer[bar_index] = value;
|
||||
@@ -446,7 +427,7 @@ void CalculateMediest(int bar_index)
|
||||
{
|
||||
//
|
||||
case X_PERIOD_AUTO:
|
||||
mMediestPeriod = GetMediestTimeFrame(_Period);
|
||||
mMediestPeriod = GetMediestPeriod(_Period);
|
||||
break;
|
||||
|
||||
//
|
||||
@@ -472,15 +453,16 @@ void CalculateMediest(int bar_index)
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c = GetCandle(
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex);
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = GetAppliedPrice(
|
||||
c,
|
||||
mediestAppliedTo);
|
||||
double value = c.GetPrice(mediestAppliedTo);
|
||||
|
||||
//
|
||||
mediestBuffer[bar_index] = value;
|
||||
@@ -498,7 +480,7 @@ void CalculateFarest(int bar_index)
|
||||
{
|
||||
//
|
||||
case X_PERIOD_AUTO:
|
||||
mFarestPeriod = GetFarestTimeFrame(_Period);
|
||||
mFarestPeriod = GetLongestPeriod(_Period);
|
||||
break;
|
||||
|
||||
//
|
||||
@@ -524,15 +506,16 @@ void CalculateFarest(int bar_index)
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c = GetCandle(
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex);
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = GetAppliedPrice(
|
||||
c,
|
||||
farestAppliedTo);
|
||||
double value = c.GetPrice(farestAppliedTo);
|
||||
|
||||
//
|
||||
farestBuffer[bar_index] = value;
|
||||
@@ -553,6 +536,7 @@ string GenerateDescriptionComment()
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
\
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/x-saherelm.xmd5.class.mq5"
|
||||
|
||||
//
|
||||
// Models ...
|
||||
@@ -435,10 +436,20 @@ struct XOHCL
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Price base On Series Mode ...
|
||||
double GetPrice(ENUM_SERIESMODE mMode) {
|
||||
//
|
||||
ENUM_X_PRICE mXMode = ToPrice(mMode);
|
||||
|
||||
//
|
||||
return GetPrice(mXMode);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Applied Price ...
|
||||
double GetPrice(
|
||||
ENUM_APPLIED_PRICE appliedTo // Select Application Method
|
||||
ENUM_APPLIED_PRICE mAppliedTo // Select Application Method
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -446,7 +457,7 @@ struct XOHCL
|
||||
|
||||
//
|
||||
// Calculate Applied Price ...
|
||||
switch (appliedTo)
|
||||
switch (mAppliedTo)
|
||||
{
|
||||
//
|
||||
case PRICE_CLOSE:
|
||||
@@ -3279,6 +3290,48 @@ string GetTypeName(const T &t)
|
||||
return typename(T);
|
||||
}
|
||||
|
||||
//
|
||||
template <typename T>
|
||||
string GetToken(T &item)
|
||||
{
|
||||
//
|
||||
string mType = GetTypeName(item);
|
||||
|
||||
//
|
||||
string result = mType;
|
||||
|
||||
//
|
||||
string parts[];
|
||||
int partsCount = SplitContent(
|
||||
parts,
|
||||
result,
|
||||
" "
|
||||
//
|
||||
);
|
||||
if (partsCount <= 0)
|
||||
{
|
||||
//
|
||||
result = mType;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasLastPart = GetLastItem(
|
||||
result,
|
||||
parts
|
||||
//
|
||||
);
|
||||
if (!hasLastPart)
|
||||
{
|
||||
//
|
||||
result = mType;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Unique Tags ...
|
||||
template <typename T>
|
||||
@@ -3704,7 +3757,7 @@ double GetMax(
|
||||
//
|
||||
// Get Min of Specific Loopback of a Buffer ...
|
||||
template <typename T>
|
||||
double GetMinValue(
|
||||
double GetMin(
|
||||
T &buffer[], // the Buffer which required to search
|
||||
int start = 0, // Start Index
|
||||
int count = 0 // Count for Search
|
||||
@@ -3753,7 +3806,7 @@ double GetMinValue(
|
||||
//
|
||||
// Find a Value less than Specified ...
|
||||
template <typename T>
|
||||
T FindLesserThanValue(
|
||||
T FindLesserThan(
|
||||
T value, // Specified Value ...
|
||||
const T &source[], // Source ...
|
||||
bool isDescend = false // Find Biggest Lesser Value ...
|
||||
@@ -3814,7 +3867,7 @@ T FindLesserThanValue(
|
||||
//
|
||||
// Find a Value less than Specified ...
|
||||
template <typename T>
|
||||
T FindBiggerThanValue(
|
||||
T FindBiggerThan(
|
||||
T value, // Specified Value ...
|
||||
const T &source[], // Source ...
|
||||
bool isDescend = false // Find Smallest Bigger Value ...
|
||||
@@ -3875,7 +3928,7 @@ T FindBiggerThanValue(
|
||||
//
|
||||
// Find Same Values in Array ...
|
||||
template <typename T>
|
||||
void FindSameValues(
|
||||
void FindSames(
|
||||
T &result[], // Holds Result ...
|
||||
T &source[], // Source ...
|
||||
int verifications = 3 // Number of Consequence Repeat ...
|
||||
@@ -4821,6 +4874,77 @@ int ParseDoubleArraySurrounded(
|
||||
//
|
||||
return count;
|
||||
}
|
||||
int ParseTimeArraySurrounded(
|
||||
datetime &result[], // Holds Result
|
||||
const string surrounded, // Surrounded Content
|
||||
const string mToken, // Specified Token
|
||||
string separator = ",", // Separator ...
|
||||
const string startString = "(", // Expression Start String must be Unique
|
||||
const string endString = ")", // Where to End Extraction, usually a Sign
|
||||
bool forceClean = true // Clean Result ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int count = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(result);
|
||||
}
|
||||
|
||||
//
|
||||
int before = ArraySize(result);
|
||||
|
||||
//
|
||||
string contentStr = ParseStringSurrounded(surrounded, mToken);
|
||||
if (!IsValid(contentStr))
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
string tmps[];
|
||||
int tmpsCount = SplitContent(
|
||||
tmps,
|
||||
contentStr
|
||||
//
|
||||
);
|
||||
if (tmpsCount <= 0)
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < tmpsCount; i++)
|
||||
{
|
||||
//
|
||||
string iTMP = tmps[i];
|
||||
if (!IsValid(iTMP))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
datetime iValue = (datetime)iTMP;
|
||||
|
||||
//
|
||||
Add(
|
||||
iValue,
|
||||
result
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
int after = ArraySize(result);
|
||||
|
||||
//
|
||||
count = after - before;
|
||||
|
||||
//
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
// Surround an String by Specific Token ...
|
||||
@@ -4859,6 +4983,38 @@ string Surround(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
template <typename T>
|
||||
string SurroundArray(
|
||||
string mToken,
|
||||
T &value[],
|
||||
string startString = "(", // Token Start Content
|
||||
string endString = ")" // Token End Content
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string valueStr = ToString(value);
|
||||
if (!IsValid(valueStr))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = Surround(
|
||||
mToken,
|
||||
valueStr,
|
||||
startString,
|
||||
endString
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Periods / Cycles ...
|
||||
|
||||
|
||||
+2018
-3183
File diff suppressed because it is too large
Load Diff
+5
-1
@@ -4,5 +4,9 @@
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
"settings": {
|
||||
"C_Cpp.default.includePath": [
|
||||
"c:\\Users\\saherelm\\AppData\\Roaming\\MetaQuotes\\Terminal\\FAE4959D5A0334AE230243FCFFFD4053\\MQL5\\Include"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user