add all required indicator and oscillators and also add all helper classes for them ...
This commit is contained in:
@@ -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 ...
|
||||
Reference in New Issue
Block a user