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 ...
|
||||
int CopyMainBuffer(
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
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 ...
|
||||
int CopyMainBuffer(
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
|
||||
+170
-177
@@ -17,57 +17,44 @@
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm X121_XHK Indicator"
|
||||
#property description "SaherElm XHK Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
// Constants ...
|
||||
|
||||
//
|
||||
// Indicator Short Name ...
|
||||
#define ShortName "X121_XHK"
|
||||
#define ShortName "XHK"
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
// Imports ...
|
||||
#include <MovingAverages.mqh>
|
||||
#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_buffers 13
|
||||
#property indicator_plots 5
|
||||
#property indicator_buffers 10
|
||||
#property indicator_plots 10
|
||||
|
||||
//
|
||||
// PLOTTED Buffers ...
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Open ...
|
||||
@@ -98,84 +85,54 @@ double candleColorBuffer[];
|
||||
#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_color1 clrAqua, clrMagenta, CLR_NONE
|
||||
#property indicator_color1 CLR_NONE, clrAqua, clrMagenta
|
||||
|
||||
//
|
||||
#define openHKBufferIndex 5
|
||||
#define openHKColorBufferIndex 6
|
||||
double openHKBuffer[];
|
||||
double openHKColorBuffer[];
|
||||
// SM Open ...
|
||||
#define openSMBufferIndex 5
|
||||
double openSMBuffer[];
|
||||
|
||||
//
|
||||
#define openHKBufferPlotIndex 1
|
||||
#property indicator_label2 "X121_XHK O"
|
||||
#property indicator_type2 DRAW_COLOR_LINE
|
||||
#property indicator_color2 clrAqua, clrMagenta, clrLightGray
|
||||
#property indicator_style2 STYLE_DOT
|
||||
#property indicator_width2 1
|
||||
// SM High ...
|
||||
#define highSMBufferIndex 6
|
||||
double highSMBuffer[];
|
||||
|
||||
//
|
||||
#define highHKBufferIndex 7
|
||||
#define highHKColorBufferIndex 8
|
||||
double highHKBuffer[];
|
||||
double highHKColorBuffer[];
|
||||
// SM Low ...
|
||||
#define lowSMBufferIndex 7
|
||||
double lowSMBuffer[];
|
||||
|
||||
//
|
||||
#define highHKBufferPlotIndex 2
|
||||
#property indicator_label3 "X121_XHK H"
|
||||
#property indicator_type3 DRAW_COLOR_LINE
|
||||
#property indicator_color3 clrAqua, clrMagenta, clrLightGray
|
||||
#property indicator_style3 STYLE_DOT
|
||||
#property indicator_width3 1
|
||||
// SM Close ...
|
||||
#define closeSMBufferIndex 8
|
||||
double closeSMBuffer[];
|
||||
|
||||
//
|
||||
#define lowHKBufferIndex 9
|
||||
#define lowHKColorBufferIndex 10
|
||||
double lowHKBuffer[];
|
||||
double lowHKColorBuffer[];
|
||||
// SM Candle Color ...
|
||||
#define candleColorSMBufferIndex 9
|
||||
double candleColorSMBuffer[];
|
||||
|
||||
//
|
||||
#define lowHKBufferPlotIndex 3
|
||||
#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 candlesSMBufferIndex 1
|
||||
|
||||
//
|
||||
#define closeHKBufferIndex 11
|
||||
#define closeHKColorBufferIndex 12
|
||||
double closeHKBuffer[];
|
||||
double closeHKColorBuffer[];
|
||||
#property indicator_label2 "XSMHK Open;XSMHK High;XSMHK Low;XSMHK Close"
|
||||
#property indicator_type2 DRAW_COLOR_CANDLES
|
||||
#property indicator_color2 CLR_NONE, clrDarkGreen, clrDarkRed
|
||||
|
||||
//
|
||||
#define closeHKBufferPlotIndex 4
|
||||
#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 ...
|
||||
//
|
||||
// Variables, Properties and etc ...
|
||||
|
||||
//
|
||||
int maxLength;
|
||||
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
double mHideColorIDX = 0;
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
@@ -228,36 +185,17 @@ void OnDeinit(const int reason)
|
||||
//
|
||||
// Calculating what we want ...
|
||||
int OnCalculate(
|
||||
//
|
||||
// total Candles on chart ...
|
||||
const int rates_total,
|
||||
//
|
||||
// total calculated Candles on charts ...
|
||||
const int prev_calculated,
|
||||
//
|
||||
// history of Candles Open Time ...
|
||||
const datetime &time[],
|
||||
//
|
||||
// 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[])
|
||||
const int rates_total, // Total Bars on Chart ...
|
||||
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||
const datetime &time[], // History of Open Time ...
|
||||
const double &open[], // History of Open Price ...
|
||||
const double &high[], // History of High Price ...
|
||||
const double &low[], // History of Low Price ...
|
||||
const double &close[], // History of Close Price ...
|
||||
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||
const long &volume[], // History of Trade Volumes ...
|
||||
const int &spread[] // History of Spread Price ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// Prepare Buffers ...
|
||||
@@ -284,17 +222,15 @@ int OnCalculate(
|
||||
CalculateBuffers(i, prev_calculated, rates_total, open, high, close, low);
|
||||
}
|
||||
|
||||
//
|
||||
CalculateSM(rates_total, prev_calculated);
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
// Functions ...
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
@@ -361,52 +297,41 @@ void DefineBuffers()
|
||||
PlotIndexSetInteger(lowBufferIndex, PLOT_SHOW_DATA, false);
|
||||
|
||||
//
|
||||
// Open HK ...
|
||||
ENUM_DRAW_TYPE openDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(openHKBuffer, true);
|
||||
SetIndexBuffer(openHKBufferIndex, openHKBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(openHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
||||
PlotIndexSetInteger(openHKBufferPlotIndex, PLOT_DRAW_TYPE, openDrawType);
|
||||
// Candles Color ...
|
||||
ArraySetAsSeries(candleColorSMBuffer, true);
|
||||
SetIndexBuffer(candleColorSMBufferIndex, candleColorSMBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(openHKColorBuffer, true);
|
||||
SetIndexBuffer(openHKColorBufferIndex, openHKColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
// Set EMPTY_VALUE on Candles Buffer ...
|
||||
PlotIndexSetDouble(candlesSMBufferIndex, PLOT_EMPTY_VALUE, 0.0);
|
||||
|
||||
//
|
||||
// High HK ...
|
||||
ENUM_DRAW_TYPE highDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(highHKBuffer, true);
|
||||
SetIndexBuffer(highHKBufferIndex, highHKBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(highHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
||||
PlotIndexSetInteger(highHKBufferPlotIndex, PLOT_DRAW_TYPE, highDrawType);
|
||||
PlotIndexSetInteger(candlesSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(candleColorSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(highHKColorBuffer, true);
|
||||
SetIndexBuffer(highHKColorBufferIndex, highHKColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
// Open ...
|
||||
ArraySetAsSeries(openSMBuffer, true);
|
||||
PlotIndexSetInteger(openSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||
SetIndexBuffer(openSMBufferIndex, openSMBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
// Low HK ...
|
||||
ENUM_DRAW_TYPE lowDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(lowHKBuffer, true);
|
||||
SetIndexBuffer(lowHKBufferIndex, lowHKBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lowHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
||||
PlotIndexSetInteger(lowHKBufferPlotIndex, PLOT_DRAW_TYPE, lowDrawType);
|
||||
// High ...
|
||||
ArraySetAsSeries(highSMBuffer, true);
|
||||
SetIndexBuffer(highSMBufferIndex, highSMBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(highSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(lowHKColorBuffer, true);
|
||||
SetIndexBuffer(lowHKColorBufferIndex, lowHKColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
// Close ...
|
||||
ArraySetAsSeries(closeSMBuffer, true);
|
||||
SetIndexBuffer(closeSMBufferIndex, closeSMBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(closeSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||
|
||||
//
|
||||
// Close HK ...
|
||||
ENUM_DRAW_TYPE closeDrawType = drawCandleLines ? DRAW_COLOR_LINE : DRAW_NONE;
|
||||
ArraySetAsSeries(closeHKBuffer, true);
|
||||
SetIndexBuffer(closeHKBufferIndex, closeHKBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(closeHKBufferPlotIndex, PLOT_SHOW_DATA, drawCandleLines);
|
||||
PlotIndexSetInteger(closeHKBufferPlotIndex, PLOT_DRAW_TYPE, closeDrawType);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(closeHKColorBuffer, true);
|
||||
SetIndexBuffer(closeHKColorBufferIndex, closeHKColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
// Low ...
|
||||
ArraySetAsSeries(lowSMBuffer, true);
|
||||
SetIndexBuffer(lowSMBufferIndex, lowSMBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lowSMBufferIndex, PLOT_SHOW_DATA, false);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -425,7 +350,8 @@ void CalculateBuffers(
|
||||
const double &open[],
|
||||
const double &high[],
|
||||
const double &close[],
|
||||
const double &low[])
|
||||
const double &low[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
double mPrevHKOpenValue;
|
||||
@@ -458,29 +384,96 @@ void CalculateBuffers(
|
||||
closeBuffer[bar_index] = mHKCloseValue;
|
||||
|
||||
//
|
||||
double candleColorValue =
|
||||
mHKOpenValue < mHKCloseValue ? 0 : 1;
|
||||
|
||||
bool isBearish =
|
||||
//
|
||||
candleColorBuffer[bar_index] = drawCandles ? candleColorValue : 2;
|
||||
openBuffer[bar_index] > closeBuffer[bar_index]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
openHKBuffer[bar_index] = mHKOpenValue;
|
||||
openHKColorBuffer[bar_index] = candleColorValue;
|
||||
|
||||
//
|
||||
highHKBuffer[bar_index] = mHKHighValue;
|
||||
highHKColorBuffer[bar_index] = candleColorValue;
|
||||
|
||||
//
|
||||
lowHKBuffer[bar_index] = mHKLowValue;
|
||||
lowHKColorBuffer[bar_index] = candleColorValue;
|
||||
|
||||
//
|
||||
closeHKBuffer[bar_index] = mHKCloseValue;
|
||||
closeHKColorBuffer[bar_index] = candleColorValue;
|
||||
candleColorBuffer[bar_index] = !drawHikenAshi
|
||||
? mHideColorIDX
|
||||
: isBearish
|
||||
? 2
|
||||
: 1;
|
||||
}
|
||||
|
||||
//
|
||||
// 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[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
cycle.Update(barIndex);
|
||||
|
||||
//
|
||||
|
||||
@@ -348,10 +348,9 @@ void DefineBuffers()
|
||||
//
|
||||
ENUM_DRAW_TYPE upDrawType = showUp ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
|
||||
ArraySetAsSeries(upBuffer, true);
|
||||
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_TYPE, upDrawType);
|
||||
|
||||
@@ -361,7 +360,6 @@ void DefineBuffers()
|
||||
//
|
||||
ENUM_DRAW_TYPE downDrawType = showDown ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
|
||||
ArraySetAsSeries(downBuffer, true);
|
||||
SetIndexBuffer(downBufferIndex, downBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(downBufferIndex, PLOT_SHOW_DATA, showDown);
|
||||
@@ -412,11 +410,16 @@ void CalculateBuffers(
|
||||
|
||||
//
|
||||
double kpiValue;
|
||||
if (closeValue > upMaValue) {
|
||||
if (closeValue > upMaValue)
|
||||
{
|
||||
kpiValue = 1;
|
||||
} else if (closeValue < downMaValue) {
|
||||
}
|
||||
else if (closeValue < downMaValue)
|
||||
{
|
||||
kpiValue = -1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
kpiValue = kpiBuffer[bar_index + 1];
|
||||
}
|
||||
|
||||
|
||||
@@ -353,6 +353,86 @@ struct XOHCL
|
||||
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 ...
|
||||
|
||||
@@ -3593,6 +3673,74 @@ int Copy(
|
||||
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 ...
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user