backup ...

This commit is contained in:
2024-08-04 12:09:42 +03:30
parent c946b98c28
commit 27de8c3655
94 changed files with 254800 additions and 0 deletions
Binary file not shown.
@@ -0,0 +1,97 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XBaseClass
// Description: provides all based classes for use ...
//
//
// 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
//
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// XBase Class ...
class XSCBase
{
//
// Public ...
public:
//
// Protected ...
//
// Represent Basic Unique Tag ...
virtual string GetTag();
//
// Retrieve Class Token ...
virtual string GetToken();
//
// Protected
protected:
//
// Private ...
private:
};
//
template <typename T>
string GenerateSpecifiedCommonSummary(
T &mItem,
string separator = "\n",
bool includeScores = true,
bool setLabel = false //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
mItem.GenerateScore(
bullishScore,
bearishScore //
);
//
result =
//
(!setLabel
? ""
: "Commons:" + separator) +
"---------------" + separator +
"Symbol: " + mItem.symbol + separator +
"Period: " + ToString(mItem.period) + separator +
"Time: " + ToString(mItem.time) + separator +
(includeScores
? "---------------" + separator +
"Scores:" + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
"---------------" + separator
: "") +
""
//
;
//
return result;
}
//
Binary file not shown.
@@ -0,0 +1,398 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSCAccount
// Description: provides all Account 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 ...
//
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include <Trade/AccountInfo.mqh>
#include "../Classes/x-saherelm.base.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Manage Account ...
class XSCAccount : public XSCBase
{
//
// Public ...
public:
//
// Constructor ...
void XSCAccount()
{
//
mAccountInfo = new CAccountInfo();
}
//
// Deconstructor ...
void ~XSCAccount()
{
}
//
// START Provided Functions ...
//
//
// User Account ...
long GetUserAccount()
{
return mAccountInfo.Login();
}
//
// Account Leverage ...
long GetLeverage()
{
return mAccountInfo.Leverage();
}
//
// Get Trade Expert State ...
bool CanExpertTrade()
{
return mAccountInfo.TradeExpert();
}
//
// User Account Trade Mopde (ENUM_ACCOUNT_TRADE_MODE) ...
// --------------------------
// ACCOUNT_TRADE_MODE_DEMO
// ACCOUNT_TRADE_MODE_CONTEST
// ACCOUNT_TRADE_MODE_REAL
ENUM_ACCOUNT_TRADE_MODE GetTradeMode()
{
return mAccountInfo.TradeMode();
}
//
// Get Account Balance ...
double GetBalance()
{
return mAccountInfo.Balance();
}
//
// Get the amount of give Credit ...
double GetCredit()
{
return mAccountInfo.Credit();
}
//
// Get the amount of current Profit on account ...
double GetProfit()
{
return mAccountInfo.Profit();
}
//
// Get the amount of current Equity on account ...
double GetEquity()
{
return mAccountInfo.Equity();
}
//
// Get the amount of reserved Margin ...
double GetMargin()
{
return mAccountInfo.Margin();
}
//
// Get the amount of free Margin ...
double GetFreeMargin()
{
return mAccountInfo.FreeMargin();
}
//
// Get the Level of Margin ...
double GetMarginLevel()
{
return mAccountInfo.MarginLevel();
}
//
// Get the Level Of Margin for a Deposit ...
double GetMarginCall()
{
return mAccountInfo.MarginCall();
}
//
// Get the Level of Margin for Stop out ...
double GetMarginStopOut()
{
return mAccountInfo.MarginStopOut();
}
//
// Get the Client Name ...
string GetName()
{
return mAccountInfo.Name();
}
//
// Get the Trade Server Name ...
string GetServerName()
{
return mAccountInfo.Server();
}
//
// Get deposit Currency Name ...
string GetCurrency()
{
return mAccountInfo.Currency();
}
//
// Get the Company Name that serves an Account ...
string GetCompany()
{
return mAccountInfo.Company();
}
//
// Calculate Profits for the current account based on passed parameters ...
double CalculateTradeProfit(
const string symbol, // trading symbol
ENUM_ORDER_TYPE type, // order type
double volume, // volume
double entry, // open price
double exit // close price
)
{
//
double result = mAccountInfo.OrderProfitCheck(
symbol,
type,
volume,
entry,
exit);
//
return result;
}
//
// Calculate amount of margin which required for trade operation ...
double CalculateMarging(
const string symbol, // trading symbol
ENUM_ORDER_TYPE type, // order type
double volume, // volume
double entry // open price
)
{
//
double result = mAccountInfo.MarginCheck(
symbol,
type,
volume,
entry);
//
return result;
}
//
// Calculate amount of free margin left after trade operation ...
double CalculateFreeMarging(
const string symbol, // trading symbol
ENUM_ORDER_TYPE type, // order type
double volume, // volume
double entry // open price
)
{
//
double result = mAccountInfo.FreeMarginCheck(
symbol,
type,
volume,
entry);
//
return result;
}
//
// Calculate the Maximum possible volume of trade operation ...
double CalculateMaxVolume(
const string symbol, // trading symbol
ENUM_ORDER_TYPE type, // order type
double entry, // open price
double percent = 100 // percent of available margin
)
{
//
double result = mAccountInfo.MaxLotCheck(
symbol,
type,
entry,
percent);
//
return result;
}
//
// Calculate Point Value for Given Symbol based on Account ...
double GetPointValue(
string symbol // trading symbol
)
{
//
double result = 0;
//
double tickSize = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE);
double tickValue = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE);
double point = SymbolInfoDouble(symbol, SYMBOL_POINT);
//
double ticksPerPoint = tickSize / point;
//
result = tickValue / ticksPerPoint;
//
return result;
}
//
// Calculate Risk Amount based on account Currency by Providing:
// Points and Volume ...
double CalculateRiskAmount(
string symbol, // trading symbol
double points, // amount of Risk Points
double volume // position Volume
)
{
//
double result = 0;
//
double pointValue = GetPointValue(symbol);
//
result = pointValue * volume * points;
//
return result;
}
//
// Calculate Risk Points based on account Currency by Providing:
// Volume and Amount ...
double CalculateRiskPoints(
string symbol, // trading symbol
double volume, // position Volume
double amount // amount of Risk based on Account Currency
)
{
//
double result = 0;
//
double pointValue = GetPointValue(symbol);
//
result = amount / (pointValue * volume);
//
return result;
}
//
// Calculate Volume based on account Currency by Providing:
// Amount and Risk Points ...
double CalculateVolume(
string symbol, // trading symbol
double amount, // amount of Risk based on Account Currency
double points // amount of Risk Points
)
{
//
double result = 0;
//
points =
points <= 0
? 10
: points;
//
double pointValue = GetPointValue(symbol);
//
result = amount / (pointValue * points);
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Account Info ...
CAccountInfo mAccountInfo;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,148 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSCBaseHelper
// Description: provides all Base 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
//
// Includes ...
#include "../Classes/x-saherelm.base.class.mq5"
//
// Definitions ...
//
// a Class for Handle base requirements ...
// for indicators ...
class XSCBaseHelper : public XSCBase
{
//
// Public ...
public:
//
// Constructor ...
void XSCBaseHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
)
{
//
mSymbol = symbol;
mPeriod = period;
}
//
// Deconstructor ...
void ~XSCBaseHelper()
{
//
IndicatorRelease(mHandler);
}
//
// Setter(s) / Getter(s) ...
//
// Symbol ...
string GetSymbol()
{
return mSymbol;
}
//
// Period ...
ENUM_TIMEFRAMES GetPeriod()
{
return mPeriod;
}
//
// Retrieve Bars ...
int CountBars()
{
//
int result =
Bars(
mSymbol,
mPeriod
//
);
//
return result;
}
//
// Retrieve Indicator Calculated Bars ...
int CountCalculatedBars()
{
return BarsCalculated(mHandler);
}
//
// Generate Tag ...
virtual string GetTag()
{
//
string result = NULL;
//
result =
//
GetToken() +
"[" +
GetSymbol() + "|" +
ToString(GetPeriod()) +
"]"
//
;
//
return result;
}
//
// Functions ...
//
// Protected ...
protected:
//
// Props ...
//
// Symbol ...
string mSymbol;
//
// Period ...
ENUM_TIMEFRAMES mPeriod;
//
// Indicator Handler ...
int mHandler;
//
// Private ...
private:
//
};
//
// Tools ....
Binary file not shown.
@@ -0,0 +1,373 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSCHttp
// Description: provides all HTTP 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
//
// Definitions ...
//
enum X_HTTP_METHOD
{
X_HTTP_GET,
X_HTTP_POST
};
//
// Imports ...
//
// Includes ...
#include "../Classes/x-saherelm.base.class.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// a Class for Manage Account ...
class XSCHttp : public XSCBase
{
//
// Public ...
public:
//
// Constructor ...
void XSCHttp()
{
XSCHttp("", 10000);
}
void XSCHttp(
string path, // Base Folder to Store Data
int timeout // base timeout for Requests
)
{
//
Path(path);
Timeout(timeout);
}
//
// Deconstructor ...
void ~XSCHttp()
{
}
//
// Properties Getter(s) / Setter(s) ...
//
// Path ...
void Path(string value)
{
//
mPath = value;
//
if (!IsValid(mPath))
{
mPath = GetTag();
}
}
string Path()
{
return mPath;
}
//
// Timeout ...
void Timeout(int value)
{
mTimeout = value;
}
//
int Timeout()
{
return mTimeout;
}
//
// Error ...
int Error()
{
return mError;
}
//
// Response ...
string Response()
{
return mResponse;
}
//
// Overrides ...
string GetTag() override
{
return GetSpecificToken(this);
}
//
// Tools ...
//
// Send Global Request ...
int SendRequest(
X_HTTP_METHOD method, // Httm Request Method
const string url, // Server Address
const string headers, // Headers providing
const char &payload[], // the Data which needs to Send
char &response[], // Response of request
string responseHeaders, // Response Headers
int timeout = 500 // Timeout for response default is 500
)
{
//
int result = -1;
//
string strMethod = ToString(method);
if (StringLen(strMethod) == 0)
{
return result;
}
//
// Reset State ...
ResetState();
//
result = WebRequest(
strMethod,
url,
headers,
timeout,
payload,
response,
responseHeaders);
//
if (result < 0)
{
mError = GetLastError();
}
else
{
mResponse = CharArrayToString(response);
}
//
return result;
}
//
// Get Request ...
int GetRequest(
const string url, // Server Address
const string headers, // Headers providing
const char &payload[], // the Data which needs to Send
char &response[], // Response of request
string responseHeaders, // Response Headers
int timeout = 500 // Timeout for response default is 500
)
{
//
int result = SendRequest(
X_HTTP_GET,
url,
headers,
payload,
response,
responseHeaders,
timeout);
//
return result;
}
//
// Post Request ...
int PostRequest(
const string url, // Server Address
const string headers, // Headers providing
const char &payload[], // the Data which needs to Send
char &response[], // Response of request
string responseHeaders, // Response Headers
int timeout = 500 // Timeout for response default is 500
)
{
//
int result = SendRequest(
X_HTTP_POST,
url,
headers,
payload,
response,
responseHeaders,
timeout);
//
return result;
}
//
// Handle Download Specific URL Content to Specific Path and File Name ...
bool Download(
string url, // the URL address which going to download
string fileName // Specify Destination file name to Store Response
)
{
//
bool result = false;
//
string filePath = GetFilePath(fileName);
string cookie = NULL;
string referer = NULL;
int timeout = Timeout();
//
char payload[];
string headers;
char response[];
string responseHeaders;
//
// Send Request ...
int requestResult = GetRequest(
url,
headers,
payload,
response,
responseHeaders,
timeout);
//
// Define File Handler ...
int mFileHandler = FileOpen(
filePath,
FILE_WRITE | FILE_BIN);
if (mFileHandler == INVALID_HANDLE)
{
//
mError = GetLastError();
return result;
}
//
// Write Response to File ...
uint writed = FileWriteArray(
mFileHandler,
response,
0,
ArraySize(response));
FileFlush(mFileHandler);
FileClose(mFileHandler);
//
result = writed > 0;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Destintion Folder Path ...
string mPath;
//
// WEB Request Timeout Value ...
int mTimeout;
//
// WEB Request's Response ...
string mResponse;
//
// Error Value ...
int mError;
//
// Private ...
private:
//
// Reset Errors State ...
void ResetState()
{
//
// Reset Errors ...
mError = -1;
mResponse = "";
ResetLastError();
}
//
// Generate Full File Path ...
string GetFilePath(string fileName)
{
//
string result = "";
//
result =
//
Path() + "\\" + fileName
//
;
//
return result;
}
};
//
// Tools ...
//
// Convert enum to String ...
string ToString(X_HTTP_METHOD method)
{
//
string result = "";
//
switch (method)
{
//
case X_HTTP_GET:
result = "GET";
break;
//
case X_HTTP_POST:
result = "POST";
break;
}
//
return result;
}
//
Binary file not shown.
@@ -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;
}
};
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,506 @@
/**
* XColor Tools Module ...
* a module for handle colorify text contents in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Module Imports ...
const XValueTools = require("./x-value.tools");
//#endregion
//
//#region Constants ...
/**
* these are available style which can applied to an string ...
*/
const AVAILABLE_STYLES = {
//
Bold: "\x1b[1m",
Dim: "\x1b[2m",
Underlined: "\x1b[4m",
Blink: "\x1b[5m",
ReverseFandB: "\x1b[7m",
Hidden: "\x1b[8m",
//
// Commonly used for reset all Styles ...
Reset: "\x1b[0m"
};
/**
* these are available foreground colors which can applied to an string ...
*/
const AVAILABLE_FOREGROUND_COLORS = {
Default: "\x1b[39m",
Black: "\x1b[30m",
Red: "\x1b[31m",
Green: "\x1b[32m",
Yellow: "\x1b[33m",
Blue: "\x1b[34m",
Magenta: "\x1b[35m",
Cyan: "\x1b[36m",
LightGray: "\x1b[37m",
DarkGray: "\x1b[90m",
LightRed: "\x1b[91m",
LightGreen: "\x1b[92m",
LightYellow: "\x1b[93m",
LightBlue: "\x1b[94m",
LightMagenta: "\x1b[95m",
LightCyan: "\x1b[96m",
White: "\x1b[97m",
};
/**
* these are available background colors which can applied to an string ...
*/
const AVAILABLE_BACKGROUND_COLORS = {
Default: "\x1b[49m",
Black: "\x1b[40m",
Red: "\x1b[41m",
Green: "\x1b[42m",
Yellow: "\x1b[43m",
Blue: "\x1b[44m",
Magenta: "\x1b[45m",
Cyan: "\x1b[46m",
LightGray: "\x1b[47m",
DarkGray: "\x1b[100m",
LightRed: "\x1b[101m",
LightGreen: "\x1b[102m",
LightYellow: "\x1b[103m",
LightBlue: "\x1b[104m",
LightMagenta: "\x1b[105m",
LightCyan: "\x1b[106m",
White: "\x1b[107m",
};
/**
* these are available style names, which exports from module and
* users can use them ...
*/
const STYLE_NAMES = {
Bold: "Bold",
Dim: "Dim",
Underlined: "Underlined",
Blink: "Blink",
ReverseFandB: "ReverseFandB",
Hidden: "Hidden",
Reset: "Reset",
};
/**
* these are available color names, which exports from module and
* users can use them ...
*/
const COLOR_NAMES = {
Default: "Default",
Black: "Black",
Red: "Red",
Green: "Green",
Yellow: "Yellow",
Blue: "Blue",
Magenta: "Magenta",
Cyan: "Cyan",
LightGray: "LightGray",
DarkGray: "DarkGray",
LightRed: "LightRed",
LightGreen: "LightGreen",
LightYellow: "LightYellow",
LightBlue: "LightBlue",
LightMagenta: "LightMagenta",
LightCyan: "LightCyan",
White: "White",
};
//#endregion
//
//#region Actions ...
/**
* apply specified style and color on a content ...
*
* @param {string} content specified content for styling ...
* @param {string} color specific color name for using to styling ...
* @param {string} style soecufic style name to use ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string} styled content ...
*/
function apply(
content,
color,
style,
toForeground = true,
toBackground = false
) {
//
let result = content;
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return result;
}
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}${result}${AVAILABLE_STYLES.Reset}`;
}
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}${result}${AVAILABLE_STYLES.Reset}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}${result}${AVAILABLE_STYLES.Reset}`;
}
}
/**
* apply specific style on a content ...
*
* @param {string} content specific content which going to styled ...
* @param {string} style a member of STYLE_NAMES which specified that which style going to applied to content ...
* @returns {string} styled content ...
*/
function applyStyle(content, style) {
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return content;
}
//
let eStyle = AVAILABLE_STYLES[style];
if (eStyle === undefined) {
return content;
}
//
return `${eStyle}${content}${AVAILABLE_STYLES.Reset}`;
}
/**
* apply specific foreground color on a content ...
*
* @param {string} content specific content which going to colorified ...
* @param {string} color a member of COLOR_NAMES which specified that which color going to applied to content ...
* @returns {string} colorified content ...
*/
function applyForegroundColor(content, color) {
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return content;
}
//
let eColor = AVAILABLE_FOREGROUND_COLORS[color];
if (eColor === undefined) {
return content;
}
//
return `${eColor}${content}${AVAILABLE_STYLES.Reset}`;
}
/**
* apply specific background color on a content ...
*
* @param {string} content specific content which going to colorified ...
* @param {string} color a member of COLOR_NAMES which specified that which color going to applied to content ...
* @returns {string} colorified content ...
*/
function applyBackgroundColor(content, color) {
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return content;
}
//
let eColor = AVAILABLE_BACKGROUND_COLORS[color];
if (eColor === undefined) {
return content;
}
//
return `${eColor}${content}${AVAILABLE_STYLES.Reset}`;
}
/**
* generate style and color applier expression ...
*
* @param {string} color specific color name for using to styling ...
* @param {string} style soecufic style name to use ...
* @param {boolean} reset close applier string by reset styles ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string} style and color applier string ...
*/
function getApplier(
style = "",
color = "",
reset = false,
toForeground = true,
toBackground = false
) {
//
let result = "";
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}`;
}
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}`;
}
//
if (
!!reset &&
result.length > 0
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* generate style applier expression ...
*
* @param {string} style soecufic style name to use ...
* @param {boolean} reset close applier string by reset styles ...
* @returns {string} style applier string ...
*/
function getStyleApplier(
style = "",
reset = false
) {
//
let result = "";
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}`;
}
//
if (
!!reset &&
result.length > 0
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* generate color applier expression ...
*
* @param {string} color specific color name for using to styling ...
* @param {boolean} reset close applier string by reset styles ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string} color applier string ...
*/
function getColorApplier(
color = "",
reset = false,
toForeground = true,
toBackground = false
) {
//
let result = "";
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}`;
}
//
if (
!!reset &&
result.length > 0
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* colorified specific content ...
*
* @param {string} content specified content for styling ...
* @param {string} color specific color name for using to styling ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string}
*/
function colorifyContent(
content = "",
color = "",
toForeground = true,
toBackground = false
) {
//
let result = content;
//
if (!XValueTools.isValidArg(content)) {
return result;
}
//
// Finde Colors ...
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}${result}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}${result}`;
}
//
if (
result.length > 0
&& (
XValueTools.isValidArg(eFColor) ||
XValueTools.isValidArg(eBColor)
)
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* apply style on specific content ...
*
* @param {string} content specified content for styling ...
* @param {string} style soecufic style name to use ...
* @returns {string}
*/
function stylifiyContent(
content = "",
style = "",
) {
//
let result = content;
//
if (!XValueTools.isValidArg(content)) {
return result;
}
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}${result}`;
}
//
if (
result.length > 0
&& XValueTools.isValidArg(eStyle)
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
//#endregion
//
//#region Module Exports ...
module.exports = {
//
STYLE_NAMES,
COLOR_NAMES,
//
apply,
applyStyle,
getApplier,
getColorApplier,
getStyleApplier,
colorifyContent,
stylifiyContent,
applyForegroundColor,
applyBackgroundColor,
}
//#endregion
@@ -0,0 +1,890 @@
/**
* XFile Tools Module ...
* a module for handle all file/folder manipulating task in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Module Imports ...
const fs = require('fs');
const os = require('os');
const Path = require('path');
const http = require('http');
const https = require('https');
const XValueTools = require('./x-value.tools');
//#endregion
//
//#region Constants ...
/**
* current os path separators ...
*/
const PathSeparator = Path.sep;
/**
* current directory ...
*/
const CurrentDir = __dirname;
//#endregion
//
//#region Actions ...
//
//#region Global ...
/**
* retrieve a path status ...
*
* @param {string} path a path value to check ...
* @returns an stat object ...
*/
function getStatus(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return undefined;
}
//
return fs.statSync(path);
}
/**
* retrieve user's Home path ...
*
* @returns {string} a path ...
*/
function getHomePath() {
return os.homedir();
}
//#endregion
//
//#region Path ...
/**
* retrieve the base name of specific address path ...
*
* @param {string} path address of file or folder ...
* @returns string ...
*/
function basename(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return '';
}
//
const result = Path.basename(path);
return result;
}
/**
* join several path segments together ...
*
* @param {...string} path path params ...
* @returns a joined paths ...
*/
function joinPath(...path) {
return Path.join(...path);
}
/**
* resolve a relative path to absolute ...
*
* @param {string[]} path a path value to check ...
* @returns {string}
*/
function resolvePath(...path) {
return Path.resolve(...path);
}
//#endregion
//
//#region File ...
/**
* determines a path destination is a file or not ...
*
* @param {string} path a path value to check ...
* @returns a boolean value ...
*/
function isFileExists(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return false;
}
//
try {
const stat = getStatus(path);
if (!stat) {
return false;
}
//
return stat.isFile();
} catch {
return false;
}
}
/**
* remove a file ...
*
* @param {string} path a file path ...
* @returns {Promise<boolean>} action done or not ...
*/
function removeFile(path = '') {
return new Promise((resolve) => {
//
if (!isFileExists(path)) {
resolve(false);
}
//
fs.unlink(path, (err) => {
//
if (err) {
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* copy a file to destination path ...
*
* @param {string} source source file path ...
* @param {string} dest dest folder path ...
* @returns {Promise<boolean>} action done or not ...
*/
function copyFile(
source = '',
dest = ''
) {
return new Promise((resolve) => {
//
if (
!isFileExists(source) ||
!isDirectoryExists(dest)
) {
resolve(false);
return;
}
//
const destFilePath = Path.join(dest, Path.basename(source));
fs.copyFile(source, destFilePath, (err) => {
//
if (err) {
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* reading specified file content ...
*
* @param {string} path a file path ...
* @returns {Promise<string>} file content ...
*/
function readFile(path = '') {
return new Promise((resolve) => {
//
if (!isFileExists(path)) {
resolve('');
return;
}
//
fs.readFile(path, 'utf8', (err, content) => {
//
if (err) {
resolve(undefined);
return;
}
//
resolve(content);
});
});
}
/**
* write content to a file ...
*
* @param {string} path a file path ...
* @param {string} content the content which going to write to the file ...
* @param {bool} overwrite determines file overwrite if exists ...
* @returns {Promise<boolean>} action done or not ...
*/
function writeFile(
path = '',
content = '',
overwrite = true
) {
return new Promise((resolve) => {
//
if (isFileExists(path) && !overwrite) {
//
resolve(false);
return;
}
//
// Normalize Content ...
content = XValueTools.isValidArg(content) ?
content :
'';
//
fs.writeFile(path, content, (err) => {
//
if (err) {
//
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* create a file ...
*
* @param {string} path file path ...
* @param {string} fileName file name ...
* @returns {Promise<boolean>} action done or not ...
*/
function createFile(
path = '',
fileName = ''
) {
return new Promise((resolve) => {
//
const filePath = Path.join(path, fileName);
if (
isFileExists(filePath) ||
!XValueTools.isValidArg(path) ||
!XValueTools.isValidArg(fileName)
) {
//
resolve(false);
return;
}
//
fs.writeFile(filePath, '', (err) => {
//
if (err) {
//
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* remove a file name extension ...
*
* @param {string} name
* @returns {string} name without extension ...
*/
function removeFileExtension(name = '') {
return name.substring(0, name.lastIndexOf('.')) || name;
}
/**
* retrieve a file extension ...
*
* @param {string} path a path which locate a file ...
* @returns {string}
*/
function getFileExtension(path = '') {
//
let result = "";
//
// Validate Arg ...
if (
!XValueTools.isValidArg(path)
|| !isFileExists(path)
) {
return result;
}
//
// Retrieve just file name ...
const fileName = basename(path);
result = fileName.replace(
removeFileExtension(fileName),
""
);
//
return result;
}
/**
* retrieve all files list recursively from specific path ...
*
* @param {string} path a source folder path ...
* @param {string[]} extensions which file extensions need to be listed, live empty for all files ...
* @returns {Promise<string[]>}
*/
async function getRecursiveFilesList(
path = "",
extensions = []
) {
//
let result = [];
//
// Validate Args ...
if (
!XValueTools.isValidArg(path)
|| !isDirectoryExists(path)
) {
return result;
}
//
const contents = await getDirectoryContents(path);
for (const item of contents) {
//
const itemPath = joinPath(
path,
item
);
//
const isItemFile = isFileExists(itemPath);
if (isItemFile) {
//
const itemFileExtension = getFileExtension(itemPath);
const isFileInSupportedExtensions =
extensions === undefined || extensions.length === 0
? true
: extensions.includes(itemFileExtension)
;
if (isFileInSupportedExtensions) {
result.push(itemPath);
}
} else if (isDirectoryExists(itemPath)) {
//
const itemPathFiles = await getRecursiveFilesList(itemPath, extensions);
result.push(...itemPathFiles);
}
}
//
return result;
}
/**
* Extract Specific files from a folder and it's content ...
*
* @param {string} path Folder Path ...
* @returns
*/
async function extractFiles(path = "", ext = [], excludeWorkspaceFolders = []) {
//
const result = [];
//
if (!ext || ext.length == 0) {
return result;
}
//
const pathContent = await getDirectoryContents(path);
if (!pathContent || pathContent.length == 0) {
return result;
}
//
// Loop through Content ...
for (const c of pathContent) {
//
// Prepare full path ...
const cPath = joinPath(path, c);
//
// check content path is file or not ...
const isCFile = isFileExists(cPath);
const isCDirectory = isDirectoryExists(cPath);
if (isCFile) {
//
// Check it is MQL file or not ...
const cExt = getFileExtension(cPath);
if (ext.includes(cExt)) {
result.push(cPath);
}
} else if (isCDirectory) {
//
const destFolderName = basename(cPath);
const isExcluded = excludeWorkspaceFolders.includes(destFolderName);
if (isExcluded) {
continue;
}
//
const cFiles = await extractFiles(cPath, ext);
if (cFiles && cFiles.length > 0) {
result.push(...cFiles);
}
}
}
//
return result;
}
//#endregion
//
//#region Directory ...
/**
* create a directory ...
*
* @param {string} path destination path including dir name ...
* @param {boolean} recursive create directories recursively ...
* @returns action done or not ...
*/
function createDirectory(
path = '',
recursive = true
) {
//
let result = false;
//
if (
isDirectoryExists(path) ||
!XValueTools.isValidArg(path)
) {
return false;
}
//
try {
//
fs.mkdirSync(path, { recursive: recursive });
result = true;
return result;
} catch {
return false;
}
}
/**
* remove a directory ...
*
* @param {string} path destination path including dir name ...
* @param {boolean} recursive removes directories recursively ...
* @returns {Promise<boolean>} action done or not ...
*/
function removeDirectory(
path = '',
recursive = false
) {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve(false);
return;
}
//
fs.rm(path, {
recursive
}, (err) => {
//
if (err) {
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* determines a path destination is a directory or not ...
*
* @param {string} path a folder path ...
* @returns represent destnation path is Directory or not ...
*/
function isDirectoryExists(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return false;
}
//
try {
//
const isExists = fs.existsSync(path);
if (!isExists) {
return false;
}
//
const stat = getStatus(path);
if (!stat) {
return false;
}
//
const result = stat.isDirectory();
return result;
} catch {
return false;
}
}
/**
* retrieve a directory content ...
*
* @param {string} path a folder path ...
* @returns {Promise<string[]>} a collection of folder files ...
*/
function getDirectoryContents(path = '') {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve([]);
return;
}
//
fs.readdir(path, (err, content) => {
//
if (err) {
resolve([]);
return;
}
//
resolve(content);
});
});
}
/**
* retrieve a directory files ...
*
* @param {string} path a folder path ...
* @returns {Promise<string[]>} a collection of folder files ...
*/
function getDirectoryFiles(
path = '',
containsHiddenFiles = false
) {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve([]);
return;
}
//
fs.readdir(path, (err, content) => {
//
if (err) {
resolve([]);
return;
}
//
if (!containsHiddenFiles) {
content = content.filter(c => !c.startsWith('.'));
}
//
const result = [];
content
.forEach(c => {
//
const cPath = Path.join(path, c);
if (isFileExists(cPath)) {
result.push(c);
}
});
//
resolve(result);
});
});
}
/**
* retrieve a directory folders ...
*
* @param {string} path a folder path ...
* @returns {Promise<string[]>} a collection of folder names ...
*/
function getDirectoryFolders(path = '') {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve([]);
return;
}
//
fs.readdir(path, (err, content) => {
//
if (err) {
resolve([]);
return;
}
//
const result = [];
content.forEach(c => {
//
const cPath = Path.join(path, c);
if (isDirectoryExists(cPath)) {
result.push(c);
}
});
//
resolve(result);
});
});
}
/**
* copy a folder with all of it's content to dest ...
*
* @param {string} source source folder path ...
* @param {string} dest dest folder path ...
* @returns {Promise<boolean>} action done or not ...
*/
async function copyFolder(
source = '',
dest = ''
) {
//
if (
!isDirectoryExists(source) ||
!XValueTools.isValidArg(dest) ||
!XValueTools.isValidArg(source)
) {
return false;
}
//
const folderName = Path.basename(source);
const destPath = Path.join(dest, folderName);
//
// Create Dest Path folder if not exists ...
if (!isDirectoryExists(destPath)) {
//
let result = createDirectory(destPath, true);
if (!result) {
return false;
}
}
//
// Files ...
const files = await getDirectoryFiles(source);
if (files && files.constructor === Array && files.length > 0) {
//
const filesPromises = files.map(file => copyFile(Path.join(source, file), destPath));
const filesResult = (await Promise.all(filesPromises)).every(r => !!r);
if (!filesResult) {
return false;
}
}
//
// Folders ...
const folders = await getDirectoryFolders(source);
if (folders && folders.constructor === Array && folders.length > 0) {
//
const folderPromises = folders.map(folder => copyFolder(Path.join(source, folder), destPath));
const filesResult = (await Promise.all(folderPromises)).every(r => !!r);
if (!filesResult) {
return false;
}
}
//
return true;
}
//#endregion
//
//#region Downloader ...
/**
* download a file from specific url and store it ...
*
* @param {string} filepath the file name and path which required to put download file on it ...
* @param {string} url the web url for downloading ...
*/
function download(filepath, url) {
//
// Validate Args ...
if (
!XValueTools.isValidArg(url)
|| !XValueTools.isValidURL(url)
|| !XValueTools.isValidArg(filepath)
) {
return;
}
//
var file = fs.createWriteStream(filepath);
//
if (url.startsWith('https:')) {
https.get(url, function (response) {
response.pipe(file);
});
} else if (url.startsWith('http:')) {
http.get(url, function (response) {
response.pipe(file);
});
}
}
//#endregion
//
//#region JSON ...
/**
* read and parse a JSON content from a file ...
*
* @param {string} path source file path ...
* @returns {any}
*/
function readJSON(path = "") {
//
// Validate Args ...
if (!isFileExists(path)) {
return undefined;
}
//
let result = undefined;
try {
result = require(path);
} catch {
result = undefined;
}
//
return result;
}
/**
* write a JSON Object content into a file ...
*
* @param {string} path dest file path ...
* @param {any} content an object which required to write to file ...
* @returns {Promise<boolean>}
*/
async function writeJSON(
path = "",
content = undefined
) {
//
let result = false;
//
// Validate Args ...
if (!XValueTools.isValidArg(path)) {
return result;
}
//
// Normallize Content ...
if (content === undefined) {
content = {};
}
//
const contentString = XValueTools.beautifyJSON(content);
//
result = await writeFile(
path,
contentString,
true
);
//
return result;
}
//#endregion
//#endregion
//
//#region Module Exports ...
module.exports = {
//
CurrentDir,
PathSeparator,
//
getStatus,
getHomePath,
//
basename,
joinPath,
resolvePath,
//
download,
//
readJSON,
writeJSON,
//
copyFile,
readFile,
writeFile,
createFile,
removeFile,
isFileExists,
getFileExtension,
removeFileExtension,
getRecursiveFilesList,
extractFiles,
//
copyFolder,
createDirectory,
removeDirectory,
createDirectory,
removeDirectory,
isDirectoryExists,
isDirectoryExists,
getDirectoryFiles,
getDirectoryFolders,
getDirectoryContents,
};
//#endregion
@@ -0,0 +1,219 @@
/**
* XShell Tools Module ...
* a module for handling shell actions and retrieve OS Info in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Imports ...
const os = require('os');
const process = require('process');
const { exec } = require("child_process");
const XFileTools = require('./x-file.tools');
//#endregion
//
//#region Constants ...
//
const OS = {
Aix: 'aix',
Darwin: 'darwin',
FreeBSD: 'freebsd',
Linux: 'linux',
OpenBSD: 'openbsd',
SnOS: 'sunos',
Windows: 'win32'
};
//
const isWindows = process.platform === OS.Windows;
//#endregion
//
//#region Actions ...
//
//#region Pure shell commands ...
/**
* execute a command using NodeJS on shell ...
*
* @param {string} cmd command to execute ...
* @param {string} cwd working directory ...
*
* @returns Promise<any, errr> instance ...
*/
function execute(cmd, cwd) {
return new Promise((resolve, reject) => {
//
if (!cmd || cmd.toString().length === 0 || (cwd && !XFileTools.isDirectoryExists(cwd))) {
reject('invalid args ...');
return;
}
//
exec(cmd, { cwd }, (err, result, stdError) => {
//
if (err) {
reject(err);
return;
}
//
if (stdError) {
//
// reject(stdError);
// return;
}
//
resolve(result);
});
});
};
/**
* determines a command exists on host or not ...
*
* @param {string} name specific command name ...
*
* @returns boolean Promise ...
*/
function checkCommandExists(name) {
return new Promise(resolve => {
//
if (!name) {
resolve(false);
return;
}
//
const cmd = isWindows ? `${name} >nul 2>&1` : `type ${name} >/dev/null 2>&1`;
execute(cmd).then(result => {
resolve(true);
})
.catch(err => {
resolve(false);
});
});
}
//#endregion
//
//#region required commands state ...
/**
* check al required commands exists or not ...
*
* @returns
*/
async function isRequiredCommandsExists() {
//
let result = false;
//
// const isTarExists = await isTarCommandExists();
// const isCatExists = await isCatCommandExists();
// const isGrepExists = await isGrepCommandExists();
// const isSedExists = await isSedCommandExists();
const isNpmExists = await isNpmCommandExists();
const isNgExists = await isNgCommandExists();
const isIonicExists = await isIonicCommandExists();
const isCordovaExists = await isCordovaCommandExists();
//
result = isNpmExists
&& isNgExists
&& isIonicExists
&& isCordovaExists
;
//
return result;
}
/**
* retrieve required commands state object ...
*
* @returns
*/
async function getRequiredCommandsStates() {
//
const result = {};
//
// const isTarExists = await isTarCommandExists();
// const isCatExists = await isCatCommandExists();
// const isGrepExists = await isGrepCommandExists();
// const isSedExists = await isSedCommandExists();
const isNpmExists = await isNpmCommandExists();
const isNgExists = await isNgCommandExists();
const isIonicExists = await isIonicCommandExists();
const isCordovaExists = await isCordovaCommandExists();
//
result['npm'] = isNpmExists;
result['ng'] = isNgExists;
result['ionic'] = isIonicExists;
result['cordova'] = isCordovaExists;
//
return result;
}
//#endregion
//
//#region Commonly used Command Checkers ...
/**
* determines npm command exists or not ...
*
* @returns
*/
function isNpmCommandExists() {
return checkCommandExists('npm');
}
/**
* determines ng command exists or not ...
*
* @returns
*/
function isNgCommandExists() {
return checkCommandExists('ng');
}
/**
* determines ionic command exists or not ...
*
* @returns
*/
function isIonicCommandExists() {
return checkCommandExists('ionic');
}
/**
* determines cordova command exists or not ...
*
* @returns
*/
function isCordovaCommandExists() {
return checkCommandExists('cordova');
}
//#endregion
//#endregion
//
//#region Module Exports ...
module.exports = {
//
execute,
checkCommandExists,
isRequiredCommandsExists,
getRequiredCommandsStates,
//
isNgCommandExists,
isIonicCommandExists,
isCordovaCommandExists,
}
//#endregion
@@ -0,0 +1,268 @@
/**
* DataType Tools Module ...
* a module for manipulate and detect supported data types in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Constants ...
/**
* all supported data types ...
*/
const DataTypes = {
Null: 'null',
Date: 'date',
Array: 'array',
Object: 'object',
String: 'string',
Number: 'number',
Unknown: 'unknown',
Boolean: 'boolean',
Function: 'function',
Undefined: 'undefined',
};
//#endregion
//
//#region Actions ...
/**
* detect type of a content ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function getType(value) {
//
const type = typeof value;
//
let result = DataTypes.Unknown;
let dateIdentifier = '[object Date]';
let constructor = value && value.constructor ?
value.constructor.toString() :
'';
//
switch (type) {
//
case 'undefined':
result = DataTypes.Undefined;
break;
//
case 'boolean':
result = DataTypes.Boolean;
break;
//
case 'string':
result = DataTypes.String;
break;
//
case 'number':
result = DataTypes.Number;
break;
//
case 'function':
result = DataTypes.Function;
break;
//
case 'object':
//
// Null ...
if (value === null) {
result = DataTypes.Null;
} else
//
// Array ...
if (Array.isArray(value)) {
result = DataTypes.Array;
} else
//
// Data ...
if (
value instanceof Date ||
isFunction(value.getMonth) ||
constructor.includes(dateIdentifier) ||
Object.prototype.toString.call(value) === dateIdentifier
) {
result = DataTypes.Date;
} else
//
// Object ...
{
result = DataTypes.Object;
}
break;
//
default:
result = DataTypes.Unknown;
break;
}
//
return result;
}
/**
* retrieve an object constructor ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function getConstructor(value) {
//
const result = value && value.constructor ?
value.constructor.toString() :
'';
//
return result;
}
/**
* retrieve an object prototype ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function getPrototype(value) {
//
const result = value ?
Object.prototype.toString.call(value) :
'';
//
return result;
}
/**
* check an object is null or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isNull(value) {
return getType(value) === DataTypes.Null;
}
/**
* check an object is undefined or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isUndefined(value) {
return getType(value) === DataTypes.Undefined;
}
/**
* check an object is null or undefined or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isNullOrUndefined(value) {
return isNull(value) || isUndefined(value);
}
/**
* check an object is a date or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isDate(value) {
return getType(value) === DataTypes.Date;
}
/**
* check an object is number or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isNumber(value) {
return getType(value) === DataTypes.Number;
}
/**
* check an object is string or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isString(value) {
return getType(value) === DataTypes.String;
}
/**
* check an object is boolean or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isBoolean(value) {
return getType(value) === DataTypes.Boolean;
}
/**
* check an object is an Array or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isArray(value) {
return getType(value) === DataTypes.Array;
}
/**
* check an object is and Object or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isObject(value) {
return getType(value) === DataTypes.Object;
}
/**
* check an object is a Function or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isFunction(value) {
return getType(value) === DataTypes.Function;
}
//#endregion
//
//#region Module Exports ...
module.exports = {
//
DataTypes,
//
getType,
getConstructor,
getPrototype,
isNull,
isUndefined,
isNullOrUndefined,
isDate,
isNumber,
isString,
isBoolean,
isArray,
isObject,
isFunction,
}
//#endregion
File diff suppressed because it is too large Load Diff
Binary file not shown.
+713
View File
@@ -0,0 +1,713 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center XTest MQL5 Expert Advisor
// -------------------------------------------------
// Name: XSTestEA
// Description: an Exper Advisor which used XTestSetup
// 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 XSTestEA"
#property strict
//
#define ShortName "XSTestEA"
//
// Imports ...
#include "../Helpers/x-saherelm.xct.helper.mq5"
#include "../Helpers/x-saherelm.xcc.helper.mq5"
//
#include "../Parsers/x-saherelm.xch.parser.mq5"
#include "../Strategies/x-saherelm.xch.strategy.mq5"
//
// Inputs ...
//
// Common ...
input group "Common";
input long eaMagicNumber = 78692110; // Magic Number
input int eaSlippage = 10; // Slippgae
input string eaLogSuffix = ""; // Log Suffix
//
// Symbols ...
input group "Symbols";
input bool eaMultiSymbol = false; // Use Multi Symbol
input bool eaUseMaxAllowedTradesPerSymbol = true; // Use Max Allowed Trades Per Symbol
input string eaSymbols = "EURUSDb,USDJPYb"; // Trading Symbols
// string eaSymbols = "EURUSDb,USDJPYb,USDCHFb,GBPUSDb,XAUUSDb,XAGUSDb"; // Trading Symbols
//
// Trades ...
input group "Trades";
input double eaVolume = 0.01; // Static Volume
input double eaR2R = 1.5; // Risk to Reward Ratio for Dynamic TP SL
input bool eaUseFixedTPSLPoints = true; // Use Fixed TP SL in Points
input bool eaIgnoreTP = false; // Ignore TP
input bool eaIgnoreSL = false; // Ignore SL
input double eaTPPoint = 150; // Static TP Point
input double eaSLPoint = 500; // Static SL Point
//
// Risk Management ...
input group "Risk Management";
//
// Risk Management > Trade Management ...
input group "Trade Management";
input bool eaAllowLong = true; // Allow Long Positions
input bool eaAllowShort = true; // Allow Short Positions
input int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
input int eaMaxAllowedShorts = 1; // Max Allowed Short Positions
input double eaMaxDrawdownPercentForOpenTrades = 3; // Max Drawdown Percent for Open Trades
//
// Risk Management > Hedging ...
input group "Hedging";
input bool eaAllowHedging = true; // Allow Hedging Trades
input int eaMinTradesForHedge = 2; // Minimum Open Trades for Hedging
input double eaMinimumProfitPerVolumeForHedging = 0.3; // Minimum Required Profit per Volume for Hedging
//
// Risk Management > Trailling Stop ...
input group "Trailling Stop";
input bool eaAllowTrailStop = false; // Allow Trail Stop
input double eaStartTrailInPoint = 100; // Trail Start After Profit (Point)
input double eaTrailStepInPoint = 30; // Trail Size in each Step (Point)
input bool eaIgnoreTPAfterTrail = true; // Ignore TP after Trail
//
// Risk Management > Trades Recovery ...
input group "Trades Recovery";
input bool eaAllowRecovery = false; // Allow Recover Trades
input double eaRecoveryTPPoint = 150; // Recovery TP (Point)
input double eaRecoverySLPoint = 200; // Recovery SL (Point)
input int eaMaxAllowedRecoveryTrades = 0; // Max Allowed Recovery Trades
input double eaRecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier
input double eaMaxAllowedRecoveryTradesVolume = 0.1; // Max Allowed Recovery Volume
//
// Alert ...
input group "Alert";
input bool eAEnableAlerts = true; // Enable Alerts
input bool eALogAlerts = true; // Log Alerts
input bool eAMailAlerts = false; // Mail Alerts
input bool eAPushAlerts = false; // Push Alerts
input bool eATerminalAlerts = false; // Terminal Alerts
//
// Time Report ...
input group "Reports";
input bool eaAlertNewMonths = false; // Alert New Month
input bool eaAlertNewWeeks = false; // Alert New Weeks
input bool eaAlertNewDays = false; // Alert New Days
input bool eaAlertNewHours = false; // Alert New Hours
//
// Variables ...
//
// int mNumberOfSLs = 0;
//
// Bar Style nad Time Instances ...
XSCXCTHelper *mCTHelper;
XSCXCCHelper *mCCHelper;
//
// Registred Strategies ...
XSCBaseStrategy *strategies[];
//
// Trader Instance Class ...
XSCTrade *eaTrader;
//
// Alert Class ...
XSCAlert *eaAlert;
//
// Time Tracker ...
XTimeTracker eaTimeTracker;
//
// Trade Handler Instance Class ...
XSCXTradeHandler *eaTradeHandler;
//
string mTag =
!IsValid(eaLogSuffix)
? ShortName
: ShortName + "_" + eaLogSuffix;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitialEA())
{
return INIT_FAILED;
}
//
drawPrefix = mTag;
//
// EventSetTimer(1);
// EventSetMillisecondTimer(100);
//
// Alert Initialization ...
string msg = "Initialized Successfully ...";
eaAlert.Alert(msg);
//
// 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
//
string msg = "MaxSameTimeTrades: " + ToString(eaTradeHandler.MaxSameTimeTrades());
eaAlert.Alert(msg);
//
// Alert De Initialization Succeeded ...
msg = "De Initialized Successfully ...";
eaAlert.Alert(msg);
//
// De Initialize XSampleEA Providers ...
delete mCTHelper;
delete mCCHelper;
//
delete eaAlert;
delete eaTrader;
delete eaTradeHandler;
//
// EventKillTimer();
//
Clean(strategies);
}
//
// On Tick Handler ...
void OnTick()
{
//
HandleTradeState();
HandleTimeReport();
HandleStrategiesOnTick();
}
//
// Handle On Trade Event ...
void OnTrade()
{
eaTrader.HandleOnTrade();
}
//
// On Timer ...
void OnTimer()
{
//
// HandleTradeState();
// HandleTimeReport();
// HandleStrategiesOnTick();
// //
// if (eaTimeTracker.IsNewDay())
// {
// mNumberOfSLs = 0;
// }
}
//
// Custom Functions ...
//
// Validate Inputs ...
bool ValidateInputs()
{
//
bool result = false;
//
result = true;
//
return result;
}
//
// Initialize all Requirements ...
bool InitialEA()
{
//
bool result = false;
//
// Bar Timer ...
XCTInputs ctInputs;
ctInputs.Default();
mCTHelper = new XSCXCTHelper();
result = mCTHelper.Init(
_Symbol,
_Period,
ctInputs //
);
if (!result)
{
return result;
}
//
// Bar Styles ...
XCCInputs ccInputs;
ccInputs.Default();
mCCHelper = new XSCXCCHelper();
result = mCCHelper.Init(
_Symbol,
_Period,
ccInputs //
);
if (!result)
{
return result;
}
//
// Create Instance of Alert Class ...
eaAlert = new XSCAlert();
eaAlert.SetPrefix(mTag);
eaAlert.SetLogAlerts(eALogAlerts);
eaAlert.SetMailAlerts(eAMailAlerts);
eaAlert.SetPushAlerts(eAPushAlerts);
eaAlert.SetEnableAlerts(eAEnableAlerts);
eaAlert.SetTerminalAlerts(eATerminalAlerts);
//
// Create Trader Instance ...
eaTrader = new XSCTrade(
eaSlippage,
eaMagicNumber //
);
eaTrader.AddOnStopLossEventHandler(OnStopLossTriggered);
eaTrader.AddOnTakeProfitEventHandler(OnTakeProfitTriggered);
eaTrader.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
//
// Initialize Trade Handler ...
eaTradeHandler = new XSCXTradeHandler(eaTrader);
eaTradeHandler.SaveTrades(true);
eaTradeHandler.SaveSignals(true);
//
// Configure Alerts ...
eaTradeHandler.SetAlertPrefix(mTag);
eaTradeHandler.SetAlertEnableAlerts(eAEnableAlerts);
eaTradeHandler.SetAlertLogAlerts(eALogAlerts);
eaTradeHandler.SetAlertMailAlerts(eAMailAlerts);
eaTradeHandler.SetAlertPushAlerts(eAPushAlerts);
eaTradeHandler.SetAlertTerminalAlerts(eATerminalAlerts);
//
// Configure Trade Management ...
eaTradeHandler.AllowLong(eaAllowLong);
eaTradeHandler.AllowShort(eaAllowShort);
eaTradeHandler.MaxAllowedLongs(eaMaxAllowedLongs);
eaTradeHandler.MaxAllowedShorts(eaMaxAllowedShorts);
eaTradeHandler.UseMaxAllowedTradesPerSymbol(eaUseMaxAllowedTradesPerSymbol);
eaTradeHandler.MaxDrawdownPercentForOpenTrades(eaMaxDrawdownPercentForOpenTrades);
//
// Configure Hedging ...
eaTradeHandler.AllowHedging(eaAllowHedging);
eaTradeHandler.HedgeVolumeFactor(eaVolume);
eaTradeHandler.MinTradesForHedge(eaMinTradesForHedge);
eaTradeHandler.HedgeMinProfitPerVolumeFactor(eaMinimumProfitPerVolumeForHedging);
//
// Configure Trailing ...
eaTradeHandler.AllowTrailStops(eaAllowTrailStop);
eaTradeHandler.TrailBasedOnProfit(true);
eaTradeHandler.TrailStartInPoint(eaStartTrailInPoint);
eaTradeHandler.TrailStepInPoint(eaTrailStepInPoint);
eaTradeHandler.IgnoreTPOnTrail(eaIgnoreTPAfterTrail);
//
// Configure Recovery ...
eaTradeHandler.AllowRecover(eaAllowRecovery);
eaTradeHandler.ForcePressuresInRecovery(false);
eaTradeHandler.RecoveryTPPoint(eaRecoveryTPPoint);
eaTradeHandler.RecoverySLPoint(eaRecoverySLPoint);
eaTradeHandler.MaxAllowedRecover(eaMaxAllowedRecoveryTrades);
eaTradeHandler.RecoveryVolumeMultiplier(eaRecoveryVolumeMultiplier);
eaTradeHandler.MaxAllowedRecoveryVolume(eaMaxAllowedRecoveryTradesVolume);
//
// Single Symbol ...
if (!eaMultiSymbol)
{
//
// Create Class Instance ...
XSCXCHStrategy *xchStrategy;
xchStrategy = new XSCXCHStrategy(
_Symbol,
_Period,
PERIOD_H1, // Analyzing Period
eaVolume,
eaR2R, // R2R ...
eaSlippage,
eaMagicNumber,
true, // Ignore Signal Execution
eaUseFixedTPSLPoints, // Use TP SL Point
false, // Use Max
eaTPPoint, // TP
eaSLPoint, // SL
eaIgnoreTP,
eaIgnoreSL,
eaAllowLong,
eaAllowShort,
eaMaxAllowedLongs, // Max Longs
eaMaxAllowedShorts // Max Shorts
);
//
// Configuere Strategy ...
xchStrategy.EnableXCHM(true);
xchStrategy.EnableXCHHK(true);
xchStrategy.EnableXCHSTR(true);
xchStrategy.EnableXCHCHE(true);
xchStrategy.DrawImportantAreas(false);
xchStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
//
// Configure Alerts ...
xchStrategy.SetAlertPrefix(mTag);
xchStrategy.SetAlertEnableAlerts(eAEnableAlerts);
xchStrategy.SetAlertLogAlerts(eALogAlerts);
xchStrategy.SetAlertMailAlerts(eAMailAlerts);
xchStrategy.SetAlertPushAlerts(eAPushAlerts);
xchStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
//
// Register Strategy ...
RegisterStrategy(xchStrategy);
}
//
// Multi Symbol ...
else
{
//
// Parse Symbols ...
string symbols[];
int symbolsCount = SplitContent(
symbols,
eaSymbols //
);
result = IsValidSize(symbolsCount);
if (!result)
{
return result;
}
//
for (int i = 0; i < symbolsCount; i++)
{
//
// Select Symbol ...
string iSymbol = symbols[i];
//
// Create Class Instance ...
XSCXCHStrategy *iStrategy;
iStrategy = new XSCXCHStrategy(
iSymbol,
_Period,
PERIOD_H1, // Analyzing Period
eaVolume,
eaR2R, // R2R ...
eaSlippage,
eaMagicNumber,
true, // Ignore Signal Execution
true, // Use TP SL Point
false, // Use Max
eaTPPoint, // TP
eaSLPoint, // SL
eaIgnoreTP,
eaIgnoreSL,
eaAllowLong,
eaAllowShort,
eaMaxAllowedLongs, // Max Longs
eaMaxAllowedShorts // Max Shorts
);
//
// Configuere Strategy ...
iStrategy.EnableXCHM(true);
iStrategy.EnableXCHHK(true);
iStrategy.EnableXCHSTR(true);
iStrategy.EnableXCHCHE(true);
iStrategy.DrawImportantAreas(false);
iStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
//
// Configure Alerts ...
iStrategy.SetAlertPrefix(mTag);
iStrategy.SetAlertEnableAlerts(eAEnableAlerts);
iStrategy.SetAlertLogAlerts(eALogAlerts);
iStrategy.SetAlertMailAlerts(eAMailAlerts);
iStrategy.SetAlertPushAlerts(eAPushAlerts);
iStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
//
// Register Strategy ...
RegisterStrategy(iStrategy);
}
}
//
return result;
}
//
// Register Strategy ...
void RegisterStrategy(XSCBaseStrategy *strategy)
{
//
if (strategy == NULL)
{
return;
}
//
ArrayResize(
strategies,
ArraySize(strategies) + 1 //
);
//
strategies[ArraySize(strategies) - 1] = strategy;
}
//
// Call All Registered Strategis Tick Handler Functions ...
void HandleStrategiesOnTick()
{
//
int count = ArraySize(strategies);
if (!IsValidSize(count))
{
return;
}
//
for (int i = 0; i < count; i++)
{
//
// Call Tick Handler Function ...
strategies[i].HandleTick();
}
}
//
// Manage Trading States ...
void HandleTradeState()
{
//
// Implement All Trade States here ...
eaTradeHandler.UpdateData();
//
// Do Protection Senarios ...
eaTradeHandler.HandleProtection();
}
//
// Time Reporting ...
void HandleTimeReport()
{
//
// Monthly Report ....
if (eaAlertNewMonths &&
eaTimeTracker.IsNewMonth())
{
//
string msg = "New Month ...";
//
eaAlert.Alert(msg);
}
//
// Weekly Report ....
if (eaAlertNewWeeks &&
eaTimeTracker.IsNewWeek())
{
//
string msg = "New Week ...";
//
eaAlert.Alert(msg);
}
//
// Daily Report ....
if (eaAlertNewDays &&
eaTimeTracker.IsNewDay())
{
//
string msg = "New Day ...";
//
eaAlert.Alert(msg);
}
//
// Hourly Report ....
if (eaAlertNewHours &&
eaTimeTracker.IsNewHour())
{
//
string msg = "New Hour ...";
//
eaAlert.Alert(msg);
}
}
//
// SIGNAL EVENT Handlers ...
//
//
// All Signals from Strategies Comming Here for Execution or
// Analyzing ...
void OnSignalRecieved(
XSignal &signal,
XCHStrategyConditions &conditions //
)
{
//
// Check Signal and Conditions Validations ...
//
if (!signal.IsValid())
{
return;
}
//
if (!conditions.IsValid())
{
return;
}
//
XCHStartegyConditionsParser parser;
bool isFiltered = parser.IsFiltered(
signal,
conditions //
);
if (isFiltered)
{
return;
}
//
// Attach Conditions Summary to Signal ...
string conditionsSummary = conditions.GenerateSummary(
false,
false,
true,
false //
);
//
signal.conditions = parser.GenerateSignalConditions(conditions); // conditionsSummary;
//
// Execute Signal Using Trade Handler ...
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = eaTradeHandler.ExecuteSignal(
signal,
state //
);
}
//
void OnStopLossTriggered(const XDeal &deal)
{
//
// Finish ...
eaTradeHandler.Finish(deal);
}
//
void OnTakeProfitTriggered(const XDeal &deal)
{
//
// Finish ...
eaTradeHandler.Finish(deal);
}
//
void OnPositionForceClosed(
const ulong ticket,
const XPosition &position,
const string comment //
)
{
//
// Finish ...
eaTradeHandler.Finish(
ticket,
position,
comment //
);
}
//
Binary file not shown.
@@ -0,0 +1,694 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center XTest MQL5 Expert Advisor
// -------------------------------------------------
// Name: XSTestEA
// Description: an Exper Advisor which used XTestSetup
// 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 XSTestEA"
#property strict
//
#define ShortName "XSTestEA"
//
// Imports ...
#include "../Helpers/x-saherelm.xct.helper.mq5"
#include "../Helpers/x-saherelm.xcc.helper.mq5"
//
#include "../Parsers/x-saherelm.xch.parser.mq5"
#include "../Strategies/x-saherelm.xch.strategy.mq5"
//
// Inputs ...
//
// Common ...
long eaMagicNumber = 78692110; // Magic Number
int eaSlippage = 10; // Slippgae
string eaLogSuffix = ""; // Log Suffix
//
// Symbols ...
bool eaMultiSymbol = false; // Use Multi Symbol
bool eaUseMaxAllowedTradesPerSymbol = true; // Use Max Allowed Trades Per Symbol
string eaSymbols = "EURUSDb,USDJPYb"; // Trading Symbols
// string eaSymbols = "EURUSDb,USDJPYb,USDCHFb,GBPUSDb,XAUUSDb,XAGUSDb"; // Trading Symbols
//
// Trades ...
double eaVolume = 0.01; // Static Volume
double eaR2R = 1.5; // Risk to Reward Ratio for Dynamic TP SL
bool eaUseFixedTPSLPoints = true; // Use Fixed TP SL in Points
bool eaIgnoreTP = false; // Ignore TP
bool eaIgnoreSL = false; // Ignore SL
double eaTPPoint = 150; // Static TP Point
double eaSLPoint = 500; // Static SL Point
//
// Risk Management ...
//
// Risk Management > Trade Management ...
bool eaAllowLong = true; // Allow Long Positions
bool eaAllowShort = true; // Allow Short Positions
int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
int eaMaxAllowedShorts = 1; // Max Allowed Short Positions
double eaMaxDrawdownPercentForOpenTrades = 3; // Max Drawdown Percent for Open Trades
//
// Risk Management > Hedging ...
bool eaAllowHedging = true; // Allow Hedging Trades
int eaMinTradesForHedge = 2; // Minimum Open Trades for Hedging
double eaMinimumProfitPerVolumeForHedging = 0.3; // Minimum Required Profit per Volume for Hedging
//
// Risk Management > Trailling Stop ...
bool eaAllowTrailStop = false; // Allow Trail Stop
double eaStartTrailInPoint = 100; // Trail Start After Profit (Point)
double eaTrailStepInPoint = 30; // Trail Size in each Step (Point)
bool eaIgnoreTPAfterTrail = true; // Ignore TP after Trail
//
// Risk Management > Trades Recovery ...
bool eaAllowRecovery = false; // Allow Recover Trades
double eaRecoveryTPPoint = 150; // Recovery TP (Point)
double eaRecoverySLPoint = 200; // Recovery SL (Point)
int eaMaxAllowedRecoveryTrades = 0; // Max Allowed Recovery Trades
double eaRecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier
double eaMaxAllowedRecoveryTradesVolume = 0.1; // Max Allowed Recovery Volume
//
// Alert ...
bool eAEnableAlerts = true; // Enable Alerts
bool eALogAlerts = true; // Log Alerts
bool eAMailAlerts = false; // Mail Alerts
bool eAPushAlerts = false; // Push Alerts
bool eATerminalAlerts = false; // Terminal Alerts
//
// Time Report ...
bool eaAlertNewMonths = false; // Alert New Month
bool eaAlertNewWeeks = false; // Alert New Weeks
bool eaAlertNewDays = false; // Alert New Days
bool eaAlertNewHours = false; // Alert New Hours
//
// Variables ...
//
// Bar Style nad Time Instances ...
XSCXCTHelper *mCTHelper;
XSCXCCHelper *mCCHelper;
//
// Registred Strategies ...
XSCBaseStrategy *strategies[];
//
// Trader Instance Class ...
XSCTrade *eaTrader;
//
// Alert Class ...
XSCAlert *eaAlert;
//
// Time Tracker ...
XTimeTracker eaTimeTracker;
//
// Trade Handler Instance Class ...
XSCXTradeHandler *eaTradeHandler;
//
string mTag =
!IsValid(eaLogSuffix)
? ShortName
: ShortName + "_" + eaLogSuffix;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitialEA())
{
return INIT_FAILED;
}
//
drawPrefix = mTag;
//
// EventSetTimer(1);
// EventSetMillisecondTimer(100);
//
// Alert Initialization ...
string msg = "Initialized Successfully ...";
eaAlert.Alert(msg);
//
// 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
//
string msg = "MaxSameTimeTrades: " + ToString(eaTradeHandler.MaxSameTimeTrades());
eaAlert.Alert(msg);
//
// Alert De Initialization Succeeded ...
msg = "De Initialized Successfully ...";
eaAlert.Alert(msg);
//
// De Initialize XSampleEA Providers ...
delete mCTHelper;
delete mCCHelper;
//
delete eaAlert;
delete eaTrader;
delete eaTradeHandler;
//
// EventKillTimer();
//
Clean(strategies);
}
//
// On Tick Handler ...
void OnTick()
{
//
HandleTradeState();
HandleTimeReport();
HandleStrategiesOnTick();
}
//
// Handle On Trade Event ...
void OnTrade()
{
eaTrader.HandleOnTrade();
}
//
// On Timer ...
void OnTimer()
{
//
// HandleTradeState();
// HandleTimeReport();
// HandleStrategiesOnTick();
}
//
// Custom Functions ...
//
// Validate Inputs ...
bool ValidateInputs()
{
//
bool result = false;
//
result = true;
//
return result;
}
//
// Initialize all Requirements ...
bool InitialEA()
{
//
bool result = false;
//
// Bar Timer ...
XCTInputs ctInputs;
ctInputs.Default();
mCTHelper = new XSCXCTHelper();
result = mCTHelper.Init(
_Symbol,
_Period,
ctInputs //
);
if (!result)
{
return result;
}
//
// Bar Styles ...
XCCInputs ccInputs;
ccInputs.Default();
mCCHelper = new XSCXCCHelper();
result = mCCHelper.Init(
_Symbol,
_Period,
ccInputs //
);
if (!result)
{
return result;
}
//
// Create Instance of Alert Class ...
eaAlert = new XSCAlert();
eaAlert.SetPrefix(mTag);
eaAlert.SetLogAlerts(eALogAlerts);
eaAlert.SetMailAlerts(eAMailAlerts);
eaAlert.SetPushAlerts(eAPushAlerts);
eaAlert.SetEnableAlerts(eAEnableAlerts);
eaAlert.SetTerminalAlerts(eATerminalAlerts);
//
// Create Trader Instance ...
eaTrader = new XSCTrade(
eaSlippage,
eaMagicNumber //
);
eaTrader.AddOnStopLossEventHandler(OnStopLossTriggered);
eaTrader.AddOnTakeProfitEventHandler(OnTakeProfitTriggered);
eaTrader.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
//
// Initialize Trade Handler ...
eaTradeHandler = new XSCXTradeHandler(eaTrader);
eaTradeHandler.SaveTrades(true);
eaTradeHandler.SaveSignals(true);
//
// Configure Alerts ...
eaTradeHandler.SetAlertPrefix(mTag);
eaTradeHandler.SetAlertEnableAlerts(eAEnableAlerts);
eaTradeHandler.SetAlertLogAlerts(eALogAlerts);
eaTradeHandler.SetAlertMailAlerts(eAMailAlerts);
eaTradeHandler.SetAlertPushAlerts(eAPushAlerts);
eaTradeHandler.SetAlertTerminalAlerts(eATerminalAlerts);
//
// Configure Trade Management ...
eaTradeHandler.AllowLong(eaAllowLong);
eaTradeHandler.AllowShort(eaAllowShort);
eaTradeHandler.MaxAllowedLongs(eaMaxAllowedLongs);
eaTradeHandler.MaxAllowedShorts(eaMaxAllowedShorts);
eaTradeHandler.UseMaxAllowedTradesPerSymbol(eaUseMaxAllowedTradesPerSymbol);
eaTradeHandler.MaxDrawdownPercentForOpenTrades(eaMaxDrawdownPercentForOpenTrades);
//
// Configure Hedging ...
eaTradeHandler.AllowHedging(eaAllowHedging);
eaTradeHandler.HedgeVolumeFactor(eaVolume);
eaTradeHandler.MinTradesForHedge(eaMinTradesForHedge);
eaTradeHandler.HedgeMinProfitPerVolumeFactor(eaMinimumProfitPerVolumeForHedging);
//
// Configure Trailing ...
eaTradeHandler.AllowTrailStops(eaAllowTrailStop);
eaTradeHandler.TrailBasedOnProfit(true);
eaTradeHandler.TrailStartInPoint(eaStartTrailInPoint);
eaTradeHandler.TrailStepInPoint(eaTrailStepInPoint);
eaTradeHandler.IgnoreTPOnTrail(eaIgnoreTPAfterTrail);
//
// Configure Recovery ...
eaTradeHandler.AllowRecover(eaAllowRecovery);
eaTradeHandler.ForcePressuresInRecovery(false);
eaTradeHandler.RecoveryTPPoint(eaRecoveryTPPoint);
eaTradeHandler.RecoverySLPoint(eaRecoverySLPoint);
eaTradeHandler.MaxAllowedRecover(eaMaxAllowedRecoveryTrades);
eaTradeHandler.RecoveryVolumeMultiplier(eaRecoveryVolumeMultiplier);
eaTradeHandler.MaxAllowedRecoveryVolume(eaMaxAllowedRecoveryTradesVolume);
//
// Single Symbol ...
if (!eaMultiSymbol)
{
//
// Create Class Instance ...
XSCXCHStrategy *xchStrategy;
xchStrategy = new XSCXCHStrategy(
_Symbol,
_Period,
PERIOD_H1, // Analyzing Period
eaVolume,
eaR2R, // R2R ...
eaSlippage,
eaMagicNumber,
true, // Ignore Signal Execution
eaUseFixedTPSLPoints, // Use TP SL Point
false, // Use Max
eaTPPoint, // TP
eaSLPoint, // SL
eaIgnoreTP,
eaIgnoreSL,
eaAllowLong,
eaAllowShort,
eaMaxAllowedLongs, // Max Longs
eaMaxAllowedShorts // Max Shorts
);
//
// Configuere Strategy ...
xchStrategy.EnableXCHM(true);
xchStrategy.EnableXCHHK(true);
xchStrategy.EnableXCHSTR(true);
xchStrategy.EnableXCHCHE(true);
xchStrategy.DrawImportantAreas(false);
xchStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
//
// Configure Alerts ...
xchStrategy.SetAlertPrefix(mTag);
xchStrategy.SetAlertEnableAlerts(eAEnableAlerts);
xchStrategy.SetAlertLogAlerts(eALogAlerts);
xchStrategy.SetAlertMailAlerts(eAMailAlerts);
xchStrategy.SetAlertPushAlerts(eAPushAlerts);
xchStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
//
// Register Strategy ...
RegisterStrategy(xchStrategy);
}
//
// Multi Symbol ...
else
{
//
// Parse Symbols ...
string symbols[];
int symbolsCount = SplitContent(
symbols,
eaSymbols //
);
result = IsValidSize(symbolsCount);
if (!result)
{
return result;
}
//
for (int i = 0; i < symbolsCount; i++)
{
//
// Select Symbol ...
string iSymbol = symbols[i];
//
// Create Class Instance ...
XSCXCHStrategy *iStrategy;
iStrategy = new XSCXCHStrategy(
iSymbol,
_Period,
PERIOD_H1, // Analyzing Period
eaVolume,
eaR2R, // R2R ...
eaSlippage,
eaMagicNumber,
true, // Ignore Signal Execution
true, // Use TP SL Point
false, // Use Max
eaTPPoint, // TP
eaSLPoint, // SL
eaIgnoreTP,
eaIgnoreSL,
eaAllowLong,
eaAllowShort,
eaMaxAllowedLongs, // Max Longs
eaMaxAllowedShorts // Max Shorts
);
//
// Configuere Strategy ...
iStrategy.EnableXCHM(true);
iStrategy.EnableXCHHK(true);
iStrategy.EnableXCHSTR(true);
iStrategy.EnableXCHCHE(true);
iStrategy.DrawImportantAreas(false);
iStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
//
// Configure Alerts ...
iStrategy.SetAlertPrefix(mTag);
iStrategy.SetAlertEnableAlerts(eAEnableAlerts);
iStrategy.SetAlertLogAlerts(eALogAlerts);
iStrategy.SetAlertMailAlerts(eAMailAlerts);
iStrategy.SetAlertPushAlerts(eAPushAlerts);
iStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
//
// Register Strategy ...
RegisterStrategy(iStrategy);
}
}
//
return result;
}
//
// Register Strategy ...
void RegisterStrategy(XSCBaseStrategy *strategy)
{
//
if (strategy == NULL)
{
return;
}
//
ArrayResize(
strategies,
ArraySize(strategies) + 1 //
);
//
strategies[ArraySize(strategies) - 1] = strategy;
}
//
// Call All Registered Strategis Tick Handler Functions ...
void HandleStrategiesOnTick()
{
//
int count = ArraySize(strategies);
if (!IsValidSize(count))
{
return;
}
//
for (int i = 0; i < count; i++)
{
//
// Call Tick Handler Function ...
strategies[i].HandleTick();
}
}
//
// Manage Trading States ...
void HandleTradeState()
{
//
// Implement All Trade States here ...
eaTradeHandler.UpdateData();
//
// Do Protection Senarios ...
eaTradeHandler.HandleProtection();
}
//
// Time Reporting ...
void HandleTimeReport()
{
//
// Monthly Report ....
if (eaAlertNewMonths &&
eaTimeTracker.IsNewMonth())
{
//
string msg = "New Month ...";
//
eaAlert.Alert(msg);
}
//
// Weekly Report ....
if (eaAlertNewWeeks &&
eaTimeTracker.IsNewWeek())
{
//
string msg = "New Week ...";
//
eaAlert.Alert(msg);
}
//
// Daily Report ....
if (eaAlertNewDays &&
eaTimeTracker.IsNewDay())
{
//
string msg = "New Day ...";
//
eaAlert.Alert(msg);
}
//
// Hourly Report ....
if (eaAlertNewHours &&
eaTimeTracker.IsNewHour())
{
//
string msg = "New Hour ...";
//
eaAlert.Alert(msg);
}
}
//
// SIGNAL EVENT Handlers ...
//
//
// All Signals from Strategies Comming Here for Execution or
// Analyzing ...
void OnSignalRecieved(
XSignal &signal,
XCHStrategyConditions &conditions //
)
{
//
// Check Signal and Conditions Validations ...
//
if (!signal.IsValid())
{
return;
}
//
if (!conditions.IsValid())
{
return;
}
//
XCHStartegyConditionsParser parser;
bool isFiltered = parser.IsFiltered(
signal,
conditions //
);
if (isFiltered)
{
return;
}
//
// Attach Conditions Summary to Signal ...
string conditionsSummary = conditions.GenerateSummary(
false,
false,
true,
false //
);
//
signal.conditions = parser.GenerateSignalConditions(conditions); // conditionsSummary;
//
// Execute Signal Using Trade Handler ...
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = eaTradeHandler.ExecuteSignal(
signal,
state //
);
}
//
void OnStopLossTriggered(const XDeal &deal)
{
//
// Finish ...
eaTradeHandler.Finish(deal);
}
//
void OnTakeProfitTriggered(const XDeal &deal)
{
//
// Finish ...
eaTradeHandler.Finish(deal);
}
//
void OnPositionForceClosed(
const ulong ticket,
const XPosition &position,
const string comment //
)
{
//
// Finish ...
eaTradeHandler.Finish(
ticket,
position,
comment //
);
}
//
Binary file not shown.
@@ -0,0 +1,245 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCCHelper
// 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 ...
//
// Input Models ...
struct XCCInputs
{
//
// Props ...
//
// Chart Style ...
ENUM_CHART_MODE mode; // Mode
color upColor; // Up Color
color downColor; // Down Color
color lineColor; // Line mode and Doji candlestick Color
color bearishColor; // Bullish Color
color bullishColor; // Bearish Color
color volumesColor; // Volumes Color
//
// Presentation ...
bool showCandles; // Show Candles
//
// Constructor(s) ...
XCCInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
mode = CHART_CANDLES;
//
upColor = CLR_NONE;
downColor = CLR_NONE;
lineColor = CLR_NONE;
bearishColor = CLR_NONE;
bullishColor = CLR_NONE;
volumesColor = CLR_NONE;
//
showCandles = false;
}
//
// Default ...
void Default()
{
//
mode = CHART_CANDLES;
//
upColor = clrLime;
downColor = clrRed;
lineColor = clrLime;
bearishColor = clrRed;
bullishColor = clrLime;
volumesColor = clrGreen;
//
showCandles = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
true
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(0, 0);
//
return result;
}
};
//
// Class ...
class XSCXCCHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXCCHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXCCHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XCCInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xcc",
//
// Inputs ...
//
// Chart Style ...
"",
mInputs.mode, // Mode
mInputs.upColor, // Up Color
mInputs.downColor, // Down Color
mInputs.lineColor, // Line mode and Doji candlestick Color
mInputs.bearishColor, // Bullish Color
mInputs.bullishColor, // Bearish Color
mInputs.volumesColor, // Volumes Color
//
// Presentation ...
"",
mInputs.showCandles // Show Candles
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XCCInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XCCInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XCCInputs mInputs; // Inputs ...
};
//
// Tools ...
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,220 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCTHelper
// 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 ...
//
// Input Models ...
struct XCTInputs
{
//
// Props ...
//
color clr; // Text Color
ENUM_BASE_CORNER corner; // Text Position
//
// Presentation ...
bool showCandleTime; // Show Candle Time
//
// Constructor(s) ...
XCTInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
clr = CLR_NONE;
corner = CORNER_RIGHT_LOWER;
//
// Presentation ...
showCandleTime = false;
}
//
// Default ...
void Default()
{
//
clr = clrYellow;
corner = CORNER_RIGHT_LOWER;
//
// Presentation ...
showCandleTime = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
true
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(0, 0);
//
return result;
}
};
//
// Class ...
class XSCXCTHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXCTHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXCTHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XCTInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xct",
//
// Inputs ...
mInputs.clr, // Text Color
mInputs.corner, // Text Position
//
// Presentation ...
"",
mInputs.showCandleTime // Show Candle Time
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XCTInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XCTInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XCTInputs mInputs; // Inputs ...
};
//
// Tools ...
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
+437
View File
@@ -0,0 +1,437 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Candle Styles
// ---------------------------------------------------
// Name: XCC
// Description: Candle Styles ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCC Indicator"
#property strict
//
// START Constants ...
//
//
// Indicator Short Name ...
#define ShortName "XCC"
//
// Holds an SnapShot of Charts Configuration ...
struct XChartStyle
{
//
// chart's ID ...
long chartId;
//
// chart's mode ...
ENUM_CHART_MODE mode;
//
// show bid line ...
bool showBidLine;
//
// show ask line ...
bool showAskLine;
//
// show grids on chart ...
bool showGrid;
//
// show volumes ...
bool showVolumes;
//
// Displaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders) ...
bool showTradeLevels;
//
// chart autoscroll ...
bool autoScroll;
//
// chart quick navigation state ...
bool quickNavigation;
//
// chart's foreground color ...
color foreGroundColor;
//
// chart's background color ...
color backGroundColor;
//
// Up Color ...
color upColor;
//
// Down Color ...
color downColor;
//
// Bullish color ...
color bullishColor;
//
// Bearish color ...
color bearishColor;
//
// grid color ...
color gridColor;
//
// bid line color ...
color bidLineColor;
//
// ask line color ...
color askLineColor;
//
// line mode and doji candlestick color ...
color lineColor;
//
// Color of stop order levels (Stop Loss and Take Profit) ...
color stopColor;
//
// volumes color ...
color volumesColor;
};
//
// END Constants ...
//
//
// START Inputs ...
//
//
input group "Chart Style";
input ENUM_CHART_MODE mode = CHART_CANDLES; // Mode
input color upColor = clrLime; // Up Color
input color downColor = clrRed; // Down Color
input color lineColor = clrLime; // Line mode and Doji candlestick Color
input color bearishColor = clrRed; // Bullish Color
input color bullishColor = clrLime; // Bearish Color
input color volumesColor = clrGreen; // Volumes Color
//
input group "Presentation";
input bool showCandles = true; // Show Candles
//
// END Inputs ...
//
//
// START Includes and Imports ...
//
//
// Includes Draw Library ...
#include "../Libraries/x-saherelm.draw.lib.mq5"
//
// Includes Common Library ...
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Includes and Imports ...
//
//
// START Buffers ...
//
//
#property indicator_chart_window
//
#property indicator_buffers 0
#property indicator_plots 0
//
// END Buffers ...
//
//
// START Global Definitions: Variables, Properties and etc ...
//
//
int maxLength;
//
XChartStyle chartStyle;
XChartStyle clearStyle;
//
// END Global Definitions: Variables, Properties and etc ...
//
//
// START Event Handlers ...
//
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
drawPrefix = ShortName;
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// Apply Chart Style ...
ApplyCustomChartStyle();
//
// 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
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
// Prepare Buffers ...
ArraySetAsSeries(time, true);
ArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(low, true);
ArraySetAsSeries(close, true);
ArraySetAsSeries(tick_volume, true);
ArraySetAsSeries(volume, true);
ArraySetAsSeries(spread, true);
//
// this counts Available Bars ...
int limit;
//
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
//
// Main Loop ...
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
{
CalculateBuffers(i);
}
//
return rates_total;
}
//
// END Event Handlers ...
//
//
// START Functions ...
//
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result = true;
//
return result;
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
return result;
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
// Calculate Buffers ...
void CalculateBuffers(
int bar_index // Selected Bar Index
)
{
}
//
// Apply Custom Chart Style ...
void ApplyCustomChartStyle()
{
//
// Read Current Chart Config and Store it ...
ReadChartStyle();
//
// After Reading Current Chart Style ...
// we have to Save Configs and Change Styles ...
clearStyle = chartStyle;
//
clearStyle.upColor = CLR_NONE;
clearStyle.downColor = CLR_NONE;
clearStyle.lineColor = CLR_NONE;
clearStyle.bullishColor = CLR_NONE;
clearStyle.bearishColor = CLR_NONE;
//
// Decide to Show or not Candles based on User Input ...
if (showCandles)
{
SetChartStyle(chartStyle);
}
else
{
SetChartStyle(clearStyle);
}
}
//
// Read Previous Chart Style ...
void ReadChartStyle()
{
//
// Retrieve Current Chart ID ...
long chartId = ChartID();
chartStyle.chartId = chartId;
//
// Retrieve Chart Mode ...
chartStyle.mode = (ENUM_CHART_MODE)ChartGetInteger(chartId, CHART_MODE);
//
chartStyle.showBidLine = (bool)ChartGetInteger(chartId, CHART_SHOW_BID_LINE);
chartStyle.showAskLine = (bool)ChartGetInteger(chartId, CHART_SHOW_ASK_LINE);
chartStyle.showGrid = (bool)ChartGetInteger(chartId, CHART_SHOW_GRID);
chartStyle.showVolumes = (bool)ChartGetInteger(chartId, CHART_SHOW_VOLUMES);
chartStyle.showTradeLevels = (bool)ChartGetInteger(chartId, CHART_SHOW_TRADE_LEVELS);
chartStyle.autoScroll = (bool)ChartGetInteger(chartId, CHART_AUTOSCROLL);
chartStyle.quickNavigation = (bool)ChartGetInteger(chartId, CHART_QUICK_NAVIGATION);
//
chartStyle.foreGroundColor = (color)ChartGetInteger(chartId, CHART_COLOR_FOREGROUND);
chartStyle.backGroundColor = (color)ChartGetInteger(chartId, CHART_COLOR_BACKGROUND);
chartStyle.upColor = (color)ChartGetInteger(chartId, CHART_COLOR_CHART_UP);
chartStyle.downColor = (color)ChartGetInteger(chartId, CHART_COLOR_CHART_DOWN);
chartStyle.bullishColor = (color)ChartGetInteger(chartId, CHART_COLOR_CANDLE_BULL);
chartStyle.bearishColor = (color)ChartGetInteger(chartId, CHART_COLOR_CANDLE_BEAR);
chartStyle.gridColor = (color)ChartGetInteger(chartId, CHART_COLOR_GRID);
chartStyle.bidLineColor = (color)ChartGetInteger(chartId, CHART_COLOR_BID);
chartStyle.askLineColor = (color)ChartGetInteger(chartId, CHART_COLOR_ASK);
chartStyle.stopColor = (color)ChartGetInteger(chartId, CHART_COLOR_STOP_LEVEL);
chartStyle.lineColor = (color)ChartGetInteger(chartId, CHART_COLOR_CHART_LINE);
chartStyle.volumesColor = (color)ChartGetInteger(chartId, CHART_COLOR_VOLUME);
//
chartStyle.mode = mode;
chartStyle.upColor = upColor;
chartStyle.downColor = downColor;
chartStyle.lineColor = lineColor;
chartStyle.bearishColor = bearishColor;
chartStyle.bullishColor = bullishColor;
chartStyle.volumesColor = volumesColor;
}
//
// Set Chart Style ...
void SetChartStyle(
XChartStyle &mChartStyle // Chart Style to Apply
)
{
//
ApplyChartStyle(
mChartStyle.chartId,
mChartStyle.mode,
mChartStyle.showBidLine,
mChartStyle.showAskLine,
mChartStyle.showGrid,
mChartStyle.showVolumes,
mChartStyle.showTradeLevels,
mChartStyle.autoScroll,
mChartStyle.quickNavigation,
mChartStyle.foreGroundColor,
mChartStyle.backGroundColor,
mChartStyle.upColor,
mChartStyle.downColor,
mChartStyle.bullishColor,
mChartStyle.bearishColor,
mChartStyle.gridColor,
mChartStyle.bidLineColor,
mChartStyle.askLineColor,
mChartStyle.lineColor,
mChartStyle.stopColor,
mChartStyle.volumesColor);
}
//
// END Functions ...
//
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,993 @@
///////////////////////////////////////////////////////
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------
// Name: XCHSwings
// Description: XCHSwings Detector ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCHVWAP Indicator"
#property strict
//
#define ShortName "XCHVWAP"
//
// Includes Common Library ...
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// Inputs ...
//
// Market ...
input group "Market";
input int length = 12; // Length
//
input group "Cycles";
//
input group "Short";
input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
//
input group "Medium";
input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
//
input group "Long";
input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
//
input group "Hind";
input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
//
// Presentation ...
input group "Presentation";
//
input bool showSwingHighs = true; // Show Swing Highs
input bool showSwingLows = true; // Show Swing Lows
//
input bool showCurrent = true; // Show Cycle Cycle
input bool showShort = true; // Show Short Cycle
input bool showMedium = true; // Show Medium Cycle
input bool showLong = true; // Show Long Cycle
input bool showHind = true; // Show Hind Cycle
//
#property indicator_chart_window
//
#property indicator_buffers 10
#property indicator_plots 10
//
#define hideColorIDX 0
#define bullishColorIDX 1
#define bearishColorIDX 2
//
// Current ...
//
#define cSHBufferIndex 0
double cSHBuffer[];
//
#property indicator_label1 "XCHVSwings CH"
#property indicator_type1 DRAW_ARROW
#property indicator_color1 clrMagenta
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
//
#define cSLBufferIndex 1
double cSLBuffer[];
//
#property indicator_label2 "XCHVSwings CL"
#property indicator_type2 DRAW_ARROW
#property indicator_color2 clrAqua
#property indicator_style2 STYLE_SOLID
#property indicator_width2 2
//
// Short ...
//
#define sSHBufferIndex 2
double sSHBuffer[];
//
#property indicator_label3 "XCHVSwings SH"
#property indicator_type3 DRAW_ARROW
#property indicator_color3 clrMagenta
#property indicator_style3 STYLE_SOLID
#property indicator_width3 2
//
#define sSLBufferIndex 3
double sSLBuffer[];
//
#property indicator_label4 "XCHVSwings SL"
#property indicator_type4 DRAW_ARROW
#property indicator_color4 clrAqua
#property indicator_style4 STYLE_SOLID
#property indicator_width4 2
//
// Medium ...
//
#define mSHBufferIndex 4
double mSHBuffer[];
//
#property indicator_label5 "XCHVSwings MH"
#property indicator_type5 DRAW_ARROW
#property indicator_color5 clrMagenta
#property indicator_style5 STYLE_SOLID
#property indicator_width5 2
//
#define mSLBufferIndex 5
double mSLBuffer[];
//
#property indicator_label6 "XCHVSwings ML"
#property indicator_type6 DRAW_ARROW
#property indicator_color6 clrAqua
#property indicator_style6 STYLE_SOLID
#property indicator_width6 2
//
// Long ...
//
#define lSHBufferIndex 6
double lSHBuffer[];
//
#property indicator_label7 "XCHVSwings LH"
#property indicator_type7 DRAW_ARROW
#property indicator_color7 clrMagenta
#property indicator_style7 STYLE_SOLID
#property indicator_width7 2
//
#define lSLBufferIndex 7
double lSLBuffer[];
//
#property indicator_label8 "XCHVSwings LL"
#property indicator_type8 DRAW_ARROW
#property indicator_color8 clrAqua
#property indicator_style8 STYLE_SOLID
#property indicator_width8 2
//
// Hind ...
//
#define hSHBufferIndex 8
double hSHBuffer[];
//
#property indicator_label9 "XCHVSwings HH"
#property indicator_type9 DRAW_ARROW
#property indicator_color9 clrMagenta
#property indicator_style9 STYLE_SOLID
#property indicator_width9 2
//
#define hSLBufferIndex 9
double hSLBuffer[];
//
#property indicator_label10 "XCHVSwings HL"
#property indicator_type10 DRAW_ARROW
#property indicator_color10 clrAqua
#property indicator_style10 STYLE_SOLID
#property indicator_width10 2
//
// Variables ...
//
int maxLength;
//
// Cuurent ...
int mCMarketLength = length;
//
double cH1 = 0;
double cL1 = 0;
datetime cH1Time = 0;
datetime cL1Time = 0;
//
// Short ...
int mSCycleLength = 0;
int mSMarketLength = 0;
ENUM_TIMEFRAMES mSCPeriod = NULL;
//
double sH1 = 0;
double sL1 = 0;
datetime sH1Time = 0;
datetime sL1Time = 0;
//
// Medium ...
int mMCycleLength = 0;
int mMMarketLength = 0;
ENUM_TIMEFRAMES mMCPeriod = NULL;
//
double mH1 = 0;
double mL1 = 0;
datetime mH1Time = 0;
datetime mL1Time = 0;
//
// Long ...
int mLCycleLength = 0;
int mLMarketLength = 0;
ENUM_TIMEFRAMES mLCPeriod = NULL;
//
double lH1 = 0;
double lL1 = 0;
datetime lH1Time = 0;
datetime lL1Time = 0;
//
// Hind ...
int mHCycleLength = 0;
int mHMarketLength = 0;
ENUM_TIMEFRAMES mHCPeriod = NULL;
//
double hH1 = 0;
double hL1 = 0;
datetime hH1Time = 0;
datetime hL1Time = 0;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitMarketCycles())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// 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
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
int start;
//
if (prev_calculated == 0)
{
start = maxLength;
}
else
{
start = prev_calculated - 1;
}
//
for (int i = start; i < rates_total - maxLength && !IsStopped(); i++)
{
//
CalculateBuffers(
i,
prev_calculated,
rates_total,
//
time,
open,
high,
close,
low,
tick_volume //
);
}
//
return rates_total;
}
//
// Functions ...
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result = false;
//
result =
//
length >= 2 &&
//
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
;
//
return result;
}
//
// Initialize Market Cycles ...
bool InitMarketCycles()
{
//
bool result = false;
//
// Current Cycle Initialization ...
//
int cPeriodSeconds = PeriodSeconds(_Period);
//
// Short Cycle Initialization ...
//
// Find Cycle Period ...
if (scMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mSCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_SHORT,
_Period //
);
}
else
{
mSCPeriod = scPeriod;
}
//
result = IsValid(mSCPeriod);
if (!result)
{
return result;
}
//
mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds;
mSMarketLength = mSCycleLength * mCMarketLength;
result = mSCycleLength > 0;
if (!result)
{
return result;
}
//
// Medium Cycle Initialization ...
//
// Find Cycle Period ...
if (mcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mMCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_MEDIUM,
_Period //
);
}
else
{
mMCPeriod = mcPeriod;
}
//
result = IsValid(mMCPeriod);
if (!result)
{
return result;
}
//
mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds;
mMMarketLength = mMCycleLength * mCMarketLength;
result = mMCycleLength > 0;
if (!result)
{
return result;
}
//
// Long Cycle Initialization ...
//
// Find Cycle Period ...
if (lcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mLCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_LONG,
_Period //
);
}
else
{
mLCPeriod = lcPeriod;
}
//
result = IsValid(mLCPeriod);
if (!result)
{
return result;
}
//
mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds;
mLMarketLength = mLCycleLength * mCMarketLength;
result = mLCycleLength > 0;
if (!result)
{
return result;
}
//
// Hind Cycle Initialization ...
//
// Find Cycle Period ...
if (hcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mHCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_HIND,
_Period //
);
}
else
{
mHCPeriod = hcPeriod;
}
//
result = IsValid(mHCPeriod);
if (!result)
{
return result;
}
//
mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds;
mHMarketLength = mHCycleLength * mCMarketLength;
result = mHCycleLength > 0;
if (!result)
{
return result;
}
//
return result;
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
result = MathMax(mCMarketLength, mSMarketLength);
result = MathMax(result, mMMarketLength);
result = MathMax(result, mLMarketLength);
result = MathMax(result, mHMarketLength);
//
return result;
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
//
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
// Setting Indicator Digits
IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// Current ...
//
ENUM_DRAW_TYPE cSHDrawType =
showCurrent && showSwingHighs
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(cSHBufferIndex, cSHBuffer, INDICATOR_DATA);
PlotIndexSetDouble(cSHBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(cSHBufferIndex, PLOT_ARROW, 234);
PlotIndexSetInteger(cSHBufferIndex, PLOT_SHOW_DATA, showCurrent && showSwingHighs);
PlotIndexSetInteger(cSHBufferIndex, PLOT_DRAW_TYPE, cSHDrawType);
//
ENUM_DRAW_TYPE cSLDrawType =
showCurrent && showSwingLows
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(cSLBufferIndex, cSLBuffer, INDICATOR_DATA);
PlotIndexSetDouble(cSLBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(cSLBufferIndex, PLOT_ARROW, 233);
PlotIndexSetInteger(cSLBufferIndex, PLOT_SHOW_DATA, showCurrent && showSwingLows);
PlotIndexSetInteger(cSLBufferIndex, PLOT_DRAW_TYPE, cSLDrawType);
//
// Short ...
//
ENUM_DRAW_TYPE sSHDrawType =
showShort && showSwingHighs
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(sSHBufferIndex, sSHBuffer, INDICATOR_DATA);
PlotIndexSetDouble(sSHBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(sSHBufferIndex, PLOT_ARROW, 234);
PlotIndexSetInteger(sSHBufferIndex, PLOT_SHOW_DATA, showShort && showSwingHighs);
PlotIndexSetInteger(sSHBufferIndex, PLOT_DRAW_TYPE, sSHDrawType);
//
ENUM_DRAW_TYPE sSLDrawType =
showShort && showSwingLows
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(sSLBufferIndex, sSLBuffer, INDICATOR_DATA);
PlotIndexSetDouble(sSLBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(sSLBufferIndex, PLOT_ARROW, 233);
PlotIndexSetInteger(sSLBufferIndex, PLOT_SHOW_DATA, showShort && showSwingLows);
PlotIndexSetInteger(sSLBufferIndex, PLOT_DRAW_TYPE, sSLDrawType);
//
// Medium ...
//
ENUM_DRAW_TYPE mSHDrawType =
showMedium && showSwingHighs
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(mSHBufferIndex, mSHBuffer, INDICATOR_DATA);
PlotIndexSetDouble(mSHBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(mSHBufferIndex, PLOT_ARROW, 234);
PlotIndexSetInteger(mSHBufferIndex, PLOT_SHOW_DATA, showMedium && showSwingHighs);
PlotIndexSetInteger(mSHBufferIndex, PLOT_DRAW_TYPE, mSHDrawType);
//
ENUM_DRAW_TYPE mSLDrawType =
showMedium && showSwingLows
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(mSLBufferIndex, mSLBuffer, INDICATOR_DATA);
PlotIndexSetDouble(mSLBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(mSLBufferIndex, PLOT_ARROW, 233);
PlotIndexSetInteger(mSLBufferIndex, PLOT_SHOW_DATA, showMedium && showSwingLows);
PlotIndexSetInteger(mSLBufferIndex, PLOT_DRAW_TYPE, mSLDrawType);
//
// Long ...
//
ENUM_DRAW_TYPE lSHDrawType =
showLong && showSwingHighs
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(lSHBufferIndex, lSHBuffer, INDICATOR_DATA);
PlotIndexSetDouble(lSHBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(lSHBufferIndex, PLOT_ARROW, 234);
PlotIndexSetInteger(lSHBufferIndex, PLOT_SHOW_DATA, showLong && showSwingHighs);
PlotIndexSetInteger(lSHBufferIndex, PLOT_DRAW_TYPE, lSHDrawType);
//
ENUM_DRAW_TYPE lSLDrawType =
showLong && showSwingLows
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(lSLBufferIndex, lSLBuffer, INDICATOR_DATA);
PlotIndexSetDouble(lSLBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(lSLBufferIndex, PLOT_ARROW, 233);
PlotIndexSetInteger(lSLBufferIndex, PLOT_SHOW_DATA, showLong && showSwingLows);
PlotIndexSetInteger(lSLBufferIndex, PLOT_DRAW_TYPE, lSLDrawType);
//
// Hind ...
//
ENUM_DRAW_TYPE hSHDrawType =
showHind && showSwingHighs
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(hSHBufferIndex, hSHBuffer, INDICATOR_DATA);
PlotIndexSetDouble(hSHBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(hSHBufferIndex, PLOT_ARROW, 234);
PlotIndexSetInteger(hSHBufferIndex, PLOT_SHOW_DATA, showHind && showSwingHighs);
PlotIndexSetInteger(hSHBufferIndex, PLOT_DRAW_TYPE, hSHDrawType);
//
ENUM_DRAW_TYPE hSLDrawType =
showHind && showSwingLows
? DRAW_ARROW
: DRAW_NONE;
//
SetIndexBuffer(hSLBufferIndex, hSLBuffer, INDICATOR_DATA);
PlotIndexSetDouble(hSLBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(hSLBufferIndex, PLOT_ARROW, 233);
PlotIndexSetInteger(hSLBufferIndex, PLOT_SHOW_DATA, showHind && showSwingLows);
PlotIndexSetInteger(hSLBufferIndex, PLOT_DRAW_TYPE, hSLDrawType);
}
//
// Calculations ...
//
// Calculate Buffers ...
void CalculateBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
//
const datetime &time[],
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
CalculateCycles(
//
bar_index,
prevCalculated,
ratesTotal,
//
time,
open,
high,
close,
low,
tickVolume //
);
}
//
void CalculateCycles(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
//
const datetime &time[],
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
// CURRENT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
//
time,
open,
high,
close,
low,
tickVolume,
//
mCMarketLength,
showCurrent,
cSHBuffer,
cSLBuffer,
cH1,
cH1Time,
cL1,
cL1Time //
);
//
// SHORT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
//
time,
open,
high,
close,
low,
tickVolume,
//
mSMarketLength,
showShort,
sSHBuffer,
sSLBuffer,
sH1,
sH1Time,
sL1,
sL1Time //
);
//
// MEDIUM ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
//
time,
open,
high,
close,
low,
tickVolume,
//
mMMarketLength,
showMedium,
mSHBuffer,
mSLBuffer,
mH1,
mH1Time,
mL1,
mL1Time //
);
//
// LONG ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
//
time,
open,
high,
close,
low,
tickVolume,
//
mLMarketLength,
showLong,
lSHBuffer,
lSLBuffer,
lH1,
lH1Time,
lL1,
lL1Time //
);
//
// HIND ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
//
time,
open,
high,
close,
low,
tickVolume,
//
mHMarketLength,
showHind,
hSHBuffer,
hSLBuffer,
hH1,
hH1Time,
hL1,
hL1Time //
);
}
//
void CalculateCycle(
//
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
//
const datetime &time[],
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[],
//
int _length, // Calculation Length
bool _show,
double &_hBuffer[],
double &_lBuffer[],
double &_h1,
datetime &_h1Time,
double &_l1,
datetime &_l1Time //
)
{
//
bool isSwingHigh = true;
bool isSwingLow = true;
//
_hBuffer[bar_index] = 0;
_lBuffer[bar_index] = 0;
//
// Check for Swing High
for (int j = 1; j <= _length; j++)
{
//
if (high[bar_index] <= high[bar_index + j] || high[bar_index] <= high[bar_index - j])
{
//
isSwingHigh = false;
break;
}
}
//
// Check for Swing Low
for (int j = 1; j <= _length; j++)
{
//
if (low[bar_index] >= low[bar_index + j] || low[bar_index] >= low[bar_index - j])
{
//
isSwingLow = false;
break;
}
}
//
if (isSwingHigh)
{
//
_hBuffer[bar_index] = high[bar_index];
if (high[bar_index] > _h1 || _h1 == 0)
{
//
_h1 = high[bar_index];
_h1Time = time[bar_index];
}
}
//
if (isSwingLow)
{
//
_lBuffer[bar_index] = low[bar_index];
if (low[bar_index] < _l1 || _l1 == 0)
{
//
_l1 = low[bar_index];
_l1Time = time[bar_index];
}
}
}
Binary file not shown.
@@ -0,0 +1,900 @@
///////////////////////////////////////////////////////
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------
// Name: XCHTD
// Description: XCHTD Cycles ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCHTD Indicator"
#property strict
//
#define ShortName "XCHTD"
//
// Includes Common Library ...
#include "../Libraries/x-saherelm.common.lib.mq5"
//
enum ENUM_XCHTD_MODE
{
XCHTD_POWER_MODE = 0, // Using Power
XCHTD_PRESSURE_MODE = 1, // Using Pressure
XCHTD_TYPE_MODE = 2, // Using Type
XCHTD_STRONG_MODE = 3, // Using Power and Pressures
};
//
// Inputs ...
//
input group "Market";
input int length = 14; // Length
input ENUM_XCHTD_MODE mode = XCHTD_POWER_MODE; // Mode
//
input group "Cycles";
//
input group "Short";
input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
//
input group "Medium";
input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
//
input group "Long";
input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
//
input group "Hind";
input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
//
// Presentation ...
input group "Presentation";
//
// Current ...
input bool showCurrent = true; // Show Current Cycle
input bool showShort = true; // Show Short Cycle
input bool showMedium = true; // Show Medium Cycle
input bool showLong = true; // Show Long Cycle
input bool showHind = true; // Show Hind Cycle
//
// Buffers ...
//
#property indicator_chart_window
//
#property indicator_buffers 10
#property indicator_plots 0
//
// Current ...
//
#define cBullBufferIndex 0
double cBullBuffer[];
//
#property indicator_label1 "XCHTD C Bull"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrLime
#property indicator_style1 STYLE_SOLID
//
#define cBearBufferIndex 1
double cBearBuffer[];
//
#property indicator_label2 "XCHTD C Bear"
#property indicator_type2 DRAW_LINE
#property indicator_style2 STYLE_SOLID
#property indicator_color2 clrRed
//
// Short ...
//
#define sBullBufferIndex 2
double sBullBuffer[];
//
#property indicator_label3 "XCHTD S Bull"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrLime
#property indicator_style3 STYLE_SOLID
//
#define sBearBufferIndex 3
double sBearBuffer[];
//
#property indicator_label4 "XCHTD S Bear"
#property indicator_type4 DRAW_LINE
#property indicator_style4 STYLE_SOLID
#property indicator_color4 clrRed
//
// Medium ...
//
#define mBullBufferIndex 4
double mBullBuffer[];
//
#property indicator_label5 "XCHTD M Bull"
#property indicator_type5 DRAW_LINE
#property indicator_color5 clrLime
#property indicator_style5 STYLE_SOLID
//
#define mBearBufferIndex 5
double mBearBuffer[];
//
#property indicator_label6 "XCHTD M Bear"
#property indicator_type6 DRAW_LINE
#property indicator_style6 STYLE_SOLID
#property indicator_color6 clrRed
//
// Long ...
//
#define lBullBufferIndex 6
double lBullBuffer[];
//
#property indicator_label7 "XCHTD L Bull"
#property indicator_type7 DRAW_LINE
#property indicator_color7 clrLime
#property indicator_style7 STYLE_SOLID
//
#define lBearBufferIndex 7
double lBearBuffer[];
//
#property indicator_label8 "XCHTD L Bear"
#property indicator_type8 DRAW_LINE
#property indicator_style8 STYLE_SOLID
#property indicator_color8 clrRed
//
// Hind ...
//
#define hBullBufferIndex 8
double hBullBuffer[];
//
#property indicator_label9 "XCHTD H Bull"
#property indicator_type9 DRAW_LINE
#property indicator_color9 clrLime
#property indicator_style9 STYLE_SOLID
//
#define hBearBufferIndex 9
double hBearBuffer[];
//
#property indicator_label10 "XCHTD H Bear"
#property indicator_type10 DRAW_LINE
#property indicator_style10 STYLE_SOLID
#property indicator_color10 clrRed
//
// Variables, Properties and etc ...
//
int maxLength;
//
// Current ...
int mCMarketLength = length;
//
// Short ...
int mSCycleLength = 0;
int mSMarketLength = 0;
ENUM_TIMEFRAMES mSCPeriod = NULL;
//
// Medium ...
int mMCycleLength = 0;
int mMMarketLength = 0;
ENUM_TIMEFRAMES mMCPeriod = NULL;
//
// Long ...
int mLCycleLength = 0;
int mLMarketLength = 0;
ENUM_TIMEFRAMES mLCPeriod = NULL;
//
// Hind ...
int mHCycleLength = 0;
int mHMarketLength = 0;
ENUM_TIMEFRAMES mHCPeriod = NULL;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitMarketCycles())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// 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
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
// Prepare Buffers ...
ArraySetAsSeries(time, true);
ArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(low, true);
ArraySetAsSeries(close, true);
ArraySetAsSeries(tick_volume, true);
ArraySetAsSeries(volume, true);
ArraySetAsSeries(spread, true);
//
// this counts Available Bars ...
int limit;
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
//
limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated;
//
// Main Loop ...
for (int i = limit; i >= 0 && !IsStopped(); i--)
{
//
CalculateBuffers(
i,
prev_calculated,
rates_total,
open,
high,
close,
low,
tick_volume //
);
}
//
return rates_total;
}
//
// Functions ...
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result = false;
//
result =
//
length >= 2 &&
//
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
;
//
return result;
}
//
// Initialize Market Cycles ...
bool InitMarketCycles()
{
//
bool result = false;
//
// Current Cycle Initialization ...
//
int cPeriodSeconds = PeriodSeconds(_Period);
//
// Short Cycle Initialization ...
//
// Find Cycle Period ...
if (scMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mSCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_SHORT,
_Period //
);
}
else
{
mSCPeriod = scPeriod;
}
//
result = IsValid(mSCPeriod);
if (!result)
{
return result;
}
//
mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds;
mSMarketLength = mSCycleLength * mCMarketLength;
result = mSCycleLength > 0;
if (!result)
{
return result;
}
//
// Medium Cycle Initialization ...
//
// Find Cycle Period ...
if (mcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mMCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_MEDIUM,
_Period //
);
}
else
{
mMCPeriod = mcPeriod;
}
//
result = IsValid(mMCPeriod);
if (!result)
{
return result;
}
//
mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds;
mMMarketLength = mMCycleLength * mCMarketLength;
result = mMCycleLength > 0;
if (!result)
{
return result;
}
//
// Long Cycle Initialization ...
//
// Find Cycle Period ...
if (lcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mLCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_LONG,
_Period //
);
}
else
{
mLCPeriod = lcPeriod;
}
//
result = IsValid(mLCPeriod);
if (!result)
{
return result;
}
//
mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds;
mLMarketLength = mLCycleLength * mCMarketLength;
result = mLCycleLength > 0;
if (!result)
{
return result;
}
//
// Hind Cycle Initialization ...
//
// Find Cycle Period ...
if (hcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mHCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_HIND,
_Period //
);
}
else
{
mHCPeriod = hcPeriod;
}
//
result = IsValid(mHCPeriod);
if (!result)
{
return result;
}
//
mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds;
mHMarketLength = mHCycleLength * mCMarketLength;
result = mHCycleLength > 0;
if (!result)
{
return result;
}
//
return result;
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
result = MathMax(mCMarketLength, mSMarketLength);
result = MathMax(result, mMMarketLength);
result = MathMax(result, mLMarketLength);
result = MathMax(result, mHMarketLength);
//
return result;
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// Current ...
//
// ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(cBullBuffer, true);
SetIndexBuffer(cBullBufferIndex, cBullBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(cBullBufferIndex, PLOT_DRAW_TYPE, cDrawType);
// PlotIndexSetInteger(cBullBufferIndex, PLOT_SHOW_DATA, showCurrent);
//
ArraySetAsSeries(cBearBuffer, true);
SetIndexBuffer(cBearBufferIndex, cBearBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(cBearBufferIndex, PLOT_DRAW_TYPE, cDrawType);
// PlotIndexSetInteger(cBearBufferIndex, PLOT_SHOW_DATA, showCurrent);
//
// Short ...
//
// ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(sBullBuffer, true);
SetIndexBuffer(sBullBufferIndex, sBullBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(sBullBufferIndex, PLOT_DRAW_TYPE, sDrawType);
// PlotIndexSetInteger(sBullBufferIndex, PLOT_SHOW_DATA, showShort);
//
ArraySetAsSeries(sBearBuffer, true);
SetIndexBuffer(sBearBufferIndex, sBearBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(sBearBufferIndex, PLOT_DRAW_TYPE, sDrawType);
// PlotIndexSetInteger(sBearBufferIndex, PLOT_SHOW_DATA, showShort);
//
// Medium ...
//
// ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(mBullBuffer, true);
SetIndexBuffer(mBullBufferIndex, mBullBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(mBullBufferIndex, PLOT_DRAW_TYPE, mDrawType);
// PlotIndexSetInteger(mBullBufferIndex, PLOT_SHOW_DATA, showMedium);
//
ArraySetAsSeries(mBearBuffer, true);
SetIndexBuffer(mBearBufferIndex, mBearBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(mBearBufferIndex, PLOT_DRAW_TYPE, mDrawType);
// PlotIndexSetInteger(mBearBufferIndex, PLOT_SHOW_DATA, showMedium);
//
// Long ...
//
// ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(lBullBuffer, true);
SetIndexBuffer(lBullBufferIndex, lBullBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(lBullBufferIndex, PLOT_DRAW_TYPE, lDrawType);
// PlotIndexSetInteger(lBullBufferIndex, PLOT_SHOW_DATA, showLong);
//
ArraySetAsSeries(lBearBuffer, true);
SetIndexBuffer(lBearBufferIndex, lBearBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(lBearBufferIndex, PLOT_DRAW_TYPE, lDrawType);
// PlotIndexSetInteger(lBearBufferIndex, PLOT_SHOW_DATA, showLong);
//
// Hind ...
//
// ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(hBullBuffer, true);
SetIndexBuffer(hBullBufferIndex, hBullBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(hBullBufferIndex, PLOT_DRAW_TYPE, hDrawType);
// PlotIndexSetInteger(hBullBufferIndex, PLOT_SHOW_DATA, showHind);
//
ArraySetAsSeries(hBearBuffer, true);
SetIndexBuffer(hBearBufferIndex, hBearBuffer, INDICATOR_CALCULATIONS);
// PlotIndexSetInteger(hBearBufferIndex, PLOT_DRAW_TYPE, hDrawType);
// PlotIndexSetInteger(hBearBufferIndex, PLOT_SHOW_DATA, showHind);
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
// Calculations ...
//
// Calculate Buffers ...
void CalculateBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
CalculateCycles(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume //
);
}
//
void CalculateCycles(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
// CURRENT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mCMarketLength,
showCurrent,
cBullBuffer,
cBearBuffer //
);
//
// SHORT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mSMarketLength,
showShort,
sBullBuffer,
sBearBuffer //
);
//
// MEDIUM ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mMMarketLength,
showMedium,
mBullBuffer,
mBearBuffer //
);
//
// LONG ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mLMarketLength,
showLong,
lBullBuffer,
lBearBuffer //
);
//
// HIND ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mHMarketLength,
showHind,
hBullBuffer,
hBearBuffer //
);
}
//
void CalculateCycle(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[],
//
int _length, // Calculation Length
bool _show,
double &_bull[],
double &_bear[] //
)
{
//
double bullPower = 0;
double bearPower = 0;
//
double lowShadow = 0;
double highShadow = 0;
//
double bullPressure = 0;
double bearPressure = 0;
//
double bullRange = 0;
double bearRange = 0;
//
for (int i = bar_index; i < bar_index + _length; i++)
{
//
bool isBullish =
//
close[i] > open[i]
//
;
//
bool isBearish =
//
close[i] < open[i]
//
;
//
double iUpper = MathMax(open[i], close[i]);
double iLower = MathMin(open[i], close[i]);
//
double iBody = iUpper - iLower;
double iRange = high[i] - low[i];
//
double iHighShadow = high[i] - iUpper;
double iLowShadow = iLower - low[i];
//
if (isBullish)
{
//
bullPower += iBody;
bullRange += iRange;
bearPressure += iHighShadow;
}
else if (isBearish)
{
//
bearPower += iBody;
bearRange += iRange;
bullPressure += iLowShadow;
}
//
lowShadow += iLowShadow;
highShadow += iHighShadow;
}
//
if (mode == XCHTD_POWER_MODE)
{
//
_bull[bar_index] = bullPower;
_bear[bar_index] = bearPower;
}
else if (mode == XCHTD_PRESSURE_MODE)
{
//
_bull[bar_index] = bullPressure;
_bear[bar_index] = bearPressure;
}
else if (mode == XCHTD_TYPE_MODE)
{
//
_bull[bar_index] = bullRange;
_bear[bar_index] = bearRange;
}
else if (mode == XCHTD_STRONG_MODE)
{
//
_bull[bar_index] = bullPower + bullPressure;
_bear[bar_index] = bearPower + bearPressure;
}
}
//
Binary file not shown.
@@ -0,0 +1,898 @@
///////////////////////////////////////////////////////
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------
// Name: XCHTD
// Description: XCHTD Cycles ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCHTD Indicator"
#property strict
//
#define ShortName "XCHTD"
//
// Includes Common Library ...
#include "../Libraries/x-saherelm.common.lib.mq5"
//
enum ENUM_XCHTD_MODE
{
XCHTD_POWER_MODE = 0, // Using Power
XCHTD_PRESSURE_MODE = 1, // Using Pressure
XCHTD_TYPE_MODE = 2, // Using Type
XCHTD_STRONG_MODE = 3, // Using Power and Pressures
};
//
// Inputs ...
//
input group "Market";
input int length = 14; // Length
input ENUM_XCHTD_MODE mode = XCHTD_POWER_MODE; // Mode
//
input group "Cycles";
//
input group "Short";
input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
//
input group "Medium";
input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
//
input group "Long";
input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
//
input group "Hind";
input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
//
// Presentation ...
input group "Presentation";
//
// Current ...
input bool showCurrent = true; // Show Current Cycle
input bool showShort = true; // Show Short Cycle
input bool showMedium = true; // Show Medium Cycle
input bool showLong = true; // Show Long Cycle
input bool showHind = true; // Show Hind Cycle
//
// Buffers ...
//
#property indicator_separate_window
//
#property indicator_buffers 10
#property indicator_plots 10
//
// Current ...
//
#define cBullBufferIndex 0
double cBullBuffer[];
//
#property indicator_label1 "XCHTD C Bull"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrLime
#property indicator_style1 STYLE_SOLID
//
#define cBearBufferIndex 1
double cBearBuffer[];
//
#property indicator_label2 "XCHTD C Bear"
#property indicator_type2 DRAW_LINE
#property indicator_style2 STYLE_SOLID
#property indicator_color2 clrRed
//
// Short ...
//
#define sBullBufferIndex 2
double sBullBuffer[];
//
#property indicator_label3 "XCHTD S Bull"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrLime
#property indicator_style3 STYLE_SOLID
//
#define sBearBufferIndex 3
double sBearBuffer[];
//
#property indicator_label4 "XCHTD S Bear"
#property indicator_type4 DRAW_LINE
#property indicator_style4 STYLE_SOLID
#property indicator_color4 clrRed
//
// Medium ...
//
#define mBullBufferIndex 4
double mBullBuffer[];
//
#property indicator_label5 "XCHTD M Bull"
#property indicator_type5 DRAW_LINE
#property indicator_color5 clrLime
#property indicator_style5 STYLE_SOLID
//
#define mBearBufferIndex 5
double mBearBuffer[];
//
#property indicator_label6 "XCHTD M Bear"
#property indicator_type6 DRAW_LINE
#property indicator_style6 STYLE_SOLID
#property indicator_color6 clrRed
//
// Long ...
//
#define lBullBufferIndex 6
double lBullBuffer[];
//
#property indicator_label7 "XCHTD L Bull"
#property indicator_type7 DRAW_LINE
#property indicator_color7 clrLime
#property indicator_style7 STYLE_SOLID
//
#define lBearBufferIndex 7
double lBearBuffer[];
//
#property indicator_label8 "XCHTD L Bear"
#property indicator_type8 DRAW_LINE
#property indicator_style8 STYLE_SOLID
#property indicator_color8 clrRed
//
// Hind ...
//
#define hBullBufferIndex 8
double hBullBuffer[];
//
#property indicator_label9 "XCHTD H Bull"
#property indicator_type9 DRAW_LINE
#property indicator_color9 clrLime
#property indicator_style9 STYLE_SOLID
//
#define hBearBufferIndex 9
double hBearBuffer[];
//
#property indicator_label10 "XCHTD H Bear"
#property indicator_type10 DRAW_LINE
#property indicator_style10 STYLE_SOLID
#property indicator_color10 clrRed
//
// Variables, Properties and etc ...
//
int maxLength;
//
// Current ...
int mCMarketLength = length;
//
// Short ...
int mSCycleLength = 0;
int mSMarketLength = 0;
ENUM_TIMEFRAMES mSCPeriod = NULL;
//
// Medium ...
int mMCycleLength = 0;
int mMMarketLength = 0;
ENUM_TIMEFRAMES mMCPeriod = NULL;
//
// Long ...
int mLCycleLength = 0;
int mLMarketLength = 0;
ENUM_TIMEFRAMES mLCPeriod = NULL;
//
// Hind ...
int mHCycleLength = 0;
int mHMarketLength = 0;
ENUM_TIMEFRAMES mHCPeriod = NULL;
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitMarketCycles())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// 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
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
// Prepare Buffers ...
ArraySetAsSeries(time, true);
ArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(low, true);
ArraySetAsSeries(close, true);
ArraySetAsSeries(tick_volume, true);
ArraySetAsSeries(volume, true);
ArraySetAsSeries(spread, true);
//
// this counts Available Bars ...
int limit;
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
//
limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated;
//
// Main Loop ...
for (int i = limit; i >= 0 && !IsStopped(); i--)
{
//
CalculateBuffers(
i,
prev_calculated,
rates_total,
open,
high,
close,
low,
tick_volume //
);
}
//
return rates_total;
}
//
// Functions ...
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result = false;
//
result =
//
length >= 2 &&
//
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
;
//
return result;
}
//
// Initialize Market Cycles ...
bool InitMarketCycles()
{
//
bool result = false;
//
// Current Cycle Initialization ...
//
int cPeriodSeconds = PeriodSeconds(_Period);
//
// Short Cycle Initialization ...
//
// Find Cycle Period ...
if (scMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mSCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_SHORT,
_Period //
);
}
else
{
mSCPeriod = scPeriod;
}
//
result = IsValid(mSCPeriod);
if (!result)
{
return result;
}
//
mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds;
mSMarketLength = mSCycleLength * mCMarketLength;
result = mSCycleLength > 0;
if (!result)
{
return result;
}
//
// Medium Cycle Initialization ...
//
// Find Cycle Period ...
if (mcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mMCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_MEDIUM,
_Period //
);
}
else
{
mMCPeriod = mcPeriod;
}
//
result = IsValid(mMCPeriod);
if (!result)
{
return result;
}
//
mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds;
mMMarketLength = mMCycleLength * mCMarketLength;
result = mMCycleLength > 0;
if (!result)
{
return result;
}
//
// Long Cycle Initialization ...
//
// Find Cycle Period ...
if (lcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mLCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_LONG,
_Period //
);
}
else
{
mLCPeriod = lcPeriod;
}
//
result = IsValid(mLCPeriod);
if (!result)
{
return result;
}
//
mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds;
mLMarketLength = mLCycleLength * mCMarketLength;
result = mLCycleLength > 0;
if (!result)
{
return result;
}
//
// Hind Cycle Initialization ...
//
// Find Cycle Period ...
if (hcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mHCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_HIND,
_Period //
);
}
else
{
mHCPeriod = hcPeriod;
}
//
result = IsValid(mHCPeriod);
if (!result)
{
return result;
}
//
mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds;
mHMarketLength = mHCycleLength * mCMarketLength;
result = mHCycleLength > 0;
if (!result)
{
return result;
}
//
return result;
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
result = MathMax(mCMarketLength, mSMarketLength);
result = MathMax(result, mMMarketLength);
result = MathMax(result, mLMarketLength);
result = MathMax(result, mHMarketLength);
//
return result;
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// Current ...
//
ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(cBullBuffer, true);
SetIndexBuffer(cBullBufferIndex, cBullBuffer, INDICATOR_DATA);
PlotIndexSetInteger(cBullBufferIndex, PLOT_DRAW_TYPE, cDrawType);
PlotIndexSetInteger(cBullBufferIndex, PLOT_SHOW_DATA, showCurrent);
//
ArraySetAsSeries(cBearBuffer, true);
SetIndexBuffer(cBearBufferIndex, cBearBuffer, INDICATOR_DATA);
PlotIndexSetInteger(cBearBufferIndex, PLOT_DRAW_TYPE, cDrawType);
PlotIndexSetInteger(cBearBufferIndex, PLOT_SHOW_DATA, showCurrent);
//
// Short ...
//
ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(sBullBuffer, true);
SetIndexBuffer(sBullBufferIndex, sBullBuffer, INDICATOR_DATA);
PlotIndexSetInteger(sBullBufferIndex, PLOT_DRAW_TYPE, sDrawType);
PlotIndexSetInteger(sBullBufferIndex, PLOT_SHOW_DATA, showShort);
//
ArraySetAsSeries(sBearBuffer, true);
SetIndexBuffer(sBearBufferIndex, sBearBuffer, INDICATOR_DATA);
PlotIndexSetInteger(sBearBufferIndex, PLOT_DRAW_TYPE, sDrawType);
PlotIndexSetInteger(sBearBufferIndex, PLOT_SHOW_DATA, showShort);
//
// Medium ...
//
ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(mBullBuffer, true);
SetIndexBuffer(mBullBufferIndex, mBullBuffer, INDICATOR_DATA);
PlotIndexSetInteger(mBullBufferIndex, PLOT_DRAW_TYPE, mDrawType);
PlotIndexSetInteger(mBullBufferIndex, PLOT_SHOW_DATA, showMedium);
//
ArraySetAsSeries(mBearBuffer, true);
SetIndexBuffer(mBearBufferIndex, mBearBuffer, INDICATOR_DATA);
PlotIndexSetInteger(mBearBufferIndex, PLOT_DRAW_TYPE, mDrawType);
PlotIndexSetInteger(mBearBufferIndex, PLOT_SHOW_DATA, showMedium);
//
// Long ...
//
ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(lBullBuffer, true);
SetIndexBuffer(lBullBufferIndex, lBullBuffer, INDICATOR_DATA);
PlotIndexSetInteger(lBullBufferIndex, PLOT_DRAW_TYPE, lDrawType);
PlotIndexSetInteger(lBullBufferIndex, PLOT_SHOW_DATA, showLong);
//
ArraySetAsSeries(lBearBuffer, true);
SetIndexBuffer(lBearBufferIndex, lBearBuffer, INDICATOR_DATA);
PlotIndexSetInteger(lBearBufferIndex, PLOT_DRAW_TYPE, lDrawType);
PlotIndexSetInteger(lBearBufferIndex, PLOT_SHOW_DATA, showLong);
//
// Hind ...
//
ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_LINE : DRAW_NONE;
//
ArraySetAsSeries(hBullBuffer, true);
SetIndexBuffer(hBullBufferIndex, hBullBuffer, INDICATOR_DATA);
PlotIndexSetInteger(hBullBufferIndex, PLOT_DRAW_TYPE, hDrawType);
PlotIndexSetInteger(hBullBufferIndex, PLOT_SHOW_DATA, showHind);
//
ArraySetAsSeries(hBearBuffer, true);
SetIndexBuffer(hBearBufferIndex, hBearBuffer, INDICATOR_DATA);
PlotIndexSetInteger(hBearBufferIndex, PLOT_DRAW_TYPE, hDrawType);
PlotIndexSetInteger(hBearBufferIndex, PLOT_SHOW_DATA, showHind);
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
// Calculations ...
//
// Calculate Buffers ...
void CalculateBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
CalculateCycles(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume //
);
}
//
void CalculateCycles(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
// CURRENT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mCMarketLength,
showCurrent,
cBullBuffer,
cBearBuffer //
);
//
// SHORT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mSMarketLength,
showShort,
sBullBuffer,
sBearBuffer //
);
//
// MEDIUM ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mMMarketLength,
showMedium,
mBullBuffer,
mBearBuffer //
);
//
// LONG ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mLMarketLength,
showLong,
lBullBuffer,
lBearBuffer //
);
//
// HIND ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mHMarketLength,
showHind,
hBullBuffer,
hBearBuffer //
);
}
//
void CalculateCycle(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[],
//
int _length, // Calculation Length
bool _show,
double &_bull[],
double &_bear[] //
)
{
//
double bullPower = 0;
double bearPower = 0;
//
double lowShadow = 0;
double highShadow = 0;
//
double bullPressure = 0;
double bearPressure = 0;
//
double bullRange = 0;
double bearRange = 0;
//
for (int i = bar_index; i < bar_index + _length; i++)
{
//
bool isBullish =
//
close[i] > open[i]
//
;
//
bool isBearish =
//
close[i] < open[i]
//
;
//
double iUpper = MathMax(open[i], close[i]);
double iLower = MathMin(open[i], close[i]);
//
double iBody = iUpper - iLower;
double iRange = high[i] - low[i];
//
double iHighShadow = high[i] - iUpper;
double iLowShadow = iLower - low[i];
//
if (isBullish)
{
//
bullPower += iBody;
bullRange += iRange;
bearPressure += iHighShadow;
}
else if (isBearish)
{
//
bearPower += iBody;
bearRange += iRange;
bullPressure += iLowShadow;
}
//
lowShadow += iLowShadow;
highShadow += iHighShadow;
}
//
if (mode == XCHTD_POWER_MODE)
{
//
_bull[bar_index] = bullPower;
_bear[bar_index] = bearPower;
}
else if (mode == XCHTD_PRESSURE_MODE)
{
//
_bull[bar_index] = bullPressure;
_bear[bar_index] = bearPressure;
}
else if (mode == XCHTD_TYPE_MODE)
{
//
_bull[bar_index] = bullRange;
_bear[bar_index] = bearRange;
} else if (mode == XCHTD_STRONG_MODE) {
//
_bull[bar_index] = bullPower + bullPressure;
_bear[bar_index] = bearPower + bearPressure;
}
}
//
Binary file not shown.
@@ -0,0 +1,815 @@
///////////////////////////////////////////////////////
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------
// Name: XCHVLM
// Description: XCHVLM Cycles ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCHVLM Indicator"
#property strict
//
#define ShortName "XCHVLM"
//
// Includes Common Library ...
#include <Math/Stat/Normal.mqh>
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// Inputs ...
//
input group "Market";
input int length = 14; // Length
//
input group "Cycles";
//
input group "Short";
input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
//
input group "Medium";
input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
//
input group "Long";
input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
//
input group "Hind";
input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
//
// Presentation ...
input group "Presentation";
//
// Current ...
input bool showCurrent = true; // Show Current Cycle
input bool showShort = true; // Show Short Cycle
input bool showMedium = true; // Show Medium Cycle
input bool showLong = true; // Show Long Cycle
input bool showHind = true; // Show Hind Cycle
//
// Buffers ...
//
#define hideColorIDX 0
#define bullishColorIDX 1
#define bearishColorIDX 2
//
#property indicator_chart_window
//
#property indicator_buffers 10
#property indicator_plots 0
//
// Current ...
//
#define cBufferIndex 0
double cBuffer[];
//
#define cColorBufferIndex 1
double cColorBuffer[];
//
#define cPlotBufferIndex 0
#property indicator_label1 "XCHVLM C"
#property indicator_style1 STYLE_SOLID
#property indicator_type1 DRAW_COLOR_HISTOGRAM
#property indicator_color1 CLR_NONE, clrLime, clrRed
//
// Short ...
//
#define sBufferIndex 2
double sBuffer[];
//
#define sColorBufferIndex 3
double sColorBuffer[];
//
#define sPlotBufferIndex 1
#property indicator_label2 "XCHVLM S"
#property indicator_style2 STYLE_SOLID
#property indicator_type2 DRAW_COLOR_HISTOGRAM
#property indicator_color2 CLR_NONE, clrLime, clrRed
//
// Medium ...
//
#define mBufferIndex 4
double mBuffer[];
//
#define mColorBufferIndex 5
double mColorBuffer[];
//
#define mPlotBufferIndex 2
#property indicator_label3 "XCHVLM M"
#property indicator_style3 STYLE_SOLID
#property indicator_type3 DRAW_COLOR_HISTOGRAM
#property indicator_color3 CLR_NONE, clrLime, clrRed
//
// Long ...
//
#define lBufferIndex 6
double lBuffer[];
//
#define lColorBufferIndex 7
double lColorBuffer[];
//
#define lPlotBufferIndex 3
#property indicator_label4 "XCHVLM L"
#property indicator_style4 STYLE_SOLID
#property indicator_type4 DRAW_COLOR_HISTOGRAM
#property indicator_color4 CLR_NONE, clrLime, clrRed
//
// Hind ...
//
#define hBufferIndex 8
double hBuffer[];
//
#define hColorBufferIndex 9
double hColorBuffer[];
//
#define hPlotBufferIndex 4
#property indicator_label5 "XCHVLM H"
#property indicator_style5 STYLE_SOLID
#property indicator_type5 DRAW_COLOR_HISTOGRAM
#property indicator_color5 CLR_NONE, clrLime, clrRed
//
// Variables, Properties and etc ...
//
int maxLength;
//
// Current ...
int mCMarketLength = length;
double cVolumes[];
double cDistances[];
//
// Short ...
int mSCycleLength = 0;
int mSMarketLength = 0;
ENUM_TIMEFRAMES mSCPeriod = NULL;
double sVolumes[];
double sDistances[];
//
// Medium ...
int mMCycleLength = 0;
int mMMarketLength = 0;
ENUM_TIMEFRAMES mMCPeriod = NULL;
double mVolumes[];
double mDistances[];
//
// Long ...
int mLCycleLength = 0;
int mLMarketLength = 0;
ENUM_TIMEFRAMES mLCPeriod = NULL;
double lVolumes[];
double lDistances[];
//
// Hind ...
int mHCycleLength = 0;
int mHMarketLength = 0;
ENUM_TIMEFRAMES mHCPeriod = NULL;
double hVolumes[];
double hDistances[];
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitMarketCycles())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Current ...
ArrayResize(cVolumes, maxLength, 0);
ArrayResize(cDistances, maxLength, 0);
//
// Short ...
ArrayResize(sVolumes, maxLength, 0);
ArrayResize(sDistances, maxLength, 0);
//
// Medium ...
ArrayResize(mVolumes, maxLength, 0);
ArrayResize(mDistances, maxLength, 0);
//
// Long ...
ArrayResize(lVolumes, maxLength, 0);
ArrayResize(lDistances, maxLength, 0);
//
// Hind ...
ArrayResize(hVolumes, maxLength, 0);
ArrayResize(hDistances, maxLength, 0);
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// 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
//
Clean(cVolumes);
Clean(cDistances);
//
Clean(sVolumes);
Clean(sDistances);
//
Clean(mVolumes);
Clean(mDistances);
//
Clean(lVolumes);
Clean(lDistances);
//
Clean(hVolumes);
Clean(hDistances);
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
static int i = maxLength * 2;
for (i; i < rates_total; i++)
{
//
CalculateBuffers(
i,
prev_calculated,
rates_total,
//
open,
high,
close,
low,
tick_volume //
);
}
//
i = rates_total - 1;
//
return rates_total;
}
//
// Functions ...
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result = false;
//
result =
//
length >= 2 &&
//
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
;
//
return result;
}
//
// Initialize Market Cycles ...
bool InitMarketCycles()
{
//
bool result = false;
//
// Current Cycle Initialization ...
//
int cPeriodSeconds = PeriodSeconds(_Period);
//
// Short Cycle Initialization ...
//
// Find Cycle Period ...
if (scMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mSCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_SHORT,
_Period //
);
}
else
{
mSCPeriod = scPeriod;
}
//
result = IsValid(mSCPeriod);
if (!result)
{
return result;
}
//
mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds;
mSMarketLength = mSCycleLength * mCMarketLength;
result = mSCycleLength > 0;
if (!result)
{
return result;
}
//
// Medium Cycle Initialization ...
//
// Find Cycle Period ...
if (mcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mMCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_MEDIUM,
_Period //
);
}
else
{
mMCPeriod = mcPeriod;
}
//
result = IsValid(mMCPeriod);
if (!result)
{
return result;
}
//
mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds;
mMMarketLength = mMCycleLength * mCMarketLength;
result = mMCycleLength > 0;
if (!result)
{
return result;
}
//
// Long Cycle Initialization ...
//
// Find Cycle Period ...
if (lcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mLCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_LONG,
_Period //
);
}
else
{
mLCPeriod = lcPeriod;
}
//
result = IsValid(mLCPeriod);
if (!result)
{
return result;
}
//
mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds;
mLMarketLength = mLCycleLength * mCMarketLength;
result = mLCycleLength > 0;
if (!result)
{
return result;
}
//
// Hind Cycle Initialization ...
//
// Find Cycle Period ...
if (hcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mHCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_HIND,
_Period //
);
}
else
{
mHCPeriod = hcPeriod;
}
//
result = IsValid(mHCPeriod);
if (!result)
{
return result;
}
//
mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds;
mHMarketLength = mHCycleLength * mCMarketLength;
result = mHCycleLength > 0;
if (!result)
{
return result;
}
//
return result;
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
result = MathMax(mCMarketLength, mSMarketLength);
result = MathMax(result, mMMarketLength);
result = MathMax(result, mLMarketLength);
result = MathMax(result, mHMarketLength);
//
return result;
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// Current ...
//
// ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(cPlotBufferIndex, PLOT_DRAW_TYPE, cDrawType);
// PlotIndexSetInteger(cPlotBufferIndex, PLOT_SHOW_DATA, showCurrent);
// SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX);
SetIndexBuffer(cBufferIndex, cBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_CALCULATIONS);
//
// Short ...
//
// ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(sPlotBufferIndex, PLOT_DRAW_TYPE, sDrawType);
// PlotIndexSetInteger(sPlotBufferIndex, PLOT_SHOW_DATA, showShort);
// SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX);
SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_CALCULATIONS);
//
// Medium ...
//
// ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(mPlotBufferIndex, PLOT_DRAW_TYPE, mDrawType);
// PlotIndexSetInteger(mPlotBufferIndex, PLOT_SHOW_DATA, showMedium);
// SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX);
SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_CALCULATIONS);
//
// Long ...
//
// ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(lPlotBufferIndex, PLOT_DRAW_TYPE, lDrawType);
// PlotIndexSetInteger(lPlotBufferIndex, PLOT_SHOW_DATA, showLong);
// SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX);
SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_CALCULATIONS);
//
// Hind ...
//
// ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(hPlotBufferIndex, PLOT_DRAW_TYPE, hDrawType);
// PlotIndexSetInteger(hPlotBufferIndex, PLOT_SHOW_DATA, showHind);
// SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX);
SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_CALCULATIONS);
SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_CALCULATIONS);
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
// Calculations ...
//
// Calculate Buffers ...
void CalculateBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
CalculateCycles(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume //
);
}
//
void CalculateCycles(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
// CURRENT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mCMarketLength,
showCurrent,
cVolumes,
cDistances,
cBuffer,
cColorBuffer //
);
//
// SHORT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mSMarketLength,
showShort,
sVolumes,
sDistances,
sBuffer,
sColorBuffer //
);
//
// MEDIUM ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mMMarketLength,
showMedium,
mVolumes,
mDistances,
mBuffer,
mColorBuffer //
);
//
// LONG ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mLMarketLength,
showLong,
lVolumes,
lDistances,
lBuffer,
lColorBuffer //
);
//
// HIND ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mHMarketLength,
showHind,
hVolumes,
hDistances,
hBuffer,
hColorBuffer //
);
}
//
void CalculateCycle(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[],
//
int _length, // Calculation Length
bool _show,
double &_volumes[],
double &_distances[],
double &_buffer[],
double &_colorBuffer[] //
)
{
//
for (int x = 0; x < _length; x++)
{
//
_volumes[x] = (double)tickVolume[bar_index - x];
_distances[x] =
(close[bar_index - x] > open[bar_index - x])
? high[bar_index - x] - low[bar_index - x]
: low[bar_index - x] - high[bar_index - x];
}
//
double iValue = MathMean(_volumes) * MathMean(_distances);
//
_buffer[bar_index] = iValue;
_colorBuffer[bar_index] = iValue > 0
? _show
? bullishColorIDX
: hideColorIDX
: _show
? bearishColorIDX
: hideColorIDX;
}
//
Binary file not shown.
@@ -0,0 +1,810 @@
///////////////////////////////////////////////////////
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------
// Name: XCHVLM
// Description: XCHVLM Cycles ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCHVLM Indicator"
#property strict
//
#define ShortName "XCHVLM"
//
// Includes Common Library ...
#include <Math/Stat/Normal.mqh>
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// Inputs ...
//
input group "Market";
input int length = 14; // Length
//
input group "Cycles";
//
input group "Short";
input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
//
input group "Medium";
input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
//
input group "Long";
input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
//
input group "Hind";
input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
//
// Presentation ...
input group "Presentation";
//
// Current ...
input bool showCurrent = true; // Show Current Cycle
input bool showShort = true; // Show Short Cycle
input bool showMedium = true; // Show Medium Cycle
input bool showLong = true; // Show Long Cycle
input bool showHind = true; // Show Hind Cycle
//
// Buffers ...
//
#define hideColorIDX 0
#define bullishColorIDX 1
#define bearishColorIDX 2
//
#property indicator_separate_window
//
#property indicator_buffers 10
#property indicator_plots 10
//
// Current ...
//
#define cBufferIndex 0
double cBuffer[];
//
#define cColorBufferIndex 1
double cColorBuffer[];
//
#define cPlotBufferIndex 0
#property indicator_label1 "XCHVLM C"
#property indicator_style1 STYLE_SOLID
#property indicator_type1 DRAW_COLOR_HISTOGRAM
#property indicator_color1 CLR_NONE, clrLime, clrRed
//
// Short ...
//
#define sBufferIndex 2
double sBuffer[];
//
#define sColorBufferIndex 3
double sColorBuffer[];
//
#define sPlotBufferIndex 1
#property indicator_label2 "XCHVLM S"
#property indicator_style2 STYLE_SOLID
#property indicator_type2 DRAW_COLOR_HISTOGRAM
#property indicator_color2 CLR_NONE, clrLime, clrRed
//
// Medium ...
//
#define mBufferIndex 4
double mBuffer[];
//
#define mColorBufferIndex 5
double mColorBuffer[];
//
#define mPlotBufferIndex 2
#property indicator_label3 "XCHVLM M"
#property indicator_style3 STYLE_SOLID
#property indicator_type3 DRAW_COLOR_HISTOGRAM
#property indicator_color3 CLR_NONE, clrLime, clrRed
//
// Long ...
//
#define lBufferIndex 6
double lBuffer[];
//
#define lColorBufferIndex 7
double lColorBuffer[];
//
#define lPlotBufferIndex 3
#property indicator_label4 "XCHVLM L"
#property indicator_style4 STYLE_SOLID
#property indicator_type4 DRAW_COLOR_HISTOGRAM
#property indicator_color4 CLR_NONE, clrLime, clrRed
//
// Hind ...
//
#define hBufferIndex 8
double hBuffer[];
//
#define hColorBufferIndex 9
double hColorBuffer[];
//
#define hPlotBufferIndex 4
#property indicator_label5 "XCHVLM H"
#property indicator_style5 STYLE_SOLID
#property indicator_type5 DRAW_COLOR_HISTOGRAM
#property indicator_color5 CLR_NONE, clrLime, clrRed
//
// Variables, Properties and etc ...
//
int maxLength;
//
// Current ...
int mCMarketLength = length;
double cVolumes[];
double cDistances[];
//
// Short ...
int mSCycleLength = 0;
int mSMarketLength = 0;
ENUM_TIMEFRAMES mSCPeriod = NULL;
double sVolumes[];
double sDistances[];
//
// Medium ...
int mMCycleLength = 0;
int mMMarketLength = 0;
ENUM_TIMEFRAMES mMCPeriod = NULL;
double mVolumes[];
double mDistances[];
//
// Long ...
int mLCycleLength = 0;
int mLMarketLength = 0;
ENUM_TIMEFRAMES mLCPeriod = NULL;
double lVolumes[];
double lDistances[];
//
// Hind ...
int mHCycleLength = 0;
int mHMarketLength = 0;
ENUM_TIMEFRAMES mHCPeriod = NULL;
double hVolumes[];
double hDistances[];
//
// Event Handlers ...
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitMarketCycles())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Current ...
ArrayResize(cVolumes, maxLength, 0);
ArrayResize(cDistances, maxLength, 0);
//
// Short ...
ArrayResize(sVolumes, maxLength, 0);
ArrayResize(sDistances, maxLength, 0);
//
// Medium ...
ArrayResize(mVolumes, maxLength, 0);
ArrayResize(mDistances, maxLength, 0);
//
// Long ...
ArrayResize(lVolumes, maxLength, 0);
ArrayResize(lDistances, maxLength, 0);
//
// Hind ...
ArrayResize(hVolumes, maxLength, 0);
ArrayResize(hDistances, maxLength, 0);
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// 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
//
Clean(cVolumes);
Clean(cDistances);
//
Clean(sVolumes);
Clean(sDistances);
//
Clean(mVolumes);
Clean(mDistances);
//
Clean(lVolumes);
Clean(lDistances);
//
Clean(hVolumes);
Clean(hDistances);
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
static int i = maxLength * 2;
for (i; i < rates_total; i++)
{
//
CalculateBuffers(
i,
prev_calculated,
rates_total,
//
open,
high,
close,
low,
tick_volume //
);
}
//
i = rates_total - 1;
//
return rates_total;
}
//
// Functions ...
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result = false;
//
result =
//
length >= 2 &&
//
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
;
//
return result;
}
//
// Initialize Market Cycles ...
bool InitMarketCycles()
{
//
bool result = false;
//
// Current Cycle Initialization ...
//
int cPeriodSeconds = PeriodSeconds(_Period);
//
// Short Cycle Initialization ...
//
// Find Cycle Period ...
if (scMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mSCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_SHORT,
_Period //
);
}
else
{
mSCPeriod = scPeriod;
}
//
result = IsValid(mSCPeriod);
if (!result)
{
return result;
}
//
mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds;
mSMarketLength = mSCycleLength * mCMarketLength;
result = mSCycleLength > 0;
if (!result)
{
return result;
}
//
// Medium Cycle Initialization ...
//
// Find Cycle Period ...
if (mcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mMCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_MEDIUM,
_Period //
);
}
else
{
mMCPeriod = mcPeriod;
}
//
result = IsValid(mMCPeriod);
if (!result)
{
return result;
}
//
mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds;
mMMarketLength = mMCycleLength * mCMarketLength;
result = mMCycleLength > 0;
if (!result)
{
return result;
}
//
// Long Cycle Initialization ...
//
// Find Cycle Period ...
if (lcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mLCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_LONG,
_Period //
);
}
else
{
mLCPeriod = lcPeriod;
}
//
result = IsValid(mLCPeriod);
if (!result)
{
return result;
}
//
mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds;
mLMarketLength = mLCycleLength * mCMarketLength;
result = mLCycleLength > 0;
if (!result)
{
return result;
}
//
// Hind Cycle Initialization ...
//
// Find Cycle Period ...
if (hcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mHCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_HIND,
_Period //
);
}
else
{
mHCPeriod = hcPeriod;
}
//
result = IsValid(mHCPeriod);
if (!result)
{
return result;
}
//
mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds;
mHMarketLength = mHCycleLength * mCMarketLength;
result = mHCycleLength > 0;
if (!result)
{
return result;
}
//
return result;
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
result = MathMax(mCMarketLength, mSMarketLength);
result = MathMax(result, mMMarketLength);
result = MathMax(result, mLMarketLength);
result = MathMax(result, mHMarketLength);
//
return result;
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// Current ...
//
// ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(cPlotBufferIndex, PLOT_DRAW_TYPE, cDrawType);
SetIndexBuffer(cBufferIndex, cBuffer, INDICATOR_DATA);
PlotIndexSetInteger(cPlotBufferIndex, PLOT_SHOW_DATA, showCurrent);
SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX);
//
// Short ...
//
// ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(sPlotBufferIndex, PLOT_DRAW_TYPE, sDrawType);
SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_DATA);
PlotIndexSetInteger(sPlotBufferIndex, PLOT_SHOW_DATA, showShort);
SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX);
//
// Medium ...
//
// ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(mPlotBufferIndex, PLOT_DRAW_TYPE, mDrawType);
SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_DATA);
PlotIndexSetInteger(mPlotBufferIndex, PLOT_SHOW_DATA, showMedium);
SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX);
//
// Long ...
//
// ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(lPlotBufferIndex, PLOT_DRAW_TYPE, lDrawType);
SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_DATA);
PlotIndexSetInteger(lPlotBufferIndex, PLOT_SHOW_DATA, showLong);
SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX);
//
// Hind ...
//
// ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_COLOR_HISTOGRAM : DRAW_NONE;
// PlotIndexSetInteger(hPlotBufferIndex, PLOT_DRAW_TYPE, hDrawType);
SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_DATA);
PlotIndexSetInteger(hPlotBufferIndex, PLOT_SHOW_DATA, showHind);
SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX);
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
// Calculations ...
//
// Calculate Buffers ...
void CalculateBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
CalculateCycles(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume //
);
}
//
void CalculateCycles(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
// CURRENT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mCMarketLength,
showCurrent,
cVolumes,
cDistances,
cBuffer,
cColorBuffer //
);
//
// SHORT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mSMarketLength,
showShort,
sVolumes,
sDistances,
sBuffer,
sColorBuffer //
);
//
// MEDIUM ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mMMarketLength,
showMedium,
mVolumes,
mDistances,
mBuffer,
mColorBuffer //
);
//
// LONG ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mLMarketLength,
showLong,
lVolumes,
lDistances,
lBuffer,
lColorBuffer //
);
//
// HIND ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mHMarketLength,
showHind,
hVolumes,
hDistances,
hBuffer,
hColorBuffer //
);
}
//
void CalculateCycle(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[],
//
int _length, // Calculation Length
bool _show,
double &_volumes[],
double &_distances[],
double &_buffer[],
double &_colorBuffer[] //
)
{
//
for (int x = 0; x < _length; x++)
{
//
_volumes[x] = (double)tickVolume[bar_index - x];
_distances[x] =
(close[bar_index - x] > open[bar_index - x])
? high[bar_index - x] - low[bar_index - x]
: low[bar_index - x] - high[bar_index - x];
}
//
double iValue = MathMean(_volumes) * MathMean(_distances);
//
_buffer[bar_index] = iValue;
_colorBuffer[bar_index] = iValue > 0
? _show
? bullishColorIDX
: hideColorIDX
: _show
? bearishColorIDX
: hideColorIDX;
}
//
Binary file not shown.
@@ -0,0 +1,830 @@
///////////////////////////////////////////////////////
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------
// Name: XCHVWAP
// Description: XCHVWAP Trend Detector ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCHVWAP Indicator"
#property strict
//
#define ShortName "XCHVWAP"
//
// Includes Common Library ...
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// Inputs ...
//
// Market ...
input group "Market";
input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Applied To
//
input group "Cycles";
//
input group "Short";
input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period
//
input group "Medium";
input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period
//
input group "Long";
input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period
//
input group "Hind";
input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period
input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
//
// Presentation ...
input group "Presentation";
input bool showShort = true; // Show Short Cycle
input bool showMedium = true; // Show Medium Cycle
input bool showLong = true; // Show Long Cycle
input bool showHind = true; // Show Hind Cycle
//
// Buffers ...
//
#property indicator_chart_window
//
#property indicator_buffers 14
#property indicator_plots 8
//
#define hideColorIDX 0
#define bullishColorIDX 1
#define bearishColorIDX 2
#define neuturalColorIDX 3
//
// Short ...
//
#define sBufferIndex 0
double sBuffer[];
//
#define sColorBufferIndex 1
double sColorBuffer[];
//
#define sPlotBufferIndex 0
#property indicator_label1 "XCHVWAP S"
#property indicator_type1 DRAW_COLOR_LINE
#property indicator_color1 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style1 STYLE_DOT
#property indicator_width1 1
//
// Medium ...
//
#define mBufferIndex 2
double mBuffer[];
//
#define mColorBufferIndex 3
double mColorBuffer[];
//
#define mPlotBufferIndex 1
#property indicator_label2 "XCHVWAP M"
#property indicator_type2 DRAW_COLOR_LINE
#property indicator_color2 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style2 STYLE_DOT
#property indicator_width2 1
//
// Long ...
//
#define lBufferIndex 4
double lBuffer[];
//
#define lColorBufferIndex 5
double lColorBuffer[];
//
#define lPlotBufferIndex 2
#property indicator_label3 "XCHVWAP L"
#property indicator_type3 DRAW_COLOR_LINE
#property indicator_color3 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style3 STYLE_DOT
#property indicator_width3 1
//
// Hind ...
//
#define hBufferIndex 6
double hBuffer[];
//
#define hColorBufferIndex 7
double hColorBuffer[];
//
#define hPlotBufferIndex 3
#property indicator_label4 "XCHVWAP H"
#property indicator_type4 DRAW_COLOR_LINE
#property indicator_color4 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style4 STYLE_DOT
#property indicator_width4 1
//
// Data Buffers ...
//
// Volumes ...
#define volumeBufferIndex 8
double volumeBuffer[];
//
// Price ...
#define priceBufferIndex 9
double priceBuffer[];
//
// SHORT ...
#define sStateBufferIndex 10
double sStateBuffer[];
//
// MEDIUM ...
#define mStateBufferIndex 11
double mStateBuffer[];
//
// LONG ...
#define lStateBufferIndex 12
double lStateBuffer[];
//
// HIND ...
#define hStateBufferIndex 13
double hStateBuffer[];
//
// Variables ...
//
int maxLength;
//
// Short ...
int mSCycleLength = 0;
ENUM_TIMEFRAMES mSCPeriod = NULL;
//
// Medium ...
int mMCycleLength = 0;
ENUM_TIMEFRAMES mMCPeriod = NULL;
//
// Long ...
int mLCycleLength = 0;
ENUM_TIMEFRAMES mLCPeriod = NULL;
//
// Hind ...
int mHCycleLength = 0;
ENUM_TIMEFRAMES mHCPeriod = NULL;
//
// EVENT Handlers ...
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (!ValidateInputs())
{
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitMarketCycles())
{
return INIT_PARAMETERS_INCORRECT;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
maxLength = ExtractMaxLengthOfInputs();
//
// Define Index Buffers ...
DefineBuffers();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// 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
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
ArraySetAsSeries(low, true);
ArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(close, true);
ArraySetAsSeries(tick_volume, true);
//
// this counts Available Bars ...
int limit;
//
limit =
(prev_calculated > rates_total || prev_calculated <= 0)
? rates_total
: (rates_total - prev_calculated) + 1;
//
// Main Loop ...
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
{
//
CalculateBuffers(
i,
prev_calculated,
rates_total,
//
open,
high,
close,
low,
tick_volume //
);
}
//
return rates_total;
}
//
// CUSTOM Functions ...
//
// Validate Input Args for Initialization ...
bool ValidateInputs()
{
//
bool result =
//
(IsValid(scMethod, scPeriod) &&
IsValid(mcMethod, mcPeriod) &&
IsValid(lcMethod, lcPeriod) &&
IsValid(hcMethod, hcPeriod))
//
;
//
return result;
}
//
// Initialize Market Cycles ...
bool InitMarketCycles()
{
//
bool result = false;
//
// Current Cycle Initialization ...
//
int cPeriodSeconds = PeriodSeconds(_Period);
//
// Short Cycle Initialization ...
//
// Find Cycle Period ...
if (scMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mSCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_SHORT,
_Period //
);
}
else
{
mSCPeriod = scPeriod;
}
//
result = IsValid(mSCPeriod);
if (!result)
{
return result;
}
//
mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds;
result = mSCycleLength > 0;
if (!result)
{
return result;
}
//
// Medium Cycle Initialization ...
//
// Find Cycle Period ...
if (mcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mMCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_MEDIUM,
_Period //
);
}
else
{
mMCPeriod = mcPeriod;
}
//
result = IsValid(mMCPeriod);
if (!result)
{
return result;
}
//
mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds;
result = mMCycleLength > 0;
if (!result)
{
return result;
}
//
// Long Cycle Initialization ...
//
// Find Cycle Period ...
if (lcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mLCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_LONG,
_Period //
);
}
else
{
mLCPeriod = lcPeriod;
}
//
result = IsValid(mLCPeriod);
if (!result)
{
return result;
}
//
mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds;
result = mLCycleLength > 0;
if (!result)
{
return result;
}
//
// Hind Cycle Initialization ...
//
// Find Cycle Period ...
if (hcMethod == X_PERIOD_AUTO)
{
//
// Select Period ...
mHCPeriod = GetCyclePeriod(
X_MARKET_CYCLE_HIND,
_Period //
);
}
else
{
mHCPeriod = hcPeriod;
}
//
result = IsValid(mHCPeriod);
if (!result)
{
return result;
}
//
mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds;
result = mHCycleLength > 0;
if (!result)
{
return result;
}
//
return result;
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// Short ...
//
ArraySetAsSeries(sBuffer, true);
ArraySetAsSeries(sColorBuffer, true);
SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_DATA);
SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX);
//
// Medium ...
//
ArraySetAsSeries(mBuffer, true);
ArraySetAsSeries(mColorBuffer, true);
SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_DATA);
SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX);
//
// Long ...
//
ArraySetAsSeries(lBuffer, true);
ArraySetAsSeries(lColorBuffer, true);
SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_DATA);
SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX);
//
// Hind ...
//
ArraySetAsSeries(hBuffer, true);
ArraySetAsSeries(hColorBuffer, true);
SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_DATA);
SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX);
//
// Data Buffers ...
//
// Volumes ...
ArraySetAsSeries(volumeBuffer, true);
SetIndexBuffer(volumeBufferIndex, volumeBuffer, INDICATOR_CALCULATIONS);
//
// Price ...
ArraySetAsSeries(priceBuffer, true);
SetIndexBuffer(priceBufferIndex, priceBuffer, INDICATOR_CALCULATIONS);
//
// Short State ...
ArraySetAsSeries(sStateBuffer, true);
SetIndexBuffer(sStateBufferIndex, sStateBuffer, INDICATOR_CALCULATIONS);
//
// Medium State ...
ArraySetAsSeries(mStateBuffer, true);
SetIndexBuffer(mStateBufferIndex, mStateBuffer, INDICATOR_CALCULATIONS);
//
// Long State ...
ArraySetAsSeries(lStateBuffer, true);
SetIndexBuffer(lStateBufferIndex, lStateBuffer, INDICATOR_CALCULATIONS);
//
// Hind State ...
ArraySetAsSeries(hStateBuffer, true);
SetIndexBuffer(hStateBufferIndex, hStateBuffer, INDICATOR_CALCULATIONS);
}
//
// Retrieve all Exists Input Max Length ...
// use for Start Of Drawing ...
int ExtractMaxLengthOfInputs()
{
//
int result = 0;
//
result = MathMax(mSCycleLength, mMCycleLength);
result = MathMax(result, mLCycleLength);
result = MathMax(result, mHCycleLength);
//
return result;
}
//
// Calculate Buffers ...
void CalculateBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
// Calculate Volumes and Price ...
//
if (ratesTotal - bar_index <= maxLength)
{
//
CalculateDataBuffers(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume //
);
return;
}
//
CalculateDataBuffers(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume //
);
//
CalculateCycles(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume //
);
}
//
void CalculateDataBuffers(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
double price = GetAppliedPrice(
appliedTo,
open,
high,
low,
close,
bar_index //
);
priceBuffer[bar_index] = price;
volumeBuffer[bar_index] = (double)tickVolume[bar_index];
}
//
void CalculateCycles(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[] //
)
{
//
// SHORT ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mSCycleLength,
showShort,
sBuffer,
sColorBuffer,
sStateBuffer //
);
//
// MEDIUM ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mMCycleLength,
showMedium,
mBuffer,
mColorBuffer,
mStateBuffer //
);
//
// LONG ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mLCycleLength,
showLong,
lBuffer,
lColorBuffer,
lStateBuffer //
);
//
// HIND ...
CalculateCycle(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low,
tickVolume,
//
mHCycleLength,
showHind,
hBuffer,
hColorBuffer,
hStateBuffer //
);
}
//
void CalculateCycle(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[],
const long &tickVolume[],
//
int _length, // Calculation Length
bool _show,
double &_buffer[],
double &_colorBuffer[],
double &_stateBuffer[] //
)
{
//
double vSum = 0;
double pSum = 0;
double mSum = 0;
for (int x = 0; x < _length; x++)
{
//
pSum += priceBuffer[x + bar_index];
vSum += volumeBuffer[x + bar_index];
mSum += priceBuffer[x + bar_index] * volumeBuffer[x + bar_index];
}
//
double iValue = mSum / vSum;
iValue = NormalizeDouble(iValue, _Digits);
//
_buffer[bar_index] = iValue;
//
bool isBullish = low[bar_index] > iValue;
bool isBearish = high[bar_index] < iValue;
//
double iColor =
isBullish
? bullishColorIDX
: isBearish
? bearishColorIDX
: neuturalColorIDX;
//
_colorBuffer[bar_index] = hideColorIDX;
_stateBuffer[bar_index] = iColor;
if (_show)
{
_colorBuffer[bar_index] = iColor;
}
}
//
Binary file not shown.
+261
View File
@@ -0,0 +1,261 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Indicator
// ---------------------------------------------
// Name: XCT
// Description: Trend Magic Indicator ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCT Indicator"
#property strict
//
// START Constants ...
//
//
#define ShortName "XCT"
#include "../Libraries/x-saherelm.common.lib.mq5"
//
// END Constants ...
//
//
// START Inputs ...
//
//
input color clr = clrYellow; // Text Color
input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER; // Text Position
//
input group "Presentation";
input bool showCandleTime = true; // Show Candle Time
//
// END Inputs ...
//
//
// START Buffers ...
//
//
#property indicator_chart_window
//
#property indicator_buffers 0
#property indicator_plots 0
//
// END Buffers ...
//
//
// START Global Definitions: Variables, Properties and etc ...
//
//
// END Global Definitions: Variables, Properties and etc ...
//
//
// START Event Handlers ...
//
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
if (showCandleTime)
{
CreateIndicatorObject();
}
else
{
ObjectDelete(0, ShortName);
}
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// 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
//
ulong chID = FindChartID(
_Symbol,
_Period
//
);
//
// Delete Object ...
ObjectDelete(chID, ShortName);
//
Comment("");
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
ArraySetAsSeries(time, true);
//
if (!showCandleTime)
{
return rates_total;
}
//
ulong chID = FindChartID(
_Symbol,
_Period
//
);
//
XBarRemainsTime barRemains;
barRemains.Init(
_Symbol,
_Period
//
);
//
string msg = barRemains
.ToString(
"",
"",
"",
"",
"",
":",
true
//
);
//
long mSpread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
//
string _sp = "";
if (mSpread < 10)
_sp = "..";
else if (mSpread < 100)
_sp = ".";
//
string objText = "Spread: " + IntegerToString(mSpread) + _sp + " Next Bar in: " + msg;
//
ObjectSetInteger(chID, ShortName, OBJPROP_COLOR, clr);
ObjectSetString(chID, ShortName, OBJPROP_TEXT, objText);
ObjectSetInteger(chID, ShortName, OBJPROP_FONTSIZE, 10);
ObjectSetString(chID, ShortName, OBJPROP_FONT, "Courier");
//
return rates_total;
}
//
// END Event Handlers ...
//
//
// START Functions ...
//
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
void CreateIndicatorObject()
{
//
if (!showCandleTime)
{
return;
}
//
ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner);
ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10);
ObjectSetInteger(0, ShortName, OBJPROP_YDISTANCE, 2);
//
ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
switch (corner)
{
case CORNER_LEFT_UPPER:
Anchor = ANCHOR_LEFT_UPPER;
break;
case CORNER_RIGHT_UPPER:
Anchor = ANCHOR_RIGHT_UPPER;
break;
case CORNER_LEFT_LOWER:
Anchor = ANCHOR_LEFT_LOWER;
break;
case CORNER_RIGHT_LOWER:
Anchor = ANCHOR_RIGHT_LOWER;
break;
}
//
ObjectSetInteger(0, ShortName, OBJPROP_ANCHOR, Anchor);
}
//
// END Functions ...
//
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,826 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Strategy Parser Library
// ------------------------------------------------
// Name: XCHStartegyConditionsParser
// Description: provide all conditions parsing
// for XCH Strategy ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// Imports ...
#include "../Strategies/x-saherelm.xch.strategy.mq5"
//
#include "../Parsers/x-saherelm.xch.eurusd.long.parser.mq5"
#include "../Parsers/x-saherelm.xch.eurusd.short.parser.mq5"
#include "../Parsers/x-saherelm.xch.gbpusd.long.parser.mq5"
#include "../Parsers/x-saherelm.xch.gbpusd.short.parser.mq5"
//
// Conditions Parser ...
struct XCHStartegyConditionsParser
{
//
string _version;
//
// Parsers ...
//
XCHStartegyEURUSDLongConditionsParser _eurusdLongParser;
XCHStartegyEURUSDShortConditionsParser _eurusdShortParser;
//
XCHStartegyGBPUSDLongConditionsParser _gbpusdLongParser;
XCHStartegyGBPUSDShortConditionsParser _gbpusdShortParser;
//
string GenerateSignalConditions(XCHStrategyConditions &conditions)
{
//
// Calculate Score ...
double bullishScore = 0;
double bearishScore = 0;
conditions.GenerateScore(
bullishScore,
bearishScore //
);
//
// Generate Signal Parser Structured Conditions ...
string result =
"---------------" + "\n" +
"Scores:" + "\n" +
"---------------" + "\n" +
"Bullish: " + ToString(bullishScore) + "\n" +
"Bearish: " + ToString(bearishScore) + "\n" +
"---------------" + "\n"
"(" +
"\n" +
"//" + "\n" +
"// XPV ..." + "\n" +
"//" + "\n" +
//
// True(s) ...
(conditions.pvConditions.isNewPeak ? "conditions.pvConditions.isNewPeak &&" + "\n" : "") +
(conditions.pvConditions.isNewPeakOverLast ? "conditions.pvConditions.isNewPeakOverLast &&" + "\n" : "") +
(conditions.pvConditions.isNewPeakUnderLast ? "conditions.pvConditions.isNewPeakUnderLast &&" + "\n" : "") +
(conditions.pvConditions.isNewVale ? "conditions.pvConditions.isNewVale &&" + "\n" : "") +
(conditions.pvConditions.isNewValeOverLast ? "conditions.pvConditions.isNewValeOverLast &&" + "\n" : "") +
(conditions.pvConditions.isNewValeUnderLast ? "conditions.pvConditions.isNewValeUnderLast &&" + "\n" : "") +
(conditions.pvConditions.isFiboIncreased ? "conditions.pvConditions.isFiboIncreased &&" + "\n" : "") +
(conditions.pvConditions.isFiboDecreased ? "conditions.pvConditions.isFiboDecreased &&" + "\n" : "") +
(conditions.pvConditions.isFiboSectionChanged ? "conditions.pvConditions.isFiboSectionChanged &&" + "\n" : "") +
(conditions.pvConditions.isCloseOverFib1 ? "conditions.pvConditions.isCloseOverFib1 &&" + "\n" : "") +
(conditions.pvConditions.isCloseOverFib2 ? "conditions.pvConditions.isCloseOverFib2 &&" + "\n" : "") +
(conditions.pvConditions.isCloseOverFib3 ? "conditions.pvConditions.isCloseOverFib3 &&" + "\n" : "") +
(conditions.pvConditions.isCloseOverFib4 ? "conditions.pvConditions.isCloseOverFib4 &&" + "\n" : "") +
(conditions.pvConditions.isCloseOverFib5 ? "conditions.pvConditions.isCloseOverFib5 &&" + "\n" : "") +
(conditions.pvConditions.isCloseUnderFib1 ? "conditions.pvConditions.isCloseUnderFib1 &&" + "\n" : "") +
(conditions.pvConditions.isCloseUnderFib2 ? "conditions.pvConditions.isCloseUnderFib2 &&" + "\n" : "") +
(conditions.pvConditions.isCloseUnderFib3 ? "conditions.pvConditions.isCloseUnderFib3 &&" + "\n" : "") +
(conditions.pvConditions.isCloseUnderFib4 ? "conditions.pvConditions.isCloseUnderFib4 &&" + "\n" : "") +
(conditions.pvConditions.isCloseUnderFib5 ? "conditions.pvConditions.isCloseUnderFib5 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedOverFib1 ? "conditions.pvConditions.isCloseCrossedOverFib1 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedOverFib2 ? "conditions.pvConditions.isCloseCrossedOverFib2 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedOverFib3 ? "conditions.pvConditions.isCloseCrossedOverFib3 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedOverFib4 ? "conditions.pvConditions.isCloseCrossedOverFib4 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedOverFib5 ? "conditions.pvConditions.isCloseCrossedOverFib5 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedUnderFib1 ? "conditions.pvConditions.isCloseCrossedUnderFib1 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedUnderFib2 ? "conditions.pvConditions.isCloseCrossedUnderFib2 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedUnderFib3 ? "conditions.pvConditions.isCloseCrossedUnderFib3 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedUnderFib4 ? "conditions.pvConditions.isCloseCrossedUnderFib4 &&" + "\n" : "") +
(conditions.pvConditions.isCloseCrossedUnderFib5 ? "conditions.pvConditions.isCloseCrossedUnderFib5 &&" + "\n" : "") +
(conditions.pvConditions.isSCBullish ? "conditions.pvConditions.isSCBullish &&" + "\n" : "") +
(conditions.pvConditions.isSCHHBullish ? "conditions.pvConditions.isSCHHBullish &&" + "\n" : "") +
(conditions.pvConditions.isSCLLBullish ? "conditions.pvConditions.isSCLLBullish &&" + "\n" : "") +
(conditions.pvConditions.isSCSwitchedToBullish ? "conditions.pvConditions.isSCSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isSCHHSwitchedToBullish ? "conditions.pvConditions.isSCHHSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isSCLLSwitchedToBullish ? "conditions.pvConditions.isSCLLSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isSCBearish ? "conditions.pvConditions.isSCBearish &&" + "\n" : "") +
(conditions.pvConditions.isSCHHBearish ? "conditions.pvConditions.isSCHHBearish &&" + "\n" : "") +
(conditions.pvConditions.isSCLLBearish ? "conditions.pvConditions.isSCLLBearish &&" + "\n" : "") +
(conditions.pvConditions.isSCSwitchedToBearish ? "conditions.pvConditions.isSCSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isSCHHSwitchedToBearish ? "conditions.pvConditions.isSCHHSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isSCLLSwitchedToBeraish ? "conditions.pvConditions.isSCLLSwitchedToBeraish &&" + "\n" : "") +
(conditions.pvConditions.isMCBullish ? "conditions.pvConditions.isMCBullish &&" + "\n" : "") +
(conditions.pvConditions.isMCHHBullish ? "conditions.pvConditions.isMCHHBullish &&" + "\n" : "") +
(conditions.pvConditions.isMCLLBullish ? "conditions.pvConditions.isMCLLBullish &&" + "\n" : "") +
(conditions.pvConditions.isMCSwitchedToBullish ? "conditions.pvConditions.isMCSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isMCHHSwitchedToBullish ? "conditions.pvConditions.isMCHHSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isMCLLSwitchedToBullish ? "conditions.pvConditions.isMCLLSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isMCBearish ? "conditions.pvConditions.isMCBearish &&" + "\n" : "") +
(conditions.pvConditions.isMCHHBearish ? "conditions.pvConditions.isMCHHBearish &&" + "\n" : "") +
(conditions.pvConditions.isMCLLBearish ? "conditions.pvConditions.isMCLLBearish &&" + "\n" : "") +
(conditions.pvConditions.isMCSwitchedToBearish ? "conditions.pvConditions.isMCSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isMCHHSwitchedToBearish ? "conditions.pvConditions.isMCHHSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isMCLLSwitchedToBeraish ? "conditions.pvConditions.isMCLLSwitchedToBeraish &&" + "\n" : "") +
(conditions.pvConditions.isLCBullish ? "conditions.pvConditions.isLCBullish &&" + "\n" : "") +
(conditions.pvConditions.isLCHHBullish ? "conditions.pvConditions.isLCHHBullish &&" + "\n" : "") +
(conditions.pvConditions.isLCLLBullish ? "conditions.pvConditions.isLCLLBullish &&" + "\n" : "") +
(conditions.pvConditions.isLCSwitchedToBullish ? "conditions.pvConditions.isLCSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isLCHHSwitchedToBullish ? "conditions.pvConditions.isLCHHSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isLCLLSwitchedToBullish ? "conditions.pvConditions.isLCLLSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isLCBearish ? "conditions.pvConditions.isLCBearish &&" + "\n" : "") +
(conditions.pvConditions.isLCHHBearish ? "conditions.pvConditions.isLCHHBearish &&" + "\n" : "") +
(conditions.pvConditions.isLCLLBearish ? "conditions.pvConditions.isLCLLBearish &&" + "\n" : "") +
(conditions.pvConditions.isLCSwitchedToBearish ? "conditions.pvConditions.isLCSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isLCHHSwitchedToBearish ? "conditions.pvConditions.isLCHHSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isLCLLSwitchedToBeraish ? "conditions.pvConditions.isLCLLSwitchedToBeraish &&" + "\n" : "") +
(conditions.pvConditions.isHCBullish ? "conditions.pvConditions.isHCBullish &&" + "\n" : "") +
(conditions.pvConditions.isHCHHBullish ? "conditions.pvConditions.isHCHHBullish &&" + "\n" : "") +
(conditions.pvConditions.isHCLLBullish ? "conditions.pvConditions.isHCLLBullish &&" + "\n" : "") +
(conditions.pvConditions.isHCSwitchedToBullish ? "conditions.pvConditions.isHCSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isHCHHSwitchedToBullish ? "conditions.pvConditions.isHCHHSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isHCLLSwitchedToBullish ? "conditions.pvConditions.isHCLLSwitchedToBullish &&" + "\n" : "") +
(conditions.pvConditions.isHCBearish ? "conditions.pvConditions.isHCBearish &&" + "\n" : "") +
(conditions.pvConditions.isHCHHBearish ? "conditions.pvConditions.isHCHHBearish &&" + "\n" : "") +
(conditions.pvConditions.isHCLLBearish ? "conditions.pvConditions.isHCLLBearish &&" + "\n" : "") +
(conditions.pvConditions.isHCSwitchedToBearish ? "conditions.pvConditions.isHCSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isHCHHSwitchedToBearish ? "conditions.pvConditions.isHCHHSwitchedToBearish &&" + "\n" : "") +
(conditions.pvConditions.isHCLLSwitchedToBeraish ? "conditions.pvConditions.isHCLLSwitchedToBeraish &&" + "\n" : "") +
"//" + "\n" +
//
// False(s) ...
(!conditions.pvConditions.isNewPeak ? "!conditions.pvConditions.isNewPeak &&" + "\n" : "") +
(!conditions.pvConditions.isNewPeakOverLast ? "!conditions.pvConditions.isNewPeakOverLast &&" + "\n" : "") +
(!conditions.pvConditions.isNewPeakUnderLast ? "!conditions.pvConditions.isNewPeakUnderLast &&" + "\n" : "") +
(!conditions.pvConditions.isNewVale ? "!conditions.pvConditions.isNewVale &&" + "\n" : "") +
(!conditions.pvConditions.isNewValeOverLast ? "!conditions.pvConditions.isNewValeOverLast &&" + "\n" : "") +
(!conditions.pvConditions.isNewValeUnderLast ? "!conditions.pvConditions.isNewValeUnderLast &&" + "\n" : "") +
(!conditions.pvConditions.isFiboIncreased ? "!conditions.pvConditions.isFiboIncreased &&" + "\n" : "") +
(!conditions.pvConditions.isFiboDecreased ? "!conditions.pvConditions.isFiboDecreased &&" + "\n" : "") +
(!conditions.pvConditions.isFiboSectionChanged ? "!conditions.pvConditions.isFiboSectionChanged &&" + "\n" : "") +
(!conditions.pvConditions.isCloseOverFib1 ? "!conditions.pvConditions.isCloseOverFib1 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseOverFib2 ? "!conditions.pvConditions.isCloseOverFib2 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseOverFib3 ? "!conditions.pvConditions.isCloseOverFib3 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseOverFib4 ? "!conditions.pvConditions.isCloseOverFib4 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseOverFib5 ? "!conditions.pvConditions.isCloseOverFib5 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseUnderFib1 ? "!conditions.pvConditions.isCloseUnderFib1 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseUnderFib2 ? "!conditions.pvConditions.isCloseUnderFib2 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseUnderFib3 ? "!conditions.pvConditions.isCloseUnderFib3 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseUnderFib4 ? "!conditions.pvConditions.isCloseUnderFib4 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseUnderFib5 ? "!conditions.pvConditions.isCloseUnderFib5 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedOverFib1 ? "!conditions.pvConditions.isCloseCrossedOverFib1 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedOverFib2 ? "!conditions.pvConditions.isCloseCrossedOverFib2 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedOverFib3 ? "!conditions.pvConditions.isCloseCrossedOverFib3 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedOverFib4 ? "!conditions.pvConditions.isCloseCrossedOverFib4 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedOverFib5 ? "!conditions.pvConditions.isCloseCrossedOverFib5 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedUnderFib1 ? "!conditions.pvConditions.isCloseCrossedUnderFib1 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedUnderFib2 ? "!conditions.pvConditions.isCloseCrossedUnderFib2 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedUnderFib3 ? "!conditions.pvConditions.isCloseCrossedUnderFib3 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedUnderFib4 ? "!conditions.pvConditions.isCloseCrossedUnderFib4 &&" + "\n" : "") +
(!conditions.pvConditions.isCloseCrossedUnderFib5 ? "!conditions.pvConditions.isCloseCrossedUnderFib5 &&" + "\n" : "") +
(!conditions.pvConditions.isSCBullish ? "!conditions.pvConditions.isSCBullish &&" + "\n" : "") +
(!conditions.pvConditions.isSCHHBullish ? "!conditions.pvConditions.isSCHHBullish &&" + "\n" : "") +
(!conditions.pvConditions.isSCLLBullish ? "!conditions.pvConditions.isSCLLBullish &&" + "\n" : "") +
(!conditions.pvConditions.isSCSwitchedToBullish ? "!conditions.pvConditions.isSCSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isSCHHSwitchedToBullish ? "!conditions.pvConditions.isSCHHSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isSCLLSwitchedToBullish ? "!conditions.pvConditions.isSCLLSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isSCBearish ? "!conditions.pvConditions.isSCBearish &&" + "\n" : "") +
(!conditions.pvConditions.isSCHHBearish ? "!conditions.pvConditions.isSCHHBearish &&" + "\n" : "") +
(!conditions.pvConditions.isSCLLBearish ? "!conditions.pvConditions.isSCLLBearish &&" + "\n" : "") +
(!conditions.pvConditions.isSCSwitchedToBearish ? "!conditions.pvConditions.isSCSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isSCHHSwitchedToBearish ? "!conditions.pvConditions.isSCHHSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isSCLLSwitchedToBeraish ? "!conditions.pvConditions.isSCLLSwitchedToBeraish &&" + "\n" : "") +
(!conditions.pvConditions.isMCBullish ? "!conditions.pvConditions.isMCBullish &&" + "\n" : "") +
(!conditions.pvConditions.isMCHHBullish ? "!conditions.pvConditions.isMCHHBullish &&" + "\n" : "") +
(!conditions.pvConditions.isMCLLBullish ? "!conditions.pvConditions.isMCLLBullish &&" + "\n" : "") +
(!conditions.pvConditions.isMCSwitchedToBullish ? "!conditions.pvConditions.isMCSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isMCHHSwitchedToBullish ? "!conditions.pvConditions.isMCHHSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isMCLLSwitchedToBullish ? "!conditions.pvConditions.isMCLLSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isMCBearish ? "!conditions.pvConditions.isMCBearish &&" + "\n" : "") +
(!conditions.pvConditions.isMCHHBearish ? "!conditions.pvConditions.isMCHHBearish &&" + "\n" : "") +
(!conditions.pvConditions.isMCLLBearish ? "!conditions.pvConditions.isMCLLBearish &&" + "\n" : "") +
(!conditions.pvConditions.isMCSwitchedToBearish ? "!conditions.pvConditions.isMCSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isMCHHSwitchedToBearish ? "!conditions.pvConditions.isMCHHSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isMCLLSwitchedToBeraish ? "!conditions.pvConditions.isMCLLSwitchedToBeraish &&" + "\n" : "") +
(!conditions.pvConditions.isLCBullish ? "!conditions.pvConditions.isLCBullish &&" + "\n" : "") +
(!conditions.pvConditions.isLCHHBullish ? "!conditions.pvConditions.isLCHHBullish &&" + "\n" : "") +
(!conditions.pvConditions.isLCLLBullish ? "!conditions.pvConditions.isLCLLBullish &&" + "\n" : "") +
(!conditions.pvConditions.isLCSwitchedToBullish ? "!conditions.pvConditions.isLCSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isLCHHSwitchedToBullish ? "!conditions.pvConditions.isLCHHSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isLCLLSwitchedToBullish ? "!conditions.pvConditions.isLCLLSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isLCBearish ? "!conditions.pvConditions.isLCBearish &&" + "\n" : "") +
(!conditions.pvConditions.isLCHHBearish ? "!conditions.pvConditions.isLCHHBearish &&" + "\n" : "") +
(!conditions.pvConditions.isLCLLBearish ? "!conditions.pvConditions.isLCLLBearish &&" + "\n" : "") +
(!conditions.pvConditions.isLCSwitchedToBearish ? "!conditions.pvConditions.isLCSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isLCHHSwitchedToBearish ? "!conditions.pvConditions.isLCHHSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isLCLLSwitchedToBeraish ? "!conditions.pvConditions.isLCLLSwitchedToBeraish &&" + "\n" : "") +
(!conditions.pvConditions.isHCBullish ? "!conditions.pvConditions.isHCBullish &&" + "\n" : "") +
(!conditions.pvConditions.isHCHHBullish ? "!conditions.pvConditions.isHCHHBullish &&" + "\n" : "") +
(!conditions.pvConditions.isHCLLBullish ? "!conditions.pvConditions.isHCLLBullish &&" + "\n" : "") +
(!conditions.pvConditions.isHCSwitchedToBullish ? "!conditions.pvConditions.isHCSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isHCHHSwitchedToBullish ? "!conditions.pvConditions.isHCHHSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isHCLLSwitchedToBullish ? "!conditions.pvConditions.isHCLLSwitchedToBullish &&" + "\n" : "") +
(!conditions.pvConditions.isHCBearish ? "!conditions.pvConditions.isHCBearish &&" + "\n" : "") +
(!conditions.pvConditions.isHCHHBearish ? "!conditions.pvConditions.isHCHHBearish &&" + "\n" : "") +
(!conditions.pvConditions.isHCLLBearish ? "!conditions.pvConditions.isHCLLBearish &&" + "\n" : "") +
(!conditions.pvConditions.isHCSwitchedToBearish ? "!conditions.pvConditions.isHCSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isHCHHSwitchedToBearish ? "!conditions.pvConditions.isHCHHSwitchedToBearish &&" + "\n" : "") +
(!conditions.pvConditions.isHCLLSwitchedToBeraish ? "!conditions.pvConditions.isHCLLSwitchedToBeraish &&" + "\n" : "") +
"//" + "\n" +
"// XCHM ..." + "\n" +
"//" + "\n" +
(conditions.chmConditions.hasBullishPower ? "conditions.chmConditions.hasBullishPower &&" + "\n" : "") +
(conditions.chmConditions.hasBearishPower ? "conditions.chmConditions.hasBearishPower &&" + "\n" : "") +
(conditions.chmConditions.isBullishPowerUp ? "conditions.chmConditions.isBullishPowerUp &&" + "\n" : "") +
(conditions.chmConditions.isBearishPowerUp ? "conditions.chmConditions.isBearishPowerUp &&" + "\n" : "") +
(conditions.chmConditions.isBullishPowerIncreasing ? "conditions.chmConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(conditions.chmConditions.isBullishPowerDecreasing ? "conditions.chmConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(conditions.chmConditions.isBearishPowerIncreasing ? "conditions.chmConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(conditions.chmConditions.isBearishPowerDecreasing ? "conditions.chmConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(conditions.chmConditions.isFastOverSlow ? "conditions.chmConditions.isFastOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isFastUnderSlow ? "conditions.chmConditions.isFastUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isFastCrossedOverSlow ? "conditions.chmConditions.isFastCrossedOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isFastCrossedUnderSlow ? "conditions.chmConditions.isFastCrossedUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isClosedOverFast ? "conditions.chmConditions.isClosedOverFast &&" + "\n" : "") +
(conditions.chmConditions.isClosedUnderFast ? "conditions.chmConditions.isClosedUnderFast &&" + "\n" : "") +
(conditions.chmConditions.isCFastOverSlow ? "conditions.chmConditions.isCFastOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isCFastUnderSlow ? "conditions.chmConditions.isCFastUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isCFastCrossedOverSlow ? "conditions.chmConditions.isCFastCrossedOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isCFastCrossedUnderSlow ? "conditions.chmConditions.isCFastCrossedUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isClosedOverCFast ? "conditions.chmConditions.isClosedOverCFast &&" + "\n" : "") +
(conditions.chmConditions.isClosedUnderCFast ? "conditions.chmConditions.isClosedUnderCFast &&" + "\n" : "") +
(conditions.chmConditions.isSFastOverSlow ? "conditions.chmConditions.isSFastOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isSFastUnderSlow ? "conditions.chmConditions.isSFastUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isSFastCrossedOverSlow ? "conditions.chmConditions.isSFastCrossedOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isSFastCrossedUnderSlow ? "conditions.chmConditions.isSFastCrossedUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isClosedOverSFast ? "conditions.chmConditions.isClosedOverSFast &&" + "\n" : "") +
(conditions.chmConditions.isClosedUnderSFast ? "conditions.chmConditions.isClosedUnderSFast &&" + "\n" : "") +
(conditions.chmConditions.isMFastOverSlow ? "conditions.chmConditions.isMFastOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isMFastUnderSlow ? "conditions.chmConditions.isMFastUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isMFastCrossedOverSlow ? "conditions.chmConditions.isMFastCrossedOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isMFastCrossedUnderSlow ? "conditions.chmConditions.isMFastCrossedUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isClosedOverMFast ? "conditions.chmConditions.isClosedOverMFast &&" + "\n" : "") +
(conditions.chmConditions.isClosedUnderMFast ? "conditions.chmConditions.isClosedUnderMFast &&" + "\n" : "") +
(conditions.chmConditions.isLFastOverSlow ? "conditions.chmConditions.isLFastOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isLFastUnderSlow ? "conditions.chmConditions.isLFastUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isLFastCrossedOverSlow ? "conditions.chmConditions.isLFastCrossedOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isLFastCrossedUnderSlow ? "conditions.chmConditions.isLFastCrossedUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isClosedOverLFast ? "conditions.chmConditions.isClosedOverLFast &&" + "\n" : "") +
(conditions.chmConditions.isClosedUnderLFast ? "conditions.chmConditions.isClosedUnderLFast &&" + "\n" : "") +
(conditions.chmConditions.isHFastOverSlow ? "conditions.chmConditions.isHFastOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isHFastUnderSlow ? "conditions.chmConditions.isHFastUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isHFastCrossedOverSlow ? "conditions.chmConditions.isHFastCrossedOverSlow &&" + "\n" : "") +
(conditions.chmConditions.isHFastCrossedUnderSlow ? "conditions.chmConditions.isHFastCrossedUnderSlow &&" + "\n" : "") +
(conditions.chmConditions.isClosedOverHFast ? "conditions.chmConditions.isClosedOverHFast &&" + "\n" : "") +
(conditions.chmConditions.isClosedUnderHFast ? "conditions.chmConditions.isClosedUnderHFast &&" + "\n" : "") +
"//" + "\n" +
(!conditions.chmConditions.hasBullishPower ? "!conditions.chmConditions.hasBullishPower &&" + "\n" : "") +
(!conditions.chmConditions.hasBearishPower ? "!conditions.chmConditions.hasBearishPower &&" + "\n" : "") +
(!conditions.chmConditions.isBullishPowerUp ? "!conditions.chmConditions.isBullishPowerUp &&" + "\n" : "") +
(!conditions.chmConditions.isBearishPowerUp ? "!conditions.chmConditions.isBearishPowerUp &&" + "\n" : "") +
(!conditions.chmConditions.isBullishPowerIncreasing ? "!conditions.chmConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(!conditions.chmConditions.isBullishPowerDecreasing ? "!conditions.chmConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(!conditions.chmConditions.isBearishPowerIncreasing ? "!conditions.chmConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(!conditions.chmConditions.isBearishPowerDecreasing ? "!conditions.chmConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(!conditions.chmConditions.isFastOverSlow ? "!conditions.chmConditions.isFastOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isFastUnderSlow ? "!conditions.chmConditions.isFastUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isFastCrossedOverSlow ? "!conditions.chmConditions.isFastCrossedOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isFastCrossedUnderSlow ? "!conditions.chmConditions.isFastCrossedUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isClosedOverFast ? "!conditions.chmConditions.isClosedOverFast &&" + "\n" : "") +
(!conditions.chmConditions.isClosedUnderFast ? "!conditions.chmConditions.isClosedUnderFast &&" + "\n" : "") +
(!conditions.chmConditions.isCFastOverSlow ? "!conditions.chmConditions.isCFastOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isCFastUnderSlow ? "!conditions.chmConditions.isCFastUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isCFastCrossedOverSlow ? "!conditions.chmConditions.isCFastCrossedOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isCFastCrossedUnderSlow ? "!conditions.chmConditions.isCFastCrossedUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isClosedOverCFast ? "!conditions.chmConditions.isClosedOverCFast &&" + "\n" : "") +
(!conditions.chmConditions.isClosedUnderCFast ? "!conditions.chmConditions.isClosedUnderCFast &&" + "\n" : "") +
(!conditions.chmConditions.isSFastOverSlow ? "!conditions.chmConditions.isSFastOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isSFastUnderSlow ? "!conditions.chmConditions.isSFastUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isSFastCrossedOverSlow ? "!conditions.chmConditions.isSFastCrossedOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isSFastCrossedUnderSlow ? "!conditions.chmConditions.isSFastCrossedUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isClosedOverSFast ? "!conditions.chmConditions.isClosedOverSFast &&" + "\n" : "") +
(!conditions.chmConditions.isClosedUnderSFast ? "!conditions.chmConditions.isClosedUnderSFast &&" + "\n" : "") +
(!conditions.chmConditions.isMFastOverSlow ? "!conditions.chmConditions.isMFastOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isMFastUnderSlow ? "!conditions.chmConditions.isMFastUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isMFastCrossedOverSlow ? "!conditions.chmConditions.isMFastCrossedOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isMFastCrossedUnderSlow ? "!conditions.chmConditions.isMFastCrossedUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isClosedOverMFast ? "!conditions.chmConditions.isClosedOverMFast &&" + "\n" : "") +
(!conditions.chmConditions.isClosedUnderMFast ? "!conditions.chmConditions.isClosedUnderMFast &&" + "\n" : "") +
(!conditions.chmConditions.isLFastOverSlow ? "!conditions.chmConditions.isLFastOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isLFastUnderSlow ? "!conditions.chmConditions.isLFastUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isLFastCrossedOverSlow ? "!conditions.chmConditions.isLFastCrossedOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isLFastCrossedUnderSlow ? "!conditions.chmConditions.isLFastCrossedUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isClosedOverLFast ? "!conditions.chmConditions.isClosedOverLFast &&" + "\n" : "") +
(!conditions.chmConditions.isClosedUnderLFast ? "!conditions.chmConditions.isClosedUnderLFast &&" + "\n" : "") +
(!conditions.chmConditions.isHFastOverSlow ? "!conditions.chmConditions.isHFastOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isHFastUnderSlow ? "!conditions.chmConditions.isHFastUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isHFastCrossedOverSlow ? "!conditions.chmConditions.isHFastCrossedOverSlow &&" + "\n" : "") +
(!conditions.chmConditions.isHFastCrossedUnderSlow ? "!conditions.chmConditions.isHFastCrossedUnderSlow &&" + "\n" : "") +
(!conditions.chmConditions.isClosedOverHFast ? "!conditions.chmConditions.isClosedOverHFast &&" + "\n" : "") +
(!conditions.chmConditions.isClosedUnderHFast ? "!conditions.chmConditions.isClosedUnderHFast &&" + "\n" : "") +
"//" + "\n" +
"// XCHHK ..." + "\n" +
"//" + "\n" +
(conditions.chhkConditions.hasBullishPower ? "conditions.chhkConditions.hasBullishPower &&" + "\n" : "") +
(conditions.chhkConditions.hasBearishPower ? "conditions.chhkConditions.hasBearishPower &&" + "\n" : "") +
(conditions.chhkConditions.isBullishPowerUp ? "conditions.chhkConditions.isBullishPowerUp &&" + "\n" : "") +
(conditions.chhkConditions.isBearishPowerUp ? "conditions.chhkConditions.isBearishPowerUp &&" + "\n" : "") +
(conditions.chhkConditions.isBullishPowerIncreasing ? "conditions.chhkConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(conditions.chhkConditions.isBullishPowerDecreasing ? "conditions.chhkConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(conditions.chhkConditions.isBearishPowerIncreasing ? "conditions.chhkConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(conditions.chhkConditions.isBearishPowerDecreasing ? "conditions.chhkConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(conditions.chhkConditions.isCBullish ? "conditions.chhkConditions.isCBullish &&" + "\n" : "") +
(conditions.chhkConditions.isCSwitchedToBullish ? "conditions.chhkConditions.isCSwitchedToBullish &&" + "\n" : "") +
(conditions.chhkConditions.isCBearish ? "conditions.chhkConditions.isCBearish &&" + "\n" : "") +
(conditions.chhkConditions.isCSwitchedToBearish ? "conditions.chhkConditions.isCSwitchedToBearish &&" + "\n" : "") +
(conditions.chhkConditions.isCloseOverCHigh ? "conditions.chhkConditions.isCloseOverCHigh &&" + "\n" : "") +
(conditions.chhkConditions.isCloseUnderCLow ? "conditions.chhkConditions.isCloseUnderCLow &&" + "\n" : "") +
(conditions.chhkConditions.isSBullish ? "conditions.chhkConditions.isSBullish &&" + "\n" : "") +
(conditions.chhkConditions.isSSwitchedToBullish ? "conditions.chhkConditions.isSSwitchedToBullish &&" + "\n" : "") +
(conditions.chhkConditions.isSBearish ? "conditions.chhkConditions.isSBearish &&" + "\n" : "") +
(conditions.chhkConditions.isSSwitchedToBearish ? "conditions.chhkConditions.isSSwitchedToBearish &&" + "\n" : "") +
(conditions.chhkConditions.isCloseOverSHigh ? "conditions.chhkConditions.isCloseOverSHigh &&" + "\n" : "") +
(conditions.chhkConditions.isCloseUnderSLow ? "conditions.chhkConditions.isCloseUnderSLow &&" + "\n" : "") +
(conditions.chhkConditions.isMBullish ? "conditions.chhkConditions.isMBullish &&" + "\n" : "") +
(conditions.chhkConditions.isMSwitchedToBullish ? "conditions.chhkConditions.isMSwitchedToBullish &&" + "\n" : "") +
(conditions.chhkConditions.isMBearish ? "conditions.chhkConditions.isMBearish &&" + "\n" : "") +
(conditions.chhkConditions.isMSwitchedToBearish ? "conditions.chhkConditions.isMSwitchedToBearish &&" + "\n" : "") +
(conditions.chhkConditions.isCloseOverMHigh ? "conditions.chhkConditions.isCloseOverMHigh &&" + "\n" : "") +
(conditions.chhkConditions.isCloseUnderMLow ? "conditions.chhkConditions.isCloseUnderMLow &&" + "\n" : "") +
(conditions.chhkConditions.isLBullish ? "conditions.chhkConditions.isLBullish &&" + "\n" : "") +
(conditions.chhkConditions.isLSwitchedToBullish ? "conditions.chhkConditions.isLSwitchedToBullish &&" + "\n" : "") +
(conditions.chhkConditions.isLBearish ? "conditions.chhkConditions.isLBearish &&" + "\n" : "") +
(conditions.chhkConditions.isLSwitchedToBearish ? "conditions.chhkConditions.isLSwitchedToBearish &&" + "\n" : "") +
(conditions.chhkConditions.isCloseOverLHigh ? "conditions.chhkConditions.isCloseOverLHigh &&" + "\n" : "") +
(conditions.chhkConditions.isCloseUnderLLow ? "conditions.chhkConditions.isCloseUnderLLow &&" + "\n" : "") +
(conditions.chhkConditions.isHBullish ? "conditions.chhkConditions.isHBullish &&" + "\n" : "") +
(conditions.chhkConditions.isHSwitchedToBullish ? "conditions.chhkConditions.isHSwitchedToBullish &&" + "\n" : "") +
(conditions.chhkConditions.isHBearish ? "conditions.chhkConditions.isHBearish &&" + "\n" : "") +
(conditions.chhkConditions.isHSwitchedToBearish ? "conditions.chhkConditions.isHSwitchedToBearish &&" + "\n" : "") +
(conditions.chhkConditions.isCloseOverHHigh ? "conditions.chhkConditions.isCloseOverHHigh &&" + "\n" : "") +
(conditions.chhkConditions.isCloseUnderHLow ? "conditions.chhkConditions.isCloseUnderHLow &&" + "\n" : "") +
"//" + "\n" +
(!conditions.chhkConditions.hasBullishPower ? "!conditions.chhkConditions.hasBullishPower && " + "\n" : "") +
(!conditions.chhkConditions.hasBearishPower ? "!conditions.chhkConditions.hasBearishPower && " + "\n" : "") +
(!conditions.chhkConditions.isBullishPowerUp ? "!conditions.chhkConditions.isBullishPowerUp && " + "\n" : "") +
(!conditions.chhkConditions.isBearishPowerUp ? "!conditions.chhkConditions.isBearishPowerUp && " + "\n" : "") +
(!conditions.chhkConditions.isBullishPowerIncreasing ? "!conditions.chhkConditions.isBullishPowerIncreasing && " + "\n" : "") +
(!conditions.chhkConditions.isBullishPowerDecreasing ? "!conditions.chhkConditions.isBullishPowerDecreasing && " + "\n" : "") +
(!conditions.chhkConditions.isBearishPowerIncreasing ? "!conditions.chhkConditions.isBearishPowerIncreasing && " + "\n" : "") +
(!conditions.chhkConditions.isBearishPowerDecreasing ? "!conditions.chhkConditions.isBearishPowerDecreasing && " + "\n" : "") +
(!conditions.chhkConditions.isCBullish ? "!conditions.chhkConditions.isCBullish && " + "\n" : "") +
(!conditions.chhkConditions.isCSwitchedToBullish ? "!conditions.chhkConditions.isCSwitchedToBullish && " + "\n" : "") +
(!conditions.chhkConditions.isCBearish ? "!conditions.chhkConditions.isCBearish && " + "\n" : "") +
(!conditions.chhkConditions.isCSwitchedToBearish ? "!conditions.chhkConditions.isCSwitchedToBearish && " + "\n" : "") +
(!conditions.chhkConditions.isCloseOverCHigh ? "!conditions.chhkConditions.isCloseOverCHigh && " + "\n" : "") +
(!conditions.chhkConditions.isCloseUnderCLow ? "!conditions.chhkConditions.isCloseUnderCLow && " + "\n" : "") +
(!conditions.chhkConditions.isSBullish ? "!conditions.chhkConditions.isSBullish && " + "\n" : "") +
(!conditions.chhkConditions.isSSwitchedToBullish ? "!conditions.chhkConditions.isSSwitchedToBullish && " + "\n" : "") +
(!conditions.chhkConditions.isSBearish ? "!conditions.chhkConditions.isSBearish && " + "\n" : "") +
(!conditions.chhkConditions.isSSwitchedToBearish ? "!conditions.chhkConditions.isSSwitchedToBearish && " + "\n" : "") +
(!conditions.chhkConditions.isCloseOverSHigh ? "!conditions.chhkConditions.isCloseOverSHigh && " + "\n" : "") +
(!conditions.chhkConditions.isCloseUnderSLow ? "!conditions.chhkConditions.isCloseUnderSLow && " + "\n" : "") +
(!conditions.chhkConditions.isMBullish ? "!conditions.chhkConditions.isMBullish && " + "\n" : "") +
(!conditions.chhkConditions.isMSwitchedToBullish ? "!conditions.chhkConditions.isMSwitchedToBullish && " + "\n" : "") +
(!conditions.chhkConditions.isMBearish ? "!conditions.chhkConditions.isMBearish && " + "\n" : "") +
(!conditions.chhkConditions.isMSwitchedToBearish ? "!conditions.chhkConditions.isMSwitchedToBearish && " + "\n" : "") +
(!conditions.chhkConditions.isCloseOverMHigh ? "!conditions.chhkConditions.isCloseOverMHigh && " + "\n" : "") +
(!conditions.chhkConditions.isCloseUnderMLow ? "!conditions.chhkConditions.isCloseUnderMLow && " + "\n" : "") +
(!conditions.chhkConditions.isLBullish ? "!conditions.chhkConditions.isLBullish && " + "\n" : "") +
(!conditions.chhkConditions.isLSwitchedToBullish ? "!conditions.chhkConditions.isLSwitchedToBullish && " + "\n" : "") +
(!conditions.chhkConditions.isLBearish ? "!conditions.chhkConditions.isLBearish && " + "\n" : "") +
(!conditions.chhkConditions.isLSwitchedToBearish ? "!conditions.chhkConditions.isLSwitchedToBearish && " + "\n" : "") +
(!conditions.chhkConditions.isCloseOverLHigh ? "!conditions.chhkConditions.isCloseOverLHigh && " + "\n" : "") +
(!conditions.chhkConditions.isCloseUnderLLow ? "!conditions.chhkConditions.isCloseUnderLLow && " + "\n" : "") +
(!conditions.chhkConditions.isHBullish ? "!conditions.chhkConditions.isHBullish && " + "\n" : "") +
(!conditions.chhkConditions.isHSwitchedToBullish ? "!conditions.chhkConditions.isHSwitchedToBullish && " + "\n" : "") +
(!conditions.chhkConditions.isHBearish ? "!conditions.chhkConditions.isHBearish && " + "\n" : "") +
(!conditions.chhkConditions.isHSwitchedToBearish ? "!conditions.chhkConditions.isHSwitchedToBearish && " + "\n" : "") +
(!conditions.chhkConditions.isCloseOverHHigh ? "!conditions.chhkConditions.isCloseOverHHigh && " + "\n" : "") +
(!conditions.chhkConditions.isCloseUnderHLow ? "!conditions.chhkConditions.isCloseUnderHLow && " + "\n" : "") +
"//" + "\n" +
"// XCHTD ..." + "\n" +
"//" + "\n" +
(conditions.chtdConditions.hasBullishPower ? "conditions.chtdConditions.hasBullishPower &&" + "\n" : "") +
(conditions.chtdConditions.hasBearishPower ? "conditions.chtdConditions.hasBearishPower &&" + "\n" : "") +
(conditions.chtdConditions.isBullishPowerUp ? "conditions.chtdConditions.isBullishPowerUp &&" + "\n" : "") +
(conditions.chtdConditions.isBearishPowerUp ? "conditions.chtdConditions.isBearishPowerUp &&" + "\n" : "") +
(conditions.chtdConditions.isBullishPowerIncreasing ? "conditions.chtdConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(conditions.chtdConditions.isBullishPowerDecreasing ? "conditions.chtdConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(conditions.chtdConditions.isBearishPowerIncreasing ? "conditions.chtdConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(conditions.chtdConditions.isBearishPowerDecreasing ? "conditions.chtdConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(conditions.chtdConditions.isCBullish ? "conditions.chtdConditions.isCBullish &&" + "\n" : "") +
(conditions.chtdConditions.isCBearish ? "conditions.chtdConditions.isCBearish &&" + "\n" : "") +
(conditions.chtdConditions.isCSwitchedToBullish ? "conditions.chtdConditions.isCSwitchedToBullish &&" + "\n" : "") +
(conditions.chtdConditions.isCSwitchedToBearish ? "conditions.chtdConditions.isCSwitchedToBearish &&" + "\n" : "") +
(conditions.chtdConditions.isSBullish ? "conditions.chtdConditions.isSBullish &&" + "\n" : "") +
(conditions.chtdConditions.isSBearish ? "conditions.chtdConditions.isSBearish &&" + "\n" : "") +
(conditions.chtdConditions.isSSwitchedToBullish ? "conditions.chtdConditions.isSSwitchedToBullish &&" + "\n" : "") +
(conditions.chtdConditions.isSSwitchedToBearish ? "conditions.chtdConditions.isSSwitchedToBearish &&" + "\n" : "") +
(conditions.chtdConditions.isMBullish ? "conditions.chtdConditions.isMBullish &&" + "\n" : "") +
(conditions.chtdConditions.isMBearish ? "conditions.chtdConditions.isMBearish &&" + "\n" : "") +
(conditions.chtdConditions.isMSwitchedToBullish ? "conditions.chtdConditions.isMSwitchedToBullish &&" + "\n" : "") +
(conditions.chtdConditions.isMSwitchedToBearish ? "conditions.chtdConditions.isMSwitchedToBearish &&" + "\n" : "") +
(conditions.chtdConditions.isLBullish ? "conditions.chtdConditions.isLBullish &&" + "\n" : "") +
(conditions.chtdConditions.isLBearish ? "conditions.chtdConditions.isLBearish &&" + "\n" : "") +
(conditions.chtdConditions.isLSwitchedToBullish ? "conditions.chtdConditions.isLSwitchedToBullish &&" + "\n" : "") +
(conditions.chtdConditions.isLSwitchedToBearish ? "conditions.chtdConditions.isLSwitchedToBearish &&" + "\n" : "") +
(conditions.chtdConditions.isHBullish ? "conditions.chtdConditions.isHBullish &&" + "\n" : "") +
(conditions.chtdConditions.isHBearish ? "conditions.chtdConditions.isHBearish &&" + "\n" : "") +
(conditions.chtdConditions.isHSwitchedToBullish ? "conditions.chtdConditions.isHSwitchedToBullish &&" + "\n" : "") +
(conditions.chtdConditions.isHSwitchedToBearish ? "conditions.chtdConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
(!conditions.chtdConditions.hasBullishPower ? "!conditions.chtdConditions.hasBullishPower &&" + "\n" : "") +
(!conditions.chtdConditions.hasBearishPower ? "!conditions.chtdConditions.hasBearishPower &&" + "\n" : "") +
(!conditions.chtdConditions.isBullishPowerUp ? "!conditions.chtdConditions.isBullishPowerUp &&" + "\n" : "") +
(!conditions.chtdConditions.isBearishPowerUp ? "!conditions.chtdConditions.isBearishPowerUp &&" + "\n" : "") +
(!conditions.chtdConditions.isBullishPowerIncreasing ? "!conditions.chtdConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(!conditions.chtdConditions.isBullishPowerDecreasing ? "!conditions.chtdConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(!conditions.chtdConditions.isBearishPowerIncreasing ? "!conditions.chtdConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(!conditions.chtdConditions.isBearishPowerDecreasing ? "!conditions.chtdConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(!conditions.chtdConditions.isCBullish ? "!conditions.chtdConditions.isCBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isCBearish ? "!conditions.chtdConditions.isCBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isCSwitchedToBullish ? "!conditions.chtdConditions.isCSwitchedToBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isCSwitchedToBearish ? "!conditions.chtdConditions.isCSwitchedToBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isSBullish ? "!conditions.chtdConditions.isSBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isSBearish ? "!conditions.chtdConditions.isSBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isSSwitchedToBullish ? "!conditions.chtdConditions.isSSwitchedToBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isSSwitchedToBearish ? "!conditions.chtdConditions.isSSwitchedToBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isMBullish ? "!conditions.chtdConditions.isMBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isMBearish ? "!conditions.chtdConditions.isMBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isMSwitchedToBullish ? "!conditions.chtdConditions.isMSwitchedToBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isMSwitchedToBearish ? "!conditions.chtdConditions.isMSwitchedToBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isLBullish ? "!conditions.chtdConditions.isLBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isLBearish ? "!conditions.chtdConditions.isLBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isLSwitchedToBullish ? "!conditions.chtdConditions.isLSwitchedToBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isLSwitchedToBearish ? "!conditions.chtdConditions.isLSwitchedToBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isHBullish ? "!conditions.chtdConditions.isHBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isHBearish ? "!conditions.chtdConditions.isHBearish &&" + "\n" : "") +
(!conditions.chtdConditions.isHSwitchedToBullish ? "!conditions.chtdConditions.isHSwitchedToBullish &&" + "\n" : "") +
(!conditions.chtdConditions.isHSwitchedToBearish ? "!conditions.chtdConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
"// XCHCHE ..." + "\n" +
"//" + "\n" +
(conditions.chcheConditions.hasBullishPower ? "conditions.chcheConditions.hasBullishPower &&" + "\n" : "") +
(conditions.chcheConditions.hasBearishPower ? "conditions.chcheConditions.hasBearishPower &&" + "\n" : "") +
(conditions.chcheConditions.isBullishPowerUp ? "conditions.chcheConditions.isBullishPowerUp &&" + "\n" : "") +
(conditions.chcheConditions.isBearishPowerUp ? "conditions.chcheConditions.isBearishPowerUp &&" + "\n" : "") +
(conditions.chcheConditions.isBullishPowerIncreasing ? "conditions.chcheConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(conditions.chcheConditions.isBullishPowerDecreasing ? "conditions.chcheConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(conditions.chcheConditions.isBearishPowerIncreasing ? "conditions.chcheConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(conditions.chcheConditions.isBearishPowerDecreasing ? "conditions.chcheConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(conditions.chcheConditions.isCBullish ? "conditions.chcheConditions.isCBullish &&" + "\n" : "") +
(conditions.chcheConditions.isCBearish ? "conditions.chcheConditions.isCBearish &&" + "\n" : "") +
(conditions.chcheConditions.isCStrongBullish ? "conditions.chcheConditions.isCStrongBullish &&" + "\n" : "") +
(conditions.chcheConditions.isCStrongBearish ? "conditions.chcheConditions.isCStrongBearish &&" + "\n" : "") +
(conditions.chcheConditions.isCSwitchedToBullish ? "conditions.chcheConditions.isCSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isCSwitchedToBearish ? "conditions.chcheConditions.isCSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isCStrongSwitchedToBullish ? "conditions.chcheConditions.isCStrongSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isCStrongSwitchedToBearish ? "conditions.chcheConditions.isCStrongSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isSBullish ? "conditions.chcheConditions.isSBullish &&" + "\n" : "") +
(conditions.chcheConditions.isSBearish ? "conditions.chcheConditions.isSBearish &&" + "\n" : "") +
(conditions.chcheConditions.isSStrongBullish ? "conditions.chcheConditions.isSStrongBullish &&" + "\n" : "") +
(conditions.chcheConditions.isSStrongBearish ? "conditions.chcheConditions.isSStrongBearish &&" + "\n" : "") +
(conditions.chcheConditions.isSSwitchedToBullish ? "conditions.chcheConditions.isSSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isSSwitchedToBearish ? "conditions.chcheConditions.isSSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isSStrongSwitchedToBullish ? "conditions.chcheConditions.isSStrongSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isSStrongSwitchedToBearish ? "conditions.chcheConditions.isSStrongSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isMBullish ? "conditions.chcheConditions.isMBullish &&" + "\n" : "") +
(conditions.chcheConditions.isMBearish ? "conditions.chcheConditions.isMBearish &&" + "\n" : "") +
(conditions.chcheConditions.isMStrongBullish ? "conditions.chcheConditions.isMStrongBullish &&" + "\n" : "") +
(conditions.chcheConditions.isMStrongBearish ? "conditions.chcheConditions.isMStrongBearish &&" + "\n" : "") +
(conditions.chcheConditions.isMSwitchedToBullish ? "conditions.chcheConditions.isMSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isMSwitchedToBearish ? "conditions.chcheConditions.isMSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isMStrongSwitchedToBullish ? "conditions.chcheConditions.isMStrongSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isMStrongSwitchedToBearish ? "conditions.chcheConditions.isMStrongSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isLBullish ? "conditions.chcheConditions.isLBullish &&" + "\n" : "") +
(conditions.chcheConditions.isLBearish ? "conditions.chcheConditions.isLBearish &&" + "\n" : "") +
(conditions.chcheConditions.isLStrongBullish ? "conditions.chcheConditions.isLStrongBullish &&" + "\n" : "") +
(conditions.chcheConditions.isLStrongBearish ? "conditions.chcheConditions.isLStrongBearish &&" + "\n" : "") +
(conditions.chcheConditions.isLSwitchedToBullish ? "conditions.chcheConditions.isLSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isLSwitchedToBearish ? "conditions.chcheConditions.isLSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isLStrongSwitchedToBullish ? "conditions.chcheConditions.isLStrongSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isLStrongSwitchedToBearish ? "conditions.chcheConditions.isLStrongSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isHBullish ? "conditions.chcheConditions.isHBullish &&" + "\n" : "") +
(conditions.chcheConditions.isHBearish ? "conditions.chcheConditions.isHBearish &&" + "\n" : "") +
(conditions.chcheConditions.isHStrongBullish ? "conditions.chcheConditions.isHStrongBullish &&" + "\n" : "") +
(conditions.chcheConditions.isHStrongBearish ? "conditions.chcheConditions.isHStrongBearish &&" + "\n" : "") +
(conditions.chcheConditions.isHSwitchedToBullish ? "conditions.chcheConditions.isHSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isHSwitchedToBearish ? "conditions.chcheConditions.isHSwitchedToBearish &&" + "\n" : "") +
(conditions.chcheConditions.isHStrongSwitchedToBullish ? "conditions.chcheConditions.isHStrongSwitchedToBullish &&" + "\n" : "") +
(conditions.chcheConditions.isHStrongSwitchedToBearish ? "conditions.chcheConditions.isHStrongSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
(!conditions.chcheConditions.hasBullishPower ? "!conditions.chcheConditions.hasBullishPower &&" + "\n" : "") +
(!conditions.chcheConditions.hasBearishPower ? "!conditions.chcheConditions.hasBearishPower &&" + "\n" : "") +
(!conditions.chcheConditions.isBullishPowerUp ? "!conditions.chcheConditions.isBullishPowerUp &&" + "\n" : "") +
(!conditions.chcheConditions.isBearishPowerUp ? "!conditions.chcheConditions.isBearishPowerUp &&" + "\n" : "") +
(!conditions.chcheConditions.isBullishPowerIncreasing ? "!conditions.chcheConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(!conditions.chcheConditions.isBullishPowerDecreasing ? "!conditions.chcheConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(!conditions.chcheConditions.isBearishPowerIncreasing ? "!conditions.chcheConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(!conditions.chcheConditions.isBearishPowerDecreasing ? "!conditions.chcheConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(!conditions.chcheConditions.isCBullish ? "!conditions.chcheConditions.isCBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isCBearish ? "!conditions.chcheConditions.isCBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isCStrongBullish ? "!conditions.chcheConditions.isCStrongBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isCStrongBearish ? "!conditions.chcheConditions.isCStrongBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isCSwitchedToBullish ? "!conditions.chcheConditions.isCSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isCSwitchedToBearish ? "!conditions.chcheConditions.isCSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isCStrongSwitchedToBullish ? "!conditions.chcheConditions.isCStrongSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isCStrongSwitchedToBearish ? "!conditions.chcheConditions.isCStrongSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isSBullish ? "!conditions.chcheConditions.isSBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isSBearish ? "!conditions.chcheConditions.isSBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isSStrongBullish ? "!conditions.chcheConditions.isSStrongBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isSStrongBearish ? "!conditions.chcheConditions.isSStrongBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isSSwitchedToBullish ? "!conditions.chcheConditions.isSSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isSSwitchedToBearish ? "!conditions.chcheConditions.isSSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isSStrongSwitchedToBullish ? "!conditions.chcheConditions.isSStrongSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isSStrongSwitchedToBearish ? "!conditions.chcheConditions.isSStrongSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isMBullish ? "!conditions.chcheConditions.isMBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isMBearish ? "!conditions.chcheConditions.isMBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isMStrongBullish ? "!conditions.chcheConditions.isMStrongBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isMStrongBearish ? "!conditions.chcheConditions.isMStrongBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isMSwitchedToBullish ? "!conditions.chcheConditions.isMSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isMSwitchedToBearish ? "!conditions.chcheConditions.isMSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isMStrongSwitchedToBullish ? "!conditions.chcheConditions.isMStrongSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isMStrongSwitchedToBearish ? "!conditions.chcheConditions.isMStrongSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isLBullish ? "!conditions.chcheConditions.isLBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isLBearish ? "!conditions.chcheConditions.isLBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isLStrongBullish ? "!conditions.chcheConditions.isLStrongBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isLStrongBearish ? "!conditions.chcheConditions.isLStrongBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isLSwitchedToBullish ? "!conditions.chcheConditions.isLSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isLSwitchedToBearish ? "!conditions.chcheConditions.isLSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isLStrongSwitchedToBullish ? "!conditions.chcheConditions.isLStrongSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isLStrongSwitchedToBearish ? "!conditions.chcheConditions.isLStrongSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isHBullish ? "!conditions.chcheConditions.isHBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isHBearish ? "!conditions.chcheConditions.isHBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isHStrongBullish ? "!conditions.chcheConditions.isHStrongBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isHStrongBearish ? "!conditions.chcheConditions.isHStrongBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isHSwitchedToBullish ? "!conditions.chcheConditions.isHSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isHSwitchedToBearish ? "!conditions.chcheConditions.isHSwitchedToBearish &&" + "\n" : "") +
(!conditions.chcheConditions.isHStrongSwitchedToBullish ? "!conditions.chcheConditions.isHStrongSwitchedToBullish &&" + "\n" : "") +
(!conditions.chcheConditions.isHStrongSwitchedToBearish ? "!conditions.chcheConditions.isHStrongSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
"// XCHSTR ..." + "\n" +
"//" + "\n" +
(conditions.chstrConditions.hasBullishPower ? "conditions.chstrConditions.hasBullishPower &&" + "\n" : "") +
(conditions.chstrConditions.hasBearishPower ? "conditions.chstrConditions.hasBearishPower &&" + "\n" : "") +
(conditions.chstrConditions.isBullishPowerUp ? "conditions.chstrConditions.isBullishPowerUp &&" + "\n" : "") +
(conditions.chstrConditions.isBearishPowerUp ? "conditions.chstrConditions.isBearishPowerUp &&" + "\n" : "") +
(conditions.chstrConditions.isBullishPowerIncreasing ? "conditions.chstrConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(conditions.chstrConditions.isBullishPowerDecreasing ? "conditions.chstrConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(conditions.chstrConditions.isBearishPowerIncreasing ? "conditions.chstrConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(conditions.chstrConditions.isBearishPowerDecreasing ? "conditions.chstrConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(conditions.chstrConditions.isCBullish ? "conditions.chstrConditions.isCBullish &&" + "\n" : "") +
(conditions.chstrConditions.isCBearish ? "conditions.chstrConditions.isCBearish &&" + "\n" : "") +
(conditions.chstrConditions.isCSwitchedToBullish ? "conditions.chstrConditions.isCSwitchedToBullish &&" + "\n" : "") +
(conditions.chstrConditions.isCSwitchedToBearish ? "conditions.chstrConditions.isCSwitchedToBearish &&" + "\n" : "") +
(conditions.chstrConditions.isSBullish ? "conditions.chstrConditions.isSBullish &&" + "\n" : "") +
(conditions.chstrConditions.isSBearish ? "conditions.chstrConditions.isSBearish &&" + "\n" : "") +
(conditions.chstrConditions.isSSwitchedToBullish ? "conditions.chstrConditions.isSSwitchedToBullish &&" + "\n" : "") +
(conditions.chstrConditions.isSSwitchedToBearish ? "conditions.chstrConditions.isSSwitchedToBearish &&" + "\n" : "") +
(conditions.chstrConditions.isMBullish ? "conditions.chstrConditions.isMBullish &&" + "\n" : "") +
(conditions.chstrConditions.isMBearish ? "conditions.chstrConditions.isMBearish &&" + "\n" : "") +
(conditions.chstrConditions.isMSwitchedToBullish ? "conditions.chstrConditions.isMSwitchedToBullish &&" + "\n" : "") +
(conditions.chstrConditions.isMSwitchedToBearish ? "conditions.chstrConditions.isMSwitchedToBearish &&" + "\n" : "") +
(conditions.chstrConditions.isLBullish ? "conditions.chstrConditions.isLBullish &&" + "\n" : "") +
(conditions.chstrConditions.isLBearish ? "conditions.chstrConditions.isLBearish &&" + "\n" : "") +
(conditions.chstrConditions.isLSwitchedToBullish ? "conditions.chstrConditions.isLSwitchedToBullish &&" + "\n" : "") +
(conditions.chstrConditions.isLSwitchedToBearish ? "conditions.chstrConditions.isLSwitchedToBearish &&" + "\n" : "") +
(conditions.chstrConditions.isHBullish ? "conditions.chstrConditions.isHBullish &&" + "\n" : "") +
(conditions.chstrConditions.isHBearish ? "conditions.chstrConditions.isHBearish &&" + "\n" : "") +
(conditions.chstrConditions.isHSwitchedToBullish ? "conditions.chstrConditions.isHSwitchedToBullish &&" + "\n" : "") +
(conditions.chstrConditions.isHSwitchedToBearish ? "conditions.chstrConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
(!conditions.chstrConditions.hasBullishPower ? "!conditions.chstrConditions.hasBullishPower &&" + "\n" : "") +
(!conditions.chstrConditions.hasBearishPower ? "!conditions.chstrConditions.hasBearishPower &&" + "\n" : "") +
(!conditions.chstrConditions.isBullishPowerUp ? "!conditions.chstrConditions.isBullishPowerUp &&" + "\n" : "") +
(!conditions.chstrConditions.isBearishPowerUp ? "!conditions.chstrConditions.isBearishPowerUp &&" + "\n" : "") +
(!conditions.chstrConditions.isBullishPowerIncreasing ? "!conditions.chstrConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(!conditions.chstrConditions.isBullishPowerDecreasing ? "!conditions.chstrConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(!conditions.chstrConditions.isBearishPowerIncreasing ? "!conditions.chstrConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(!conditions.chstrConditions.isBearishPowerDecreasing ? "!conditions.chstrConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(!conditions.chstrConditions.isCBullish ? "!conditions.chstrConditions.isCBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isCBearish ? "!conditions.chstrConditions.isCBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isCSwitchedToBullish ? "!conditions.chstrConditions.isCSwitchedToBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isCSwitchedToBearish ? "!conditions.chstrConditions.isCSwitchedToBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isSBullish ? "!conditions.chstrConditions.isSBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isSBearish ? "!conditions.chstrConditions.isSBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isSSwitchedToBullish ? "!conditions.chstrConditions.isSSwitchedToBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isSSwitchedToBearish ? "!conditions.chstrConditions.isSSwitchedToBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isMBullish ? "!conditions.chstrConditions.isMBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isMBearish ? "!conditions.chstrConditions.isMBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isMSwitchedToBullish ? "!conditions.chstrConditions.isMSwitchedToBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isMSwitchedToBearish ? "!conditions.chstrConditions.isMSwitchedToBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isLBullish ? "!conditions.chstrConditions.isLBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isLBearish ? "!conditions.chstrConditions.isLBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isLSwitchedToBullish ? "!conditions.chstrConditions.isLSwitchedToBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isLSwitchedToBearish ? "!conditions.chstrConditions.isLSwitchedToBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isHBullish ? "!conditions.chstrConditions.isHBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isHBearish ? "!conditions.chstrConditions.isHBearish &&" + "\n" : "") +
(!conditions.chstrConditions.isHSwitchedToBullish ? "!conditions.chstrConditions.isHSwitchedToBullish &&" + "\n" : "") +
(!conditions.chstrConditions.isHSwitchedToBearish ? "!conditions.chstrConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
"// XCHVLM ..." + "\n" +
"//" + "\n" +
(conditions.chvlmConditions.hasBullishPower ? "conditions.chvlmConditions.hasBullishPower &&" + "\n" : "") +
(conditions.chvlmConditions.hasBearishPower ? "conditions.chvlmConditions.hasBearishPower &&" + "\n" : "") +
(conditions.chvlmConditions.isBullishPowerUp ? "conditions.chvlmConditions.isBullishPowerUp &&" + "\n" : "") +
(conditions.chvlmConditions.isBearishPowerUp ? "conditions.chvlmConditions.isBearishPowerUp &&" + "\n" : "") +
(conditions.chvlmConditions.isBullishPowerIncreasing ? "conditions.chvlmConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(conditions.chvlmConditions.isBullishPowerDecreasing ? "conditions.chvlmConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(conditions.chvlmConditions.isBearishPowerIncreasing ? "conditions.chvlmConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(conditions.chvlmConditions.isBearishPowerDecreasing ? "conditions.chvlmConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(conditions.chvlmConditions.isCBullish ? "conditions.chvlmConditions.isCBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isCBearish ? "conditions.chvlmConditions.isCBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isCSwitchedToBullish ? "conditions.chvlmConditions.isCSwitchedToBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isCSwitchedToBearish ? "conditions.chvlmConditions.isCSwitchedToBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isSBullish ? "conditions.chvlmConditions.isSBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isSBearish ? "conditions.chvlmConditions.isSBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isSSwitchedToBullish ? "conditions.chvlmConditions.isSSwitchedToBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isSSwitchedToBearish ? "conditions.chvlmConditions.isSSwitchedToBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isMBullish ? "conditions.chvlmConditions.isMBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isMBearish ? "conditions.chvlmConditions.isMBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isMSwitchedToBullish ? "conditions.chvlmConditions.isMSwitchedToBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isMSwitchedToBearish ? "conditions.chvlmConditions.isMSwitchedToBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isLBullish ? "conditions.chvlmConditions.isLBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isLBearish ? "conditions.chvlmConditions.isLBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isLSwitchedToBullish ? "conditions.chvlmConditions.isLSwitchedToBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isLSwitchedToBearish ? "conditions.chvlmConditions.isLSwitchedToBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isHBullish ? "conditions.chvlmConditions.isHBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isHBearish ? "conditions.chvlmConditions.isHBearish &&" + "\n" : "") +
(conditions.chvlmConditions.isHSwitchedToBullish ? "conditions.chvlmConditions.isHSwitchedToBullish &&" + "\n" : "") +
(conditions.chvlmConditions.isHSwitchedToBearish ? "conditions.chvlmConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
(!conditions.chvlmConditions.hasBullishPower ? "!conditions.chvlmConditions.hasBullishPower &&" + "\n" : "") +
(!conditions.chvlmConditions.hasBearishPower ? "!conditions.chvlmConditions.hasBearishPower &&" + "\n" : "") +
(!conditions.chvlmConditions.isBullishPowerUp ? "!conditions.chvlmConditions.isBullishPowerUp &&" + "\n" : "") +
(!conditions.chvlmConditions.isBearishPowerUp ? "!conditions.chvlmConditions.isBearishPowerUp &&" + "\n" : "") +
(!conditions.chvlmConditions.isBullishPowerIncreasing ? "!conditions.chvlmConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(!conditions.chvlmConditions.isBullishPowerDecreasing ? "!conditions.chvlmConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(!conditions.chvlmConditions.isBearishPowerIncreasing ? "!conditions.chvlmConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(!conditions.chvlmConditions.isBearishPowerDecreasing ? "!conditions.chvlmConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(!conditions.chvlmConditions.isCBullish ? "!conditions.chvlmConditions.isCBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isCBearish ? "!conditions.chvlmConditions.isCBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isCSwitchedToBullish ? "!conditions.chvlmConditions.isCSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isCSwitchedToBearish ? "!conditions.chvlmConditions.isCSwitchedToBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isSBullish ? "!conditions.chvlmConditions.isSBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isSBearish ? "!conditions.chvlmConditions.isSBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isSSwitchedToBullish ? "!conditions.chvlmConditions.isSSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isSSwitchedToBearish ? "!conditions.chvlmConditions.isSSwitchedToBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isMBullish ? "!conditions.chvlmConditions.isMBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isMBearish ? "!conditions.chvlmConditions.isMBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isMSwitchedToBullish ? "!conditions.chvlmConditions.isMSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isMSwitchedToBearish ? "!conditions.chvlmConditions.isMSwitchedToBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isLBullish ? "!conditions.chvlmConditions.isLBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isLBearish ? "!conditions.chvlmConditions.isLBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isLSwitchedToBullish ? "!conditions.chvlmConditions.isLSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isLSwitchedToBearish ? "!conditions.chvlmConditions.isLSwitchedToBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isHBullish ? "!conditions.chvlmConditions.isHBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isHBearish ? "!conditions.chvlmConditions.isHBearish &&" + "\n" : "") +
(!conditions.chvlmConditions.isHSwitchedToBullish ? "!conditions.chvlmConditions.isHSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvlmConditions.isHSwitchedToBearish ? "!conditions.chvlmConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
"// XCHVWAP ..." + "\n" +
"//" + "\n" +
(conditions.chvwapConditions.hasBullishPower ? "conditions.chvwapConditions.hasBullishPower &&" + "\n" : "") +
(conditions.chvwapConditions.hasBearishPower ? "conditions.chvwapConditions.hasBearishPower &&" + "\n" : "") +
(conditions.chvwapConditions.isBullishPowerUp ? "conditions.chvwapConditions.isBullishPowerUp &&" + "\n" : "") +
(conditions.chvwapConditions.isBearishPowerUp ? "conditions.chvwapConditions.isBearishPowerUp &&" + "\n" : "") +
(conditions.chvwapConditions.isBullishPowerIncreasing ? "conditions.chvwapConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(conditions.chvwapConditions.isBullishPowerDecreasing ? "conditions.chvwapConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(conditions.chvwapConditions.isBearishPowerIncreasing ? "conditions.chvwapConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(conditions.chvwapConditions.isBearishPowerDecreasing ? "conditions.chvwapConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(conditions.chvwapConditions.isSBullish ? "conditions.chvwapConditions.isSBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isSBearish ? "conditions.chvwapConditions.isSBearish &&" + "\n" : "") +
(conditions.chvwapConditions.isSSwitchedToBullish ? "conditions.chvwapConditions.isSSwitchedToBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isSSwitchedToBearish ? "conditions.chvwapConditions.isSSwitchedToBearish &&" + "\n" : "") +
(conditions.chvwapConditions.isMBullish ? "conditions.chvwapConditions.isMBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isMBearish ? "conditions.chvwapConditions.isMBearish &&" + "\n" : "") +
(conditions.chvwapConditions.isMSwitchedToBullish ? "conditions.chvwapConditions.isMSwitchedToBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isMSwitchedToBearish ? "conditions.chvwapConditions.isMSwitchedToBearish &&" + "\n" : "") +
(conditions.chvwapConditions.isLBullish ? "conditions.chvwapConditions.isLBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isLBearish ? "conditions.chvwapConditions.isLBearish &&" + "\n" : "") +
(conditions.chvwapConditions.isLSwitchedToBullish ? "conditions.chvwapConditions.isLSwitchedToBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isLSwitchedToBearish ? "conditions.chvwapConditions.isLSwitchedToBearish &&" + "\n" : "") +
(conditions.chvwapConditions.isHBullish ? "conditions.chvwapConditions.isHBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isHBearish ? "conditions.chvwapConditions.isHBearish &&" + "\n" : "") +
(conditions.chvwapConditions.isHSwitchedToBullish ? "conditions.chvwapConditions.isHSwitchedToBullish &&" + "\n" : "") +
(conditions.chvwapConditions.isHSwitchedToBearish ? "conditions.chvwapConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
(!conditions.chvwapConditions.hasBullishPower ? "!conditions.chvwapConditions.hasBullishPower &&" + "\n" : "") +
(!conditions.chvwapConditions.hasBearishPower ? "!conditions.chvwapConditions.hasBearishPower &&" + "\n" : "") +
(!conditions.chvwapConditions.isBullishPowerUp ? "!conditions.chvwapConditions.isBullishPowerUp &&" + "\n" : "") +
(!conditions.chvwapConditions.isBearishPowerUp ? "!conditions.chvwapConditions.isBearishPowerUp &&" + "\n" : "") +
(!conditions.chvwapConditions.isBullishPowerIncreasing ? "!conditions.chvwapConditions.isBullishPowerIncreasing &&" + "\n" : "") +
(!conditions.chvwapConditions.isBullishPowerDecreasing ? "!conditions.chvwapConditions.isBullishPowerDecreasing &&" + "\n" : "") +
(!conditions.chvwapConditions.isBearishPowerIncreasing ? "!conditions.chvwapConditions.isBearishPowerIncreasing &&" + "\n" : "") +
(!conditions.chvwapConditions.isBearishPowerDecreasing ? "!conditions.chvwapConditions.isBearishPowerDecreasing &&" + "\n" : "") +
(!conditions.chvwapConditions.isSBullish ? "!conditions.chvwapConditions.isSBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isSBearish ? "!conditions.chvwapConditions.isSBearish &&" + "\n" : "") +
(!conditions.chvwapConditions.isSSwitchedToBullish ? "!conditions.chvwapConditions.isSSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isSSwitchedToBearish ? "!conditions.chvwapConditions.isSSwitchedToBearish &&" + "\n" : "") +
(!conditions.chvwapConditions.isMBullish ? "!conditions.chvwapConditions.isMBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isMBearish ? "!conditions.chvwapConditions.isMBearish &&" + "\n" : "") +
(!conditions.chvwapConditions.isMSwitchedToBullish ? "!conditions.chvwapConditions.isMSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isMSwitchedToBearish ? "!conditions.chvwapConditions.isMSwitchedToBearish &&" + "\n" : "") +
(!conditions.chvwapConditions.isLBullish ? "!conditions.chvwapConditions.isLBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isLBearish ? "!conditions.chvwapConditions.isLBearish &&" + "\n" : "") +
(!conditions.chvwapConditions.isLSwitchedToBullish ? "!conditions.chvwapConditions.isLSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isLSwitchedToBearish ? "!conditions.chvwapConditions.isLSwitchedToBearish &&" + "\n" : "") +
(!conditions.chvwapConditions.isHBullish ? "!conditions.chvwapConditions.isHBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isHBearish ? "!conditions.chvwapConditions.isHBearish &&" + "\n" : "") +
(!conditions.chvwapConditions.isHSwitchedToBullish ? "!conditions.chvwapConditions.isHSwitchedToBullish &&" + "\n" : "") +
(!conditions.chvwapConditions.isHSwitchedToBearish ? "!conditions.chvwapConditions.isHSwitchedToBearish &&" + "\n" : "") +
"//" + "\n" +
")";
//
return result;
}
//
bool IsFiltered(
XSignal &signal, // Provided Signal
XCHStrategyConditions &conditions // Market Conditions
)
{
//
bool result = false;
//
// Validate Args ...
if (!signal.IsValid() || !conditions.IsValid())
{
//
result = true;
return result;
}
//
bool isLong = IsLong(signal.type);
//
result =
//
isLong
? IsLongFiltered(conditions)
: IsShortFiltered(conditions)
//
;
//
return result;
}
//
// Filter Long Signals ...
bool IsLongFiltered(XCHStrategyConditions &conditions)
{
//
bool result = false;
//
result =
//
_eurusdLongParser.IsFiltered(conditions)
//
||
//
_gbpusdLongParser.IsFiltered(conditions)
//
;
//
return result;
}
//
// Filter Short Signals ...
bool IsShortFiltered(XCHStrategyConditions &conditions)
{
//
bool result = false;
//
result =
//
_eurusdShortParser.IsFiltered(conditions)
//
||
//
_gbpusdShortParser.IsFiltered(conditions)
//
;
//
return result;
}
};
//
Binary file not shown.
File diff suppressed because it is too large Load Diff