Files
xMQL5/BKPS/14030823/BKPs/14030802-X121/Helpers/x-saherelm.xchdon.helper.mq5
T
2024-11-15 10:50:11 +03:30

3887 lines
77 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCHDONHelper
// 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"
//
enum ENUM_XCHDON_BUFFERS
{
//
// Current ...
//
XCHDON_C_OPEN_UPPER_LINE = 0,
XCHDON_C_OPEN_LOWER_LINE = 1,
//
XCHDON_C_HIGH_UPPER_LINE = 2,
XCHDON_C_HIGH_LOWER_LINE = 3,
//
XCHDON_C_LOW_UPPER_LINE = 4,
XCHDON_C_LOW_LOWER_LINE = 5,
//
XCHDON_C_CLOSE_UPPER_LINE = 6,
XCHDON_C_CLOSE_LOWER_LINE = 7,
//
// Short ...
//
XCHDON_S_OPEN_UPPER_LINE = 8,
XCHDON_S_OPEN_LOWER_LINE = 9,
//
XCHDON_S_HIGH_UPPER_LINE = 10,
XCHDON_S_HIGH_LOWER_LINE = 11,
//
XCHDON_S_LOW_UPPER_LINE = 12,
XCHDON_S_LOW_LOWER_LINE = 13,
//
XCHDON_S_CLOSE_UPPER_LINE = 14,
XCHDON_S_CLOSE_LOWER_LINE = 15,
//
// Medium ...
//
XCHDON_M_OPEN_UPPER_LINE = 16,
XCHDON_M_OPEN_LOWER_LINE = 17,
//
XCHDON_M_HIGH_UPPER_LINE = 18,
XCHDON_M_HIGH_LOWER_LINE = 19,
//
XCHDON_M_LOW_UPPER_LINE = 20,
XCHDON_M_LOW_LOWER_LINE = 21,
//
XCHDON_M_CLOSE_UPPER_LINE = 22,
XCHDON_M_CLOSE_LOWER_LINE = 23,
//
// Long ...
//
XCHDON_L_OPEN_UPPER_LINE = 24,
XCHDON_L_OPEN_LOWER_LINE = 25,
//
XCHDON_L_HIGH_UPPER_LINE = 26,
XCHDON_L_HIGH_LOWER_LINE = 27,
//
XCHDON_L_LOW_UPPER_LINE = 28,
XCHDON_L_LOW_LOWER_LINE = 29,
//
XCHDON_L_CLOSE_UPPER_LINE = 30,
XCHDON_L_CLOSE_LOWER_LINE = 31,
//
// Hind ...
//
XCHDON_H_OPEN_UPPER_LINE = 32,
XCHDON_H_OPEN_LOWER_LINE = 33,
//
XCHDON_H_HIGH_UPPER_LINE = 34,
XCHDON_H_HIGH_LOWER_LINE = 35,
//
XCHDON_H_LOW_UPPER_LINE = 36,
XCHDON_H_LOW_LOWER_LINE = 37,
//
XCHDON_H_CLOSE_UPPER_LINE = 38,
XCHDON_H_CLOSE_LOWER_LINE = 39,
};
//
// Input Models ...
struct XCHDONInputs
{
//
// Props ...
//
// Market ...
int length; // Market Length
//
// 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
//
// Presentation ...
//
bool showUpper; // Show Upper Band
bool showLower; // Show Lower Band
//
bool showOpen; // Show Open
bool showHigh; // Show High
bool showClose; // Show Close
bool showLow; // Show Low
//
bool showCurrent; // Show Current Cycle
bool showShort; // Show Short Cycle
bool showMedium; // Show Medium Cycle
bool showLong; // Show Long Cycle
bool showHind; // Show Hind Cycle
//
// Constructor(s) ...
XCHDONInputs()
{
//
Clean();
}
//
// Tools ...
//
// Clean ...
void Clean()
{
//
length = 0;
//
scMethod = X_PERIOD_AUTO;
scPeriod = NULL;
mcMethod = X_PERIOD_AUTO;
mcPeriod = NULL;
lcMethod = X_PERIOD_AUTO;
lcPeriod = NULL;
hcMethod = X_PERIOD_AUTO;
hcPeriod = NULL;
//
showUpper = false;
showLower = false;
//
showOpen = false;
showHigh = false;
showClose = false;
showLow = false;
//
showCurrent = false;
showShort = false;
showMedium = false;
showLong = false;
showHind = false;
}
//
// Default ...
void Default()
{
//
length = 52;
//
scMethod = X_PERIOD_AUTO;
scPeriod = NULL;
mcMethod = X_PERIOD_AUTO;
mcPeriod = NULL;
lcMethod = X_PERIOD_AUTO;
lcPeriod = NULL;
hcMethod = X_PERIOD_AUTO;
hcPeriod = NULL;
//
showUpper = true;
showLower = true;
//
showOpen = true;
showHigh = true;
showClose = true;
showLow = true;
//
showCurrent = true;
showShort = true;
showMedium = true;
showLong = true;
showHind = true;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length > 2
//
&&
//
(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, length);
//
return result;
}
};
//
// Define Conditions ...
struct XCHDONConditions
{
//
// Common ...
string symbol;
ENUM_TIMEFRAMES period;
datetime time;
//
// Buffers ...
//
// Current ...
double cOpenUpper[];
double cOpenLower[];
double cHighUpper[];
double cHighLower[];
double cLowUpper[];
double cLowLower[];
double cCloseUpper[];
double cCloseLower[];
//
// Short ...
double sOpenUpper[];
double sOpenLower[];
double sHighUpper[];
double sHighLower[];
double sLowUpper[];
double sLowLower[];
double sCloseUpper[];
double sCloseLower[];
//
// Medium ...
double mOpenUpper[];
double mOpenLower[];
double mHighUpper[];
double mHighLower[];
double mLowUpper[];
double mLowLower[];
double mCloseUpper[];
double mCloseLower[];
//
// Long ...
double lOpenUpper[];
double lOpenLower[];
double lHighUpper[];
double lHighLower[];
double lLowUpper[];
double lLowLower[];
double lCloseUpper[];
double lCloseLower[];
//
// Hind ...
double hOpenUpper[];
double hOpenLower[];
double hHighUpper[];
double hHighLower[];
double hLowUpper[];
double hLowLower[];
double hCloseUpper[];
double hCloseLower[];
//
// Conditions ...
//
// Current ...
//
// Short ...
//
// Medium ...
//
// Long ...
//
// Hind ...
//
void Clean()
{
//
// Buffers ...
//
Clean(cOpenUpper);
Clean(cOpenLower);
Clean(cHighUpper);
Clean(cHighLower);
Clean(cLowUpper);
Clean(cLowLower);
Clean(cCloseUpper);
Clean(cCloseLower);
Clean(sOpenUpper);
Clean(sOpenLower);
Clean(sHighUpper);
Clean(sHighLower);
Clean(sLowUpper);
Clean(sLowLower);
Clean(sCloseUpper);
Clean(sCloseLower);
Clean(mOpenUpper);
Clean(mOpenLower);
Clean(mHighUpper);
Clean(mHighLower);
Clean(mLowUpper);
Clean(mLowLower);
Clean(mCloseUpper);
Clean(mCloseLower);
Clean(lOpenUpper);
Clean(lOpenLower);
Clean(lHighUpper);
Clean(lHighLower);
Clean(lLowUpper);
Clean(lLowLower);
Clean(lCloseUpper);
Clean(lCloseLower);
Clean(hOpenUpper);
Clean(hOpenLower);
Clean(hHighUpper);
Clean(hHighLower);
Clean(hLowUpper);
Clean(hLowLower);
Clean(hCloseUpper);
Clean(hCloseLower);
//
ArraySetAsSeries(cOpenUpper, true);
ArraySetAsSeries(cOpenLower, true);
ArraySetAsSeries(cHighUpper, true);
ArraySetAsSeries(cHighLower, true);
ArraySetAsSeries(cLowUpper, true);
ArraySetAsSeries(cLowLower, true);
ArraySetAsSeries(cCloseUpper, true);
ArraySetAsSeries(cCloseLower, true);
ArraySetAsSeries(sOpenUpper, true);
ArraySetAsSeries(sOpenLower, true);
ArraySetAsSeries(sHighUpper, true);
ArraySetAsSeries(sHighLower, true);
ArraySetAsSeries(sLowUpper, true);
ArraySetAsSeries(sLowLower, true);
ArraySetAsSeries(sCloseUpper, true);
ArraySetAsSeries(sCloseLower, true);
ArraySetAsSeries(mOpenUpper, true);
ArraySetAsSeries(mOpenLower, true);
ArraySetAsSeries(mHighUpper, true);
ArraySetAsSeries(mHighLower, true);
ArraySetAsSeries(mLowUpper, true);
ArraySetAsSeries(mLowLower, true);
ArraySetAsSeries(mCloseUpper, true);
ArraySetAsSeries(mCloseLower, true);
ArraySetAsSeries(lOpenUpper, true);
ArraySetAsSeries(lOpenLower, true);
ArraySetAsSeries(lHighUpper, true);
ArraySetAsSeries(lHighLower, true);
ArraySetAsSeries(lLowUpper, true);
ArraySetAsSeries(lLowLower, true);
ArraySetAsSeries(lCloseUpper, true);
ArraySetAsSeries(lCloseLower, true);
ArraySetAsSeries(hOpenUpper, true);
ArraySetAsSeries(hOpenLower, true);
ArraySetAsSeries(hHighUpper, true);
ArraySetAsSeries(hHighLower, true);
ArraySetAsSeries(hLowUpper, true);
ArraySetAsSeries(hLowLower, true);
ArraySetAsSeries(hCloseUpper, true);
ArraySetAsSeries(hCloseLower, true);
//
// Current ...
//
// Short ...
//
// Medium ...
//
// Long ...
//
// Hind ...
}
//
void GenerateScore(
double &bullishScore,
double &bearishScore //
)
{
//
bullishScore = 0;
bearishScore = 0;
//
// Current ...
//
// Short ...
//
// Medium ...
//
// Long ...
//
// Hind ...
}
//
string GenerateSummary(
bool onlyCommons = false,
bool onlyConditions = false,
bool includeScores = true,
bool ignoreFalseConditions = true,
string separator = "\n" //
)
{
//
string result = NULL;
//
double bullishScore = 0;
double bearishScore = 0;
GenerateScore(
bullishScore,
bearishScore //
);
//
string scoresStr =
//
"Scores: " + separator +
"---------------" + separator +
"Bullish: " + ToString(bullishScore) + separator +
"Bearish: " + ToString(bearishScore) + separator +
""
//
;
//
string commonStr = GenerateSpecifiedCommonSummary(
this,
separator,
includeScores //
);
//
string conditionsStr =
//
// Current ...
//
// Short ...
//
// Medium ...
//
// Long ...
//
// Hind ...
//
""
//
;
//
result =
//
"[" + GetTag() + "]" + separator +
(onlyConditions
? ""
: commonStr) +
(!includeScores
? ""
: scoresStr) +
" " + separator +
(onlyCommons
? ""
: conditionsStr) +
""
//
;
//
return result;
}
//
string GetTag()
{
return "XCHDON";
}
};
//
// Class ...
class XSCXCHDONHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Props ...
//
// Constructors ...
XSCXCHDONHelper() : XSCBaseHelper(_Symbol, _Period)
{
}
//
// Deconstructor ...
~XSCXCHDONHelper()
{
//
Clean(cOpenUpperBuffer);
Clean(cOpenLowerBuffer);
Clean(cHighUpperBuffer);
Clean(cHighLowerBuffer);
Clean(cLowUpperBuffer);
Clean(cLowLowerBuffer);
Clean(cCloseUpperBuffer);
Clean(cCloseLowerBuffer);
Clean(sOpenUpperBuffer);
Clean(sOpenLowerBuffer);
Clean(sHighUpperBuffer);
Clean(sHighLowerBuffer);
Clean(sLowUpperBuffer);
Clean(sLowLowerBuffer);
Clean(sCloseUpperBuffer);
Clean(sCloseLowerBuffer);
Clean(mOpenUpperBuffer);
Clean(mOpenLowerBuffer);
Clean(mHighUpperBuffer);
Clean(mHighLowerBuffer);
Clean(mLowUpperBuffer);
Clean(mLowLowerBuffer);
Clean(mCloseUpperBuffer);
Clean(mCloseLowerBuffer);
Clean(lOpenUpperBuffer);
Clean(lOpenLowerBuffer);
Clean(lHighUpperBuffer);
Clean(lHighLowerBuffer);
Clean(lLowUpperBuffer);
Clean(lLowLowerBuffer);
Clean(lCloseUpperBuffer);
Clean(lCloseLowerBuffer);
Clean(hOpenUpperBuffer);
Clean(hOpenLowerBuffer);
Clean(hHighUpperBuffer);
Clean(hHighLowerBuffer);
Clean(hLowUpperBuffer);
Clean(hLowLowerBuffer);
Clean(hCloseUpperBuffer);
Clean(hCloseLowerBuffer);
}
//
// Tools ...
bool Init(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period, // Trading Period
XCHDONInputs &inputs // Inputs
)
{
//
bool result = false;
//
mSymbol = symbol;
mPeriod = period;
//
result = inputs.IsValid();
if (!result)
{
return result;
}
//
mInputs = inputs;
//
ArraySetAsSeries(cOpenUpperBuffer, true);
ArraySetAsSeries(cOpenLowerBuffer, true);
ArraySetAsSeries(cHighUpperBuffer, true);
ArraySetAsSeries(cHighLowerBuffer, true);
ArraySetAsSeries(cLowUpperBuffer, true);
ArraySetAsSeries(cLowLowerBuffer, true);
ArraySetAsSeries(cCloseUpperBuffer, true);
ArraySetAsSeries(cCloseLowerBuffer, true);
ArraySetAsSeries(sOpenUpperBuffer, true);
ArraySetAsSeries(sOpenLowerBuffer, true);
ArraySetAsSeries(sHighUpperBuffer, true);
ArraySetAsSeries(sHighLowerBuffer, true);
ArraySetAsSeries(sLowUpperBuffer, true);
ArraySetAsSeries(sLowLowerBuffer, true);
ArraySetAsSeries(sCloseUpperBuffer, true);
ArraySetAsSeries(sCloseLowerBuffer, true);
ArraySetAsSeries(mOpenUpperBuffer, true);
ArraySetAsSeries(mOpenLowerBuffer, true);
ArraySetAsSeries(mHighUpperBuffer, true);
ArraySetAsSeries(mHighLowerBuffer, true);
ArraySetAsSeries(mLowUpperBuffer, true);
ArraySetAsSeries(mLowLowerBuffer, true);
ArraySetAsSeries(mCloseUpperBuffer, true);
ArraySetAsSeries(mCloseLowerBuffer, true);
ArraySetAsSeries(lOpenUpperBuffer, true);
ArraySetAsSeries(lOpenLowerBuffer, true);
ArraySetAsSeries(lHighUpperBuffer, true);
ArraySetAsSeries(lHighLowerBuffer, true);
ArraySetAsSeries(lLowUpperBuffer, true);
ArraySetAsSeries(lLowLowerBuffer, true);
ArraySetAsSeries(lCloseUpperBuffer, true);
ArraySetAsSeries(lCloseLowerBuffer, true);
ArraySetAsSeries(hOpenUpperBuffer, true);
ArraySetAsSeries(hOpenLowerBuffer, true);
ArraySetAsSeries(hHighUpperBuffer, true);
ArraySetAsSeries(hHighLowerBuffer, true);
ArraySetAsSeries(hLowUpperBuffer, true);
ArraySetAsSeries(hLowLowerBuffer, true);
ArraySetAsSeries(hCloseUpperBuffer, true);
ArraySetAsSeries(hCloseLowerBuffer, true);
//
mHandler = iCustom(
mSymbol,
mPeriod,
"x-saherelm.xchdon",
//
// Inputs ...
//
// Market ...
"",
mInputs.length,
//
// Cycles ...
"",
//
// Short ...
"",
mInputs.scMethod,
mInputs.scPeriod,
//
// Medium ...
"",
mInputs.mcMethod,
mInputs.mcPeriod,
//
// Long ...
"",
mInputs.lcMethod,
mInputs.lcPeriod,
//
// Hind ...
"",
mInputs.hcMethod,
mInputs.hcPeriod,
//
// Presentation ...
"",
//
mInputs.showUpper, // Show Upper Band
mInputs.showLower, // Show Lower Band
//
mInputs.showOpen, // Show Open
mInputs.showHigh, // Show High
mInputs.showClose, // Show Close
mInputs.showLow, // Show Low
//
// Cycles ...
mInputs.showCurrent, // Show Current Cycle
mInputs.showShort, // Show Short Cycle
mInputs.showMedium, // Show Medium Cycle
mInputs.showLong, // Show Long Cycle
mInputs.showHind // Show Hind Cycle
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
return result;
}
//
// Buffers ...
//
// Current ...
//
// Open ...
//
double GetCOpenUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cOpenUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCOpenUpper(
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,
cOpenUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetCOpenLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cOpenLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCOpenLower(
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,
cOpenLowerBuffer,
buffer,
forceClean
//
);
}
//
// High ...
//
double GetCHighUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cHighUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCHighUpper(
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,
cHighUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetCHighLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cHighLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCHighLower(
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,
cHighLowerBuffer,
buffer,
forceClean
//
);
}
//
// Low ...
//
double GetCLowUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cLowUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCLowUpper(
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,
cLowUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetCLowLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cLowLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCLowLower(
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,
cLowLowerBuffer,
buffer,
forceClean
//
);
}
//
// Close ...
//
double GetCCloseUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cCloseUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCCloseUpper(
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,
cCloseUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetCCloseLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return cCloseLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyCCloseLower(
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,
cCloseLowerBuffer,
buffer,
forceClean
//
);
}
//
// Short ...
//
// Open ...
//
double GetSOpenUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sOpenUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySOpenUpper(
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,
sOpenUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetSOpenLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sOpenLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySOpenLower(
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,
sOpenLowerBuffer,
buffer,
forceClean
//
);
}
//
// High ...
//
double GetSHighUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sHighUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySHighUpper(
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,
sHighUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetSHighLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sHighLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySHighLower(
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,
sHighLowerBuffer,
buffer,
forceClean
//
);
}
//
// Low ...
//
double GetSLowUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sLowUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySLowUpper(
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,
sLowUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetSLowLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sLowLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySLowLower(
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,
sLowLowerBuffer,
buffer,
forceClean
//
);
}
//
// Close ...
//
double GetSCloseUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sCloseUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySCloseUpper(
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,
sCloseUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetSCloseLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return sCloseLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopySCloseLower(
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,
sCloseLowerBuffer,
buffer,
forceClean
//
);
}
//
// Medium ...
//
// Open ...
//
double GetMOpenUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mOpenUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMOpenUpper(
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,
mOpenUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetMOpenLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mOpenLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMOpenLower(
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,
mOpenLowerBuffer,
buffer,
forceClean
//
);
}
//
// High ...
//
double GetMHighUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mHighUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMHighUpper(
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,
mHighUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetMHighLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mHighLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMHighLower(
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,
mHighLowerBuffer,
buffer,
forceClean
//
);
}
//
// Low ...
//
double GetMLowUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mLowUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMLowUpper(
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,
mLowUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetMLowLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mLowLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMLowLower(
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,
mLowLowerBuffer,
buffer,
forceClean
//
);
}
//
// Close ...
//
double GetMCloseUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mCloseUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMCloseUpper(
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,
mCloseUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetMCloseLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return mCloseLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyMCloseLower(
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,
mCloseLowerBuffer,
buffer,
forceClean
//
);
}
//
// Long ...
//
// Open ...
//
double GetLOpenUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lOpenUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLOpenUpper(
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,
lOpenUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetLOpenLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lOpenLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLOpenLower(
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,
lOpenLowerBuffer,
buffer,
forceClean
//
);
}
//
// High ...
//
double GetLHighUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lHighUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLHighUpper(
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,
lHighUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetLHighLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lHighLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLHighLower(
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,
lHighLowerBuffer,
buffer,
forceClean
//
);
}
//
// Low ...
//
double GetLLowUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lLowUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLLowUpper(
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,
lLowUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetLLowLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lLowLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLLowLower(
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,
lLowLowerBuffer,
buffer,
forceClean
//
);
}
//
// Close ...
//
double GetLCloseUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lCloseUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLCloseUpper(
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,
lCloseUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetLCloseLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return lCloseLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyLCloseLower(
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,
lCloseLowerBuffer,
buffer,
forceClean
//
);
}
//
// Hind ...
//
// Open ...
//
double GetHOpenUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hOpenUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHOpenUpper(
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,
hOpenUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetHOpenLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hOpenLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHOpenLower(
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,
hOpenLowerBuffer,
buffer,
forceClean
//
);
}
//
// High ...
//
double GetHHighUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hHighUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHHighUpper(
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,
hHighUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetHHighLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hHighLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHHighLower(
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,
hHighLowerBuffer,
buffer,
forceClean
//
);
}
//
// Low ...
//
double GetHLowUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hLowUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHLowUpper(
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,
hLowUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetHLowLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hLowLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHLowLower(
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,
hLowLowerBuffer,
buffer,
forceClean
//
);
}
//
// Close ...
//
double GetHCloseUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hCloseUpperBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHCloseUpper(
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,
hCloseUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetHCloseLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
return hCloseLowerBuffer[barIndex];
}
//
// Copy Required Buffer ...
int CopyHCloseLower(
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,
hCloseLowerBuffer,
buffer,
forceClean
//
);
}
//
// Tools ...
//
void GetCycleValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES cycle, // Cycle
//
double &openUpper,
double &openLower,
double &highUpper,
double &highLower,
double &lowUpper,
double &lowLower,
double &closeUpper,
double &closeLower //
)
{
//
openUpper = 0;
openLower = 0;
highUpper = 0;
highLower = 0;
lowUpper = 0;
lowLower = 0;
closeUpper = 0;
closeLower = 0;
//
if (barIndex < 0)
{
barIndex = 0;
}
switch (cycle)
{
//
// Current ...
case X_MARKET_CYCLE_UNKNOWN:
//
openUpper = GetCOpenUpper(barIndex);
openLower = GetCOpenLower(barIndex);
highUpper = GetCHighUpper(barIndex);
highLower = GetCHighLower(barIndex);
lowUpper = GetCLowUpper(barIndex);
lowLower = GetCLowLower(barIndex);
closeUpper = GetCCloseUpper(barIndex);
closeLower = GetCCloseLower(barIndex);
break;
//
// Short ...
case X_MARKET_CYCLE_SHORT:
//
openUpper = GetSOpenUpper(barIndex);
openLower = GetSOpenLower(barIndex);
highUpper = GetSHighUpper(barIndex);
highLower = GetSHighLower(barIndex);
lowUpper = GetSLowUpper(barIndex);
lowLower = GetSLowLower(barIndex);
closeUpper = GetSCloseUpper(barIndex);
closeLower = GetSCloseLower(barIndex);
break;
//
// Medium ...
case X_MARKET_CYCLE_MEDIUM:
//
openUpper = GetMOpenUpper(barIndex);
openLower = GetMOpenLower(barIndex);
highUpper = GetMHighUpper(barIndex);
highLower = GetMHighLower(barIndex);
lowUpper = GetMLowUpper(barIndex);
lowLower = GetMLowLower(barIndex);
closeUpper = GetMCloseUpper(barIndex);
closeLower = GetMCloseLower(barIndex);
break;
//
// Long ...
case X_MARKET_CYCLE_LONG:
//
openUpper = GetLOpenUpper(barIndex);
openLower = GetLOpenLower(barIndex);
highUpper = GetLHighUpper(barIndex);
highLower = GetLHighLower(barIndex);
lowUpper = GetLLowUpper(barIndex);
lowLower = GetLLowLower(barIndex);
closeUpper = GetLCloseUpper(barIndex);
closeLower = GetLCloseLower(barIndex);
break;
//
// Hind ...
case X_MARKET_CYCLE_HIND:
//
openUpper = GetHOpenUpper(barIndex);
openLower = GetHOpenLower(barIndex);
highUpper = GetHHighUpper(barIndex);
highLower = GetHHighLower(barIndex);
lowUpper = GetHLowUpper(barIndex);
lowLower = GetHLowLower(barIndex);
closeUpper = GetHCloseUpper(barIndex);
closeLower = GetHCloseLower(barIndex);
break;
}
}
//
int GetCyclesUpperValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iOpenUpper,
values //
);
//
Add(
iHighUpper,
values //
);
//
Add(
iLowUpper,
values //
);
//
Add(
iCloseUpper,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesOpenUpperValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iOpenUpper,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesOpenLowerValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iOpenLower,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesHighUpperValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iHighUpper,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesHighLowerValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iHighLower,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesLowUpperValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iLowUpper,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesLowLowerValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iLowLower,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesCloseUpperValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iCloseUpper,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesCloseLowerValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iCloseLower,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
int GetCyclesLowerValues(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
int result = 0;
//
double values[];
//
int count = ArraySize(cycles);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
double iOpenUpper = 0;
double iOpenLower = 0;
double iHighUpper = 0;
double iHighLower = 0;
double iLowUpper = 0;
double iLowLower = 0;
double iCloseUpper = 0;
double iCloseLower = 0;
GetCycleValues(
barIndex,
cycles[i],
iOpenUpper,
iOpenLower,
iHighUpper,
iHighLower,
iLowUpper,
iLowLower,
iCloseUpper,
iCloseLower //
);
//
Add(
iOpenLower,
values //
);
//
Add(
iHighLower,
values //
);
//
Add(
iLowLower,
values //
);
//
Add(
iCloseLower,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
//
double GetCyclesUpperMax(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
double values[];
int count = GetCyclesUpperValues(
barIndex,
cycles //
);
if (!IsValidSize(count))
{
return result;
}
//
result = GetSpecifiedMax(values);
//
return result;
}
//
double GetCyclesUpperMin(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
double values[];
int count = GetCyclesUpperValues(
barIndex,
cycles //
);
if (!IsValidSize(count))
{
return result;
}
//
result = GetSpecifiedMin(values);
//
return result;
}
//
double GetCyclesLowerMax(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
double values[];
int count = GetCyclesLowerValues(
barIndex,
cycles //
);
if (!IsValidSize(count))
{
return result;
}
//
result = GetSpecifiedMax(values);
//
return result;
}
//
double GetCyclesLowerMin(
int barIndex, // Bar Index
ENUM_X_MARKET_CYCLES &cycles[] // Cycles
)
{
//
double result = 0;
//
double values[];
int count = GetCyclesLowerValues(
barIndex,
cycles //
);
if (!IsValidSize(count))
{
return result;
}
//
result = GetSpecifiedMin(values);
//
return result;
}
//
// Conditions ...
//
bool GetConditions(
XCHDONConditions &conditions, //
int barIndex = 0, //
int loopback = 5 //
)
{
//
bool result = true;
//
if (loopback < 5)
{
loopback = 5;
}
//
conditions.Clean();
//
conditions.symbol = mSymbol;
conditions.period = mPeriod;
conditions.time = TimeCurrent();
//
int zIndex = barIndex;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Buffers ...
//
// Current ...
// CopyCTenkanSen(
// zIndex,
// loopback,
// conditions.cTK //
// );
//
// Short ...
//
// Medium ...
//
// Long ...
//
// Hind ...
//
// Conditions ...
//
XOHCL cBar;
result = cBar.Init(
mSymbol,
mPeriod,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
mSymbol,
mPeriod,
pIndex //
);
if (!result)
{
return result;
}
//
// Conditions ...
//
// Current ...
//
// Short ...
//
// Medium ...
//
// Long ...
//
// Hind ...
//
return result;
}
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
XCHDONInputs mInputs; // Inputs ...
//
// Buffers ...
//
// Current ...
double cOpenUpperBuffer[];
double cOpenLowerBuffer[];
double cHighUpperBuffer[];
double cHighLowerBuffer[];
double cLowUpperBuffer[];
double cLowLowerBuffer[];
double cCloseUpperBuffer[];
double cCloseLowerBuffer[];
//
// Short ...
double sOpenUpperBuffer[];
double sOpenLowerBuffer[];
double sHighUpperBuffer[];
double sHighLowerBuffer[];
double sLowUpperBuffer[];
double sLowLowerBuffer[];
double sCloseUpperBuffer[];
double sCloseLowerBuffer[];
//
// Medium ...
double mOpenUpperBuffer[];
double mOpenLowerBuffer[];
double mHighUpperBuffer[];
double mHighLowerBuffer[];
double mLowUpperBuffer[];
double mLowLowerBuffer[];
double mCloseUpperBuffer[];
double mCloseLowerBuffer[];
//
// Long ...
double lOpenUpperBuffer[];
double lOpenLowerBuffer[];
double lHighUpperBuffer[];
double lHighLowerBuffer[];
double lLowUpperBuffer[];
double lLowLowerBuffer[];
double lCloseUpperBuffer[];
double lCloseLowerBuffer[];
//
// Hind ...
double hOpenUpperBuffer[];
double hOpenLowerBuffer[];
double hHighUpperBuffer[];
double hHighLowerBuffer[];
double hLowUpperBuffer[];
double hLowLowerBuffer[];
double hCloseUpperBuffer[];
double hCloseLowerBuffer[];
//
// Tools ...
//
// Calculate Values Until Now ...
void Calculate()
{
//
int totalBars = CountBars();
if (totalBars > 1000)
{
totalBars = 1000;
}
//
// Current ...
CopyBuffer(
mHandler,
XCHDON_C_OPEN_UPPER_LINE,
0,
totalBars,
cOpenUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_C_OPEN_LOWER_LINE,
0,
totalBars,
cOpenLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_C_HIGH_UPPER_LINE,
0,
totalBars,
cHighUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_C_HIGH_LOWER_LINE,
0,
totalBars,
cHighLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_C_LOW_UPPER_LINE,
0,
totalBars,
cLowUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_C_LOW_LOWER_LINE,
0,
totalBars,
cLowLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_C_CLOSE_UPPER_LINE,
0,
totalBars,
cCloseUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_C_CLOSE_LOWER_LINE,
0,
totalBars,
cCloseLowerBuffer //
);
//
// Short ...
CopyBuffer(
mHandler,
XCHDON_S_OPEN_UPPER_LINE,
0,
totalBars,
sOpenUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_S_OPEN_LOWER_LINE,
0,
totalBars,
sOpenLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_S_HIGH_UPPER_LINE,
0,
totalBars,
sHighUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_S_HIGH_LOWER_LINE,
0,
totalBars,
sHighLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_S_LOW_UPPER_LINE,
0,
totalBars,
sLowUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_S_LOW_LOWER_LINE,
0,
totalBars,
sLowLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_S_CLOSE_UPPER_LINE,
0,
totalBars,
sCloseUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_S_CLOSE_LOWER_LINE,
0,
totalBars,
sCloseLowerBuffer //
);
//
// Medium ...
CopyBuffer(
mHandler,
XCHDON_M_OPEN_UPPER_LINE,
0,
totalBars,
mOpenUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_M_OPEN_LOWER_LINE,
0,
totalBars,
mOpenLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_M_HIGH_UPPER_LINE,
0,
totalBars,
mHighUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_M_HIGH_LOWER_LINE,
0,
totalBars,
mHighLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_M_LOW_UPPER_LINE,
0,
totalBars,
mLowUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_M_LOW_LOWER_LINE,
0,
totalBars,
mLowLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_M_CLOSE_UPPER_LINE,
0,
totalBars,
mCloseUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_M_CLOSE_LOWER_LINE,
0,
totalBars,
mCloseLowerBuffer //
);
//
// Long ...
CopyBuffer(
mHandler,
XCHDON_L_OPEN_UPPER_LINE,
0,
totalBars,
lOpenUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_L_OPEN_LOWER_LINE,
0,
totalBars,
lOpenLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_L_HIGH_UPPER_LINE,
0,
totalBars,
lHighUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_L_HIGH_LOWER_LINE,
0,
totalBars,
lHighLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_L_LOW_UPPER_LINE,
0,
totalBars,
lLowUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_L_LOW_LOWER_LINE,
0,
totalBars,
lLowLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_L_CLOSE_UPPER_LINE,
0,
totalBars,
lCloseUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_L_CLOSE_LOWER_LINE,
0,
totalBars,
lCloseLowerBuffer //
);
//
// Hind ...
CopyBuffer(
mHandler,
XCHDON_H_OPEN_UPPER_LINE,
0,
totalBars,
hOpenUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_H_OPEN_LOWER_LINE,
0,
totalBars,
hOpenLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_H_HIGH_UPPER_LINE,
0,
totalBars,
hHighUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_H_HIGH_LOWER_LINE,
0,
totalBars,
hHighLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_H_LOW_UPPER_LINE,
0,
totalBars,
hLowUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_H_LOW_LOWER_LINE,
0,
totalBars,
hLowLowerBuffer //
);
CopyBuffer(
mHandler,
XCHDON_H_CLOSE_UPPER_LINE,
0,
totalBars,
hCloseUpperBuffer //
);
CopyBuffer(
mHandler,
XCHDON_H_CLOSE_LOWER_LINE,
0,
totalBars,
hCloseLowerBuffer //
);
};
};
//