last ...
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "../Helpers/x-saherelm.x121.xche.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xdon.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xhk.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xmas.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xpv.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xstr.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xtrend.helper.mq5"
|
||||
@@ -43,6 +44,7 @@ struct X121Inputs
|
||||
X121XCCInputs xccInputs;
|
||||
X121XPVInputs xpvInputs;
|
||||
X121XHKInputs xhkInputs;
|
||||
X121XMASInputs xmasInputs;
|
||||
X121XATRInputs xatrInputs;
|
||||
X121XSTRInputs xstrInputs;
|
||||
X121XCHEInputs xcheInputs;
|
||||
@@ -70,6 +72,7 @@ struct X121Inputs
|
||||
xccInputs.Clean();
|
||||
xpvInputs.Clean();
|
||||
xhkInputs.Clean();
|
||||
xmasInputs.Clean();
|
||||
xatrInputs.Clean();
|
||||
xstrInputs.Clean();
|
||||
xcheInputs.Clean();
|
||||
@@ -90,6 +93,7 @@ struct X121Inputs
|
||||
xccInputs.Default();
|
||||
xpvInputs.Default();
|
||||
xhkInputs.Default();
|
||||
xmasInputs.Default();
|
||||
xatrInputs.Default();
|
||||
xstrInputs.Default();
|
||||
xcheInputs.Default();
|
||||
@@ -115,6 +119,7 @@ struct X121Inputs
|
||||
xccInputs.IsValid() &&
|
||||
xpvInputs.IsValid() &&
|
||||
xhkInputs.IsValid() &&
|
||||
xmasInputs.IsValid() &&
|
||||
xatrInputs.IsValid() &&
|
||||
xstrInputs.IsValid() &&
|
||||
xcheInputs.IsValid() &&
|
||||
@@ -141,6 +146,7 @@ struct X121Inputs
|
||||
//
|
||||
int xpvMax = xpvInputs.Max();
|
||||
int xhkMax = xpvInputs.Max();
|
||||
int xmasMax = xpvInputs.Max();
|
||||
int xatrMax = xatrInputs.Max();
|
||||
int xstrMax = xstrInputs.Max();
|
||||
int xcheMax = xcheInputs.Max();
|
||||
@@ -150,6 +156,7 @@ struct X121Inputs
|
||||
|
||||
//
|
||||
result = MathMax(xpvMax, xhkMax);
|
||||
result = MathMax(result, xmasMax);
|
||||
result = MathMax(result, xatrMax);
|
||||
result = MathMax(result, xstrMax);
|
||||
result = MathMax(result, xcheMax);
|
||||
@@ -202,6 +209,9 @@ struct X121Conditions
|
||||
double valesBuffer[];
|
||||
double strUpBuffer[];
|
||||
double downTBuffer[];
|
||||
double masMidBuffer[];
|
||||
double masUpperBuffer[];
|
||||
double masLowerBuffer[];
|
||||
double strDownBuffer[];
|
||||
double vwapMidBuffer[];
|
||||
double upTrendBuffer[];
|
||||
@@ -635,10 +645,13 @@ struct X121Conditions
|
||||
Clean(strUpBuffer);
|
||||
Clean(downTBuffer);
|
||||
Clean(volumeBuffer);
|
||||
Clean(masMidBuffer);
|
||||
Clean(strDownBuffer);
|
||||
Clean(vwapMidBuffer);
|
||||
Clean(upTrendBuffer);
|
||||
Clean(x3maMidBuffer);
|
||||
Clean(masUpperBuffer);
|
||||
Clean(masLowerBuffer);
|
||||
Clean(le1StartBuffer);
|
||||
Clean(se1StartBuffer);
|
||||
Clean(le2StartBuffer);
|
||||
@@ -710,10 +723,13 @@ struct X121Conditions
|
||||
ArraySetAsSeries(strUpBuffer, true);
|
||||
ArraySetAsSeries(downTBuffer, true);
|
||||
ArraySetAsSeries(volumeBuffer, true);
|
||||
ArraySetAsSeries(masMidBuffer, true);
|
||||
ArraySetAsSeries(strDownBuffer, true);
|
||||
ArraySetAsSeries(vwapMidBuffer, true);
|
||||
ArraySetAsSeries(upTrendBuffer, true);
|
||||
ArraySetAsSeries(x3maMidBuffer, true);
|
||||
ArraySetAsSeries(masUpperBuffer, true);
|
||||
ArraySetAsSeries(masLowerBuffer, true);
|
||||
ArraySetAsSeries(le1StartBuffer, true);
|
||||
ArraySetAsSeries(se1StartBuffer, true);
|
||||
ArraySetAsSeries(le2StartBuffer, true);
|
||||
@@ -2397,6 +2413,7 @@ class XCX121Helper : public XCBase
|
||||
XCX121XCCHelper *xccHelper;
|
||||
XCX121XPVHelper *xpvHelper;
|
||||
XCX121XHKHelper *xhkHelper;
|
||||
XCX121XMASHelper *xmasHelper;
|
||||
XCX121XATRHelper *xatrHelper;
|
||||
XCX121XSTRHelper *xstrHelper;
|
||||
XCX121XCHEHelper *xcheHelper;
|
||||
@@ -2420,6 +2437,7 @@ class XCX121Helper : public XCBase
|
||||
xccInputs.Clean();
|
||||
xpvInputs.Clean();
|
||||
xhkInputs.Clean();
|
||||
xmasInputs.Clean();
|
||||
xatrInputs.Clean();
|
||||
xdonInputs.Clean();
|
||||
xstrInputs.Clean();
|
||||
@@ -2432,6 +2450,7 @@ class XCX121Helper : public XCBase
|
||||
delete xccHelper;
|
||||
delete xpvHelper;
|
||||
delete xhkHelper;
|
||||
delete xmasHelper;
|
||||
delete xatrHelper;
|
||||
delete xstrHelper;
|
||||
delete xcheHelper;
|
||||
@@ -2444,6 +2463,7 @@ class XCX121Helper : public XCBase
|
||||
ZeroMemory(xccHelper);
|
||||
ZeroMemory(xpvHelper);
|
||||
ZeroMemory(xhkHelper);
|
||||
ZeroMemory(xmasHelper);
|
||||
ZeroMemory(xatrHelper);
|
||||
ZeroMemory(xstrHelper);
|
||||
ZeroMemory(xcheHelper);
|
||||
@@ -2508,6 +2528,7 @@ class XCX121Helper : public XCBase
|
||||
xccInputs = inputs.xccInputs;
|
||||
xpvInputs = inputs.xpvInputs;
|
||||
xhkInputs = inputs.xhkInputs;
|
||||
xmasInputs = inputs.xmasInputs;
|
||||
xatrInputs = inputs.xatrInputs;
|
||||
xstrInputs = inputs.xstrInputs;
|
||||
xcheInputs = inputs.xcheInputs;
|
||||
@@ -2558,6 +2579,19 @@ class XCX121Helper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XMAS ...
|
||||
xmasHelper = new XCX121XMASHelper();
|
||||
result = xmasHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
xmasInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
xatrHelper = new XCX121XATRHelper();
|
||||
@@ -2719,6 +2753,28 @@ class XCX121Helper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XMAS ...
|
||||
bool GetMASConditions(
|
||||
X121XMASConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = xmasHelper.GetConditions(
|
||||
conditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
bool GetATRConditions(
|
||||
@@ -2879,6 +2935,7 @@ class XCX121Helper : public XCBase
|
||||
//
|
||||
xpvHelper.Free();
|
||||
xhkHelper.Free();
|
||||
xmasHelper.Free();
|
||||
xatrHelper.Free();
|
||||
xstrHelper.Free();
|
||||
xcheHelper.Free();
|
||||
@@ -2979,6 +3036,19 @@ class XCX121Helper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XMAS ...
|
||||
X121XMASConditions xmasConditions;
|
||||
result = GetMASConditions(
|
||||
xmasConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
X121XATRConditions xatrConditions;
|
||||
@@ -3293,6 +3363,30 @@ class XCX121Helper : public XCBase
|
||||
conditions.isSMHKSwitchedToBullish = xhkConditions.isSMHKSwitchedToBullish;
|
||||
conditions.isRawHKSwitchedToBullish = xhkConditions.isRawHKSwitchedToBullish;
|
||||
|
||||
//
|
||||
// XMAS ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
Copy(
|
||||
xmasConditions.upperBuffer,
|
||||
conditions.masUpperBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xmasConditions.midBuffer,
|
||||
conditions.masMidBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xmasConditions.lowerBuffer,
|
||||
conditions.masLowerBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
// XTREND ...
|
||||
|
||||
@@ -4458,6 +4552,7 @@ class XCX121Helper : public XCBase
|
||||
//
|
||||
xpvConditions.Clean();
|
||||
xhkConditions.Clean();
|
||||
xmasConditions.Clean();
|
||||
xatrConditions.Clean();
|
||||
xstrConditions.Clean();
|
||||
xcheConditions.Clean();
|
||||
@@ -4491,6 +4586,7 @@ class XCX121Helper : public XCBase
|
||||
X121XCCInputs xccInputs;
|
||||
X121XPVInputs xpvInputs;
|
||||
X121XHKInputs xhkInputs;
|
||||
X121XMASInputs xmasInputs;
|
||||
X121XATRInputs xatrInputs;
|
||||
X121XDONInputs xdonInputs;
|
||||
X121XSTRInputs xstrInputs;
|
||||
|
||||
@@ -0,0 +1,788 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XCX121XMASHelper
|
||||
// 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.x-helper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
enum ENUM_X121_XMAS_BUFFERS
|
||||
{
|
||||
//
|
||||
X121_XMAS_UPPER_LINE = 0,
|
||||
X121_XMAS_MID_LINE = 1,
|
||||
X121_XMAS_LOWER_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct X121XMASInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
int length; // MA Length
|
||||
ENUM_MA_METHOD method; // MA Method
|
||||
ENUM_APPLIED_PRICE upperAppliedTo; // Upper Applied To
|
||||
ENUM_APPLIED_PRICE midAppliedTo; // Mid Applied To
|
||||
ENUM_APPLIED_PRICE lowerAppliedTo; // Lower Applied To
|
||||
|
||||
//
|
||||
int startCalculationForLastBars; // Calculate Last n Bars
|
||||
bool showUpper; // Show Upper
|
||||
bool showMid; // Show Mid
|
||||
bool showLower; // Show Lower
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
X121XMASInputs()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0; // MA Length
|
||||
method = MODE_EMA; // MA Method
|
||||
upperAppliedTo = PRICE_HIGH; // Upper Applied To
|
||||
midAppliedTo = PRICE_MEDIAN; // Mid Applied To
|
||||
lowerAppliedTo = PRICE_LOW; // Lower Applied To
|
||||
|
||||
//
|
||||
startCalculationForLastBars = 0; // Calculate Last n Bars
|
||||
showUpper = false; // Show Upper
|
||||
showMid = false; // Show Mid
|
||||
showLower = false; // Show Lower
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 14; // MA Length
|
||||
method = MODE_EMA; // MA Method
|
||||
upperAppliedTo = PRICE_HIGH; // Upper Applied To
|
||||
midAppliedTo = PRICE_MEDIAN; // Mid Applied To
|
||||
lowerAppliedTo = PRICE_LOW; // Lower Applied To
|
||||
|
||||
//
|
||||
startCalculationForLastBars = 1000; // Calculate Last n Bars
|
||||
showUpper = true; // Show Upper
|
||||
showMid = true; // Show Mid
|
||||
showLower = true; // Show Lower
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
struct X121XMASConditions
|
||||
{
|
||||
//
|
||||
// Common ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double upperBuffer[];
|
||||
double midBuffer[];
|
||||
double lowerBuffer[];
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
X121XMASConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleaning Up ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Commons ...
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
Clean(upperBuffer);
|
||||
Clean(midBuffer);
|
||||
Clean(lowerBuffer);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(upperBuffer, true);
|
||||
ArraySetAsSeries(midBuffer, true);
|
||||
ArraySetAsSeries(lowerBuffer, true);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Conditions Scores ...
|
||||
*
|
||||
* @param bullishScore: Double, Directional Scores Reference ...
|
||||
* @param bearishScore: Double, Directional Scores Reference ...
|
||||
*/
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
// TODO: Implement if Required ...
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Summary String for Represent Conditions State ...
|
||||
*
|
||||
* @param onlyCommons: Boolean, Just Generate Only Commons Conditions ...
|
||||
* @param onlyConditions: Boolean, Just Generate Only Conditions ...
|
||||
* @param includeScores: Boolean, Attach Scores Representations on Result ...
|
||||
* @param ignoreFalseConditions: Boolean, Ignore False Conditions on Result ...
|
||||
* @param separator: String, Separate Lines ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
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 =
|
||||
//
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
(!includeScores
|
||||
? ""
|
||||
: scoresStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve nique Tag Identifier ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetTag()
|
||||
{
|
||||
return GetTypeName(this);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XCX121XMASHelper : public XCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XCX121XMASHelper()
|
||||
: XCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCX121XMASHelper()
|
||||
{
|
||||
//
|
||||
mInputs.Clean();
|
||||
|
||||
//
|
||||
Clean(upperBuffer);
|
||||
Clean(midBuffer);
|
||||
Clean(lowerBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
X121XMASInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ArraySetAsSeries(upperBuffer, true);
|
||||
ArraySetAsSeries(midBuffer, true);
|
||||
ArraySetAsSeries(lowerBuffer, true);
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.x121.xmas",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length,
|
||||
mInputs.method,
|
||||
mInputs.upperAppliedTo,
|
||||
mInputs.midAppliedTo,
|
||||
mInputs.lowerAppliedTo,
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
//
|
||||
mInputs.startCalculationForLastBars,
|
||||
//
|
||||
mInputs.showUpper,
|
||||
mInputs.showMid,
|
||||
mInputs.showLower
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
X121XMASInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
X121XMASInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Readers ...
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
|
||||
//
|
||||
double GetUpper(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(upperBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upperBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyUpper(
|
||||
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,
|
||||
upperBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Mid ...
|
||||
|
||||
//
|
||||
double GetUMid(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(midBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return midBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyMid(
|
||||
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,
|
||||
midBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
|
||||
//
|
||||
double GetULower(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lowerBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lowerBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
int CopyLower(
|
||||
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,
|
||||
lowerBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetConditions(
|
||||
X121XMASConditions &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;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
result = zBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
zIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
result = pBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
pIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
CopyUpper(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.upperBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
CopyMid(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.midBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
CopyLower(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.lowerBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
int cIDX = 1;
|
||||
int pIDX = cIDX + 1;
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
|
||||
//
|
||||
Cleanup();
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
X121XMASInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double upperBuffer[];
|
||||
double midBuffer[];
|
||||
double lowerBuffer[];
|
||||
|
||||
//
|
||||
void Calculate(
|
||||
int maxRequiredBars = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// FAST ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XMAS_UPPER_LINE,
|
||||
0,
|
||||
maxRequiredBars,
|
||||
upperBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// FAST STATE ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XMAS_MID_LINE,
|
||||
0,
|
||||
maxRequiredBars,
|
||||
midBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// MID ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X121_XMAS_LOWER_LINE,
|
||||
0,
|
||||
maxRequiredBars,
|
||||
lowerBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
void Cleanup(
|
||||
int maxAllowed = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
upperBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
midBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
lowerBuffer,
|
||||
maxAllowed //
|
||||
);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Reference in New Issue
Block a user