332 lines
6.0 KiB
Plaintext
332 lines
6.0 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// --------------------------------------
|
|
// Name: XSSLC Indicator Provider
|
|
// Description: SSL Channel ...
|
|
//
|
|
//
|
|
// 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 Import and Inclused requirements ...
|
|
//
|
|
|
|
//
|
|
// Includes ...
|
|
#include "../Libraries/x-saherelm.alert.lib.mq5"
|
|
#include "../Libraries/x-saherelm.models.lib.mq5"
|
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
|
|
|
//
|
|
// END Import and Inclused requirements ...
|
|
//
|
|
|
|
//
|
|
// START Definitions ...
|
|
//
|
|
|
|
//
|
|
// XPeaksAndVales Exported Buffers ...
|
|
enum ENUM_X_XSSLC_BUFFERS
|
|
{
|
|
//
|
|
X_SSLC_UP_LINE = 0,
|
|
X_SSLC_DOWN_LINE = 1,
|
|
X_SSLC_UP_MA_LINE = 2,
|
|
X_SSLC_DOWN_MA_LINE = 3,
|
|
X_SSLC_KPI_LINE = 4,
|
|
};
|
|
|
|
//
|
|
// END Definitions ...
|
|
//
|
|
|
|
//
|
|
// START Overrides ...
|
|
//
|
|
|
|
//
|
|
// END Overrides ...
|
|
//
|
|
|
|
class XSCXSSLCHelper
|
|
{
|
|
//
|
|
public:
|
|
//
|
|
// Properties ...
|
|
double upBuffer[];
|
|
double downBuffer[];
|
|
double kpiBuffer[];
|
|
|
|
//
|
|
// Constructor ...
|
|
void XSCXSSLCHelper()
|
|
{
|
|
mSymbol = _Symbol;
|
|
mPeriod = _Period;
|
|
}
|
|
void XSCXSSLCHelper(
|
|
//
|
|
// Symbol ...
|
|
string symbol,
|
|
//
|
|
// Period ...
|
|
ENUM_TIMEFRAMES period,
|
|
//
|
|
// Buffer Reading ...
|
|
int numberOfItemsReadPerTick = 52,
|
|
//
|
|
// MARKET ...
|
|
int length = 10, // Length
|
|
//
|
|
// CALCULATION ...
|
|
ENUM_MA_METHOD method = MODE_SMA, // Method
|
|
ENUM_APPLIED_PRICE upAppliedTo = PRICE_HIGH, // Up Applied To
|
|
ENUM_APPLIED_PRICE downAppliedTo = PRICE_LOW // Down Applied To
|
|
//
|
|
)
|
|
{
|
|
//
|
|
// Setting Requirements ...
|
|
|
|
//
|
|
// Symbol ...
|
|
mSymbol = symbol;
|
|
|
|
//
|
|
// Period ...
|
|
mPeriod = period;
|
|
|
|
//
|
|
// Number of Reading Buffer Items per Tick ...
|
|
mNumberOfItemsReadPerTick = numberOfItemsReadPerTick;
|
|
|
|
//
|
|
// MARKET ...
|
|
mLength = length;
|
|
|
|
//
|
|
// CALCULATION ...
|
|
mMethod = method;
|
|
mUpAppliedTo = upAppliedTo;
|
|
mDownAppliedTo = downAppliedTo;
|
|
|
|
//
|
|
mTag = "XSSLC " + mSymbol + ", " + ToString(mPeriod);
|
|
|
|
//
|
|
// Initial Handler ...
|
|
mHandler = iCustom(
|
|
mSymbol,
|
|
mPeriod,
|
|
"x-saherelm.x121.xsslc",
|
|
//
|
|
// Inputs ...
|
|
//
|
|
// MARKET ...
|
|
"",
|
|
mLength,
|
|
//
|
|
// CALCULATION ...
|
|
"",
|
|
mMethod,
|
|
mUpAppliedTo,
|
|
mDownAppliedTo,
|
|
//
|
|
// PRESENTATION ...
|
|
"",
|
|
false,
|
|
false
|
|
//
|
|
);
|
|
if (mHandler == INVALID_HANDLE)
|
|
{
|
|
LogMessage("failed to Initialize Indicator: " + (string)GetLastError());
|
|
}
|
|
|
|
//
|
|
ArraySetAsSeries(upBuffer, true);
|
|
ArraySetAsSeries(downBuffer, true);
|
|
ArraySetAsSeries(kpiBuffer, true);
|
|
}
|
|
|
|
//
|
|
// DeConstructor ...
|
|
void ~XSCXSSLCHelper()
|
|
{
|
|
//
|
|
// Release Indicators ...
|
|
IndicatorRelease(mHandler);
|
|
}
|
|
|
|
//
|
|
// Reading Buffers ...
|
|
void ReadBuffers()
|
|
{
|
|
//
|
|
// UP ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
X_SSLC_UP_LINE,
|
|
0,
|
|
mNumberOfItemsReadPerTick,
|
|
upBuffer);
|
|
|
|
//
|
|
// DOWN ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
X_SSLC_DOWN_LINE,
|
|
0,
|
|
mNumberOfItemsReadPerTick,
|
|
downBuffer);
|
|
|
|
//
|
|
// KPI ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
X_SSLC_KPI_LINE,
|
|
0,
|
|
mNumberOfItemsReadPerTick,
|
|
kpiBuffer);
|
|
}
|
|
|
|
//
|
|
// START Tools Functions ...
|
|
//
|
|
|
|
//
|
|
// Check Up Buffer Crossed Over Down ...
|
|
bool IsUpCrossedOverDown(
|
|
int bar_index // Bar Index ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (!IsValidArraySize(bar_index + 1))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
upBuffer[bar_index] > downBuffer[bar_index] &&
|
|
upBuffer[bar_index + 1] <= downBuffer[bar_index + 1]
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Up Buffer Crossed Under Down ...
|
|
bool IsUpCrossedUnderDown(
|
|
int bar_index // Bar Index ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (!IsValidArraySize(bar_index + 1))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
upBuffer[bar_index] < downBuffer[bar_index] &&
|
|
upBuffer[bar_index + 1] >= downBuffer[bar_index + 1]
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// END Tools Functions ...
|
|
//
|
|
|
|
//
|
|
protected:
|
|
//
|
|
private:
|
|
//
|
|
// Symbol ...
|
|
string mSymbol;
|
|
|
|
//
|
|
// Period ...
|
|
ENUM_TIMEFRAMES mPeriod;
|
|
|
|
//
|
|
// Buffer Reading ...
|
|
int mNumberOfItemsReadPerTick;
|
|
|
|
//
|
|
// MARKET ...
|
|
|
|
//
|
|
// Length ...
|
|
int mLength;
|
|
|
|
//
|
|
// CALCULATION ...
|
|
|
|
//
|
|
// Method ...
|
|
ENUM_MA_METHOD mMethod;
|
|
|
|
//
|
|
// Up Applied To
|
|
ENUM_APPLIED_PRICE mUpAppliedTo;
|
|
|
|
//
|
|
// Down Applied To
|
|
ENUM_APPLIED_PRICE mDownAppliedTo;
|
|
|
|
//
|
|
string mTag;
|
|
|
|
//
|
|
int mHandler;
|
|
|
|
//
|
|
bool IsValidArraySize(int bar_index)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int rCount = ArraySize(upBuffer);
|
|
result = rCount > bar_index + 1;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}; |