add all required indicator and oscillators and also add all helper classes for them ...
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// SaherElm IT Center MQL5 Helper Class Library
|
// SaherElm IT Center MQL5 Helper Class Library
|
||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
// Name: XSCXSSLCHelper
|
// Name: XSCXZGHelper
|
||||||
// Description: provides all Indicator
|
// Description: provides all Indicator
|
||||||
// Helper requirements ...
|
// Helper requirements ...
|
||||||
//
|
//
|
||||||
@@ -28,21 +28,21 @@
|
|||||||
// Definitions ...
|
// Definitions ...
|
||||||
|
|
||||||
//
|
//
|
||||||
enum ENUM_XSSLC_BUFFERS
|
enum ENUM_XZG_BUFFERS
|
||||||
{
|
{
|
||||||
XSSLC_MAIN_LINE = 0
|
XZG_MAIN_LINE = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Input Models ...
|
// Input Models ...
|
||||||
struct XSSLCInputs
|
struct XZGInputs
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor(s) ...
|
// Constructor(s) ...
|
||||||
XSSLCInputs()
|
XZGInputs()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Clean();
|
Clean();
|
||||||
@@ -100,7 +100,7 @@ struct XSSLCInputs
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Class ...
|
// Class ...
|
||||||
class XSCXSSLCHelper : public XSCBaseHelper
|
class XSCXZGHelper : public XSCBaseHelper
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Public ...
|
// Public ...
|
||||||
@@ -110,20 +110,20 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Constructors ...
|
// Constructors ...
|
||||||
XSCXSSLCHelper() : XSCBaseHelper(_Symbol, _Period)
|
XSCXZGHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Deconstructor ...
|
// Deconstructor ...
|
||||||
~XSCXSSLCHelper() {}
|
~XSCXZGHelper() {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tools ...
|
// Tools ...
|
||||||
bool Init(
|
bool Init(
|
||||||
string symbol, // Trading Symbol
|
string symbol, // Trading Symbol
|
||||||
ENUM_TIMEFRAMES period, // Trading Period
|
ENUM_TIMEFRAMES period, // Trading Period
|
||||||
XSSLCInputs &inputs // Inputs
|
XZGInputs &inputs // Inputs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -167,14 +167,14 @@ public:
|
|||||||
// Inputs ...
|
// Inputs ...
|
||||||
|
|
||||||
//
|
//
|
||||||
XSSLCInputs GetInputs()
|
XZGInputs GetInputs()
|
||||||
{
|
{
|
||||||
return mInputs;
|
return mInputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool SetInputs(
|
bool SetInputs(
|
||||||
XSSLCInputs &inputs // Configs
|
XZGInputs &inputs // Configs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -247,7 +247,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
XSSLCInputs mInputs; // Inputs ...
|
XZGInputs mInputs; // Inputs ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Buffers ...
|
// Buffers ...
|
||||||
@@ -267,7 +267,7 @@ private:
|
|||||||
// // Main Buffer ...
|
// // Main Buffer ...
|
||||||
// CopyBuffer(
|
// CopyBuffer(
|
||||||
// mHandler,
|
// mHandler,
|
||||||
// XSSLC_MAIN_LINE,
|
// XZG_MAIN_LINE,
|
||||||
// 0,
|
// 0,
|
||||||
// totalBars,
|
// totalBars,
|
||||||
// mainBuffer
|
// mainBuffer
|
||||||
@@ -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,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 XXCTInputs
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
color clr; // Text Color
|
||||||
|
ENUM_BASE_CORNER corner; // Text Position
|
||||||
|
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
bool showCandleTime; // Show Candle Time
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor(s) ...
|
||||||
|
XXCTInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
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
|
||||||
|
XXCTInputs &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 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XXCTInputs GetInputs()
|
||||||
|
{
|
||||||
|
return mInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool SetInputs(
|
||||||
|
XXCTInputs &inputs // Configs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return Init(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
inputs
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protected ...
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
// Private ...
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
XXCTInputs mInputs; // Inputs ...
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
@@ -0,0 +1,831 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Helper Class Library
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Name: XSCXDONHelper
|
||||||
|
// Description: provides all Indicator
|
||||||
|
// Helper requirements ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property library
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://www.saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
enum ENUM_XDON_BUFFERS
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Open ...
|
||||||
|
XDON_UPPER_O_LINE = 0,
|
||||||
|
XDON_LOWER_O_LINE = 1,
|
||||||
|
//
|
||||||
|
// Close ...
|
||||||
|
XDON_UPPER_C_LINE = 2,
|
||||||
|
XDON_LOWER_C_LINE = 3,
|
||||||
|
//
|
||||||
|
// High ...
|
||||||
|
XDON_UPPER_H_LINE = 4,
|
||||||
|
XDON_LOWER_H_LINE = 5,
|
||||||
|
//
|
||||||
|
// Low ...
|
||||||
|
XDON_UPPER_L_LINE = 6,
|
||||||
|
XDON_LOWER_L_LINE = 7,
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Input Models ...
|
||||||
|
struct XDONInputs
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
int length; // Market Length
|
||||||
|
double offset; // Offset
|
||||||
|
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
bool showOpen; // Show Open
|
||||||
|
bool showHigh; // Show High
|
||||||
|
bool showClose; // Show Close
|
||||||
|
bool showLow; // Show Low
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor(s) ...
|
||||||
|
XDONInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clean ...
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
length = 0;
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
showOpen = false;
|
||||||
|
showHigh = false;
|
||||||
|
showClose = false;
|
||||||
|
showLow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Default ...
|
||||||
|
void Default()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
length = 52;
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
showOpen = true;
|
||||||
|
showHigh = true;
|
||||||
|
showClose = true;
|
||||||
|
showLow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
length >= 5 &&
|
||||||
|
offset >= 0
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve MAx Length ...
|
||||||
|
int Max()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = MathMax(0, length);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class ...
|
||||||
|
class XSCXDONHelper : public XSCBaseHelper
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Public ...
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructors ...
|
||||||
|
XSCXDONHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
~XSCXDONHelper() {}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
bool Init(
|
||||||
|
string symbol, // Trading Symbol
|
||||||
|
ENUM_TIMEFRAMES period, // Trading Period
|
||||||
|
XDONInputs &inputs // Inputs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
mSymbol = symbol;
|
||||||
|
mPeriod = period;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = inputs.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mInputs = inputs;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(upperOBuffer, true);
|
||||||
|
ArraySetAsSeries(lowerOBuffer, true);
|
||||||
|
ArraySetAsSeries(upperCBuffer, true);
|
||||||
|
ArraySetAsSeries(lowerCBuffer, true);
|
||||||
|
ArraySetAsSeries(upperHBuffer, true);
|
||||||
|
ArraySetAsSeries(lowerHBuffer, true);
|
||||||
|
ArraySetAsSeries(upperLBuffer, true);
|
||||||
|
ArraySetAsSeries(lowerLBuffer, true);
|
||||||
|
|
||||||
|
//
|
||||||
|
mHandler = iCustom(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
"x-saherelm.xdon",
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
"",
|
||||||
|
mInputs.length, // Market Length
|
||||||
|
mInputs.offset, // Offset
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
"",
|
||||||
|
mInputs.showOpen, // Show Open
|
||||||
|
mInputs.showHigh, // Show High
|
||||||
|
mInputs.showClose, // Show Close
|
||||||
|
mInputs.showLow // Show Low
|
||||||
|
//
|
||||||
|
);
|
||||||
|
result = mHandler != INVALID_HANDLE;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XDONInputs GetInputs()
|
||||||
|
{
|
||||||
|
return mInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool SetInputs(
|
||||||
|
XDONInputs &inputs // Configs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return Init(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
inputs
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetUpperO(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(upperOBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return upperOBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyUpperO(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
upperOBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetLowerO(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(lowerOBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return lowerOBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyLowerO(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
lowerOBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetUpperC(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(upperCBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return upperCBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyUpperC(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
upperCBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetLowerC(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(lowerCBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return lowerCBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyLowerC(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
lowerCBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// High ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetUpperH(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(upperHBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return upperHBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyUpperH(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
upperHBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetLowerH(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(lowerHBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return lowerHBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyLowerH(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
lowerHBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Low ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetUpperL(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(upperLBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return upperLBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyUpperL(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
upperLBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetLowerL(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(lowerLBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return lowerLBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyLowerL(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
lowerLBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protected ...
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
// Private ...
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
XDONInputs mInputs; // Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
double upperOBuffer[];
|
||||||
|
double lowerOBuffer[];
|
||||||
|
double upperCBuffer[];
|
||||||
|
double lowerCBuffer[];
|
||||||
|
double upperHBuffer[];
|
||||||
|
double lowerHBuffer[];
|
||||||
|
double upperLBuffer[];
|
||||||
|
double lowerLBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Values Until Now ...
|
||||||
|
void Calculate()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int totalBars = CountBars();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_UPPER_O_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
upperOBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_LOWER_O_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
lowerOBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_UPPER_C_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
upperCBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_LOWER_C_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
lowerCBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// High ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_UPPER_H_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
upperHBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_LOWER_H_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
lowerHBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Low ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_UPPER_L_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
upperLBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower Buffer ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XDON_LOWER_L_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
lowerLBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
@@ -0,0 +1,399 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Helper Class Library
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Name: XSCXHULLCHelper
|
||||||
|
// 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 XHULLCInputs
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// 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) ...
|
||||||
|
XHULLCInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
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 XSCXHULLCHelper : public XSCBaseHelper
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Public ...
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructors ...
|
||||||
|
XSCXHULLCHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
~XSCXHULLCHelper() {}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
bool Init(
|
||||||
|
string symbol, // Trading Symbol
|
||||||
|
ENUM_TIMEFRAMES period, // Trading Period
|
||||||
|
XHULLCInputs &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 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XHULLCInputs GetInputs()
|
||||||
|
{
|
||||||
|
return mInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool SetInputs(
|
||||||
|
XHULLCInputs &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 ...
|
||||||
|
XHULLCInputs 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,755 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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,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,421 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Helper Class Library
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Name: XSCXSTRRHelper
|
||||||
|
// 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 XSTRRInputs
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// 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) ...
|
||||||
|
XSTRRInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
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 XSCXSTRRHelper : public XSCBaseHelper
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Public ...
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructors ...
|
||||||
|
XSCXSTRRHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
~XSCXSTRRHelper() {}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
bool Init(
|
||||||
|
string symbol, // Trading Symbol
|
||||||
|
ENUM_TIMEFRAMES period, // Trading Period
|
||||||
|
XSTRRInputs &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 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XSTRRInputs GetInputs()
|
||||||
|
{
|
||||||
|
return mInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool SetInputs(
|
||||||
|
XSTRRInputs &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 ...
|
||||||
|
XSTRRInputs 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,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 GetPeaksAndValues(
|
||||||
|
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 CopyPeaksAndValues(
|
||||||
|
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 ...
|
||||||
@@ -24,9 +24,17 @@
|
|||||||
// INPUT ...
|
// INPUT ...
|
||||||
|
|
||||||
//
|
//
|
||||||
|
input group "Market";
|
||||||
input int length = 52; // Market Length
|
input int length = 52; // Market Length
|
||||||
input double offset = 0; // Offset
|
input double offset = 0; // Offset
|
||||||
|
|
||||||
|
//
|
||||||
|
input group "Presentation";
|
||||||
|
input bool showOpen = true; // Show Open
|
||||||
|
input bool showHigh = true; // Show High
|
||||||
|
input bool showClose = true; // Show Close
|
||||||
|
input bool showLow = true; // Show Low
|
||||||
|
|
||||||
//
|
//
|
||||||
// BUFFERS ...
|
// BUFFERS ...
|
||||||
|
|
||||||
@@ -164,36 +172,17 @@ void OnDeinit(const int reason)
|
|||||||
//
|
//
|
||||||
// Calculating what we want ...
|
// Calculating what we want ...
|
||||||
int OnCalculate(
|
int OnCalculate(
|
||||||
//
|
const int rates_total, // Total Bars on Chart ...
|
||||||
// total Candles on chart ...
|
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||||
const int rates_total,
|
const datetime &time[], // History of Open Time ...
|
||||||
//
|
const double &open[], // History of Open Price ...
|
||||||
// total calculated Candles on charts ...
|
const double &high[], // History of High Price ...
|
||||||
const int prev_calculated,
|
const double &low[], // History of Low Price ...
|
||||||
//
|
const double &close[], // History of Close Price ...
|
||||||
// history of Candles Open Time ...
|
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||||
const datetime &time[],
|
const long &volume[], // History of Trade Volumes ...
|
||||||
//
|
const int &spread[] // History of Spread Price ...
|
||||||
// history of Candles Open Price ...
|
)
|
||||||
const double &open[],
|
|
||||||
//
|
|
||||||
// history of Candles High Price ...
|
|
||||||
const double &high[],
|
|
||||||
//
|
|
||||||
// history of Candles Low Price ...
|
|
||||||
const double &low[],
|
|
||||||
//
|
|
||||||
// history of Candles Close Price ...
|
|
||||||
const double &close[],
|
|
||||||
//
|
|
||||||
// history of Tick Volumes on Candle ...
|
|
||||||
const long &tick_volume[],
|
|
||||||
//
|
|
||||||
// history of Trade Volumes ...
|
|
||||||
const long &volume[],
|
|
||||||
//
|
|
||||||
// history of Candles Spread Price ...
|
|
||||||
const int &spread[])
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (rates_total < length - 1)
|
if (rates_total < length - 1)
|
||||||
@@ -298,63 +287,75 @@ void DefineBuffers()
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Open ...
|
// Open ...
|
||||||
|
ENUM_DRAW_TYPE openDrawType = showOpen ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// UPPER ...
|
// UPPER ...
|
||||||
SetIndexBuffer(upperOBufferIndex, upperOBuffer, INDICATOR_DATA);
|
SetIndexBuffer(upperOBufferIndex, upperOBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(upperOBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(upperOBufferIndex, PLOT_SHOW_DATA, showOpen);
|
||||||
PlotIndexSetDouble(upperOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(upperOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(upperOBufferIndex, PLOT_DRAW_TYPE, openDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// LOWER ...
|
// LOWER ...
|
||||||
SetIndexBuffer(lowerOBufferIndex, lowerOBuffer, INDICATOR_DATA);
|
SetIndexBuffer(lowerOBufferIndex, lowerOBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(lowerOBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(lowerOBufferIndex, PLOT_SHOW_DATA, showOpen);
|
||||||
PlotIndexSetDouble(lowerOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(lowerOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(lowerOBufferIndex, PLOT_DRAW_TYPE, openDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Close ...
|
// Close ...
|
||||||
|
ENUM_DRAW_TYPE closeDrawType = showClose ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// UPPER ...
|
// UPPER ...
|
||||||
SetIndexBuffer(upperCBufferIndex, upperCBuffer, INDICATOR_DATA);
|
SetIndexBuffer(upperCBufferIndex, upperCBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(upperCBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(upperCBufferIndex, PLOT_SHOW_DATA, showClose);
|
||||||
PlotIndexSetDouble(upperCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(upperCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(upperCBufferIndex, PLOT_DRAW_TYPE, closeDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// LOWER ...
|
// LOWER ...
|
||||||
SetIndexBuffer(lowerCBufferIndex, lowerCBuffer, INDICATOR_DATA);
|
SetIndexBuffer(lowerCBufferIndex, lowerCBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(lowerCBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(lowerCBufferIndex, PLOT_SHOW_DATA, showClose);
|
||||||
PlotIndexSetDouble(lowerCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(lowerCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(lowerCBufferIndex, PLOT_DRAW_TYPE, closeDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// High ...
|
// High ...
|
||||||
|
ENUM_DRAW_TYPE highDrawType = showHigh ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// UPPER ...
|
// UPPER ...
|
||||||
SetIndexBuffer(upperHBufferIndex, upperHBuffer, INDICATOR_DATA);
|
SetIndexBuffer(upperHBufferIndex, upperHBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(upperHBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(upperHBufferIndex, PLOT_SHOW_DATA, showHigh);
|
||||||
PlotIndexSetDouble(upperHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(upperHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(upperHBufferIndex, PLOT_DRAW_TYPE, highDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// LOWER ...
|
// LOWER ...
|
||||||
SetIndexBuffer(lowerHBufferIndex, lowerHBuffer, INDICATOR_DATA);
|
SetIndexBuffer(lowerHBufferIndex, lowerHBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(lowerHBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(lowerHBufferIndex, PLOT_SHOW_DATA, showHigh);
|
||||||
PlotIndexSetDouble(lowerHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(lowerHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(lowerHBufferIndex, PLOT_DRAW_TYPE, highDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Low ...
|
// Low ...
|
||||||
|
ENUM_DRAW_TYPE lowDrawType = showLow ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// UPPER ...
|
// UPPER ...
|
||||||
SetIndexBuffer(upperLBufferIndex, upperLBuffer, INDICATOR_DATA);
|
SetIndexBuffer(upperLBufferIndex, upperLBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(upperLBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(upperLBufferIndex, PLOT_SHOW_DATA, showLow);
|
||||||
PlotIndexSetDouble(upperLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(upperLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(upperLBufferIndex, PLOT_DRAW_TYPE, lowDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// LOWER ...
|
// LOWER ...
|
||||||
SetIndexBuffer(lowerLBufferIndex, lowerLBuffer, INDICATOR_DATA);
|
SetIndexBuffer(lowerLBufferIndex, lowerLBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(lowerLBufferIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(lowerLBufferIndex, PLOT_SHOW_DATA, showLow);
|
||||||
PlotIndexSetDouble(lowerLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
PlotIndexSetDouble(lowerLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(lowerLBufferIndex, PLOT_DRAW_TYPE, lowDrawType);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -378,36 +378,17 @@ void OnDeinit(const int reason)
|
|||||||
//
|
//
|
||||||
// Calculating what we want ...
|
// Calculating what we want ...
|
||||||
int OnCalculate(
|
int OnCalculate(
|
||||||
//
|
const int rates_total, // Total Bars on Chart ...
|
||||||
// total Candles on chart ...
|
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||||
const int rates_total,
|
const datetime &time[], // History of Open Time ...
|
||||||
//
|
const double &open[], // History of Open Price ...
|
||||||
// total calculated Candles on charts ...
|
const double &high[], // History of High Price ...
|
||||||
const int prev_calculated,
|
const double &low[], // History of Low Price ...
|
||||||
//
|
const double &close[], // History of Close Price ...
|
||||||
// history of Candles Open Time ...
|
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||||
const datetime &time[],
|
const long &volume[], // History of Trade Volumes ...
|
||||||
//
|
const int &spread[] // History of Spread Price ...
|
||||||
// history of Candles Open Price ...
|
)
|
||||||
const double &open[],
|
|
||||||
//
|
|
||||||
// history of Candles High Price ...
|
|
||||||
const double &high[],
|
|
||||||
//
|
|
||||||
// history of Candles Low Price ...
|
|
||||||
const double &low[],
|
|
||||||
//
|
|
||||||
// history of Candles Close Price ...
|
|
||||||
const double &close[],
|
|
||||||
//
|
|
||||||
// history of Tick Volumes on Candle ...
|
|
||||||
const long &tick_volume[],
|
|
||||||
//
|
|
||||||
// history of Trade Volumes ...
|
|
||||||
const long &volume[],
|
|
||||||
//
|
|
||||||
// history of Candles Spread Price ...
|
|
||||||
const int &spread[])
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// this counts Available Bars ...
|
// this counts Available Bars ...
|
||||||
|
|||||||
@@ -44,11 +44,17 @@ enum ENUM_X_ZG_PRICE_MODE
|
|||||||
// INPUT ...
|
// INPUT ...
|
||||||
|
|
||||||
//
|
//
|
||||||
|
input group "Market";
|
||||||
input int depth = 12; // Depth
|
input int depth = 12; // Depth
|
||||||
input int deviation = 5; // Deviation
|
input int deviation = 5; // Deviation
|
||||||
input int backStep = 3; // Back Step
|
input int backStep = 3; // Back Step
|
||||||
input ENUM_X_ZG_PRICE_MODE mode = X_ZG_PRICE_HIGH_LOW_MODE; // Mode
|
input ENUM_X_ZG_PRICE_MODE mode = X_ZG_PRICE_HIGH_LOW_MODE; // Mode
|
||||||
|
|
||||||
|
//
|
||||||
|
input group "Presentation";
|
||||||
|
input bool showZigZag = true; // Show ZigZag
|
||||||
|
input bool showPeaksAndVales = true; // Show Peaks and Vales
|
||||||
|
|
||||||
//
|
//
|
||||||
// BUFFERS ...
|
// BUFFERS ...
|
||||||
|
|
||||||
@@ -56,8 +62,8 @@ input ENUM_X_ZG_PRICE_MODE mode = X_ZG_PRICE_HIGH_LOW_MODE; // Mode
|
|||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 5
|
#property indicator_buffers 6
|
||||||
#property indicator_plots 3
|
#property indicator_plots 4
|
||||||
|
|
||||||
//
|
//
|
||||||
// ZigZag ...
|
// ZigZag ...
|
||||||
@@ -67,10 +73,13 @@ input ENUM_X_ZG_PRICE_MODE mode = X_ZG_PRICE_HIGH_LOW_MODE; // Mode
|
|||||||
#define mainBufferPlotIndex 0
|
#define mainBufferPlotIndex 0
|
||||||
double mainBuffer[];
|
double mainBuffer[];
|
||||||
|
|
||||||
|
#define mainColorBufferIndex 1
|
||||||
|
double mainColorBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label1 "XZG Main"
|
#property indicator_label1 "XZG Main"
|
||||||
#property indicator_type1 DRAW_SECTION
|
#property indicator_type1 DRAW_COLOR_SECTION
|
||||||
#property indicator_color1 clrYellow
|
#property indicator_color1 CLR_NONE, clrRoyalBlue, clrSaddleBrown
|
||||||
#property indicator_width1 2
|
#property indicator_width1 2
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -78,29 +87,29 @@ double mainBuffer[];
|
|||||||
|
|
||||||
//
|
//
|
||||||
// ZigZag Pointer or Line Indicator ...
|
// ZigZag Pointer or Line Indicator ...
|
||||||
#define arrowBufferIndex 1
|
#define arrowBufferIndex 2
|
||||||
#define arrowBufferPlotIndex 1
|
#define arrowBufferPlotIndex 1
|
||||||
double arrowBuffer[];
|
double arrowBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define arrowColorBufferIndex 2
|
#define arrowColorBufferIndex 3
|
||||||
double arrowColorBuffer[];
|
double arrowColorBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label2 "XZG PV"
|
#property indicator_label2 "XZG PV"
|
||||||
#property indicator_type2 DRAW_COLOR_ARROW
|
#property indicator_type2 DRAW_COLOR_ARROW
|
||||||
#property indicator_color2 clrAqua, clrMagenta
|
#property indicator_color2 CLR_NONE, clrAqua, clrMagenta
|
||||||
#property indicator_width2 1
|
#property indicator_width2 1
|
||||||
|
|
||||||
//
|
//
|
||||||
#define highsBufferIndex 3
|
#define highsBufferIndex 4
|
||||||
double highsBuffer[];
|
double highsBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Lows ...
|
// Lows ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define lowsBufferIndex 4
|
#define lowsBufferIndex 5
|
||||||
double lowsBuffer[];
|
double lowsBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -159,36 +168,16 @@ void OnDeinit(const int reason)
|
|||||||
//
|
//
|
||||||
// Calculating what we want ...
|
// Calculating what we want ...
|
||||||
int OnCalculate(
|
int OnCalculate(
|
||||||
//
|
const int rates_total, // Total Bars on Chart ...
|
||||||
// total Candles on chart ...
|
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||||
const int rates_total,
|
const datetime &time[], // History of Open Time ...
|
||||||
//
|
const double &open[], // History of Open Price ...
|
||||||
// total calculated Candles on charts ...
|
const double &high[], // History of High Price ...
|
||||||
const int prev_calculated,
|
const double &low[], // History of Low Price ...
|
||||||
//
|
const double &close[], // History of Close Price ...
|
||||||
// history of Candles Open Time ...
|
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||||
const datetime &time[],
|
const long &volume[], // History of Trade Volumes ...
|
||||||
//
|
const int &spread[] // History of Spread Price ...
|
||||||
// history of Candles Open Price ...
|
|
||||||
const double &open[],
|
|
||||||
//
|
|
||||||
// history of Candles High Price ...
|
|
||||||
const double &high[],
|
|
||||||
//
|
|
||||||
// history of Candles Low Price ...
|
|
||||||
const double &low[],
|
|
||||||
//
|
|
||||||
// history of Candles Close Price ...
|
|
||||||
const double &close[],
|
|
||||||
//
|
|
||||||
// history of Tick Volumes on Candle ...
|
|
||||||
const long &tick_volume[],
|
|
||||||
//
|
|
||||||
// history of Trade Volumes ...
|
|
||||||
const long &volume[],
|
|
||||||
//
|
|
||||||
// history of Candles Spread Price ...
|
|
||||||
const int &spread[] //
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -278,9 +267,10 @@ void DefineBuffers()
|
|||||||
|
|
||||||
//
|
//
|
||||||
SetIndexBuffer(mainBufferIndex, mainBuffer, INDICATOR_DATA);
|
SetIndexBuffer(mainBufferIndex, mainBuffer, INDICATOR_DATA);
|
||||||
|
SetIndexBuffer(mainColorBufferIndex, mainColorBuffer, INDICATOR_COLOR_INDEX);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(mainBufferPlotIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(mainBufferPlotIndex, PLOT_SHOW_DATA, showZigZag);
|
||||||
PlotIndexSetInteger(mainBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
PlotIndexSetInteger(mainBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||||
PlotIndexSetDouble(mainBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(mainBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||||
|
|
||||||
@@ -291,7 +281,7 @@ void DefineBuffers()
|
|||||||
SetIndexBuffer(arrowBufferIndex, arrowBuffer, INDICATOR_DATA);
|
SetIndexBuffer(arrowBufferIndex, arrowBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_SHOW_DATA, true);
|
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_SHOW_DATA, showPeaksAndVales);
|
||||||
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||||
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_ARROW, 159);
|
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_ARROW, 159);
|
||||||
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_ARROW_SHIFT, 0);
|
PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_ARROW_SHIFT, 0);
|
||||||
@@ -664,11 +654,14 @@ int CalcukateZigZag(
|
|||||||
//
|
//
|
||||||
colorIDX =
|
colorIDX =
|
||||||
lastZigZagValue > iZigZagForColor
|
lastZigZagValue > iZigZagForColor
|
||||||
? 0
|
|
||||||
: lastZigZagValue < iZigZagForColor
|
|
||||||
? 1
|
? 1
|
||||||
|
: lastZigZagValue < iZigZagForColor
|
||||||
|
? 2
|
||||||
: colorIDX;
|
: colorIDX;
|
||||||
arrowColorBuffer[shift] = colorIDX;
|
|
||||||
|
//
|
||||||
|
mainColorBuffer[shift] = showZigZag ? colorIDX : 0;
|
||||||
|
arrowColorBuffer[shift] = showPeaksAndVales ? colorIDX : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user