complete some sort of new indicators helpers classes ...
This commit is contained in:
@@ -0,0 +1,280 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Helper Class Library
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Name: XSCXSSLCHelper
|
||||||
|
// Description: provides all Indicator
|
||||||
|
// Helper requirements ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property library
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://www.saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
enum ENUM_XSSLC_BUFFERS
|
||||||
|
{
|
||||||
|
XSSLC_MAIN_LINE = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Input Models ...
|
||||||
|
struct XSSLCInputs
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor(s) ...
|
||||||
|
XSSLCInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clean ...
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Default ...
|
||||||
|
void Default()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
false
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve MAx Length ...
|
||||||
|
int Max()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = MathMax(0, 0);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class ...
|
||||||
|
class XSCXSSLCHelper : public XSCBaseHelper
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Public ...
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructors ...
|
||||||
|
XSCXSSLCHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
~XSCXSSLCHelper() {}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
bool Init(
|
||||||
|
string symbol, // Trading Symbol
|
||||||
|
ENUM_TIMEFRAMES period, // Trading Period
|
||||||
|
XSSLCInputs &inputs // Inputs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
mSymbol = symbol;
|
||||||
|
mPeriod = period;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = inputs.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mInputs = inputs;
|
||||||
|
|
||||||
|
//
|
||||||
|
// ArraySetAsSeries(mainBuffer, true);
|
||||||
|
// mHandler = iCustom(
|
||||||
|
// mSymbol,
|
||||||
|
// mPeriod,
|
||||||
|
// "x-saherelm.xsslc",
|
||||||
|
// //
|
||||||
|
// // Inputs ...
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
// result = mHandler != INVALID_HANDLE;
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XSSLCInputs GetInputs()
|
||||||
|
{
|
||||||
|
return mInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool SetInputs(
|
||||||
|
XSSLCInputs &inputs // Configs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return Init(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
inputs
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double GetMain(
|
||||||
|
// int barIndex // Bar Index
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// if (barIndex < 0)
|
||||||
|
// {
|
||||||
|
// barIndex = 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// Calculate();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// int count = ArraySize(mainBuffer);
|
||||||
|
// if (barIndex >= count)
|
||||||
|
// {
|
||||||
|
// barIndex = count - 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// return mainBuffer[barIndex];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Copy Required Items ...
|
||||||
|
// int CopyMain(
|
||||||
|
// int start, // Start
|
||||||
|
// int count, // Number of Items for read
|
||||||
|
// double &buffer[], // Dest Buffer
|
||||||
|
// bool forceClean = true // Force To Clean buffer
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Update Calculations ...
|
||||||
|
// Calculate();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Copy Items ...
|
||||||
|
// return Copy(
|
||||||
|
// start,
|
||||||
|
// count,
|
||||||
|
// mainBuffer,
|
||||||
|
// buffer,
|
||||||
|
// forceClean
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protected ...
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
// Private ...
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
XSSLCInputs mInputs; // Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
// double mainBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Values Until Now ...
|
||||||
|
void Calculate()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int totalBars = CountBars();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Main Buffer ...
|
||||||
|
// CopyBuffer(
|
||||||
|
// mHandler,
|
||||||
|
// XSSLC_MAIN_LINE,
|
||||||
|
// 0,
|
||||||
|
// totalBars,
|
||||||
|
// mainBuffer
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
@@ -252,8 +252,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Copy Required Main Buffer ...
|
// Copy Required Items ...
|
||||||
int CopyMainBuffer(
|
int CopyMain(
|
||||||
int start, // Start
|
int start, // Start
|
||||||
int count, // Number of Items for read
|
int count, // Number of Items for read
|
||||||
double &buffer[], // Dest Buffer
|
double &buffer[], // Dest Buffer
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,408 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Helper Class Library
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Name: XSCXSSLCHelper
|
||||||
|
// Description: provides all Indicator
|
||||||
|
// Helper requirements ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property library
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://www.saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
enum ENUM_XSSLC_BUFFERS
|
||||||
|
{
|
||||||
|
XSSLC_UP_LINE = 0,
|
||||||
|
XSSLC_DOWN_LINE = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Input Models ...
|
||||||
|
struct XSSLCInputs
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
int length; // Length
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculation ...
|
||||||
|
ENUM_MA_METHOD method; // Method
|
||||||
|
ENUM_APPLIED_PRICE upAppliedTo; // Up Applied To
|
||||||
|
ENUM_APPLIED_PRICE downAppliedTo; // Down Applied To
|
||||||
|
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
bool showUp; // Show Up
|
||||||
|
bool showDown; // Show Down
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor(s) ...
|
||||||
|
XSSLCInputs()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clean ...
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
length = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculation ...
|
||||||
|
method = MODE_SMA;
|
||||||
|
upAppliedTo = PRICE_HIGH;
|
||||||
|
downAppliedTo = PRICE_LOW;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
showUp = false;
|
||||||
|
showDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Default ...
|
||||||
|
void Default()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
length = 36;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculation ...
|
||||||
|
method = MODE_SMA;
|
||||||
|
upAppliedTo = PRICE_HIGH;
|
||||||
|
downAppliedTo = PRICE_LOW;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
showUp = true;
|
||||||
|
showDown = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
false
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve MAx Length ...
|
||||||
|
int Max()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = MathMax(0, 0);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class ...
|
||||||
|
class XSCXSSLCHelper : public XSCBaseHelper
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Public ...
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructors ...
|
||||||
|
XSCXSSLCHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
~XSCXSSLCHelper() {}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
bool Init(
|
||||||
|
string symbol, // Trading Symbol
|
||||||
|
ENUM_TIMEFRAMES period, // Trading Period
|
||||||
|
XSSLCInputs &inputs // Inputs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
mSymbol = symbol;
|
||||||
|
mPeriod = period;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = inputs.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mInputs = inputs;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(upBuffer, true);
|
||||||
|
ArraySetAsSeries(downBuffer, true);
|
||||||
|
|
||||||
|
//
|
||||||
|
mHandler = iCustom(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
"x-saherelm.xsslc",
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
//
|
||||||
|
// Market ...
|
||||||
|
"",
|
||||||
|
mInputs.length, // Length
|
||||||
|
//
|
||||||
|
// Calculation ...
|
||||||
|
"",
|
||||||
|
mInputs.method, // Method
|
||||||
|
mInputs.upAppliedTo, // Up Applied To
|
||||||
|
mInputs.downAppliedTo, // Down Applied To
|
||||||
|
//
|
||||||
|
// Presentation ...
|
||||||
|
"",
|
||||||
|
mInputs.showUp, // Show Up
|
||||||
|
mInputs.showDown // Show Down
|
||||||
|
//
|
||||||
|
);
|
||||||
|
result = mHandler != INVALID_HANDLE;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XSSLCInputs GetInputs()
|
||||||
|
{
|
||||||
|
return mInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool SetInputs(
|
||||||
|
XSSLCInputs &inputs // Configs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return Init(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
inputs
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Up ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetUp(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(upBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return upBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyUp(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
upBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Down ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetDown(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(downBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return downBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Required Items ...
|
||||||
|
int CopyDown(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
downBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protected ...
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
// Private ...
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
XSSLCInputs mInputs; // Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
double upBuffer[];
|
||||||
|
double downBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Values Until Now ...
|
||||||
|
void Calculate()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int totalBars = CountBars();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Up ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XSSLC_UP_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
upBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Down ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
XSSLC_DOWN_LINE,
|
||||||
|
0,
|
||||||
|
totalBars,
|
||||||
|
downBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
@@ -245,8 +245,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Copy Required Main Buffer ...
|
// Copy Required Items ...
|
||||||
int CopyMainBuffer(
|
int CopyMain(
|
||||||
int start, // Start
|
int start, // Start
|
||||||
int count, // Number of Items for read
|
int count, // Number of Items for read
|
||||||
double &buffer[], // Dest Buffer
|
double &buffer[], // Dest Buffer
|
||||||
|
|||||||
+170
-177
@@ -17,57 +17,44 @@
|
|||||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
#property link "https://saherelm.ir"
|
#property link "https://saherelm.ir"
|
||||||
#property version "1.00"
|
#property version "1.00"
|
||||||
#property description "SaherElm X121_XHK Indicator"
|
#property description "SaherElm XHK Indicator"
|
||||||
#property strict
|
#property strict
|
||||||
|
|
||||||
//
|
//
|
||||||
// START Constants ...
|
// Constants ...
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Indicator Short Name ...
|
// Indicator Short Name ...
|
||||||
#define ShortName "X121_XHK"
|
#define ShortName "XHK"
|
||||||
|
|
||||||
//
|
//
|
||||||
// END Constants ...
|
// Imports ...
|
||||||
//
|
#include <MovingAverages.mqh>
|
||||||
|
|
||||||
//
|
|
||||||
// START Inputs ...
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
input group "Presentation";
|
|
||||||
input bool drawCandles = true; // Draw Hiken Ashi Candle
|
|
||||||
input bool drawCandleLines = false; // Show HikenAshi Lines
|
|
||||||
|
|
||||||
//
|
|
||||||
// END Inputs ...
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// START Includes and Imports ...
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Includes Common Library ...
|
|
||||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// END Includes and Imports ...
|
// Inputs ...
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// START Buffers ...
|
input group "Market";
|
||||||
|
input int smoothingLength = 17; // Smoothing Length
|
||||||
|
//
|
||||||
|
input group "Presentation";
|
||||||
|
input bool drawHikenAshi = true; // Draw Hiken Ashi
|
||||||
|
input bool drawSmoothedHikenAshi = true; // Draw Smoothed Hiken Ashi
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 13
|
#property indicator_buffers 10
|
||||||
#property indicator_plots 5
|
#property indicator_plots 10
|
||||||
|
|
||||||
//
|
//
|
||||||
// PLOTTED Buffers ...
|
// Buffers ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open ...
|
// Open ...
|
||||||
@@ -98,84 +85,54 @@ double candleColorBuffer[];
|
|||||||
#define candlesBufferIndex 0
|
#define candlesBufferIndex 0
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_label1 "X121_XHK Open;X121_XHK High;X121_XHK Low;X121_XHK Close"
|
#property indicator_label1 "XHK Open;XHK High;XHK Low;XHK Close"
|
||||||
#property indicator_type1 DRAW_COLOR_CANDLES
|
#property indicator_type1 DRAW_COLOR_CANDLES
|
||||||
#property indicator_color1 clrAqua, clrMagenta, CLR_NONE
|
#property indicator_color1 CLR_NONE, clrAqua, clrMagenta
|
||||||
|
|
||||||
//
|
//
|
||||||
#define openHKBufferIndex 5
|
// SM Open ...
|
||||||
#define openHKColorBufferIndex 6
|
#define openSMBufferIndex 5
|
||||||
double openHKBuffer[];
|
double openSMBuffer[];
|
||||||
double openHKColorBuffer[];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#define openHKBufferPlotIndex 1
|
// SM High ...
|
||||||
#property indicator_label2 "X121_XHK O"
|
#define highSMBufferIndex 6
|
||||||
#property indicator_type2 DRAW_COLOR_LINE
|
double highSMBuffer[];
|
||||||
#property indicator_color2 clrAqua, clrMagenta, clrLightGray
|
|
||||||
#property indicator_style2 STYLE_DOT
|
|
||||||
#property indicator_width2 1
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#define highHKBufferIndex 7
|
// SM Low ...
|
||||||
#define highHKColorBufferIndex 8
|
#define lowSMBufferIndex 7
|
||||||
double highHKBuffer[];
|
double lowSMBuffer[];
|
||||||
double highHKColorBuffer[];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#define highHKBufferPlotIndex 2
|
// SM Close ...
|
||||||
#property indicator_label3 "X121_XHK H"
|
#define closeSMBufferIndex 8
|
||||||
#property indicator_type3 DRAW_COLOR_LINE
|
double closeSMBuffer[];
|
||||||
#property indicator_color3 clrAqua, clrMagenta, clrLightGray
|
|
||||||
#property indicator_style3 STYLE_DOT
|
|
||||||
#property indicator_width3 1
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#define lowHKBufferIndex 9
|
// SM Candle Color ...
|
||||||
#define lowHKColorBufferIndex 10
|
#define candleColorSMBufferIndex 9
|
||||||
double lowHKBuffer[];
|
double candleColorSMBuffer[];
|
||||||
double lowHKColorBuffer[];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#define lowHKBufferPlotIndex 3
|
#define candlesSMBufferIndex 1
|
||||||
#property indicator_label4 "X121_XHK L"
|
|
||||||
#property indicator_type4 DRAW_COLOR_LINE
|
|
||||||
#property indicator_color4 clrAqua, clrMagenta, clrLightGray
|
|
||||||
#property indicator_style4 STYLE_DOT
|
|
||||||
#property indicator_width4 1
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#define closeHKBufferIndex 11
|
#property indicator_label2 "XSMHK Open;XSMHK High;XSMHK Low;XSMHK Close"
|
||||||
#define closeHKColorBufferIndex 12
|
#property indicator_type2 DRAW_COLOR_CANDLES
|
||||||
double closeHKBuffer[];
|
#property indicator_color2 CLR_NONE, clrDarkGreen, clrDarkRed
|
||||||
double closeHKColorBuffer[];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#define closeHKBufferPlotIndex 4
|
// Variables, Properties and etc ...
|
||||||
#property indicator_label5 "X121_XHK C"
|
|
||||||
#property indicator_type5 DRAW_COLOR_LINE
|
|
||||||
#property indicator_color5 clrAqua, clrMagenta, clrLightGray
|
|
||||||
#property indicator_style5 STYLE_DOT
|
|
||||||
#property indicator_width5 1
|
|
||||||
|
|
||||||
//
|
|
||||||
// END Buffers ...
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// START Global Definitions: Variables, Properties and etc ...
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
int maxLength;
|
int maxLength;
|
||||||
|
|
||||||
//
|
//
|
||||||
// END Global Definitions: Variables, Properties and etc ...
|
double mHideColorIDX = 0;
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// START Event Handlers ...
|
// Event Handlers ...
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialization ...
|
// Initialization ...
|
||||||
@@ -228,36 +185,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[])
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Prepare Buffers ...
|
// Prepare Buffers ...
|
||||||
@@ -284,17 +222,15 @@ int OnCalculate(
|
|||||||
CalculateBuffers(i, prev_calculated, rates_total, open, high, close, low);
|
CalculateBuffers(i, prev_calculated, rates_total, open, high, close, low);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
CalculateSM(rates_total, prev_calculated);
|
||||||
|
|
||||||
//
|
//
|
||||||
return rates_total;
|
return rates_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// END Event Handlers ...
|
// Functions ...
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// START Functions ...
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Input Args for Initialization ...
|
// Validate Input Args for Initialization ...
|
||||||
@@ -361,52 +297,41 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(lowBufferIndex, PLOT_SHOW_DATA, false);
|
PlotIndexSetInteger(lowBufferIndex, PLOT_SHOW_DATA, false);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open HK ...
|
// Candles Color ...
|
||||||
ENUM_DRAW_TYPE openDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
ArraySetAsSeries(candleColorSMBuffer, true);
|
||||||
ArraySetAsSeries(openHKBuffer, true);
|
SetIndexBuffer(candleColorSMBufferIndex, candleColorSMBuffer, INDICATOR_COLOR_INDEX);
|
||||||
SetIndexBuffer(openHKBufferIndex, openHKBuffer, INDICATOR_DATA);
|
|
||||||
PlotIndexSetInteger(openHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
|
||||||
PlotIndexSetInteger(openHKBufferPlotIndex, PLOT_DRAW_TYPE, openDrawType);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(openHKColorBuffer, true);
|
// Set EMPTY_VALUE on Candles Buffer ...
|
||||||
SetIndexBuffer(openHKColorBufferIndex, openHKColorBuffer, INDICATOR_COLOR_INDEX);
|
PlotIndexSetDouble(candlesSMBufferIndex, PLOT_EMPTY_VALUE, 0.0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// High HK ...
|
PlotIndexSetInteger(candlesSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||||
ENUM_DRAW_TYPE highDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
PlotIndexSetInteger(candleColorSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||||
ArraySetAsSeries(highHKBuffer, true);
|
|
||||||
SetIndexBuffer(highHKBufferIndex, highHKBuffer, INDICATOR_DATA);
|
|
||||||
PlotIndexSetInteger(highHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
|
||||||
PlotIndexSetInteger(highHKBufferPlotIndex, PLOT_DRAW_TYPE, highDrawType);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(highHKColorBuffer, true);
|
// Open ...
|
||||||
SetIndexBuffer(highHKColorBufferIndex, highHKColorBuffer, INDICATOR_COLOR_INDEX);
|
ArraySetAsSeries(openSMBuffer, true);
|
||||||
|
PlotIndexSetInteger(openSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||||
|
SetIndexBuffer(openSMBufferIndex, openSMBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Low HK ...
|
// High ...
|
||||||
ENUM_DRAW_TYPE lowDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
ArraySetAsSeries(highSMBuffer, true);
|
||||||
ArraySetAsSeries(lowHKBuffer, true);
|
SetIndexBuffer(highSMBufferIndex, highSMBuffer, INDICATOR_DATA);
|
||||||
SetIndexBuffer(lowHKBufferIndex, lowHKBuffer, INDICATOR_DATA);
|
PlotIndexSetInteger(highSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||||
PlotIndexSetInteger(lowHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
|
||||||
PlotIndexSetInteger(lowHKBufferPlotIndex, PLOT_DRAW_TYPE, lowDrawType);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(lowHKColorBuffer, true);
|
// Close ...
|
||||||
SetIndexBuffer(lowHKColorBufferIndex, lowHKColorBuffer, INDICATOR_COLOR_INDEX);
|
ArraySetAsSeries(closeSMBuffer, true);
|
||||||
|
SetIndexBuffer(closeSMBufferIndex, closeSMBuffer, INDICATOR_DATA);
|
||||||
|
PlotIndexSetInteger(closeSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Close HK ...
|
// Low ...
|
||||||
ENUM_DRAW_TYPE closeDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
ArraySetAsSeries(lowSMBuffer, true);
|
||||||
ArraySetAsSeries(closeHKBuffer, true);
|
SetIndexBuffer(lowSMBufferIndex, lowSMBuffer, INDICATOR_DATA);
|
||||||
SetIndexBuffer(closeHKBufferIndex, closeHKBuffer, INDICATOR_DATA);
|
PlotIndexSetInteger(lowSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||||
PlotIndexSetInteger(closeHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
|
||||||
PlotIndexSetInteger(closeHKBufferPlotIndex, PLOT_DRAW_TYPE, closeDrawType);
|
|
||||||
|
|
||||||
//
|
|
||||||
ArraySetAsSeries(closeHKColorBuffer, true);
|
|
||||||
SetIndexBuffer(closeHKColorBufferIndex, closeHKColorBuffer, INDICATOR_COLOR_INDEX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -425,7 +350,8 @@ void CalculateBuffers(
|
|||||||
const double &open[],
|
const double &open[],
|
||||||
const double &high[],
|
const double &high[],
|
||||||
const double &close[],
|
const double &close[],
|
||||||
const double &low[])
|
const double &low[] //
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
double mPrevHKOpenValue;
|
double mPrevHKOpenValue;
|
||||||
@@ -458,29 +384,96 @@ void CalculateBuffers(
|
|||||||
closeBuffer[bar_index] = mHKCloseValue;
|
closeBuffer[bar_index] = mHKCloseValue;
|
||||||
|
|
||||||
//
|
//
|
||||||
double candleColorValue =
|
bool isBearish =
|
||||||
mHKOpenValue < mHKCloseValue ? 0 : 1;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
candleColorBuffer[bar_index] = drawCandles ? candleColorValue : 2;
|
openBuffer[bar_index] > closeBuffer[bar_index]
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
//
|
//
|
||||||
openHKBuffer[bar_index] = mHKOpenValue;
|
candleColorBuffer[bar_index] = !drawHikenAshi
|
||||||
openHKColorBuffer[bar_index] = candleColorValue;
|
? mHideColorIDX
|
||||||
|
: isBearish
|
||||||
//
|
? 2
|
||||||
highHKBuffer[bar_index] = mHKHighValue;
|
: 1;
|
||||||
highHKColorBuffer[bar_index] = candleColorValue;
|
|
||||||
|
|
||||||
//
|
|
||||||
lowHKBuffer[bar_index] = mHKLowValue;
|
|
||||||
lowHKColorBuffer[bar_index] = candleColorValue;
|
|
||||||
|
|
||||||
//
|
|
||||||
closeHKBuffer[bar_index] = mHKCloseValue;
|
|
||||||
closeHKColorBuffer[bar_index] = candleColorValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// END Functions ...
|
// Calculate Smoothed HikenAshi ...
|
||||||
//
|
void CalculateSM(
|
||||||
|
int ratesTotal, // Total Bars
|
||||||
|
int prevCalculated // Calculated Bars
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Open ...
|
||||||
|
int calculatedSMHKOpens = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
smoothingLength,
|
||||||
|
openBuffer,
|
||||||
|
openSMBuffer);
|
||||||
|
|
||||||
|
//
|
||||||
|
// High ...
|
||||||
|
int calculatedSMHKHighs = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
smoothingLength,
|
||||||
|
highBuffer,
|
||||||
|
highSMBuffer);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Low ...
|
||||||
|
int calculatedSMHKLows = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
smoothingLength,
|
||||||
|
lowBuffer,
|
||||||
|
lowSMBuffer);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close ...
|
||||||
|
int calculatedSMHKCloses = ExponentialMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
0,
|
||||||
|
smoothingLength,
|
||||||
|
closeBuffer,
|
||||||
|
closeSMBuffer);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find Calculated Items for Colors ...
|
||||||
|
int mNumberOfItems = MathMin(calculatedSMHKOpens, calculatedSMHKHighs);
|
||||||
|
mNumberOfItems = MathMin(mNumberOfItems, calculatedSMHKLows);
|
||||||
|
mNumberOfItems = MathMin(mNumberOfItems, calculatedSMHKCloses);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create a Loop for Color of Candles ...
|
||||||
|
for (int i = 0; i < mNumberOfItems; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isBearish =
|
||||||
|
//
|
||||||
|
openSMBuffer[i] > closeSMBuffer[i]
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (drawSmoothedHikenAshi)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
candleColorSMBuffer[i] = isBearish
|
||||||
|
? 2
|
||||||
|
: 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
candleColorSMBuffer[i] = mHideColorIDX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -906,6 +906,7 @@ void CalculateCycle(
|
|||||||
double &llColorBuffer[] //
|
double &llColorBuffer[] //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
cycle.Update(barIndex);
|
cycle.Update(barIndex);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -348,10 +348,9 @@ void DefineBuffers()
|
|||||||
//
|
//
|
||||||
ENUM_DRAW_TYPE upDrawType = showUp ? DRAW_LINE : DRAW_NONE;
|
ENUM_DRAW_TYPE upDrawType = showUp ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
|
|
||||||
ArraySetAsSeries(upBuffer, true);
|
ArraySetAsSeries(upBuffer, true);
|
||||||
SetIndexBuffer(upBufferIndex, upBuffer, INDICATOR_DATA);
|
SetIndexBuffer(upBufferIndex, upBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(upBufferIndex, PLOT_SHOW_DATA, false);
|
PlotIndexSetInteger(upBufferIndex, PLOT_SHOW_DATA, showUp);
|
||||||
PlotIndexSetInteger(upBufferIndex, PLOT_DRAW_BEGIN, maxLength);
|
PlotIndexSetInteger(upBufferIndex, PLOT_DRAW_BEGIN, maxLength);
|
||||||
PlotIndexSetInteger(upBufferIndex, PLOT_DRAW_TYPE, upDrawType);
|
PlotIndexSetInteger(upBufferIndex, PLOT_DRAW_TYPE, upDrawType);
|
||||||
|
|
||||||
@@ -361,7 +360,6 @@ void DefineBuffers()
|
|||||||
//
|
//
|
||||||
ENUM_DRAW_TYPE downDrawType = showDown ? DRAW_LINE : DRAW_NONE;
|
ENUM_DRAW_TYPE downDrawType = showDown ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
|
|
||||||
ArraySetAsSeries(downBuffer, true);
|
ArraySetAsSeries(downBuffer, true);
|
||||||
SetIndexBuffer(downBufferIndex, downBuffer, INDICATOR_DATA);
|
SetIndexBuffer(downBufferIndex, downBuffer, INDICATOR_DATA);
|
||||||
PlotIndexSetInteger(downBufferIndex, PLOT_SHOW_DATA, showDown);
|
PlotIndexSetInteger(downBufferIndex, PLOT_SHOW_DATA, showDown);
|
||||||
@@ -412,11 +410,16 @@ void CalculateBuffers(
|
|||||||
|
|
||||||
//
|
//
|
||||||
double kpiValue;
|
double kpiValue;
|
||||||
if (closeValue > upMaValue) {
|
if (closeValue > upMaValue)
|
||||||
|
{
|
||||||
kpiValue = 1;
|
kpiValue = 1;
|
||||||
} else if (closeValue < downMaValue) {
|
}
|
||||||
|
else if (closeValue < downMaValue)
|
||||||
|
{
|
||||||
kpiValue = -1;
|
kpiValue = -1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
kpiValue = kpiBuffer[bar_index + 1];
|
kpiValue = kpiBuffer[bar_index + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,6 +353,86 @@ struct XOHCL
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool Init(
|
||||||
|
string mSymbol = NULL, // Trading Symbol
|
||||||
|
ENUM_TIMEFRAMES mPeriod = NULL, // Trading Period
|
||||||
|
double mOpen = 0, // Open
|
||||||
|
double mHigh = 0, // High
|
||||||
|
double mClose = 0, // Close
|
||||||
|
double mLow = 0, // Low
|
||||||
|
int barIndex = 0 // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
mSymbol = NormalizeSymbol(mSymbol);
|
||||||
|
mPeriod = NormalizePeriod(mPeriod);
|
||||||
|
|
||||||
|
//
|
||||||
|
symbol = mSymbol;
|
||||||
|
period = mPeriod;
|
||||||
|
|
||||||
|
//
|
||||||
|
time = iTime(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
barIndex
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
open = mOpen;
|
||||||
|
high = mHigh;
|
||||||
|
close = mClose;
|
||||||
|
low = mLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
return IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool Init(
|
||||||
|
string mSymbol = NULL, // Trading Symbol
|
||||||
|
ENUM_TIMEFRAMES mPeriod = NULL, // Trading Period
|
||||||
|
double mOpen = 0, // Open
|
||||||
|
double mHigh = 0, // High
|
||||||
|
double mClose = 0, // Close
|
||||||
|
double mLow = 0, // Low
|
||||||
|
datetime mTime = NULL // Bar Time
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
mSymbol = NormalizeSymbol(mSymbol);
|
||||||
|
mPeriod = NormalizePeriod(mPeriod);
|
||||||
|
|
||||||
|
//
|
||||||
|
symbol = mSymbol;
|
||||||
|
period = mPeriod;
|
||||||
|
|
||||||
|
//
|
||||||
|
int barIndex = iBarShift(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
mTime);
|
||||||
|
|
||||||
|
//
|
||||||
|
time = iTime(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
barIndex
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
open = mOpen;
|
||||||
|
high = mHigh;
|
||||||
|
close = mClose;
|
||||||
|
low = mLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
return IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tools ...
|
// Tools ...
|
||||||
|
|
||||||
@@ -3593,6 +3673,74 @@ int Copy(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items from a Buffer ...
|
||||||
|
template <typename T>
|
||||||
|
int CopyRef(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
T &source[], // Source Buffer
|
||||||
|
T &dest[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (forceClean)
|
||||||
|
{
|
||||||
|
Clean(dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (start < 0)
|
||||||
|
{
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (start >= ArraySize(source))
|
||||||
|
{
|
||||||
|
start = ArraySize(source) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int beforeSize = ArraySize(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool asSeriesDest = ArrayGetAsSeries(dest);
|
||||||
|
bool asSeriesSource = ArrayGetAsSeries(source);
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(dest, true);
|
||||||
|
ArraySetAsSeries(source, true);
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = start; i < start + count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
source[i],
|
||||||
|
dest
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int afterSize = ArraySize(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = afterSize - beforeSize;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(dest, asSeriesDest);
|
||||||
|
ArraySetAsSeries(source, asSeriesSource);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrive Last Item of Specified Buffer ...
|
// Retrive Last Item of Specified Buffer ...
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
Reference in New Issue
Block a user