complete xrl indicator and it's related helper class ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+138
-76
@@ -30,16 +30,17 @@
|
|||||||
//
|
//
|
||||||
input group "Market";
|
input group "Market";
|
||||||
input group "Fast";
|
input group "Fast";
|
||||||
input int fastLength = 9; // Length
|
input int fastLength = 9; // Length
|
||||||
input ENUM_APPLIED_PRICE fastAppliedTo = PRICE_CLOSE; // Applied To
|
input ENUM_APPLIED_PRICE fastAppliedTo = PRICE_CLOSE; // Applied To
|
||||||
input int slowLength = 18; // Length
|
input group "Slow";
|
||||||
input ENUM_APPLIED_PRICE slowAppliedTo = PRICE_CLOSE; // Applied To
|
input int slowLength = 18; // Length
|
||||||
|
input ENUM_APPLIED_PRICE slowAppliedTo = PRICE_CLOSE; // Applied To
|
||||||
|
|
||||||
//
|
//
|
||||||
input group "Presentation";
|
input group "Presentation";
|
||||||
input bool showFast = true; // Show Fast
|
input bool showFast = true; // Show Fast
|
||||||
input bool showSlow = true; // Show Slow
|
input bool showSlow = true; // Show Slow
|
||||||
input bool showVerifier = true; // Show Verifier
|
input bool showVerifier = true; // Show Verifier
|
||||||
|
|
||||||
//
|
//
|
||||||
// Buffers ...
|
// Buffers ...
|
||||||
@@ -48,20 +49,20 @@ input bool showVerifier = true; // Show Verifier
|
|||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 8
|
#property indicator_buffers 11
|
||||||
#property indicator_plots 6
|
#property indicator_plots 6
|
||||||
|
|
||||||
//
|
//
|
||||||
#define hideColorIDX 0
|
#define hideColorIDX 0
|
||||||
#define neuturalColorIDX 1
|
#define neuturalColorIDX 1
|
||||||
#define bullColorIDX 2
|
#define bullColorIDX 2
|
||||||
#define bearColorIDX 3
|
#define bearColorIDX 3
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fast ...
|
// Fast ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define fastBufferIndex 0
|
#define fastBufferIndex 0
|
||||||
#define fastBufferPlotIndex 0
|
#define fastBufferPlotIndex 0
|
||||||
double fastBuffer[];
|
double fastBuffer[];
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ double fastBufferColor[];
|
|||||||
// Slow ...
|
// Slow ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define slowBufferIndex 2
|
#define slowBufferIndex 2
|
||||||
#define slowBufferPlotIndex 1
|
#define slowBufferPlotIndex 1
|
||||||
double slowBuffer[];
|
double slowBuffer[];
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@ double slowBufferColor[];
|
|||||||
// Verifier ...
|
// Verifier ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define verifierBufferIndex 4
|
#define verifierBufferIndex 4
|
||||||
#define verifierBufferPlotIndex 2
|
#define verifierBufferPlotIndex 2
|
||||||
double verifierBuffer[];
|
double verifierBuffer[];
|
||||||
|
|
||||||
@@ -121,6 +122,18 @@ double fastLRBuffer[];
|
|||||||
#define slowLRBufferIndex 7
|
#define slowLRBufferIndex 7
|
||||||
double slowLRBuffer[];
|
double slowLRBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define fastStateBufferIndex 8
|
||||||
|
double fastStateBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define slowStateBufferIndex 9
|
||||||
|
double slowStateBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define verifierStateBufferIndex 10
|
||||||
|
double verifierStateBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variables ...
|
// Variables ...
|
||||||
|
|
||||||
@@ -137,10 +150,12 @@ XLinearRegression verifierCalculator;
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Initialization ...
|
// Initialization ...
|
||||||
int OnInit() {
|
int OnInit()
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Validate Inputs ...
|
// Validate Inputs ...
|
||||||
if(!ValidateInputs()) {
|
if (!ValidateInputs())
|
||||||
|
{
|
||||||
return INIT_PARAMETERS_INCORRECT;
|
return INIT_PARAMETERS_INCORRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +181,8 @@ int OnInit() {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// DeInitialization ...
|
// DeInitialization ...
|
||||||
void OnDeinit(const int reason) {
|
void OnDeinit(const int reason)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
||||||
// REASON_REMOVE 1 Program removed from a chart
|
// REASON_REMOVE 1 Program removed from a chart
|
||||||
@@ -183,17 +199,18 @@ 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 ...
|
const int rates_total, // Total Bars on Chart ...
|
||||||
const int prev_calculated, // Total Calculated Bars on Charts ...
|
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||||
const datetime &time[], // History of Open Time ...
|
const datetime &time[], // History of Open Time ...
|
||||||
const double &open[], // History of Open Price ...
|
const double &open[], // History of Open Price ...
|
||||||
const double &high[], // History of High Price ...
|
const double &high[], // History of High Price ...
|
||||||
const double &low[], // History of Low Price ...
|
const double &low[], // History of Low Price ...
|
||||||
const double &close[], // History of Close Price ...
|
const double &close[], // History of Close Price ...
|
||||||
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||||
const long &volume[], // History of Trade Volumes ...
|
const long &volume[], // History of Trade Volumes ...
|
||||||
const int &spread[] // History of Spread Price ...
|
const int &spread[] // History of Spread Price ...
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
int limit = (prev_calculated > 0) ? prev_calculated - 1 : 0;
|
int limit = (prev_calculated > 0) ? prev_calculated - 1 : 0;
|
||||||
|
|
||||||
@@ -205,7 +222,7 @@ int OnCalculate(
|
|||||||
low,
|
low,
|
||||||
close,
|
close,
|
||||||
limit,
|
limit,
|
||||||
rates_total //
|
rates_total //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -216,7 +233,7 @@ int OnCalculate(
|
|||||||
low,
|
low,
|
||||||
close,
|
close,
|
||||||
limit,
|
limit,
|
||||||
rates_total //
|
rates_total //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -227,7 +244,7 @@ int OnCalculate(
|
|||||||
low,
|
low,
|
||||||
close,
|
close,
|
||||||
limit,
|
limit,
|
||||||
rates_total //
|
rates_total //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -239,7 +256,8 @@ int OnCalculate(
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Validate Input Args for Initialization ...
|
// Validate Input Args for Initialization ...
|
||||||
bool ValidateInputs() {
|
bool ValidateInputs()
|
||||||
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@@ -254,7 +272,8 @@ bool ValidateInputs() {
|
|||||||
//
|
//
|
||||||
// Retrieve all Exists Input Max Length ...
|
// Retrieve all Exists Input Max Length ...
|
||||||
// use for Start Of Drawing ...
|
// use for Start Of Drawing ...
|
||||||
int ExtractMaxLengthOfInputs() {
|
int ExtractMaxLengthOfInputs()
|
||||||
|
{
|
||||||
//
|
//
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
@@ -268,13 +287,15 @@ int ExtractMaxLengthOfInputs() {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||||
void SetIndicatorName() {
|
void SetIndicatorName()
|
||||||
|
{
|
||||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Define Indexes and Styles ...
|
// Define Indexes and Styles ...
|
||||||
void DefineBuffers() {
|
void DefineBuffers()
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Fast ...
|
// Fast ...
|
||||||
|
|
||||||
@@ -326,6 +347,11 @@ void DefineBuffers() {
|
|||||||
//
|
//
|
||||||
SetIndexBuffer(fastLRBufferIndex, fastLRBuffer, INDICATOR_CALCULATIONS);
|
SetIndexBuffer(fastLRBufferIndex, fastLRBuffer, INDICATOR_CALCULATIONS);
|
||||||
SetIndexBuffer(slowLRBufferIndex, slowLRBuffer, INDICATOR_CALCULATIONS);
|
SetIndexBuffer(slowLRBufferIndex, slowLRBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
SetIndexBuffer(fastStateBufferIndex, fastStateBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
SetIndexBuffer(slowStateBufferIndex, slowStateBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
SetIndexBuffer(verifierStateBufferIndex, verifierStateBuffer, INDICATOR_CALCULATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -333,21 +359,23 @@ void DefineBuffers() {
|
|||||||
|
|
||||||
//
|
//
|
||||||
void CalculateFast(
|
void CalculateFast(
|
||||||
const double &open[], // History of Open Price ...
|
const double &open[], // History of Open Price ...
|
||||||
const double &high[], // History of High Price ...
|
const double &high[], // History of High Price ...
|
||||||
const double &low[], // History of Low Price ...
|
const double &low[], // History of Low Price ...
|
||||||
const double &close[], // History of Close Price ...
|
const double &close[], // History of Close Price ...
|
||||||
int limit,
|
int limit,
|
||||||
const int rates_total //
|
const int rates_total //
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Fast ...
|
// Fast ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Fast Intercept and Slope ...
|
// Calculate Fast Intercept and Slope ...
|
||||||
double fastSlope = 0;
|
double fastSlope = 0;
|
||||||
double fastIntercept = 0;
|
double fastIntercept = 0;
|
||||||
for(int i = limit; i < rates_total && !IsStopped(); i++) {
|
for (int i = limit; i < rates_total && !IsStopped(); i++)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
double fastAppliedPrice = iGetPrice(fastAppliedTo, open[i], high[i], low[i], close[i]);
|
double fastAppliedPrice = iGetPrice(fastAppliedTo, open[i], high[i], low[i], close[i]);
|
||||||
|
|
||||||
@@ -358,25 +386,33 @@ void CalculateFast(
|
|||||||
fastSlope,
|
fastSlope,
|
||||||
fastIntercept,
|
fastIntercept,
|
||||||
i,
|
i,
|
||||||
rates_total //
|
rates_total //
|
||||||
);
|
);
|
||||||
fastLRBuffer[i] = fastLRValue;
|
fastLRBuffer[i] = fastLRValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Fast ...
|
// Calculate Fast ...
|
||||||
for(int i = 0; i < fastLength && !IsStopped(); i++) {
|
for (int i = 0; i < fastLength && !IsStopped(); i++)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
double fast = fastIntercept + fastSlope * (fastLength - i - 1);
|
double fast = fastIntercept + fastSlope * (fastLength - i - 1);
|
||||||
fastBuffer[rates_total - i - 1] = fast;
|
fastBuffer[rates_total - i - 1] = fast;
|
||||||
|
|
||||||
//
|
//
|
||||||
double fastColor =
|
double fastColor =
|
||||||
(fastSlope > 0) ? bullColorIDX : (fastSlope < 0) ? bearColorIDX :
|
(fastSlope > 0)
|
||||||
neuturalColorIDX;
|
? bullColorIDX
|
||||||
|
: (fastSlope < 0)
|
||||||
|
? bearColorIDX
|
||||||
|
: neuturalColorIDX;
|
||||||
|
double fastState = (fastSlope > 0)
|
||||||
|
? 1
|
||||||
|
: -1;
|
||||||
|
|
||||||
//
|
//
|
||||||
fastBufferColor[rates_total - i - 1] = fastColor;
|
fastBufferColor[rates_total - i - 1] = fastColor;
|
||||||
|
fastStateBuffer[rates_total - i - 1] = fastState;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -386,21 +422,23 @@ void CalculateFast(
|
|||||||
|
|
||||||
//
|
//
|
||||||
void CalculateSlow(
|
void CalculateSlow(
|
||||||
const double &open[], // History of Open Price ...
|
const double &open[], // History of Open Price ...
|
||||||
const double &high[], // History of High Price ...
|
const double &high[], // History of High Price ...
|
||||||
const double &low[], // History of Low Price ...
|
const double &low[], // History of Low Price ...
|
||||||
const double &close[], // History of Close Price ...
|
const double &close[], // History of Close Price ...
|
||||||
int limit,
|
int limit,
|
||||||
const int rates_total //
|
const int rates_total //
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Slow ...
|
// Slow ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Slow Intercept and Slope ...
|
// Calculate Slow Intercept and Slope ...
|
||||||
double slowSlope = 0;
|
double slowSlope = 0;
|
||||||
double slowIntercept = 0;
|
double slowIntercept = 0;
|
||||||
for(int i = limit; i < rates_total && !IsStopped(); i++) {
|
for (int i = limit; i < rates_total && !IsStopped(); i++)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
double slowAppliedPrice = iGetPrice(slowAppliedTo, open[i], high[i], low[i], close[i]);
|
double slowAppliedPrice = iGetPrice(slowAppliedTo, open[i], high[i], low[i], close[i]);
|
||||||
|
|
||||||
@@ -411,25 +449,33 @@ void CalculateSlow(
|
|||||||
slowSlope,
|
slowSlope,
|
||||||
slowIntercept,
|
slowIntercept,
|
||||||
i,
|
i,
|
||||||
rates_total //
|
rates_total //
|
||||||
);
|
);
|
||||||
slowLRBuffer[i] = slowLRValue;
|
slowLRBuffer[i] = slowLRValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Slow ...
|
// Calculate Slow ...
|
||||||
for(int i = 0; i < slowLength && !IsStopped(); i++) {
|
for (int i = 0; i < slowLength && !IsStopped(); i++)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
double slow = slowIntercept + slowSlope * (slowLength - i - 1);
|
double slow = slowIntercept + slowSlope * (slowLength - i - 1);
|
||||||
slowBuffer[rates_total - i - 1] = slow;
|
slowBuffer[rates_total - i - 1] = slow;
|
||||||
|
|
||||||
//
|
//
|
||||||
double slowColor =
|
double slowColor =
|
||||||
(slowSlope > 0) ? bullColorIDX : (slowSlope < 0) ? bearColorIDX :
|
(slowSlope > 0)
|
||||||
neuturalColorIDX;
|
? bullColorIDX
|
||||||
|
: (slowSlope < 0)
|
||||||
|
? bearColorIDX
|
||||||
|
: neuturalColorIDX;
|
||||||
|
double slowState = (slowSlope > 0)
|
||||||
|
? 1
|
||||||
|
: -1;
|
||||||
|
|
||||||
//
|
//
|
||||||
slowBufferColor[rates_total - i - 1] = slowColor;
|
slowBufferColor[rates_total - i - 1] = slowColor;
|
||||||
|
slowStateBuffer[rates_total - i - 1] = slowState;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -439,16 +485,18 @@ void CalculateSlow(
|
|||||||
|
|
||||||
//
|
//
|
||||||
void CalculateVerifier(
|
void CalculateVerifier(
|
||||||
const double &open[], // History of Open Price ...
|
const double &open[], // History of Open Price ...
|
||||||
const double &high[], // History of High Price ...
|
const double &high[], // History of High Price ...
|
||||||
const double &low[], // History of Low Price ...
|
const double &low[], // History of Low Price ...
|
||||||
const double &close[], // History of Close Price ...
|
const double &close[], // History of Close Price ...
|
||||||
int limit,
|
int limit,
|
||||||
const int rates_total //
|
const int rates_total //
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Calculate Verifier ...
|
// Calculate Verifier ...
|
||||||
for(int i = limit; i < rates_total && !IsStopped(); i++) {
|
for (int i = limit; i < rates_total && !IsStopped(); i++)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
double verifierSlope;
|
double verifierSlope;
|
||||||
double verifierIntercept;
|
double verifierIntercept;
|
||||||
@@ -463,17 +511,31 @@ void CalculateVerifier(
|
|||||||
verifierSlope,
|
verifierSlope,
|
||||||
verifierIntercept,
|
verifierIntercept,
|
||||||
i,
|
i,
|
||||||
rates_total //
|
rates_total //
|
||||||
);
|
);
|
||||||
verifierBuffer[i] = verifier;
|
verifierBuffer[i] = verifier;
|
||||||
|
|
||||||
//
|
//
|
||||||
double verifierColor =
|
double verifierColor =
|
||||||
(i > 0) ?
|
(i > 0)
|
||||||
(verifierBuffer[i] > verifierBuffer[i - 1]) ? bullColorIDX : (verifierBuffer[i] < verifierBuffer[i - 1]) ? bearColorIDX :
|
? (verifierBuffer[i] > verifierBuffer[i - 1])
|
||||||
verifierBuffer[i - 1] :
|
? bullColorIDX
|
||||||
neuturalColorIDX;
|
: (verifierBuffer[i] < verifierBuffer[i - 1])
|
||||||
|
? bearColorIDX
|
||||||
|
: verifierBufferColor[i - 1]
|
||||||
|
: neuturalColorIDX;
|
||||||
|
double verifierState =
|
||||||
|
(i > 0)
|
||||||
|
? (verifierBuffer[i] > verifierBuffer[i - 1])
|
||||||
|
? 1
|
||||||
|
: (verifierBuffer[i] < verifierBuffer[i - 1])
|
||||||
|
? -1
|
||||||
|
: verifierStateBuffer[i - 1]
|
||||||
|
: -1;
|
||||||
|
|
||||||
|
//
|
||||||
verifierBufferColor[i] = verifierColor;
|
verifierBufferColor[i] = verifierColor;
|
||||||
|
verifierStateBuffer[i] = verifierState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-7
@@ -4,10 +4,5 @@
|
|||||||
"path": "."
|
"path": "."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {}
|
||||||
"C_Cpp.default.includePath": [
|
}
|
||||||
"c:\\Users\\saherelm\\AppData\\Roaming\\MetaQuotes\\Terminal\\FAE4959D5A0334AE230243FCFFFD4053\\MQL5\\Include"
|
|
||||||
],
|
|
||||||
"C_Cpp.clang_format_style": "file:c:\\Users\\saherelm\\.vscode\\extensions\\l-i-v.mql-tools-2.1.0\\files\\.clang-format"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user