Prepare XFIMA BackTester for Test ...
This commit is contained in:
@@ -89,6 +89,9 @@ input int zigzagDeviation = 5; // ZigZag Devia
|
||||
input int zigzagBackStep = 3; // ZigZag Back Step
|
||||
input ENUM_X_PRICE zigzagUppersMode = X_PRICE_HIGH; // ZigZag High Detect Mode
|
||||
input ENUM_X_PRICE zigzagLowersMode = X_PRICE_LOW; // ZigZag Low Detect Mode
|
||||
input bool hkIgnoreShadows = true; // HK Remove noises
|
||||
input int hkSmoothingLength = 21; // HK Smoothing Length
|
||||
input ENUM_X_MA_METHOD hkSmoothingMode = X_MA_MODE_EMA; // HK Smoothing Method
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
@@ -134,7 +137,7 @@ input int valeArrowCode = 159; // Vales Arrow Code
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 34
|
||||
#property indicator_buffers 38
|
||||
#property indicator_plots 12
|
||||
|
||||
//
|
||||
@@ -333,7 +336,7 @@ double hkColorBuffer[];
|
||||
#define hkBufferPlotIndex 11
|
||||
#property indicator_label12 "XHK Open;XHK High;XHK Low;XHK Close"
|
||||
#property indicator_type12 DRAW_COLOR_CANDLES
|
||||
#property indicator_color12 CLR_NONE, clrAqua, clrMagenta
|
||||
#property indicator_color12 CLR_NONE, clrAqua, clrMagenta, clrGray
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
@@ -425,6 +428,25 @@ double lowsBuffer[];
|
||||
#define lowsTimeBufferIndex mLastBufferIndex + 15
|
||||
double lowsTimeBuffer[];
|
||||
|
||||
//
|
||||
// XHK Data ...
|
||||
|
||||
//
|
||||
#define hkRawHighBufferIndex mLastBufferIndex + 16
|
||||
double hkRawHighBuffer[];
|
||||
|
||||
//
|
||||
#define hkRawOpenBufferIndex mLastBufferIndex + 17
|
||||
double hkRawOpenBuffer[];
|
||||
|
||||
//
|
||||
#define hkRawLowBufferIndex mLastBufferIndex + 18
|
||||
double hkRawLowBuffer[];
|
||||
|
||||
//
|
||||
#define hkRawCloseBufferIndex mLastBufferIndex + 19
|
||||
double hkRawCloseBuffer[];
|
||||
|
||||
//
|
||||
// Variables, Properties and etc ...
|
||||
|
||||
@@ -1086,6 +1108,25 @@ void DefineBuffers()
|
||||
SetIndexBuffer(lowsBufferIndex, lowsBuffer, INDICATOR_CALCULATIONS);
|
||||
SetIndexBuffer(lowsTimeBufferIndex, lowsTimeBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// XHK Data ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawHighBuffer, true);
|
||||
SetIndexBuffer(hkRawHighBufferIndex, hkRawHighBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawOpenBuffer, true);
|
||||
SetIndexBuffer(hkRawOpenBufferIndex, hkRawOpenBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawLowBuffer, true);
|
||||
SetIndexBuffer(hkRawLowBufferIndex, hkRawLowBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawCloseBuffer, true);
|
||||
SetIndexBuffer(hkRawCloseBufferIndex, hkRawCloseBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
@@ -2032,18 +2073,101 @@ void CalculateHKBar(
|
||||
double iHKLowValue = MathMin(low[barIndex], MathMin(iHKOpenValue, iHKCloseValue));
|
||||
|
||||
//
|
||||
// Raw HK Buffers ...
|
||||
bool isBullish = iHKOpenValue < iHKCloseValue;
|
||||
bool isBearish = iHKOpenValue > iHKCloseValue;
|
||||
|
||||
//
|
||||
if (hkIgnoreShadows)
|
||||
{
|
||||
//
|
||||
iHKHighValue = isBullish
|
||||
? iHKCloseValue
|
||||
: iHKOpenValue;
|
||||
|
||||
//
|
||||
iHKLowValue = isBullish
|
||||
? iHKOpenValue
|
||||
: iHKCloseValue;
|
||||
}
|
||||
|
||||
//
|
||||
// XHK Buffers ...
|
||||
hkOpenBuffer[barIndex] = iHKOpenValue;
|
||||
hkHighBuffer[barIndex] = iHKHighValue;
|
||||
hkLowBuffer[barIndex] = iHKLowValue;
|
||||
hkCloseBuffer[barIndex] = iHKCloseValue;
|
||||
|
||||
//
|
||||
// XHK Raw Bufferss ...
|
||||
hkRawOpenBuffer[barIndex] = iHKOpenValue;
|
||||
hkRawHighBuffer[barIndex] = iHKHighValue;
|
||||
hkRawLowBuffer[barIndex] = iHKLowValue;
|
||||
hkRawCloseBuffer[barIndex] = iHKCloseValue;
|
||||
|
||||
//
|
||||
// Smoothing ...
|
||||
if (IsXValid(hkSmoothingMode) && hkSmoothingLength > 0)
|
||||
{
|
||||
//
|
||||
// XHK Signal ...
|
||||
|
||||
//
|
||||
// High ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
hkSmoothingLength,
|
||||
hkRawHighBuffer,
|
||||
hkHighBuffer,
|
||||
hkSmoothingMode //
|
||||
);
|
||||
|
||||
//
|
||||
// Open ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
hkSmoothingLength,
|
||||
hkRawOpenBuffer,
|
||||
hkOpenBuffer,
|
||||
hkSmoothingMode //
|
||||
);
|
||||
|
||||
//
|
||||
// Close ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
hkSmoothingLength,
|
||||
hkRawLowBuffer,
|
||||
hkLowBuffer,
|
||||
hkSmoothingMode //
|
||||
);
|
||||
|
||||
//
|
||||
// Close ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
hkSmoothingLength,
|
||||
hkRawCloseBuffer,
|
||||
hkCloseBuffer,
|
||||
hkSmoothingMode //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate HK Color ...
|
||||
double iHKColorValue =
|
||||
hkOpenBuffer[barIndex] < hkCloseBuffer[barIndex]
|
||||
isBullish
|
||||
? bullishColorIDX
|
||||
: bearishColorIDX;
|
||||
: isBearish
|
||||
? bearishColorIDX
|
||||
: neuturalColorIDX;
|
||||
hkColorBuffer[barIndex] =
|
||||
showHK
|
||||
? iHKColorValue
|
||||
|
||||
Reference in New Issue
Block a user