add all required indicator and oscillators and also add all helper classes for them ...
This commit is contained in:
@@ -0,0 +1,831 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXDONHelper
|
||||
// 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_XDON_BUFFERS
|
||||
{
|
||||
//
|
||||
// Open ...
|
||||
XDON_UPPER_O_LINE = 0,
|
||||
XDON_LOWER_O_LINE = 1,
|
||||
//
|
||||
// Close ...
|
||||
XDON_UPPER_C_LINE = 2,
|
||||
XDON_LOWER_C_LINE = 3,
|
||||
//
|
||||
// High ...
|
||||
XDON_UPPER_H_LINE = 4,
|
||||
XDON_LOWER_H_LINE = 5,
|
||||
//
|
||||
// Low ...
|
||||
XDON_UPPER_L_LINE = 6,
|
||||
XDON_LOWER_L_LINE = 7,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XDONInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
int length; // Market Length
|
||||
double offset; // Offset
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showOpen; // Show Open
|
||||
bool showHigh; // Show High
|
||||
bool showClose; // Show Close
|
||||
bool showLow; // Show Low
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XDONInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 0;
|
||||
offset = 0;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showOpen = false;
|
||||
showHigh = false;
|
||||
showClose = false;
|
||||
showLow = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 52;
|
||||
offset = 0;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showOpen = true;
|
||||
showHigh = true;
|
||||
showClose = true;
|
||||
showLow = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 5 &&
|
||||
offset >= 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(0, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXDONHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXDONHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXDONHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XDONInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(upperOBuffer, true);
|
||||
ArraySetAsSeries(lowerOBuffer, true);
|
||||
ArraySetAsSeries(upperCBuffer, true);
|
||||
ArraySetAsSeries(lowerCBuffer, true);
|
||||
ArraySetAsSeries(upperHBuffer, true);
|
||||
ArraySetAsSeries(lowerHBuffer, true);
|
||||
ArraySetAsSeries(upperLBuffer, true);
|
||||
ArraySetAsSeries(lowerLBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xdon",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length, // Market Length
|
||||
mInputs.offset, // Offset
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showOpen, // Show Open
|
||||
mInputs.showHigh, // Show High
|
||||
mInputs.showClose, // Show Close
|
||||
mInputs.showLow // Show Low
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XDONInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XDONInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Open ...
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
|
||||
//
|
||||
double GetUpperO(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(upperOBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upperOBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyUpperO(
|
||||
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,
|
||||
upperOBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
|
||||
//
|
||||
double GetLowerO(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lowerOBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lowerOBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLowerO(
|
||||
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,
|
||||
lowerOBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Close ...
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
|
||||
//
|
||||
double GetUpperC(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(upperCBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upperCBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyUpperC(
|
||||
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,
|
||||
upperCBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
|
||||
//
|
||||
double GetLowerC(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lowerCBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lowerCBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLowerC(
|
||||
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,
|
||||
lowerCBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// High ...
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
|
||||
//
|
||||
double GetUpperH(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(upperHBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upperHBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyUpperH(
|
||||
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,
|
||||
upperHBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
|
||||
//
|
||||
double GetLowerH(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lowerHBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lowerHBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLowerH(
|
||||
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,
|
||||
lowerHBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Low ...
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
|
||||
//
|
||||
double GetUpperL(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(upperLBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upperLBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyUpperL(
|
||||
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,
|
||||
upperLBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
|
||||
//
|
||||
double GetLowerL(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lowerLBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lowerLBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLowerL(
|
||||
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,
|
||||
lowerLBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XDONInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double upperOBuffer[];
|
||||
double lowerOBuffer[];
|
||||
double upperCBuffer[];
|
||||
double lowerCBuffer[];
|
||||
double upperHBuffer[];
|
||||
double lowerHBuffer[];
|
||||
double upperLBuffer[];
|
||||
double lowerLBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Open ...
|
||||
|
||||
//
|
||||
// Upper Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_UPPER_O_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
upperOBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Lower Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_LOWER_O_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lowerOBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Close ...
|
||||
|
||||
//
|
||||
// Upper Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_UPPER_C_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
upperCBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Lower Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_LOWER_C_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lowerCBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// High ...
|
||||
|
||||
//
|
||||
// Upper Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_UPPER_H_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
upperHBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Lower Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_LOWER_H_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lowerHBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Low ...
|
||||
|
||||
//
|
||||
// Upper Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_UPPER_L_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
upperLBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Lower Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XDON_LOWER_L_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lowerLBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Reference in New Issue
Block a user