1870 lines
34 KiB
Plaintext
1870 lines
34 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Helper Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSCXPVHelper
|
|
// 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_XPV_BUFFERS
|
|
{
|
|
//
|
|
// Peaks and Vales ...
|
|
XPV_PEAKS_LINE = 0,
|
|
XPV_VALES_LINE = 1,
|
|
//
|
|
// Support and Resistances ...
|
|
XPV_RESISTANCE_LINE = 2,
|
|
XPV_SUPPORT_LINE = 4,
|
|
//
|
|
// Fibonacci ...
|
|
XPV_FIB_1_LINE = 6,
|
|
XPV_FIB_2_LINE = 8,
|
|
XPV_FIB_3_LINE = 10,
|
|
XPV_FIB_4_LINE = 12,
|
|
XPV_FIB_5_LINE = 14,
|
|
//
|
|
// Short ...
|
|
XPV_SC_HH_LINE = 16,
|
|
XPV_SC_LL_LINE = 18,
|
|
//
|
|
// Medium ...
|
|
XPV_MC_HH_LINE = 20,
|
|
XPV_MC_LL_LINE = 22,
|
|
//
|
|
// Long ...
|
|
XPV_LC_HH_LINE = 24,
|
|
XPV_LC_LL_LINE = 26,
|
|
//
|
|
// Hind ...
|
|
XPV_HC_HH_LINE = 28,
|
|
XPV_HC_LL_LINE = 30,
|
|
};
|
|
|
|
//
|
|
// Input Models ...
|
|
struct XPVInputs
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Makret Cycles ...
|
|
|
|
//
|
|
// Short ...
|
|
ENUM_X_PERIOD_METHOD scMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES scPeriod; // Time Period
|
|
|
|
//
|
|
// Medium ...
|
|
ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES mcPeriod; // Time Period
|
|
|
|
//
|
|
// Long ...
|
|
ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES lcPeriod; // Time Period
|
|
|
|
//
|
|
// Hind ...
|
|
ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period
|
|
ENUM_TIMEFRAMES hcPeriod; // Time Period
|
|
|
|
//
|
|
// Fibonacci ...
|
|
double fiboLevel1; // Fibio 1st Level
|
|
double fiboLevel2; // Fibio 2st Level
|
|
double fiboLevel3; // Fibio 3rd Level
|
|
double fiboLevel4; // Fibio 4th Level
|
|
double fiboLevel5; // Fibio 5th Level
|
|
|
|
//
|
|
// Boundary Detection Modes ...
|
|
ENUM_SERIESMODE hhMode; // Highest High Calculation Method
|
|
ENUM_SERIESMODE llMode; // Lowest Low Calculation Method
|
|
|
|
//
|
|
// Presentation ...
|
|
bool showPeaksAndVales; // Show Peaks and Vales
|
|
bool showLevels; // Show Levels
|
|
bool showConsolidations; // Show Consolidations
|
|
bool showFibo1Levels; // Show Fibo 1st Level
|
|
bool showFibo2Levels; // Show Fibo 2nd Level
|
|
bool showFibo3Levels; // Show Fibo 3rd Level
|
|
bool showFibo4Levels; // Show Fibo 4th Level
|
|
bool showFibo5Levels; // Show Fibo 5th Level
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
XPVInputs()
|
|
{
|
|
//
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Clean ...
|
|
void Clean()
|
|
{
|
|
//
|
|
// Makret Cycles ...
|
|
|
|
//
|
|
// Short ...
|
|
scMethod = X_PERIOD_NOTHING;
|
|
scPeriod = NULL;
|
|
|
|
//
|
|
// Medium ...
|
|
mcMethod = X_PERIOD_NOTHING;
|
|
mcPeriod = NULL;
|
|
|
|
//
|
|
// Long ...
|
|
lcMethod = X_PERIOD_NOTHING;
|
|
lcPeriod = NULL;
|
|
|
|
//
|
|
// Hind ...
|
|
hcMethod = X_PERIOD_NOTHING;
|
|
hcPeriod = NULL;
|
|
|
|
//
|
|
// Fibonacci ...
|
|
fiboLevel1 = 0;
|
|
fiboLevel2 = 0;
|
|
fiboLevel3 = 0;
|
|
fiboLevel4 = 0;
|
|
fiboLevel5 = 0;
|
|
|
|
//
|
|
// Boundary Detection Modes ...
|
|
hhMode = MODE_HIGH;
|
|
llMode = MODE_LOW;
|
|
|
|
//
|
|
// Presentation ...
|
|
showPeaksAndVales = false;
|
|
showLevels = false;
|
|
showConsolidations = false;
|
|
showFibo1Levels = false;
|
|
showFibo2Levels = false;
|
|
showFibo3Levels = false;
|
|
showFibo4Levels = false;
|
|
showFibo5Levels = false;
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default()
|
|
{
|
|
//
|
|
// Makret Cycles ...
|
|
|
|
//
|
|
// Short ...
|
|
scMethod = X_PERIOD_AUTO;
|
|
scPeriod = NULL;
|
|
|
|
//
|
|
// Medium ...
|
|
mcMethod = X_PERIOD_AUTO;
|
|
mcPeriod = NULL;
|
|
|
|
//
|
|
// Long ...
|
|
lcMethod = X_PERIOD_AUTO;
|
|
lcPeriod = NULL;
|
|
|
|
//
|
|
// Hind ...
|
|
hcMethod = X_PERIOD_AUTO;
|
|
hcPeriod = NULL;
|
|
|
|
//
|
|
// Fibonacci ...
|
|
fiboLevel1 = 0.236;
|
|
fiboLevel2 = 0.382;
|
|
fiboLevel3 = 0.5;
|
|
fiboLevel4 = 0.618;
|
|
fiboLevel5 = 0.764;
|
|
|
|
//
|
|
// Boundary Detection Modes ...
|
|
hhMode = MODE_HIGH;
|
|
llMode = MODE_LOW;
|
|
|
|
//
|
|
// Presentation ...
|
|
showPeaksAndVales = true;
|
|
showLevels = false;
|
|
showConsolidations = false;
|
|
showFibo1Levels = true;
|
|
showFibo2Levels = true;
|
|
showFibo3Levels = true;
|
|
showFibo4Levels = true;
|
|
showFibo5Levels = true;
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsValid(scMethod, scPeriod) &&
|
|
IsValid(mcMethod, mcPeriod) &&
|
|
IsValid(lcMethod, lcPeriod) &&
|
|
IsValid(hcMethod, hcPeriod)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve MAx Length ...
|
|
int Max()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
result = MathMax(result, 0);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
class XSCXPVHelper : public XSCBaseHelper
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Constructors ...
|
|
XSCXPVHelper() : XSCBaseHelper(_Symbol, _Period)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XSCXPVHelper() {}
|
|
|
|
//
|
|
// Tools ...
|
|
bool Init(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period, // Trading Period
|
|
XPVInputs &inputs // Inputs
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
mSymbol = symbol;
|
|
mPeriod = period;
|
|
|
|
//
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mInputs = inputs;
|
|
|
|
//
|
|
ArraySetAsSeries(peaksBuffer, true);
|
|
ArraySetAsSeries(valesBuffer, true);
|
|
ArraySetAsSeries(resistanceBuffer, true);
|
|
ArraySetAsSeries(supportBuffer, true);
|
|
ArraySetAsSeries(fib1Buffer, true);
|
|
ArraySetAsSeries(fib2Buffer, true);
|
|
ArraySetAsSeries(fib3Buffer, true);
|
|
ArraySetAsSeries(fib4Buffer, true);
|
|
ArraySetAsSeries(fib5Buffer, true);
|
|
ArraySetAsSeries(scHHBuffer, true);
|
|
ArraySetAsSeries(scLLBuffer, true);
|
|
ArraySetAsSeries(mcHHBuffer, true);
|
|
ArraySetAsSeries(mcLLBuffer, true);
|
|
ArraySetAsSeries(lcHHBuffer, true);
|
|
ArraySetAsSeries(lcLLBuffer, true);
|
|
ArraySetAsSeries(hcHHBuffer, true);
|
|
ArraySetAsSeries(hcLLBuffer, true);
|
|
|
|
//
|
|
mHandler = iCustom(
|
|
mSymbol,
|
|
mPeriod,
|
|
"x-saherelm.xpv",
|
|
//
|
|
// Inputs ...
|
|
//
|
|
// Makret Cycles ...
|
|
"",
|
|
//
|
|
// Short ...
|
|
"",
|
|
mInputs.scMethod, // How to Find Period
|
|
mInputs.scPeriod, // Time Period
|
|
//
|
|
// Medium ...
|
|
"",
|
|
mInputs.mcMethod, // How to Find Period
|
|
mInputs.mcPeriod, // Time Period
|
|
//
|
|
// Long ...
|
|
"",
|
|
mInputs.lcMethod, // How to Find Period
|
|
mInputs.lcPeriod, // Time Period
|
|
//
|
|
// Hind ...
|
|
"",
|
|
mInputs.hcMethod, // How to Find Period
|
|
mInputs.hcPeriod, // Time Period
|
|
//
|
|
// Fibonacci ...
|
|
"",
|
|
mInputs.fiboLevel1, // Fibio 1st Level
|
|
mInputs.fiboLevel2, // Fibio 2st Level
|
|
mInputs.fiboLevel3, // Fibio 3rd Level
|
|
mInputs.fiboLevel4, // Fibio 4th Level
|
|
mInputs.fiboLevel5, // Fibio 5th Level
|
|
//
|
|
// Boundary Detection Modes ...
|
|
"",
|
|
mInputs.hhMode, // Highest High Calculation Method
|
|
mInputs.llMode, // Lowest Low Calculation Method
|
|
//
|
|
// Presentation ...
|
|
"",
|
|
mInputs.showPeaksAndVales, // Show Peaks and Vales
|
|
mInputs.showLevels, // Show Levels
|
|
mInputs.showConsolidations, // Show Consolidations
|
|
mInputs.showFibo1Levels, // Show Fibo 1st Level
|
|
mInputs.showFibo2Levels, // Show Fibo 2nd Level
|
|
mInputs.showFibo3Levels, // Show Fibo 3rd Level
|
|
mInputs.showFibo4Levels, // Show Fibo 4th Level
|
|
mInputs.showFibo5Levels // Show Fibo 5th Level
|
|
//
|
|
);
|
|
result = mHandler != INVALID_HANDLE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Inputs ...
|
|
|
|
//
|
|
XPVInputs GetInputs()
|
|
{
|
|
return mInputs;
|
|
}
|
|
|
|
//
|
|
bool SetInputs(
|
|
XPVInputs &inputs // Configs
|
|
)
|
|
{
|
|
//
|
|
return Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
inputs
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
// Peaks ...
|
|
|
|
//
|
|
double GetPeak(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(peaksBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return peaksBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyPeak(
|
|
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,
|
|
peaksBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSamePeak(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
peaksBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Vales ...
|
|
|
|
//
|
|
double GetVale(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(valesBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return valesBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyVale(
|
|
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,
|
|
valesBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameVale(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
valesBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Resistance ...
|
|
|
|
//
|
|
double GetResistance(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(resistanceBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return resistanceBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyResistance(
|
|
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,
|
|
resistanceBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Support ...
|
|
|
|
//
|
|
double GetSupport(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(supportBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return supportBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopySupport(
|
|
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,
|
|
supportBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Fibonacci ...
|
|
|
|
//
|
|
// Level 1 ...
|
|
|
|
//
|
|
double GetFib1(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fib1Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fib1Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFib1(
|
|
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,
|
|
fib1Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameFib1(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
fib1Buffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Level 2 ...
|
|
|
|
//
|
|
double GetFib2(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fib2Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fib2Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFib2(
|
|
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,
|
|
fib2Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameFib2(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
fib2Buffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Level 3 ...
|
|
|
|
//
|
|
double GetFib3(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fib3Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fib3Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFib3(
|
|
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,
|
|
fib3Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameFib3(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
fib3Buffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Level 4 ...
|
|
|
|
//
|
|
double GetFib4(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fib4Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fib4Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFib4(
|
|
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,
|
|
fib4Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameFib4(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
fib4Buffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Level 5 ...
|
|
|
|
//
|
|
double GetFib5(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fib5Buffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fib5Buffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFib5(
|
|
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,
|
|
fib5Buffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameFib5(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
fib5Buffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Cycles ...
|
|
|
|
//
|
|
// Short ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetSCHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(scHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return scHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopySCHH(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
scHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameSCHH(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
scHHBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetSCLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(scLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return scLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopySCLL(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
scLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameSCLL(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
scLLBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Medium ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetMCHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(mcHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return mcHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyMCHH(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
mcHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameMCHH(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
mcHHBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetMCLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(mcLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return mcLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyMCLL(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
mcLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameMCLL(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
mcLLBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Long ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetLCHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(lcHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return lcHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyLCHH(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
lcHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameLCHH(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
lcHHBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetLCLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(lcLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return lcLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyLCLL(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
lcLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameLCLL(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
lcLLBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Hind ...
|
|
|
|
//
|
|
// HH ...
|
|
|
|
//
|
|
double GetHCHH(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(hcHHBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hcHHBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyHCHH(
|
|
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,
|
|
hcHHBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameHCHH(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
hcHHBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// LL ...
|
|
|
|
//
|
|
double GetHCLL(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(hcLLBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return hcLLBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyHCLL(
|
|
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,
|
|
hcLLBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsSameHCLL(
|
|
int barIndex, // Start Bar Index
|
|
int verifier = 71 // Number of Verifiers
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
return IsSame(
|
|
hcLLBuffer,
|
|
verifier,
|
|
barIndex //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
XPVInputs mInputs; // Inputs ...
|
|
|
|
//
|
|
// Buffers ...
|
|
double peaksBuffer[];
|
|
double valesBuffer[];
|
|
double resistanceBuffer[];
|
|
double supportBuffer[];
|
|
double fib1Buffer[];
|
|
double fib2Buffer[];
|
|
double fib3Buffer[];
|
|
double fib4Buffer[];
|
|
double fib5Buffer[];
|
|
double scHHBuffer[];
|
|
double scLLBuffer[];
|
|
double mcHHBuffer[];
|
|
double mcLLBuffer[];
|
|
double lcHHBuffer[];
|
|
double lcLLBuffer[];
|
|
double hcHHBuffer[];
|
|
double hcLLBuffer[];
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Calculate Values Until Now ...
|
|
void Calculate()
|
|
{
|
|
//
|
|
int totalBars = CountBars();
|
|
|
|
//
|
|
// Peaks and Vales ...
|
|
|
|
//
|
|
// Peaks Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_PEAKS_LINE,
|
|
0,
|
|
totalBars,
|
|
peaksBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Vales Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_VALES_LINE,
|
|
0,
|
|
totalBars,
|
|
valesBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Support and Resistances ...
|
|
|
|
//
|
|
// Resistances Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_RESISTANCE_LINE,
|
|
0,
|
|
totalBars,
|
|
resistanceBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Supports Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_SUPPORT_LINE,
|
|
0,
|
|
totalBars,
|
|
supportBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Fibonacci ...
|
|
|
|
//
|
|
// Level 1 Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_FIB_1_LINE,
|
|
0,
|
|
totalBars,
|
|
fib1Buffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Level 2 Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_FIB_2_LINE,
|
|
0,
|
|
totalBars,
|
|
fib2Buffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Level 3 Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_FIB_3_LINE,
|
|
0,
|
|
totalBars,
|
|
fib3Buffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Level 4 Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_FIB_4_LINE,
|
|
0,
|
|
totalBars,
|
|
fib4Buffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Level 5 Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_FIB_5_LINE,
|
|
0,
|
|
totalBars,
|
|
fib5Buffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Cycles ...
|
|
|
|
//
|
|
// Short ...
|
|
|
|
//
|
|
// HH ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_SC_HH_LINE,
|
|
0,
|
|
totalBars,
|
|
scHHBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// LL ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_SC_LL_LINE,
|
|
0,
|
|
totalBars,
|
|
scLLBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Medium ...
|
|
|
|
//
|
|
// HH ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_MC_HH_LINE,
|
|
0,
|
|
totalBars,
|
|
mcHHBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// LL ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_MC_LL_LINE,
|
|
0,
|
|
totalBars,
|
|
mcLLBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Long ...
|
|
|
|
//
|
|
// HH ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_LC_HH_LINE,
|
|
0,
|
|
totalBars,
|
|
lcHHBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// LL ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_LC_LL_LINE,
|
|
0,
|
|
totalBars,
|
|
lcLLBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Hind ...
|
|
|
|
//
|
|
// HH ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_HC_HH_LINE,
|
|
0,
|
|
totalBars,
|
|
hcHHBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// LL ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XPV_HC_LL_LINE,
|
|
0,
|
|
totalBars,
|
|
hcLLBuffer
|
|
//
|
|
);
|
|
}
|
|
};
|
|
|
|
//
|
|
// Tools ... |