This commit is contained in:
2024-05-28 08:03:47 +03:30
parent 8ea1b6540a
commit 8de6979fba
69 changed files with 170678 additions and 0 deletions
@@ -0,0 +1,317 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXAMAHelper
// 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_XAMA_BUFFERS
{
XAMA_MAIN_LINE = 0
};
//
// Input Models ...
struct XAMAInputs
{
//
// Props ...
//
// Market ...
int length; // Period
int fastEMA; // Fast EMA Period
int slowEMA; // Slow EMA Period
int maShift; // Shift
ENUM_APPLIED_PRICE appliedTo; // Applied To
//
// Presentation ...
bool showLine; // Show Line
//
// Constructor(s) ...
XAMAInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
fastEMA = 0;
slowEMA = 0;
maShift = 0;
showLine = false;
appliedTo = PRICE_CLOSE;
}
//
// Default ...
void Default()
{
//
length = 18;
fastEMA = 2;
slowEMA = 30;
maShift = 0;
showLine = true;
appliedTo = PRICE_CLOSE;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length > 0 &&
fastEMA > 0 &&
slowEMA > 0 &&
slowEMA > fastEMA
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(length, length);
//
return result;
}
};
//
// Class ...
class XSCXAMAHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXAMAHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXAMAHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XAMAInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(mainBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xama",
//
// Inputs ...
//
// Market ...
"",
mInputs.length, // Period
mInputs.fastEMA, // Fast EMA Period
mInputs.slowEMA, // Slow EMA Period
mInputs.maShift, // Shift
mInputs.appliedTo, // Applied To
//
// Presentation ...
"",
mInputs.showLine // Show Line
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XAMAInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XAMAInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetMain(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mainBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mainBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMain(
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,
mainBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XAMAInputs mInputs; // Inputs ...
//
// Buffers ...
double mainBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Main Buffer ...
CopyBuffer(
mHandler,
XAMA_MAIN_LINE,
0,
totalBars,
mainBuffer
//
);
}
};
//
// Tools ...
@@ -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 ...
@@ -0,0 +1,514 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCHEHelper
// 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
//
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XCHE_BUFFERS
{
X_CHE_LONG_EXIT_1_LINE = 0,
X_CHE_SHORT_EXIT_1_LINE = 1,
X_CHE_LONG_EXIT_2_LINE = 2,
X_CHE_SHORT_EXIT_2_LINE = 3,
};
//
// Input Models ...
struct XCHEInputs
{
//
// Props ...
//
// Market ...
int length; // Length
int loopback; // Loopback
double multiplier1; // 1st Multiplier
double multiplier2; // 2nd Multiplier
//
// Calculation ...
ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied To
ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied To
//
// Presentation ...
bool showLongExit1Line; // Show 1st Long Exit
bool showShortExit1Line; // Show 1st Short Exit
bool showLongExit2Line; // Show 2st Long Exit
bool showShortExit2Line; // Show 2st Short Exit
//
// Constructor(s) ...
XCHEInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
loopback = 0;
multiplier1 = 0;
multiplier2 = 0;
//
upAppliedTo = PRICE_HIGH;
downAppliedTo = PRICE_LOW;
//
showLongExit1Line = false;
showShortExit1Line = false;
showLongExit2Line = false;
showShortExit2Line = false;
}
//
// Default ...
void Default()
{
//
length = 35;
loopback = 26;
multiplier1 = 3.0;
multiplier2 = 3.5;
//
upAppliedTo = PRICE_HIGH;
downAppliedTo = PRICE_LOW;
//
showLongExit1Line = true;
showShortExit1Line = true;
showLongExit2Line = true;
showShortExit2Line = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length > 0 &&
loopback < length &&
multiplier1 > 0 &&
multiplier2 > multiplier1
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(length, loopback);
//
return result;
}
};
//
// Class ...
class XSCXCHEHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXCHEHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXCHEHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XCHEInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(longExit1Buffer, true);
ArraySetAsSeries(longExit2Buffer, true);
ArraySetAsSeries(shortExit1Buffer, true);
ArraySetAsSeries(shortExit2Buffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xche",
//
// Inputs ...
//
// Market ...
"",
mInputs.length,
mInputs.loopback,
mInputs.multiplier1,
mInputs.multiplier2,
//
// Calculations ...
"",
mInputs.upAppliedTo,
mInputs.downAppliedTo,
//
// Presentation ...
"",
mInputs.showLongExit1Line, // Show 1st Long Exit,
mInputs.showShortExit1Line, // Show 1st Short Exit,
mInputs.showLongExit2Line, // Show 2st Long Exit,
mInputs.showShortExit2Line // Show 2st Short Exit
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XCHEInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XCHEInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs);
}
//
// Buffers ...
//
double GetLongExit1(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return longExit1Buffer[barIndex];
}
//
// Copy Required Long Exits 1 ...
int CopyLongExit1(
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,
longExit1Buffer,
buffer,
forceClean
//
);
}
//
double GetLongExit2(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return longExit2Buffer[barIndex];
}
//
// Copy Required Long Exits 2 ...
int CopyLongExit2(
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,
longExit2Buffer,
buffer,
forceClean
//
);
}
//
double GetShortExit1(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return shortExit1Buffer[barIndex];
}
//
// Copy Required Short Exits 1 ...
int CopyShortExit1(
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,
shortExit1Buffer,
buffer,
forceClean
//
);
}
//
double GetShortExit2(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return shortExit2Buffer[barIndex];
}
//
// Copy Required Short Exits 2 ...
int CopyShortExit2(
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,
shortExit2Buffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XCHEInputs mInputs; // Inputs ...
//
// Buffers ...
//
double longExit1Buffer[];
double longExit2Buffer[];
double shortExit1Buffer[];
double shortExit2Buffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
int calculatedBars = CountCalculatedBars();
//
// Long Exit 1 ...
CopyBuffer(
mHandler,
X_CHE_LONG_EXIT_1_LINE,
0,
totalBars,
longExit1Buffer
//
);
//
// Long Exit 2 ...
CopyBuffer(
mHandler,
X_CHE_LONG_EXIT_2_LINE,
0,
totalBars,
longExit2Buffer
//
);
//
// Short Exit 1 ...
CopyBuffer(
mHandler,
X_CHE_SHORT_EXIT_1_LINE,
0,
totalBars,
shortExit1Buffer
//
);
//
// Short Exit 2 ...
CopyBuffer(
mHandler,
X_CHE_SHORT_EXIT_2_LINE,
0,
totalBars,
shortExit2Buffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,967 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCHLHHelper
// 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_XCHLH_BUFFERS
{
//
// LC ...
XCHLH_LC_HH_LINE = 0,
XCHLH_LC_LL_LINE = 1,
//
// MC ...
XCHLH_MC_HH_LINE = 2,
XCHLH_MC_LL_LINE = 3,
//
// SC ...
XCHLH_SC_HH_LINE = 4,
XCHLH_SC_LL_LINE = 5,
//
// Hot State ...
XCHLH_HOT_STATE_LINE = 6
};
//
// Input Models ...
struct XCHLHInputs
{
//
// Props ...
//
// Hot Areas ...
bool drawHotAreas; // Draw Hot Areas Symbol
uchar hotHHArrowCode; // Hot HH Arrow Code
color hotHHArrowColor; // Hot HH Arrow Color
uchar hotLLArrowCode; // Hot LL Arrow Code
color hotLLArrowColor; // Hot LL Arrow Color
//
// Long Cycle ...
// LC Market ...
int lcLength; // Length
double lcThresholdInPips; // Threshold In Pips
ENUM_SERIESMODE lcHHMode; // Highest High Calculation Method
ENUM_SERIESMODE lcLLMode; // Lowest Low Calculation Method
//
// LC Style ...
int lcDrawWidth; // Draw Width
ENUM_DRAW_TYPE lcDrawType; // Draw Type
ENUM_LINE_STYLE lcDrawStyle; // Draw Style
color lcHHColor; // Highest High Color
color lcLLColor; // Lowest Low Color
// LC Drawings ...
bool lcDrawHH; // Draw Highest High
bool lcDrawLL; // Draw Lowest Low
//
// Medium Cycle ...
// MC Market ...
int mcLength; // Length
double mcThresholdInPips; // Threshold In Pips
ENUM_SERIESMODE mcHHMode; // Highest High Calculation Method
ENUM_SERIESMODE mcLLMode; // Lowest Low Calculation Method
// MC Style ...
int mcDrawWidth; // Draw Width
ENUM_DRAW_TYPE mcDrawType; // Draw Type
ENUM_LINE_STYLE mcDrawStyle; // Draw Style
color mcHHColor; // Highest High Color
color mcLLColor; // Lowest Low Color
// MC Drawings ...
bool mcDrawHH; // Draw Highest High
bool mcDrawLL; // Draw Lowest Low
//
// Short Cycle ...
// SC Market ...
int scLength; // Length
double scThresholdInPips; // Threshold In Pips
ENUM_SERIESMODE scHHMode; // Highest High Calculation Method
ENUM_SERIESMODE scLLMode; // Lowest Low Calculation Method
// SC Style ...
int scDrawWidth; // Draw Width
ENUM_DRAW_TYPE scDrawType; // Draw Type
ENUM_LINE_STYLE scDrawStyle; // Draw Style
color scHHColor; // Highest High Color
color scLLColor; // Lowest Low Color
// SC Drawings ...
bool scDrawHH; // Draw Highest High
bool scDrawLL; // Draw Lowest Low
//
// Constructor(s) ...
XCHLHInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Hot Areas ...
drawHotAreas = false;
hotHHArrowCode = 234;
hotHHArrowColor = CLR_NONE;
hotLLArrowCode = 233;
hotLLArrowColor = CLR_NONE;
//
// Long Cycle ...
// LC Market ...
lcLength = 0;
lcThresholdInPips = 0;
lcHHMode = MODE_HIGH;
lcLLMode = MODE_LOW;
//
// LC Style ...
lcDrawWidth = 1;
lcDrawType = DRAW_NONE;
lcDrawStyle = STYLE_DOT;
lcHHColor = CLR_NONE;
lcLLColor = CLR_NONE;
// LC Drawings ...
lcDrawHH = false;
lcDrawLL = false;
//
// Medium Cycle ...
// MC Market ...
mcLength = 0;
mcThresholdInPips = 0;
mcHHMode = MODE_HIGH;
mcLLMode = MODE_LOW;
// MC Style ...
mcDrawWidth = 1;
mcDrawType = DRAW_NONE;
mcDrawStyle = STYLE_DOT;
mcHHColor = CLR_NONE;
mcLLColor = CLR_NONE;
// MC Drawings ...
mcDrawHH = false;
mcDrawLL = false;
//
// Short Cycle ...
// SC Market ...
scLength = 0;
scThresholdInPips = 0;
scHHMode = MODE_HIGH;
scLLMode = MODE_LOW;
// SC Style ...
scDrawWidth = 1;
scDrawType = DRAW_NONE;
scDrawStyle = STYLE_DOT;
scHHColor = CLR_NONE;
scLLColor = CLR_NONE;
// SC Drawings ...
scDrawHH = false;
scDrawLL = false;
}
//
// Default ...
void Default()
{
//
// Hot Areas ...
drawHotAreas = false;
hotHHArrowCode = 234;
hotHHArrowColor = CLR_NONE;
hotLLArrowCode = 233;
hotLLArrowColor = CLR_NONE;
//
// Long Cycle ...
// LC Market ...
lcLength = 28;
lcThresholdInPips = 0.3;
lcHHMode = MODE_HIGH;
lcLLMode = MODE_LOW;
//
// LC Style ...
lcDrawWidth = 1;
lcDrawType = DRAW_LINE;
lcDrawStyle = STYLE_DOT;
lcHHColor = clrAqua;
lcLLColor = clrFuchsia;
// LC Drawings ...
lcDrawHH = false;
lcDrawLL = false;
//
// Medium Cycle ...
// MC Market ...
mcLength = 14;
mcThresholdInPips = 0.3;
mcHHMode = MODE_HIGH;
mcLLMode = MODE_LOW;
// MC Style ...
mcDrawWidth = 1;
mcDrawType = DRAW_LINE;
mcDrawStyle = STYLE_DOT;
mcHHColor = clrLime;
mcLLColor = clrRed;
// MC Drawings ...
mcDrawHH = false;
mcDrawLL = false;
//
// Short Cycle ...
// SC Market ...
scLength = 7;
scThresholdInPips = 0.3;
scHHMode = MODE_HIGH;
scLLMode = MODE_LOW;
// SC Style ...
scDrawWidth = 1;
scDrawType = DRAW_LINE;
scDrawStyle = STYLE_DOT;
scHHColor = clrLightBlue;
scLLColor = clrLightSalmon;
// SC Drawings ...
scDrawHH = false;
scDrawLL = false;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
// LC ...
(lcLength >= 4 &&
lcLength > mcLength &&
lcLength > scLength)
//
&&
//
// MC ...
(mcLength >= 4 &&
mcLength > scLength &&
mcLength < lcLength)
//
&&
//
// SC ...
(scLength >= 4 &&
scLength < mcLength &&
scLength < lcLength)
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(lcLength, mcLength);
result = MathMax(result, scLength);
//
return result;
}
};
//
// Class ...
class XSCXCHLHHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXCHLHHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXCHLHHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XCHLHInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(scHHBuffer, true);
ArraySetAsSeries(scLLBuffer, true);
ArraySetAsSeries(mcHHBuffer, true);
ArraySetAsSeries(mcLLBuffer, true);
ArraySetAsSeries(lcHHBuffer, true);
ArraySetAsSeries(lcLLBuffer, true);
ArraySetAsSeries(hotStateBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xchlh",
//
// Inputs ...
//
// Hot Areas ...
"",
//
mInputs.drawHotAreas, // Draw Hot Areas Symbol
mInputs.hotHHArrowCode, // Hot HH Arrow Code
mInputs.hotHHArrowColor, // Hot HH Arrow Color
mInputs.hotLLArrowCode, // Hot LL Arrow Code
mInputs.hotLLArrowColor, // Hot LL Arrow Color
//
// Long Cycle ...
"",
// LC Market ...
"",
//
mInputs.lcLength, // Length
mInputs.lcThresholdInPips, // Threshold In Pips
mInputs.lcHHMode, // Highest High Calculation Method
mInputs.lcLLMode, // Lowest Low Calculation Method
//
// LC Style ...
"",
//
mInputs.lcDrawWidth, // Draw Width
mInputs.lcDrawType, // Draw Type
mInputs.lcDrawStyle, // Draw Style
mInputs.lcHHColor, // Highest High Color
mInputs.lcLLColor, // Lowest Low Color
//
// LC Drawings ...
"",
mInputs.lcDrawHH, // Draw Highest High
mInputs.lcDrawLL, // Draw Lowest Low
//
// Medium Cycle ...
"",
// MC Market ...
"",
//
mInputs.mcLength, // Length
mInputs.mcThresholdInPips, // Threshold In Pips
mInputs.mcHHMode, // Highest High Calculation Method
mInputs.mcLLMode, // Lowest Low Calculation Method
//
// MC Style ...
"",
//
mInputs.mcDrawWidth, // Draw Width
mInputs.mcDrawType, // Draw Type
mInputs.mcDrawStyle, // Draw Style
mInputs.mcHHColor, // Highest High Color
mInputs.mcLLColor, // Lowest Low Color
//
// MC Drawings ...
"",
mInputs.mcDrawHH, // Draw Highest High
mInputs.mcDrawLL, // Draw Lowest Low
//
// Short Cycle ...
"",
// SC Market ...
"",
//
mInputs.scLength, // Length
mInputs.scThresholdInPips, // Threshold In Pips
mInputs.scHHMode, // Highest High Calculation Method
mInputs.scLLMode, // Lowest Low Calculation Method
//
// SC Style ...
"",
//
mInputs.scDrawWidth, // Draw Width
mInputs.scDrawType, // Draw Type
mInputs.scDrawStyle, // Draw Style
mInputs.scHHColor, // Highest High Color
mInputs.scLLColor, // Lowest Low Color
//
// SC Drawings ...
"",
mInputs.scDrawHH, // Draw Highest High
mInputs.scDrawLL // Draw Lowest Low
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XCHLHInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XCHLHInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
// Short ...
//
double GetSCHH(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(scHHBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return scHHBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySCHH(
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,
scHHBuffer,
buffer,
forceClean
//
);
}
//
double GetSCLL(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(scLLBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return scLLBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySCLL(
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,
scLLBuffer,
buffer,
forceClean
//
);
}
//
// Medium ...
//
double GetMCHH(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mcHHBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mcHHBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMCHH(
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,
mcHHBuffer,
buffer,
forceClean
//
);
}
//
double GetMCLL(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mcLLBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mcLLBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMCLL(
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,
mcLLBuffer,
buffer,
forceClean
//
);
}
//
// Long ...
//
double GetLCHH(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(lcHHBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return lcHHBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLCHH(
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,
lcHHBuffer,
buffer,
forceClean
//
);
}
//
double GetLCLL(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(lcLLBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return lcLLBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLCLL(
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,
lcLLBuffer,
buffer,
forceClean
//
);
}
//
double GetHotState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(hotStateBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return hotStateBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyHotState(
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,
hotStateBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XCHLHInputs mInputs; // Inputs ...
//
// Buffers ...
double scHHBuffer[];
double scLLBuffer[];
double mcHHBuffer[];
double mcLLBuffer[];
double lcHHBuffer[];
double lcLLBuffer[];
double hotStateBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Short Cycle ...
//
// HH ...
CopyBuffer(
mHandler,
XCHLH_SC_HH_LINE,
0,
totalBars,
scHHBuffer
//
);
//
// LL ...
CopyBuffer(
mHandler,
XCHLH_SC_LL_LINE,
0,
totalBars,
scLLBuffer
//
);
//
// Medium Cycle ...
//
// HH ...
CopyBuffer(
mHandler,
XCHLH_MC_HH_LINE,
0,
totalBars,
mcHHBuffer
//
);
//
// LL ...
CopyBuffer(
mHandler,
XCHLH_MC_LL_LINE,
0,
totalBars,
mcLLBuffer
//
);
//
// Long Cycle ...
//
// HH ...
CopyBuffer(
mHandler,
XCHLH_LC_HH_LINE,
0,
totalBars,
lcHHBuffer
//
);
//
// LL ...
CopyBuffer(
mHandler,
XCHLH_LC_LL_LINE,
0,
totalBars,
lcLLBuffer
//
);
//
// Hot State ...
CopyBuffer(
mHandler,
XCHLH_HOT_STATE_LINE,
0,
totalBars,
hotStateBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,960 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCHMAHelper
// 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_XCHMA_BUFFERS
{
//
// LC ...
XCHMA_LC_FAST_LINE = 0,
XCHMA_LC_SLOW_LINE = 1,
//
// MC ...
XCHMA_MC_FAST_LINE = 2,
XCHMA_MC_SLOW_LINE = 3,
//
// SC ...
XCHMA_SC_FAST_LINE = 4,
XCHMA_SC_SLOW_LINE = 5,
//
XCHMA_HOT_STATE_LINE = 6,
};
//
// Input Models ...
struct XCHMAInputs
{
//
// Props ...
//
// Hot Areas ...
bool drawHotAreas; // Draw Hot Areas Symbol
uchar hotBullishArrowCode; // Hot Bullish Arrow Code
color hotBullishArrowColor; // Hot Bullish Arrow Color
uchar hotBearishArrowCode; // Hot Bearish Arrow Code
color hotBearishArrowColor; // Hot Bearish Arrow Color
//
// Long Cycle ...
// LC Market ...
int lcFastLength; // Fast Length
int lcSlowLength; // Slow Length
ENUM_MA_METHOD lcMethod; // Calculation Method
ENUM_APPLIED_PRICE lcAppliedTo; // Applied To
// LC Style ...
int lcDrawWidth; // Draw Width
ENUM_DRAW_TYPE lcDrawType; // Draw Type
ENUM_LINE_STYLE lcDrawStyle; // Draw Style
color lcFastColor; // Fast Color
color lcSlowColor; // Slow Color
// LC Drawings ...
bool lcDrawFast; // Draw Fast
bool lcDrawSlow; // Draw Slow
bool lcDrawCrosses; // Draw Cross Lines
//
// Medium Cycle ...
// MC Market ...
int mcFastLength; // Fast Length
int mcSlowLength; // Slow Length
ENUM_MA_METHOD mcMethod; // Calculation Method
ENUM_APPLIED_PRICE mcAppliedTo; // Applied To
// MC Style ...
int mcDrawWidth; // Draw Width
ENUM_DRAW_TYPE mcDrawType; // Draw Type
ENUM_LINE_STYLE mcDrawStyle; // Draw Style
color mcFastColor; // Fast Color
color mcSlowColor; // Slow Color
// MC Drawings ...
bool mcDrawFast; // Draw Fast
bool mcDrawSlow; // Draw Slow
bool mcDrawCrosses; // Draw Cross Lines
//
// Short Cycle ...
// SC Market ...
int scFastLength; // Fast Length
int scSlowLength; // Slow Length
ENUM_MA_METHOD scMethod; // Calculation Method
ENUM_APPLIED_PRICE scAppliedTo; // Applied To
// SC Style ...
int scDrawWidth; // Draw Width
ENUM_DRAW_TYPE scDrawType; // Draw Type
ENUM_LINE_STYLE scDrawStyle; // Draw Style
color scFastColor; // Fast Color
color scSlowColor; // Slow Color
// SC Drawings ...
bool scDrawFast; // Draw Fast
bool scDrawSlow; // Draw Slow
bool scDrawCrosses; // Draw Cross Lines
//
// Constructor(s) ...
XCHMAInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Hot Areas ...
drawHotAreas = false;
hotBullishArrowCode = 228;
hotBullishArrowColor = CLR_NONE;
hotBearishArrowCode = 230;
hotBearishArrowColor = CLR_NONE;
//
// Long Cycle ...
// LC Market ...
lcFastLength = 20;
lcSlowLength = 50;
lcMethod = MODE_EMA;
lcAppliedTo = PRICE_CLOSE;
// LC Style ...
lcDrawWidth = 1;
lcDrawType = DRAW_NONE;
lcDrawStyle = STYLE_DOT;
lcFastColor = CLR_NONE;
lcSlowColor = CLR_NONE;
// LC Drawings ...
lcDrawFast = false;
lcDrawSlow = false;
lcDrawCrosses = false;
//
// Medium Cycle ...
// MC Market ...
mcFastLength = 10;
mcSlowLength = 30;
mcMethod = MODE_EMA;
mcAppliedTo = PRICE_CLOSE;
// MC Style ...
mcDrawWidth = 1;
mcDrawType = DRAW_NONE;
mcDrawStyle = STYLE_DOT;
mcFastColor = CLR_NONE;
mcSlowColor = CLR_NONE;
// MC Drawings ...
mcDrawFast = false;
mcDrawSlow = false;
mcDrawCrosses = false;
//
// Short Cycle ...
// SC Market ...
scFastLength = 7;
scSlowLength = 14;
scMethod = MODE_EMA;
scAppliedTo = PRICE_CLOSE;
// SC Style ...
scDrawWidth = 1;
scDrawType = DRAW_NONE;
scDrawStyle = STYLE_SOLID;
scFastColor = CLR_NONE;
scSlowColor = CLR_NONE;
// SC Drawings ...
scDrawFast = false;
scDrawSlow = false;
scDrawCrosses = false;
}
//
// Default ...
void Default()
{
//
// Hot Areas ...
drawHotAreas = false;
hotBullishArrowCode = 228;
hotBullishArrowColor = CLR_NONE;
hotBearishArrowCode = 230;
hotBearishArrowColor = CLR_NONE;
//
// Long Cycle ...
// LC Market ...
lcFastLength = 20;
lcSlowLength = 50;
lcMethod = MODE_EMA;
lcAppliedTo = PRICE_CLOSE;
// LC Style ...
lcDrawWidth = 1;
lcDrawType = DRAW_LINE;
lcDrawStyle = STYLE_DOT;
lcFastColor = clrAqua;
lcSlowColor = clrFuchsia;
// LC Drawings ...
lcDrawFast = false;
lcDrawSlow = false;
lcDrawCrosses = false;
//
// Medium Cycle ...
// MC Market ...
mcFastLength = 10;
mcSlowLength = 30;
mcMethod = MODE_EMA;
mcAppliedTo = PRICE_CLOSE;
// MC Style ...
mcDrawWidth = 1;
mcDrawType = DRAW_LINE;
mcDrawStyle = STYLE_DOT;
mcFastColor = clrLime;
mcSlowColor = clrRed;
// MC Drawings ...
mcDrawFast = false;
mcDrawSlow = false;
mcDrawCrosses = false;
//
// Short Cycle ...
// SC Market ...
scFastLength = 7;
scSlowLength = 14;
scMethod = MODE_EMA;
scAppliedTo = PRICE_CLOSE;
// SC Style ...
scDrawWidth = 1;
scDrawType = DRAW_LINE;
scDrawStyle = STYLE_SOLID;
scFastColor = clrLightBlue;
scSlowColor = clrLightSalmon;
// SC Drawings ...
scDrawFast = false;
scDrawSlow = false;
scDrawCrosses = false;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
(lcFastLength >= 4 && lcSlowLength > lcFastLength) &&
(mcFastLength >= 4 && mcSlowLength > mcFastLength) &&
(scFastLength >= 4 && scSlowLength > scFastLength) &&
(lcFastLength > mcFastLength &&
mcFastLength > scFastLength)
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(scFastLength, scSlowLength);
result = MathMax(result, lcFastLength);
result = MathMax(result, lcSlowLength);
result = MathMax(result, mcFastLength);
result = MathMax(result, mcSlowLength);
//
return result;
}
};
//
// Class ...
class XSCXCHMAHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXCHMAHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXCHMAHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XCHMAInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(scFastBuffer, true);
ArraySetAsSeries(scSlowBuffer, true);
ArraySetAsSeries(mcFastBuffer, true);
ArraySetAsSeries(mcSlowBuffer, true);
ArraySetAsSeries(lcFastBuffer, true);
ArraySetAsSeries(lcSlowBuffer, true);
ArraySetAsSeries(hotStateBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xchma",
//
// Inputs ...
//
// Hot Areas ...
"",
mInputs.drawHotAreas, // Draw Hot Areas Symbol
mInputs.hotBullishArrowCode, // Hot Bullish Arrow Code
mInputs.hotBullishArrowColor, // Hot Bullish Arrow Color
mInputs.hotBearishArrowCode, // Hot Bearish Arrow Code
mInputs.hotBearishArrowColor, // Hot Bearish Arrow Color
//
// Long Cycle ...
"",
//
// LC Market ...
"",
mInputs.lcFastLength, // Fast Length
mInputs.lcSlowLength, // Slow Length
mInputs.lcMethod, // Calculation Method
mInputs.lcAppliedTo, // Applied To
//
// LC Style ...
"",
mInputs.lcDrawWidth, // Draw Width
mInputs.lcDrawType, // Draw Type
mInputs.lcDrawStyle, // Draw Style
mInputs.lcFastColor, // Fast Color
mInputs.lcSlowColor, // Slow Color
//
// LC Drawings ...
"",
mInputs.lcDrawFast, // Draw Fast
mInputs.lcDrawSlow, // Draw Slow
mInputs.lcDrawCrosses, // Draw Cross Lines
//
// Medium Cycle ...
"",
//
// MC Market ...
"",
mInputs.mcFastLength, // Fast Length
mInputs.mcSlowLength, // Slow Length
mInputs.mcMethod, // Calculation Method
mInputs.mcAppliedTo, // Applied To
//
// MC Style ...
"",
mInputs.mcDrawWidth, // Draw Width
mInputs.mcDrawType, // Draw Type
mInputs.mcDrawStyle, // Draw Style
mInputs.mcFastColor, // Fast Color
mInputs.mcSlowColor, // Slow Color
//
// MC Drawings ...
"",
mInputs.mcDrawFast, // Draw Fast
mInputs.mcDrawSlow, // Draw Slow
mInputs.mcDrawCrosses, // Draw Cross Lines
//
// Short Cycle ...
"",
//
// SC Market ...
"",
mInputs.scFastLength, // Fast Length
mInputs.scSlowLength, // Slow Length
mInputs.scMethod, // Calculation Method
mInputs.scAppliedTo, // Applied To
//
// SC Style ...
"",
mInputs.scDrawWidth, // Draw Width
mInputs.scDrawType, // Draw Type
mInputs.scDrawStyle, // Draw Style
mInputs.scFastColor, // Fast Color
mInputs.scSlowColor, // Slow Color
//
// SC Drawings ...
"",
mInputs.scDrawFast, // Draw Fast
mInputs.scDrawSlow, // Draw Slow
mInputs.scDrawCrosses // Draw Cross Lines
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XCHMAInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XCHMAInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
// Short ...
//
double GetSCFast(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(scFastBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return scFastBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySCFast(
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,
scFastBuffer,
buffer,
forceClean
//
);
}
//
double GetSCSlow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(scSlowBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return scSlowBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySCSlow(
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,
scSlowBuffer,
buffer,
forceClean
//
);
}
//
// Medium ...
//
double GetMCFast(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mcFastBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mcFastBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMCFast(
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,
mcFastBuffer,
buffer,
forceClean
//
);
}
//
double GetMCSlow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mcSlowBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mcSlowBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMCSlow(
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,
mcSlowBuffer,
buffer,
forceClean
//
);
}
//
// Long ...
//
double GetLCFast(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(lcFastBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return lcFastBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLCFast(
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,
lcFastBuffer,
buffer,
forceClean
//
);
}
//
double GetLCSlow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(lcSlowBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return lcSlowBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLCSlow(
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,
lcSlowBuffer,
buffer,
forceClean
//
);
}
//
double GetHotState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(hotStateBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return hotStateBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyHotState(
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,
hotStateBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XCHMAInputs mInputs; // Inputs ...
//
// Buffers ...
double scFastBuffer[];
double scSlowBuffer[];
double mcFastBuffer[];
double mcSlowBuffer[];
double lcFastBuffer[];
double lcSlowBuffer[];
double hotStateBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Short Cycle ...
//
// Fast ...
CopyBuffer(
mHandler,
XCHMA_SC_FAST_LINE,
0,
totalBars,
scFastBuffer
//
);
//
// Slow ...
CopyBuffer(
mHandler,
XCHMA_SC_SLOW_LINE,
0,
totalBars,
scSlowBuffer
//
);
//
// Medium Cycle ...
//
// Fast ...
CopyBuffer(
mHandler,
XCHMA_MC_FAST_LINE,
0,
totalBars,
mcFastBuffer
//
);
//
// Slow ...
CopyBuffer(
mHandler,
XCHMA_MC_SLOW_LINE,
0,
totalBars,
mcSlowBuffer
//
);
//
// Long Cycle ...
//
// Fast ...
CopyBuffer(
mHandler,
XCHMA_LC_FAST_LINE,
0,
totalBars,
lcFastBuffer
//
);
//
// Slow ...
CopyBuffer(
mHandler,
XCHMA_LC_SLOW_LINE,
0,
totalBars,
lcSlowBuffer
//
);
//
// Hot State ...
CopyBuffer(
mHandler,
XCHMA_HOT_STATE_LINE,
0,
totalBars,
hotStateBuffer
//
);
}
};
//
// Tools ...
@@ -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 = false;
}
//
// 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 ...
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,292 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXFIHelper
// 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_XFI_BUFFERS
{
XFI_MAIN_LINE = 0
};
//
// Input Models ...
struct XFIInputs
{
//
// Props ...
int length; // Length
ENUM_MA_METHOD method; // MA Method
ENUM_APPLIED_VOLUME appliedTo; // Applied To
//
// Constructor(s) ...
XFIInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
method = MODE_SMA;
appliedTo = VOLUME_TICK;
}
//
// Default ...
void Default()
{
//
length = 18;
method = MODE_SMA;
appliedTo = VOLUME_TICK;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 2
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, length);
//
return result;
}
};
//
// Class ...
class XSCXFIHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXFIHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXFIHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XFIInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(mainBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xfi",
//
// Inputs ...
mInputs.length, // Length
mInputs.method, // MA Method
mInputs.appliedTo // Applied To
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XFIInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XFIInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetMain(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mainBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mainBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMain(
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,
mainBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XFIInputs mInputs; // Inputs ...
//
// Buffers ...
double mainBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Short Exit 2 ...
CopyBuffer(
mHandler,
XFI_MAIN_LINE,
0,
totalBars,
mainBuffer
//
);
}
};
//
// Tools ...
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,399 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXHULLHelper
// 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_XHULLC_BUFFERS
{
XHULLC_UP_LINE = 0,
XHULLC_DOWN_LINE = 2,
};
//
// Input Models ...
struct XHULLInputs
{
//
// Props ...
//
// Market ...
int length; // Length
double divisor; // Divisor (Speed)
//
// Calculation ...
ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied to
ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied to
//
// Presentation ...
bool showUpZone; // Show Up Zone
bool showDownZone; // Show Down Zone
//
// Constructor(s) ...
XHULLInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Market ...
length = 0;
divisor = 0;
//
// Calculation ...
upAppliedTo = PRICE_HIGH;
downAppliedTo = PRICE_LOW;
//
// Presentation ...
showUpZone = false;
showDownZone = false;
}
//
// Default ...
void Default()
{
//
// Market ...
length = 72;
divisor = 2.0;
//
// Calculation ...
upAppliedTo = PRICE_HIGH;
downAppliedTo = PRICE_LOW;
//
// Presentation ...
showUpZone = true;
showDownZone = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 9 &&
divisor >= 0.5
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(0, length);
//
return result;
}
};
//
// Class ...
class XSCXHULLHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXHULLHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXHULLHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XHULLInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
// ArraySetAsSeries(mainBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xhull",
//
// Inputs ...
//
// Market ...
"",
mInputs.length, // Length
mInputs.divisor, // Divisor (Speed)
//
// Calculation ...
"",
mInputs.upAppliedTo, // Up Zone Applied to
mInputs.downAppliedTo, // Down Zone Applied to
//
// Presentation ...
"",
mInputs.showUpZone, // Show Up Zone
mInputs.showDownZone // Show Down Zone
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XHULLInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XHULLInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
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
//
);
}
//
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 ...
XHULLInputs mInputs; // Inputs ...
//
// Buffers ...
double upBuffer[];
double downBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Up Buffer ...
CopyBuffer(
mHandler,
XHULLC_UP_LINE,
0,
totalBars,
upBuffer
//
);
//
// Down Buffer ...
CopyBuffer(
mHandler,
XHULLC_DOWN_LINE,
0,
totalBars,
downBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,827 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXICHHelper
// 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
//
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
// Ichimoku Lines Calculator Mode ...
enum ENUM_XICH_CALCULATION_MODE
{
//
X_XICH_HH_LL_MODE = 1, // Highest High and Lowest Low
X_XICH_HO_LC_MODE = 2, // Highest Open and Lowest Close
};
//
enum ENUM_XICH_BUFFERS
{
X_ICH_TEANKANSEN_LINE = 0,
X_ICH_KIJUNSEN_LINE = 1,
X_ICH_CHIKOUSPAN_LINE = 4,
X_ICH_SENKOUSPANA_LINE = 5,
X_ICH_SENKOUSPANB_LINE = 6,
};
//
// Input Models ...
struct XICHInputs
{
//
// Props ...
//
// Market ...
//
// Tenkan Sen ...
int tenkanSenLength; // Length
ENUM_XICH_CALCULATION_MODE tenkanSenMode; // Calculation Mode
//
// Kijun Sen ...
int kijunSenLength; // Length
ENUM_XICH_CALCULATION_MODE kijunSenMode; // Calculation Mode
//
// Senkou Span B ...
int senkouSpanBLength; // Length
ENUM_XICH_CALCULATION_MODE senkouSpanBMode; // Calculation Mode
//
// Chikou Span ...
ENUM_APPLIED_PRICE chikuoSpanAppliedTo; // Price Type
//
// Presentation ...
bool showTenkanSen; // Show Tenkan Sen
bool showKijunSen; // Show Kijun Sen
bool showKijunSenPlus; // Show Kijun Sen +
bool showKijunSenNegative; // Show Kijun Sen -
bool showChikouSpan; // Show Chikou Span
bool showSenkouSpanA; // Show Senkou Span A
bool showSenkouSpanB; // Show Senkou Span B
bool showKumo; // Show Kumo
bool shiftKumo; // Shift Kumo to Future
//
// Constructor(s) ...
XICHInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
kijunSenLength = 0;
tenkanSenLength = 0;
senkouSpanBLength = 0;
//
kijunSenMode = X_XICH_HH_LL_MODE;
tenkanSenMode = X_XICH_HH_LL_MODE;
senkouSpanBMode = X_XICH_HH_LL_MODE;
//
chikuoSpanAppliedTo = PRICE_CLOSE;
//
showTenkanSen = false;
showKijunSen = false;
showKijunSenPlus = false;
showKijunSenNegative = false;
showChikouSpan = false;
showSenkouSpanA = false;
showSenkouSpanB = false;
showKumo = false;
shiftKumo = true;
}
//
// Default ...
void Default()
{
//
kijunSenLength = 26;
tenkanSenLength = 9;
senkouSpanBLength = 52;
//
kijunSenMode = X_XICH_HH_LL_MODE;
tenkanSenMode = X_XICH_HH_LL_MODE;
senkouSpanBMode = X_XICH_HH_LL_MODE;
//
chikuoSpanAppliedTo = PRICE_CLOSE;
//
showTenkanSen = true;
showKijunSen = true;
showKijunSenPlus = false;
showKijunSenNegative = false;
showChikouSpan = true;
showSenkouSpanA = true;
showSenkouSpanB = true;
showKumo = true;
shiftKumo = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
tenkanSenLength > 2 &&
kijunSenLength > tenkanSenLength &&
senkouSpanBLength > kijunSenLength
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, tenkanSenLength);
result = MathMax(result, kijunSenLength);
result = MathMax(result, senkouSpanBLength);
//
return result;
}
};
//
// Class ...
class XSCXICHHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXICHHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXICHHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XICHInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(tenkanSenBuffer, true);
ArraySetAsSeries(kijunSenBuffer, true);
ArraySetAsSeries(chikouSpanBuffer, true);
ArraySetAsSeries(senkouSpanABuffer, true);
ArraySetAsSeries(senkouSpanBBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xich",
//
// Inputs ...
//
// TenkanSen ...
"",
mInputs.tenkanSenLength,
mInputs.tenkanSenMode,
//
// KijunSen ...
"",
mInputs.kijunSenLength,
mInputs.kijunSenMode,
//
// SenkouSpan B ...
"",
mInputs.senkouSpanBLength,
mInputs.senkouSpanBMode,
//
// ChikouSpan ...
"",
mInputs.chikuoSpanAppliedTo,
//
// Presentation ...
"",
mInputs.showTenkanSen, // Show Tenkan Sen
mInputs.showKijunSen, // Show Kijun Sen
mInputs.showKijunSenPlus, // Show Kijun Sen +
mInputs.showKijunSenNegative, // Show Kijun Sen -
mInputs.showChikouSpan, // Show Chikou Span
mInputs.showSenkouSpanA, // Show Senkou Span A
mInputs.showSenkouSpanB, // Show Senkou Span B
mInputs.showKumo, // Show Kumo
mInputs.shiftKumo // Shift Kumo to Future
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XICHInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XICHInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs);
}
//
// Buffers ...
//
// TenkanSen ...
//
double GetTenkanSen(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return tenkanSenBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyTenkanSen(
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,
tenkanSenBuffer,
buffer,
forceClean
//
);
}
//
bool IsSameTenkanSen(
int barIndex, // Start Bar Index
int verifier = 71 // Number of Verifiers
)
{
//
// Update Calculations ...
Calculate();
//
return IsSame(
tenkanSenBuffer,
verifier,
barIndex //
);
}
//
// KijunSen ...
//
double GetKijunSen(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return kijunSenBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyKijunSen(
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,
kijunSenBuffer,
buffer,
forceClean
//
);
}
//
bool IsSameKijunSen(
int barIndex, // Start Bar Index
int verifier = 71 // Number of Verifiers
)
{
//
// Update Calculations ...
Calculate();
//
return IsSame(
kijunSenBuffer,
verifier,
barIndex //
);
}
//
// ChikouSpan ...
//
double GetChikouSpan(
int barIndex // Bar Index
)
{
//
barIndex -= mInputs.kijunSenLength;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (barIndex > ArraySize(chikouSpanBuffer))
{
barIndex = ArraySize(chikouSpanBuffer) - 1;
}
//
Calculate();
//
return chikouSpanBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyChikouSpan(
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 - mInputs.kijunSenLength,
count,
chikouSpanBuffer,
buffer,
forceClean
//
);
}
//
// SenkouSpanA ...
//
double GetSenkouSpanA(
int barIndex // Bar Index
)
{
//
barIndex += mInputs.kijunSenLength;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (barIndex > ArraySize(senkouSpanABuffer))
{
barIndex = ArraySize(senkouSpanABuffer) - 1;
}
//
Calculate();
//
return senkouSpanABuffer[barIndex];
}
//
// Copy Required Items ...
int CopySenkouSpanA(
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 + mInputs.kijunSenLength,
count,
senkouSpanABuffer,
buffer,
forceClean
//
);
}
//
bool IsSameSenkouSpanA(
int barIndex, // Start Bar Index
int verifier = 71 // Number of Verifiers
)
{
//
// Update Calculations ...
Calculate();
//
return IsSame(
senkouSpanABuffer,
verifier,
barIndex //
);
}
//
// SenkouSpanB ...
//
double GetSenkouSpanB(
int barIndex // Bar Index
)
{
//
barIndex += mInputs.kijunSenLength;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (barIndex > ArraySize(senkouSpanBBuffer))
{
barIndex = ArraySize(senkouSpanBBuffer) - 1;
}
//
Calculate();
//
return senkouSpanBBuffer[barIndex + mInputs.kijunSenLength];
}
//
// Copy Required Items ...
int CopySenkouSpanB(
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 + mInputs.kijunSenLength,
count,
senkouSpanBBuffer,
buffer,
forceClean
//
);
}
//
bool IsSameSenkouSpanB(
int barIndex, // Start Bar Index
int verifier = 71 // Number of Verifiers
)
{
//
// Update Calculations ...
Calculate();
//
return IsSame(
senkouSpanBBuffer,
verifier,
barIndex //
);
}
//
// Future SenkouSpanA ...
//
double GetFutureSenkouSpanA(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return senkouSpanABuffer[barIndex];
}
//
// Copy Required Items ...
int CopyFutureSenkouSpanA(
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,
senkouSpanABuffer,
buffer,
forceClean
//
);
}
//
// SenkouSpanB ...
//
double GetFutureSenkouSpanB(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return senkouSpanBBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyFutureSenkouSpanB(
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,
senkouSpanBBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XICHInputs mInputs; // Inputs ...
//
// Buffers ...
double tenkanSenBuffer[];
double kijunSenBuffer[];
double chikouSpanBuffer[];
double senkouSpanABuffer[];
double senkouSpanBBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
int calculatedBars = CountCalculatedBars();
//
// TenkanSen ...
CopyBuffer(
mHandler,
X_ICH_TEANKANSEN_LINE,
0,
totalBars,
tenkanSenBuffer
//
);
//
// KijunSen ...
CopyBuffer(
mHandler,
X_ICH_KIJUNSEN_LINE,
0,
totalBars,
kijunSenBuffer
//
);
//
// ChikouSpan ...
CopyBuffer(
mHandler,
X_ICH_CHIKOUSPAN_LINE,
0,
totalBars,
chikouSpanBuffer
//
);
//
// SenkouSpan A ...
CopyBuffer(
mHandler,
X_ICH_SENKOUSPANA_LINE,
0,
totalBars,
senkouSpanABuffer
//
);
//
// SenkouSpan B ...
CopyBuffer(
mHandler,
X_ICH_SENKOUSPANB_LINE,
0,
totalBars,
senkouSpanBBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,422 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXLHHelper
// 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_XLH_BUFFERS
{
XLH_HH_LINE = 0,
XLH_LL_LINE = 1,
XLH_SIGNAL_LINE = 2,
};
//
// Input Models ...
struct XLHInputs
{
//
// Props ...
int length; // Length
ENUM_SERIESMODE hhMode; // Highest High Calculation Method
ENUM_SERIESMODE llMode; // Lowest Low Calculation Method
//
// Constructor(s) ...
XLHInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
hhMode = MODE_HIGH;
llMode = MODE_LOW;
}
//
// Default ...
void Default()
{
//
length = 14;
hhMode = MODE_HIGH;
llMode = MODE_LOW;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 2
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, length);
//
return result;
}
};
//
// Class ...
class XSCXLHHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXLHHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXLHHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XLHInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(hhBuffer, true);
ArraySetAsSeries(llBuffer, true);
ArraySetAsSeries(signalBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xlh",
//
// Inputs ...
mInputs.length, // Length
mInputs.hhMode, // Highest High Calculation Method
mInputs.llMode // Lowest Low Calculation Method
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XLHInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XLHInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetHH(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(hhBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return hhBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyHH(
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,
hhBuffer,
buffer,
forceClean
//
);
}
//
double GetLL(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(llBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return llBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLL(
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,
llBuffer,
buffer,
forceClean
//
);
}
//
double GetSignal(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(signalBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return signalBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySignal(
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,
signalBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XLHInputs mInputs; // Inputs ...
//
// Buffers ...
double hhBuffer[];
double llBuffer[];
double signalBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// HH ...
CopyBuffer(
mHandler,
XLH_HH_LINE,
0,
totalBars,
hhBuffer
//
);
//
// LL ...
CopyBuffer(
mHandler,
XLH_LL_LINE,
0,
totalBars,
llBuffer
//
);
//
// Signal ...
CopyBuffer(
mHandler,
XLH_SIGNAL_LINE,
0,
totalBars,
signalBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,497 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXMCHelper
// 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
//
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XMC_BUFFERS
{
X_MC_FAST_LINE = 0,
X_MC_SLOW_LINE = 1,
X_MC_VERIFIER_LINE = 2,
};
//
// Input Models ...
struct XMCInputs
{
//
// Props ...
//
// Market ...
//
// Fast ...
int fastLength; // Length
int fastShift; // Shift
ENUM_MA_METHOD fastMethod; // Method
ENUM_APPLIED_PRICE fastAppliedTo; // Applied To
//
// Slow ...
int slowLength; // Length
int slowShift; // Shift
ENUM_MA_METHOD slowMethod; // Method
ENUM_APPLIED_PRICE slowAppliedTo; // Applied To
//
// Verifier ...
int verifierLength; // Length
int verifierShift; // Shift
ENUM_MA_METHOD verifierMethod; // Method
ENUM_APPLIED_PRICE verifierAppliedTo; // Applied To
//
// Presentation ...
bool showFastMa; // Show Fast
bool showSlowMa; // Show Slow
bool showVerifierMa; // Show Verifier
//
// Constructor(s) ...
XMCInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
fastLength = 0;
fastShift = 0;
fastMethod = 0;
fastAppliedTo = PRICE_CLOSE;
//
slowLength = 0;
slowShift = 0;
slowMethod = 0;
slowAppliedTo = PRICE_CLOSE;
//
verifierLength = 0;
verifierShift = 0;
verifierMethod = 0;
verifierAppliedTo = PRICE_CLOSE;
//
showFastMa = false;
showSlowMa = false;
showVerifierMa = false;
}
//
// Default ...
void Default()
{
//
fastLength = 9;
fastShift = 0;
fastMethod = MODE_EMA;
fastAppliedTo = PRICE_CLOSE;
//
slowLength = 18;
slowShift = 0;
slowMethod = MODE_EMA;
slowAppliedTo = PRICE_CLOSE;
//
verifierLength = 200;
verifierShift = 0;
verifierMethod = MODE_EMA;
verifierAppliedTo = PRICE_CLOSE;
//
showFastMa = true;
showSlowMa = true;
showVerifierMa = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
fastLength > 1 &&
slowLength > fastLength &&
verifierLength > slowLength
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(fastLength, slowLength);
result = MathMax(result, verifierLength);
//
return result;
}
};
//
// Class ...
class XSCXMCHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXMCHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXMCHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XMCInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(fastBuffer, true);
ArraySetAsSeries(slowBuffer, true);
ArraySetAsSeries(verifierBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xmc",
//
// Inputs ...
//
// Fast ...
"",
mInputs.fastLength,
mInputs.fastShift,
mInputs.fastMethod,
mInputs.fastAppliedTo,
//
// Slow ...
"",
mInputs.slowLength,
mInputs.slowShift,
mInputs.slowMethod,
mInputs.slowAppliedTo,
//
// Verifier ...
"",
mInputs.verifierLength,
mInputs.verifierShift,
mInputs.verifierMethod,
mInputs.verifierAppliedTo,
//
// Presentation ...
"",
mInputs.showFastMa, // Show Fast,
mInputs.showSlowMa, // Show Slow,
mInputs.showVerifierMa // Show Verifier
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XMCInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XMCInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs);
}
//
// Buffers ...
//
// Fast ...
//
double GetFast(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return fastBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyFast(
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,
fastBuffer,
buffer,
forceClean
//
);
}
//
// Slow ...
//
double GetSlow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return slowBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySlow(
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,
slowBuffer,
buffer,
forceClean
//
);
}
//
// Verifier ...
//
double GetVerifier(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return verifierBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyVerifier(
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,
verifierBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XMCInputs mInputs; // Inputs ...
//
// Buffers ...
//
double fastBuffer[];
double slowBuffer[];
double verifierBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
int calculatedBars = CountCalculatedBars();
//
// Fast ...
CopyBuffer(
mHandler,
X_MC_FAST_LINE,
0,
totalBars,
fastBuffer
//
);
//
// Slow ...
CopyBuffer(
mHandler,
X_MC_SLOW_LINE,
0,
totalBars,
slowBuffer
//
);
//
// Verifier ...
CopyBuffer(
mHandler,
X_MC_VERIFIER_LINE,
0,
totalBars,
verifierBuffer
//
);
}
};
//
// Tools ...
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,306 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXOBDHelper
// 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_XOBD_BUFFERS
{
XOBD_MAIN_LINE = 0
};
//
// Input Models ...
struct XOBDInputs
{
//
// Props ...
//
int length; // Swing Length
//
uchar swingHighArrowCode; // Swing High Arrow Code
color swingHighArrowColor; // Swing High Arrow Color
//
uchar swingLowArrowCode; // Swing Low Arrow Code
color swingLowArrowColor; // Swing Low Arrow Color
//
// Constructor(s) ...
XOBDInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
swingHighArrowCode = 0;
swingHighArrowColor = CLR_NONE;
swingLowArrowCode = 0;
swingLowArrowColor = CLR_NONE;
}
//
// Default ...
void Default()
{
//
length = 5;
swingHighArrowCode = 0;
swingHighArrowColor = CLR_NONE;
swingLowArrowCode = 0;
swingLowArrowColor = CLR_NONE;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 3
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, length);
//
return result;
}
};
//
// Class ...
class XSCXOBDHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXOBDHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXOBDHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XOBDInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(mainBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xobd",
//
// Inputs ...
mInputs.length, // Swing Length
mInputs.swingHighArrowCode, // Swing High Arrow Code
mInputs.swingHighArrowColor, // Swing High Arrow Color
mInputs.swingLowArrowCode, // Swing Low Arrow Code
mInputs.swingLowArrowColor // Swing Low Arrow Color
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XOBDInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XOBDInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetMain(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mainBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mainBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMain(
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,
mainBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XOBDInputs mInputs; // Inputs ...
//
// Buffers ...
double mainBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Main ...
CopyBuffer(
mHandler,
XOBD_MAIN_LINE,
0,
totalBars,
mainBuffer
//
);
}
};
//
// Tools ...
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,392 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXRSIHelper
// 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_XRSI_BUFFERS
{
XRSI_MAIN_LINE = 0
};
//
// Input Models ...
struct XRSIInputs
{
//
// Props ...
//
// Market ...
int length; // Market Length
ENUM_APPLIED_PRICE appliedTo; // Applied To
//
// Short Entry ...
double shortEntryValue; // Short Entry Level
color shortEntryColor; // Short Entry Level Color
ENUM_LINE_STYLE shortEntryLineStyle; // Short Entry Style
//
// Short Exit ...
double shortExitValue; // Short Exit Level
color shortExitColor; // Short Exit Level Color
ENUM_LINE_STYLE shortExitLineStyle; // Short Exit Style
//
// Long Entry ...
double longEntryValue; // Long Entry Level
color longEntryColor; // Long Entry Level Color
ENUM_LINE_STYLE longEntryLineStyle; // Long Entry Style
//
// Long Exit ...
double longExitValue; // Long Exit Level
color longExitColor; // Long Exit Level Color
ENUM_LINE_STYLE longExitLineStyle; // Long Exit Style
//
// Constructor(s) ...
XRSIInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Market ...
length = 0;
appliedTo = PRICE_CLOSE;
//
// Short Entry ...
shortEntryValue = 0;
shortEntryColor = CLR_NONE;
shortEntryLineStyle = STYLE_DOT;
//
// Short Exit ...
shortExitValue = 0;
shortExitColor = CLR_NONE;
shortExitLineStyle = STYLE_DOT;
//
// Long Entry ...
longEntryValue = 0;
longEntryColor = CLR_NONE;
longEntryLineStyle = STYLE_DOT;
//
// Long Exit ...
longExitValue = 0;
longExitColor = CLR_NONE;
longExitLineStyle = STYLE_DOT;
}
//
// Default ...
void Default()
{
//
// Market ...
length = 14;
appliedTo = PRICE_CLOSE;
//
// Short Entry ...
shortEntryValue = 70;
shortEntryColor = CLR_NONE;
shortEntryLineStyle = STYLE_DOT;
//
// Short Exit ...
shortExitValue = 40;
shortExitColor = CLR_NONE;
shortExitLineStyle = STYLE_DOT;
//
// Long Entry ...
longEntryValue = 30;
longEntryColor = CLR_NONE;
longEntryLineStyle = STYLE_DOT;
//
// Long Exit ...
longExitValue = 60;
longExitColor = CLR_NONE;
longExitLineStyle = STYLE_DOT;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 2
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, length);
//
return result;
}
};
//
// Class ...
class XSCXRSIHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXRSIHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXRSIHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XRSIInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(mainBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xrsi",
//
// Inputs ...
//
// Market ...
"",
mInputs.length, // Market Length
mInputs.appliedTo, // Applied To
//
// Short Entry ...
"",
mInputs.shortEntryValue, // Short Entry Level
mInputs.shortEntryColor, // Short Entry Level Color
mInputs.shortEntryLineStyle, // Short Entry Style
//
// Short Exit ...
"",
mInputs.shortExitValue, // Short Exit Level
mInputs.shortExitColor, // Short Exit Level Color
mInputs.shortExitLineStyle, // Short Exit Style
//
// Long Entry ...
"",
mInputs.longEntryValue, // Long Entry Level
mInputs.longEntryColor, // Long Entry Level Color
mInputs.longEntryLineStyle, // Long Entry Style
//
// Long Exit ...
"",
mInputs.longExitValue, // Long Exit Level
mInputs.longExitColor, // Long Exit Level Color
mInputs.longExitLineStyle // Long Exit Style
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XRSIInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XRSIInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetMain(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mainBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mainBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMain(
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,
mainBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XRSIInputs mInputs; // Inputs ...
//
// Buffers ...
double mainBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Main ...
CopyBuffer(
mHandler,
XRSI_MAIN_LINE,
0,
totalBars,
mainBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,408 @@
///////////////////////////////////////////////////////
//
// 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 ...
@@ -0,0 +1,421 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXSTRHelper
// 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
//
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// Definitions ...
//
enum ENUM_XSTR_BUFFERS
{
X_STR_TREND_LINE = 0,
X_STR_STATE_LINE = 5,
};
//
enum ENUM_XSTR_TREND_STATES
{
X_STR_BULLISH = 1, // Bullish
X_STR_BEARISH = -1, // Bearish
};
//
// Input Models ...
struct XSTRInputs
{
//
// Props ...
//
// Market ...
int length; // Length
double multiplier; // Multiplier
ENUM_APPLIED_PRICE appliedTo; // Applied To
//
// Presentation ...
bool showTrends; // Show Trends
bool fillTrends; // Fill Trends
//
// Constructor(s) ...
XSTRInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
multiplier = 0;
appliedTo = PRICE_CLOSE;
//
showTrends = false;
fillTrends = false;
}
//
// Default ...
void Default()
{
//
length = 14;
multiplier = 3.5;
appliedTo = PRICE_MEDIAN;
//
showTrends = true;
fillTrends = false;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length > 0 &&
multiplier > 0
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = length;
//
return result;
}
};
//
// Class ...
class XSCXSTRHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXSTRHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXSTRHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XSTRInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(trendBuffer, true);
ArraySetAsSeries(stateBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xstr",
//
// Inputs ...
//
// ATR ...
"",
mInputs.length, // Length
mInputs.multiplier, // Multiplier
mInputs.appliedTo, // Applied To
//
// Presentation ...
"",
mInputs.showTrends, // Show Trends
mInputs.fillTrends // Fill Trends
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XSTRInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XSTRInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs);
}
//
// Buffers ...
//
// Trend ...
//
double GetTrend(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return trendBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyTrend(
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,
trendBuffer,
buffer,
forceClean
//
);
}
//
// State ...
//
ENUM_XSTR_TREND_STATES GetState(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return (ENUM_XSTR_TREND_STATES)((int)stateBuffer[barIndex]);
}
//
// Copy Required Buffer ...
int CopyState(
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,
stateBuffer,
buffer,
forceClean
//
);
}
//
// Tools ...
//
ENUM_XSTR_TREND_STATES ToState(double state)
{
return (ENUM_XSTR_TREND_STATES)((int)state);
}
//
bool IsBullish(double state)
{
//
bool result = false;
//
result =
//
ToState(state) == X_STR_BULLISH;
//
;
//
return result;
}
//
bool IsBearish(double state)
{
//
bool result = false;
//
result =
//
ToState(state) == X_STR_BEARISH;
//
;
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XSTRInputs mInputs; // Inputs ...
//
// Buffers ...
double trendBuffer[];
double stateBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
int calculatedBars = CountCalculatedBars();
//
// Trend ...
CopyBuffer(
mHandler,
X_STR_TREND_LINE,
0,
totalBars,
trendBuffer
//
);
//
// State ...
CopyBuffer(
mHandler,
X_STR_STATE_LINE,
0,
totalBars,
stateBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,458 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXTDHelper
// 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_XTD_BUFFERS
{
XTD_BULLISH_LINE = 0,
XTD_BEARISH_LINE = 1,
XTD_SIGNAL_LINE = 2,
};
//
// Input Models ...
struct XTDInputs
{
//
// Props ...
//
int length; // Market Length
bool drawCrosses; // Draw Cross Arrows
//
// Bullish ...
uchar bullishArrowCode; // Cross Over Arrow Code
color bullishArrowColor; // Cross Over Arrow Color
//
// Bearish ...
uchar bearishArrowCode; // Cross Under Arrow Code
color bearishArrowColor; // Cross Under Arrow Color
//
// Constructor(s) ...
XTDInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
drawCrosses = false;
//
// Bullish ...
bullishArrowCode = 228;
bullishArrowColor = CLR_NONE;
//
// Bearish ...
bearishArrowCode = 230;
bearishArrowColor = CLR_NONE;
}
//
// Default ...
void Default()
{
//
length = 14;
drawCrosses = false;
//
// Bullish ...
bullishArrowCode = 228;
bullishArrowColor = CLR_NONE;
//
// Bearish ...
bearishArrowCode = 230;
bearishArrowColor = CLR_NONE;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length >= 2
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, length);
//
return result;
}
};
//
// Class ...
class XSCXTDHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXTDHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXTDHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XTDInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(bullishBuffer, true);
ArraySetAsSeries(bearishBuffer, true);
ArraySetAsSeries(signalBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xtd",
//
// Inputs ...
//
mInputs.length, // Market Length
mInputs.drawCrosses, // Draw Cross Arrows
//
// Bullish ...
mInputs.bullishArrowCode, // Cross Over Arrow Code
mInputs.bullishArrowColor, // Cross Over Arrow Color
//
// Bearish ...
mInputs.bearishArrowCode, // Cross Under Arrow Code
mInputs.bearishArrowColor // Cross Under Arrow Color
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XTDInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XTDInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetBullish(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(bullishBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return bullishBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyBullish(
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,
bullishBuffer,
buffer,
forceClean
//
);
}
//
double GetBearish(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(bearishBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return bearishBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyBearish(
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,
bearishBuffer,
buffer,
forceClean
//
);
}
//
double GetSignal(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(signalBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return signalBuffer[barIndex];
}
//
// Copy Required Items ...
int CopySignal(
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,
signalBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XTDInputs mInputs; // Inputs ...
//
// Buffers ...
double bullishBuffer[];
double bearishBuffer[];
double signalBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Bullish ...
CopyBuffer(
mHandler,
XTD_BULLISH_LINE,
0,
totalBars,
bullishBuffer
//
);
//
// Bearish ...
CopyBuffer(
mHandler,
XTD_BEARISH_LINE,
0,
totalBars,
bearishBuffer
//
);
//
// Signal ...
CopyBuffer(
mHandler,
XTD_SIGNAL_LINE,
0,
totalBars,
signalBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,310 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXTMHelper
// 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_XTM_BUFFERS
{
XTM_MAIN_LINE = 0
};
//
// Input Models ...
struct XTMInputs
{
//
// Props ...
//
// Market ...
int maPeriod; // Period
int maShift; // Shift
ENUM_MA_METHOD maMethod; // Method
ENUM_APPLIED_PRICE maAppliedTo; // Applied To
//
// Presentation ...
bool showLine; // Show Line
//
// Constructor(s) ...
XTMInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
maShift = 0;
maPeriod = 0;
showLine = false;
maMethod = MODE_SMA;
maAppliedTo = PRICE_CLOSE;
}
//
// Default ...
void Default()
{
//
maShift = 0;
maPeriod = 14;
showLine = true;
maMethod = MODE_SMA;
maAppliedTo = PRICE_CLOSE;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
maPeriod >= 2
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, maPeriod);
//
return result;
}
};
//
// Class ...
class XSCXTMHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXTMHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXTMHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XTMInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(mainBuffer, true);
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xtm",
//
// Inputs ...
//
// Market ...
"",
mInputs.maPeriod, // Period
mInputs.maShift, // Shift
mInputs.maMethod, // Method
mInputs.maAppliedTo, // Applied To
//
// Presentation ...
"",
mInputs.showLine // Show Line
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XTMInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XTMInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetMain(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mainBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mainBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMain(
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,
mainBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XTMInputs mInputs; // Inputs ...
//
// Buffers ...
double mainBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Main Buffer ...
CopyBuffer(
mHandler,
XTM_MAIN_LINE,
0,
totalBars,
mainBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,550 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXTSHelper
// 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_XTS_BUFFERS
{
XTS_CURRENT_LINE = 0,
XTS_NEAREST_LINE = 1,
XTS_MEDIEST_LINE = 2,
XTS_FAREST_LINE = 3,
};
//
// Input Models ...
struct XTSInputs
{
//
// Props ...
//
// Current Period ...
ENUM_APPLIED_PRICE currentAppliedTo; // Current Applied To
//
// Nearest Period ...
ENUM_X_PERIOD_METHOD nearestMethod; // How to Find Nearest Period
ENUM_TIMEFRAMES nearestPeriod; // Nearest Time Frame
ENUM_APPLIED_PRICE nearestAppliedTo; // Nearest Applied To
//
// Mediest Period ...
ENUM_X_PERIOD_METHOD mediestMethod; // How to Find Mediest Period
ENUM_TIMEFRAMES mediestPeriod; // Mediest Time Frame
ENUM_APPLIED_PRICE mediestAppliedTo; // Mediest Applied To
//
// Farest Period ...
ENUM_X_PERIOD_METHOD farestMethod; // How to Find Farest Period
ENUM_TIMEFRAMES farestPeriod; // Farest Time Frame
ENUM_APPLIED_PRICE farestAppliedTo; // Farest Applied To
//
// Constructor(s) ...
XTSInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Current Period ...
currentAppliedTo = PRICE_CLOSE;
//
// Nearest Period ...
nearestMethod = X_PERIOD_NOTHING;
nearestPeriod = NULL;
nearestAppliedTo = PRICE_CLOSE;
//
// Mediest Period ...
mediestMethod = X_PERIOD_NOTHING;
mediestPeriod = NULL;
mediestAppliedTo = PRICE_CLOSE;
//
// Farest Period ...
farestMethod = X_PERIOD_NOTHING;
farestPeriod = NULL;
farestAppliedTo = PRICE_CLOSE;
}
//
// Default ...
void Default()
{
//
// Current Period ...
currentAppliedTo = PRICE_CLOSE;
//
// Nearest Period ...
nearestMethod = X_PERIOD_AUTO;
nearestPeriod = NULL;
nearestAppliedTo = PRICE_CLOSE;
//
// Mediest Period ...
mediestMethod = X_PERIOD_AUTO;
mediestPeriod = NULL;
mediestAppliedTo = PRICE_CLOSE;
//
// Farest Period ...
farestMethod = X_PERIOD_AUTO;
farestPeriod = NULL;
farestAppliedTo = PRICE_CLOSE;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
IsValid(nearestMethod, nearestPeriod) &&
IsValid(mediestMethod, mediestPeriod) &&
IsValid(farestMethod, farestPeriod)
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(result, 0);
//
return result;
}
};
//
// Class ...
class XSCXTSHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXTSHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXTSHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XTSInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(currentBuffer, true);
ArraySetAsSeries(nearestBuffer, true);
ArraySetAsSeries(mediestBuffer, true);
ArraySetAsSeries(farestBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xts",
//
// Inputs ...
//
// Current Period ...
"",
mInputs.currentAppliedTo, // Current Applied To
//
// Nearest Period ...
"",
mInputs.nearestMethod, // How to Find Nearest Period
mInputs.nearestPeriod, // Nearest Time Frame
mInputs.nearestAppliedTo, // Nearest Applied To
//
// Mediest Period ...
"",
mInputs.mediestMethod, // How to Find Mediest Period
mInputs.mediestPeriod, // Mediest Time Frame
mInputs.mediestAppliedTo, // Mediest Applied To
//
// Farest Period ...
"",
mInputs.farestMethod, // How to Find Farest Period
mInputs.farestPeriod, // Farest Time Frame
mInputs.farestAppliedTo // Farest Applied To
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XTSInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XTSInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetCurrent(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(currentBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return currentBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyCurrent(
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,
currentBuffer,
buffer,
forceClean
//
);
}
//
double GetNearest(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(nearestBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return nearestBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyNearest(
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,
nearestBuffer,
buffer,
forceClean
//
);
}
//
double GetMediest(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mediestBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mediestBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMediest(
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,
mediestBuffer,
buffer,
forceClean
//
);
}
//
double GetFarest(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(farestBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return farestBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyFarest(
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,
farestBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XTSInputs mInputs; // Inputs ...
//
// Buffers ...
double currentBuffer[];
double nearestBuffer[];
double mediestBuffer[];
double farestBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Current ...
CopyBuffer(
mHandler,
XTS_CURRENT_LINE,
0,
totalBars,
currentBuffer
//
);
//
// Nearest ...
CopyBuffer(
mHandler,
XTS_NEAREST_LINE,
0,
totalBars,
nearestBuffer
//
);
//
// Mediest ...
CopyBuffer(
mHandler,
XTS_MEDIEST_LINE,
0,
totalBars,
mediestBuffer
//
);
//
// Farest ...
CopyBuffer(
mHandler,
XTS_FAREST_LINE,
0,
totalBars,
farestBuffer
//
);
}
};
//
// Tools ...
@@ -0,0 +1,527 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXZGHelper
// 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 ...
//
// How to Calculate Up and Down Price ...
enum ENUM_X_ZG_PRICE_MODE
{
//
X_ZG_PRICE_HIGH_LOW_MODE = 1,
X_ZG_PRICE_OPEN_CLOSE_MODE = 2,
};
//
enum ENUM_XZG_BUFFERS
{
//
XZG_MAIN_LINE = 0,
XZG_PEAKSANDVALES_LINE = 2,
XZG_HIGHS_LINE = 4,
XZG_LOWS_LINE = 5,
};
//
// Input Models ...
struct XZGInputs
{
//
// Props ...
//
// Market ...
int depth; // Depth
int deviation; // Deviation
int backStep; // Back Step
ENUM_X_ZG_PRICE_MODE mode; // Mode
//
// Presentation ...
bool showZigZag; // Show ZigZag
bool showPeaksAndVales; // Show Peaks and Vales
//
// Constructor(s) ...
XZGInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
// Market ...
depth = 0;
deviation = 0;
backStep = 0;
mode = X_ZG_PRICE_HIGH_LOW_MODE;
//
// Presentation ...
showZigZag = false;
showPeaksAndVales = false;
}
//
// Default ...
void Default()
{
//
// Market ...
depth = 12;
deviation = 5;
backStep = 3;
mode = X_ZG_PRICE_HIGH_LOW_MODE;
//
// Presentation ...
showZigZag = true;
showPeaksAndVales = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
depth > 0 &&
deviation > 0 &&
backStep > 0
//
;
//
return result;
}
//
// Retrieve MAx Length ...
int Max()
{
//
int result = 0;
//
result = MathMax(backStep, depth);
//
return result;
}
};
//
// Class ...
class XSCXZGHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXZGHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXZGHelper() {}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XZGInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(mainBuffer, true);
ArraySetAsSeries(PeaksAndValesBuffer, true);
ArraySetAsSeries(highsBuffer, true);
ArraySetAsSeries(lowsBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xzg",
//
// Inputs ...
//
// Market ...
"",
mInputs.depth, // Depth
mInputs.deviation, // Deviation
mInputs.backStep, // Back Step
mInputs.mode, // Mode
//
// Presentation ...
"",
mInputs.showZigZag, // Show ZigZag
mInputs.showPeaksAndVales // Show Peaks and Vales
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Inputs ...
//
XZGInputs GetInputs()
{
return mInputs;
}
//
bool SetInputs(
XZGInputs &inputs // Configs
)
{
//
return Init(
mSymbol,
mPeriod,
inputs
//
);
}
//
// Buffers ...
//
double GetMain(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(mainBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return mainBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyMain(
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,
mainBuffer,
buffer,
forceClean
//
);
}
//
double GetPeaksAndVales(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(PeaksAndValesBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return PeaksAndValesBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyPeaksAndVales(
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,
PeaksAndValesBuffer,
buffer,
forceClean
//
);
}
//
double GetHigh(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(highsBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return highsBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyHigh(
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,
highsBuffer,
buffer,
forceClean
//
);
}
//
double GetLow(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(lowsBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return lowsBuffer[barIndex];
}
//
// Copy Required Items ...
int CopyLow(
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,
lowsBuffer,
buffer,
forceClean
//
);
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XZGInputs mInputs; // Inputs ...
//
// Buffers ...
double mainBuffer[];
double PeaksAndValesBuffer[];
double highsBuffer[];
double lowsBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
//
// Main Buffer ...
CopyBuffer(
mHandler,
XZG_MAIN_LINE,
0,
totalBars,
mainBuffer
//
);
//
// Peaks and Vales Buffer ...
CopyBuffer(
mHandler,
XZG_PEAKSANDVALES_LINE,
0,
totalBars,
PeaksAndValesBuffer
//
);
//
// Highs Buffer ...
CopyBuffer(
mHandler,
XZG_HIGHS_LINE,
0,
totalBars,
highsBuffer
//
);
//
// Lows Buffer ...
CopyBuffer(
mHandler,
XZG_LOWS_LINE,
0,
totalBars,
lowsBuffer
//
);
}
};
//
// Tools ...