Files
xMQL5/MQLTestWorkspace/BKPS/14030308/Helpers/x-saherelm.xsslc.helper.mq5
T
2024-05-28 08:03:47 +03:30

408 lines
6.8 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXSSLCHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// Imports ...
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XSSLC_BUFFERS
{
XSSLC_UP_LINE = 0,
XSSLC_DOWN_LINE = 1,
};
//
// Input Models ...
struct XSSLCInputs
{
//
// Props ...
//
// Market ...
int length; // Length
//
// Calculation ...
ENUM_MA_METHOD method; // Method
ENUM_APPLIED_PRICE upAppliedTo; // Up Applied To
ENUM_APPLIED_PRICE downAppliedTo; // Down Applied To
//
// Presentation ...
bool showUp; // Show Up
bool showDown; // Show Down
//
// Constructor(s) ...
XSSLCInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Market ...
length = 0;
//
// Calculation ...
method = MODE_SMA;
upAppliedTo = PRICE_HIGH;
downAppliedTo = PRICE_LOW;
//
// Presentation ...
showUp = false;
showDown = false;
}
//
// Default ...
void Default()
{
//
// Market ...
length = 36;
//
// Calculation ...
method = MODE_SMA;
upAppliedTo = PRICE_HIGH;
downAppliedTo = PRICE_LOW;
//
// Presentation ...
showUp = true;
showDown = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
false
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(0, 0);
//
return result;
}
};
//
// Class ...
class XSCXSSLCHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXSSLCHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXSSLCHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XSSLCInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(upBuffer, true);
ArraySetAsSeries(downBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xsslc",
//
// Inputs ...
//
// Market ...
"",
mInputs.length, // Length
//
// Calculation ...
"",
mInputs.method, // Method
mInputs.upAppliedTo, // Up Applied To
mInputs.downAppliedTo, // Down Applied To
//
// Presentation ...
"",
mInputs.showUp, // Show Up
mInputs.showDown // Show Down
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XSSLCInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XSSLCInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
// Up ...
//
double GetUp(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(upBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return upBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyUp(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
upBuffer,
buffer,
forceClean
//
);
}
//
// Down ...
//
double GetDown(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(downBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return downBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyDown(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate();
//
// Copy Items ...
return Copy(
start,
count,
downBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XSSLCInputs mInputs; // Inputs ...
//
// Buffers ...
double upBuffer[];
double downBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Up ...
CopyBuffer(
mHandler,
XSSLC_UP_LINE,
0,
totalBars,
upBuffer
//
);
//
// Down ...
CopyBuffer(
mHandler,
XSSLC_DOWN_LINE,
0,
totalBars,
downBuffer
//
);
}
};
//
// Tools ...