refactor all requirements for draw and detect pois and also add Fima Helper, Parser Class Implementations for Separation of Concerns ...
This commit is contained in:
+331
-105
@@ -83,7 +83,7 @@ input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
|
||||
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
||||
input int maFastLength = 7; // Fast MA Length
|
||||
input int maSlowLength = 21; // Slow MA Length
|
||||
input int maBondLength = 21; // MA Bond Length
|
||||
input int maBandLength = 21; // MA Band Length
|
||||
input int zigzagDepth = 12; // ZigZag Depth
|
||||
input int zigzagDeviation = 5; // ZigZag Deviation
|
||||
input int zigzagBackStep = 3; // ZigZag Back Step
|
||||
@@ -92,6 +92,12 @@ input ENUM_X_PRICE zigzagLowersMode = X_PRICE_LOW; // ZigZag Low D
|
||||
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
|
||||
input int atrLength = 14; // ATR Length
|
||||
input double atrMultiplier = 1.5; // ATR Band Multiplier
|
||||
input int atrSmoothingLength = 21; // ATR Smoothing Length
|
||||
input ENUM_X_PRICE atrUpperPriceType = X_PRICE_HIGH; // ATR Upper Zone Applied To
|
||||
input ENUM_X_PRICE atrLowerPriceType = X_PRICE_LOW; // ATR Lower Zone Applied To
|
||||
input ENUM_X_MA_METHOD atrSmoothingMode = X_MA_MODE_EMA; // ATR Smoothing Method
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
@@ -101,8 +107,9 @@ input bool showHK = true; // Show HK
|
||||
input bool showSAR = true; // Show Sar
|
||||
input bool showMAFast = true; // Show MA Fast
|
||||
input bool showMASlow = true; // Show MA Slow
|
||||
input bool showMABond = true; // Show MA Bond
|
||||
input bool showHKBond = true; // Show HK Bond
|
||||
input bool showMABand = true; // Show MA Band
|
||||
input bool showHKBand = true; // Show HK Band
|
||||
input bool showATRBand = true; // Show ATR Band
|
||||
input bool showZigZag = true; // Show ZigZag
|
||||
input bool showFiboZone = true; // Show Fibo Zone
|
||||
|
||||
@@ -138,8 +145,8 @@ input int valeArrowCode = 159; // Vales Arrow Code
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 44
|
||||
#property indicator_plots 16
|
||||
#property indicator_buffers 49
|
||||
#property indicator_plots 18
|
||||
|
||||
//
|
||||
// Plot Buffers ...
|
||||
@@ -160,7 +167,7 @@ double maFastColorBuffer[];
|
||||
#property indicator_label1 "FastMA"
|
||||
#property indicator_type1 DRAW_COLOR_LINE
|
||||
#property indicator_color1 CLR_NONE, clrLime, clrLime, clrLime // clrYellow, clrOrangeRed, clrGray
|
||||
#property indicator_width1 3
|
||||
#property indicator_width1 2
|
||||
|
||||
//
|
||||
// Slow MA ...
|
||||
@@ -178,7 +185,7 @@ double maSlowColorBuffer[];
|
||||
#property indicator_label2 "SlowMA"
|
||||
#property indicator_type2 DRAW_COLOR_LINE
|
||||
#property indicator_color2 CLR_NONE, clrRed, clrRed, clrRed // clrLime, clrRed, clrGray
|
||||
#property indicator_width2 3
|
||||
#property indicator_width2 2
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
@@ -286,29 +293,29 @@ double zigzagBuffer[];
|
||||
// MA Upper ...
|
||||
|
||||
//
|
||||
#define maBondUpperBufferIndex 12
|
||||
double maBondUpperBuffer[];
|
||||
#define maBandUpperBufferIndex 12
|
||||
double maBandUpperBuffer[];
|
||||
|
||||
//
|
||||
#define maBondUpperBufferPlotIndex 9
|
||||
#define maBandUpperBufferPlotIndex 9
|
||||
#property indicator_label10 "UpperMA"
|
||||
#property indicator_type10 DRAW_LINE
|
||||
#property indicator_color10 clrLime
|
||||
#property indicator_width10 3
|
||||
#property indicator_width10 2
|
||||
|
||||
//
|
||||
// MA Lower ...
|
||||
|
||||
//
|
||||
#define maBondLowerBufferIndex 13
|
||||
double maBondLowerBuffer[];
|
||||
#define maBandLowerBufferIndex 13
|
||||
double maBandLowerBuffer[];
|
||||
|
||||
//
|
||||
#define maBondLowerBufferPlotIndex 10
|
||||
#define maBandLowerBufferPlotIndex 10
|
||||
#property indicator_label11 "LowerMA"
|
||||
#property indicator_type11 DRAW_LINE
|
||||
#property indicator_color11 clrRed
|
||||
#property indicator_width11 3
|
||||
#property indicator_width11 2
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
@@ -340,60 +347,88 @@ double hkColorBuffer[];
|
||||
#property indicator_color12 CLR_NONE, clrAqua, clrMagenta, clrGray
|
||||
|
||||
//
|
||||
#define hkBondUpperBufferIndex 19
|
||||
double hkBondUpperBuffer[];
|
||||
#define hkBandUpperBufferIndex 19
|
||||
double hkBandUpperBuffer[];
|
||||
|
||||
//
|
||||
#define hkBondUpperBufferPlotIndex 12
|
||||
#define hkBandUpperBufferPlotIndex 12
|
||||
#property indicator_label13 "UpperHK"
|
||||
#property indicator_type13 DRAW_LINE
|
||||
#property indicator_color13 clrAqua
|
||||
#property indicator_width13 3
|
||||
#property indicator_width13 2
|
||||
|
||||
//
|
||||
#define hkBondLowerBufferIndex 20
|
||||
double hkBondLowerBuffer[];
|
||||
#define hkBandLowerBufferIndex 20
|
||||
double hkBandLowerBuffer[];
|
||||
|
||||
//
|
||||
#define hkBondLowerBufferPlotIndex 13
|
||||
#define hkBandLowerBufferPlotIndex 13
|
||||
#property indicator_label14 "LowerHK"
|
||||
#property indicator_type14 DRAW_LINE
|
||||
#property indicator_color14 clrMagenta
|
||||
#property indicator_width14 3
|
||||
#property indicator_width14 2
|
||||
|
||||
//
|
||||
// PB Upper ...
|
||||
|
||||
//
|
||||
#define pbBondUpperBufferIndex 21
|
||||
double pbBondUpperBuffer[];
|
||||
#define pbBandUpperBufferIndex 21
|
||||
double pbBandUpperBuffer[];
|
||||
|
||||
//
|
||||
#define pbBondUpperBufferPlotIndex 14
|
||||
#define pbBandUpperBufferPlotIndex 14
|
||||
#property indicator_label15 "UpperPB"
|
||||
#property indicator_type15 DRAW_LINE
|
||||
#property indicator_color15 clrRoyalBlue
|
||||
#property indicator_width15 3
|
||||
#property indicator_width15 2
|
||||
|
||||
//
|
||||
// PB Lower ...
|
||||
|
||||
//
|
||||
#define pbBondLowerBufferIndex 22
|
||||
double pbBondLowerBuffer[];
|
||||
#define pbBandLowerBufferIndex 22
|
||||
double pbBandLowerBuffer[];
|
||||
|
||||
//
|
||||
#define pbBondLowerBufferPlotIndex 15
|
||||
#define pbBandLowerBufferPlotIndex 15
|
||||
#property indicator_label16 "LowerPB"
|
||||
#property indicator_type16 DRAW_LINE
|
||||
#property indicator_color16 clrOrangeRed
|
||||
#property indicator_width16 3
|
||||
#property indicator_color16 clrRoyalBlue
|
||||
#property indicator_width16 2
|
||||
|
||||
//
|
||||
// ATR Upper ...
|
||||
|
||||
//
|
||||
#define atrBandUpperBufferIndex 23
|
||||
double atrBandUpperBuffer[];
|
||||
|
||||
//
|
||||
#define atrBandUpperBufferPlotIndex 16
|
||||
#property indicator_label17 "UpperATR"
|
||||
#property indicator_type17 DRAW_LINE
|
||||
#property indicator_color17 clrOrange
|
||||
#property indicator_width17 2
|
||||
|
||||
//
|
||||
// ATR Lower ...
|
||||
|
||||
//
|
||||
#define atrBandLowerBufferIndex 24
|
||||
double atrBandLowerBuffer[];
|
||||
|
||||
//
|
||||
#define atrBandLowerBufferPlotIndex 17
|
||||
#property indicator_label18 "LowerATR"
|
||||
#property indicator_type18 DRAW_LINE
|
||||
#property indicator_color18 clrOrange
|
||||
#property indicator_width18 2
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
//
|
||||
#define mLastBufferIndex 22
|
||||
#define mLastBufferIndex 24
|
||||
|
||||
//
|
||||
// MA ...
|
||||
@@ -502,12 +537,27 @@ double hkRawCloseBuffer[];
|
||||
// XPB Data ...
|
||||
|
||||
//
|
||||
#define pbBondRawUpperBufferIndex mLastBufferIndex + 20
|
||||
double pbBondRawUpperBuffer[];
|
||||
#define pbBandRawUpperBufferIndex mLastBufferIndex + 20
|
||||
double pbBandRawUpperBuffer[];
|
||||
|
||||
//
|
||||
#define pbBondRawLowerBufferIndex mLastBufferIndex + 21
|
||||
double pbBondRawLowerBuffer[];
|
||||
#define pbBandRawLowerBufferIndex mLastBufferIndex + 21
|
||||
double pbBandRawLowerBuffer[];
|
||||
|
||||
//
|
||||
// XATR Data ...
|
||||
|
||||
//
|
||||
#define atrBufferIndex mLastBufferIndex + 22
|
||||
double atrBuffer[];
|
||||
|
||||
//
|
||||
#define atrBandRawUpperBufferIndex mLastBufferIndex + 23
|
||||
double atrBandRawUpperBuffer[];
|
||||
|
||||
//
|
||||
#define atrBandRawLowerBufferIndex mLastBufferIndex + 24
|
||||
double atrBandRawLowerBuffer[];
|
||||
|
||||
//
|
||||
// Variables, Properties and etc ...
|
||||
@@ -534,6 +584,7 @@ ENUM_TIMEFRAMES mHCPeriod = NULL;
|
||||
|
||||
//
|
||||
int sarHandler = INVALID_HANDLE;
|
||||
int atrHandler = INVALID_HANDLE;
|
||||
int maFastHandler = INVALID_HANDLE;
|
||||
int maSlowHandler = INVALID_HANDLE;
|
||||
int maUpperHandler = INVALID_HANDLE;
|
||||
@@ -662,6 +713,7 @@ void OnDeinit(const int reason)
|
||||
//
|
||||
// De Initialize all Handlers and etc ...
|
||||
IndicatorRelease(sarHandler);
|
||||
IndicatorRelease(atrHandler);
|
||||
IndicatorRelease(maFastHandler);
|
||||
IndicatorRelease(maSlowHandler);
|
||||
IndicatorRelease(maUpperHandler);
|
||||
@@ -739,6 +791,10 @@ int OnCalculate(
|
||||
// SAR ...
|
||||
int sarCalculatedBars = BarsCalculated(sarHandler);
|
||||
|
||||
//
|
||||
// ATR ...
|
||||
int atrCalculatedBars = BarsCalculated(atrHandler);
|
||||
|
||||
//
|
||||
bool isPassedRequiredCalculatedBars =
|
||||
//
|
||||
@@ -749,7 +805,10 @@ int OnCalculate(
|
||||
maLowerCalculatedBars >= maxLength &&
|
||||
//
|
||||
// SAR ...
|
||||
sarCalculatedBars >= maxLength
|
||||
sarCalculatedBars >= maxLength &&
|
||||
//
|
||||
// ATR ...
|
||||
atrCalculatedBars >= maxLength
|
||||
//
|
||||
;
|
||||
if (!isPassedRequiredCalculatedBars)
|
||||
@@ -769,13 +828,17 @@ int OnCalculate(
|
||||
// MA ...
|
||||
int copiedMAFasts = CopyBuffer(maFastHandler, MAIN_LINE, 0, limit, maFastBuffer);
|
||||
int copiedMASlows = CopyBuffer(maSlowHandler, MAIN_LINE, 0, limit, maSlowBuffer);
|
||||
int copiedMAUppers = CopyBuffer(maUpperHandler, MAIN_LINE, 0, limit, maBondUpperBuffer);
|
||||
int copiedMALowers = CopyBuffer(maLowerHandler, MAIN_LINE, 0, limit, maBondLowerBuffer);
|
||||
int copiedMAUppers = CopyBuffer(maUpperHandler, MAIN_LINE, 0, limit, maBandUpperBuffer);
|
||||
int copiedMALowers = CopyBuffer(maLowerHandler, MAIN_LINE, 0, limit, maBandLowerBuffer);
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
int copiedSARs = CopyBuffer(sarHandler, MAIN_LINE, 0, limit, sarBuffer);
|
||||
|
||||
//
|
||||
// ATR ...
|
||||
int copiedATRs = CopyBuffer(atrHandler, MAIN_LINE, 0, limit, atrBuffer);
|
||||
|
||||
//
|
||||
// Validate Copied Items ...
|
||||
bool isPassedRequiredCopiedItems =
|
||||
@@ -787,7 +850,10 @@ int OnCalculate(
|
||||
copiedMALowers >= limit &&
|
||||
//
|
||||
// SAR ...
|
||||
copiedSARs >= limit
|
||||
copiedSARs >= limit &&
|
||||
//
|
||||
// ATR ...
|
||||
copiedATRs >= limit
|
||||
//
|
||||
;
|
||||
if (!isPassedRequiredCopiedItems)
|
||||
@@ -846,7 +912,7 @@ bool ValidateInputs()
|
||||
// MA ...
|
||||
maFastLength >= 2 &&
|
||||
maSlowLength >= 2 &&
|
||||
maBondLength >= 2 &&
|
||||
maBandLength >= 2 &&
|
||||
maSlowLength > maFastLength &&
|
||||
//
|
||||
// SAR ...
|
||||
@@ -854,6 +920,12 @@ bool ValidateInputs()
|
||||
sarStep > 0 &&
|
||||
sarMax > sarStep &&
|
||||
//
|
||||
// ATR ...
|
||||
atrLength > 0 &&
|
||||
atrMultiplier >= 1 &&
|
||||
IsXValid(atrUpperPriceType) &&
|
||||
IsXValid(atrLowerPriceType) &&
|
||||
//
|
||||
// CYCLES ...
|
||||
(IsValid(scMethod, scPeriod) &&
|
||||
IsValid(mcMethod, mcPeriod) &&
|
||||
@@ -893,7 +965,8 @@ int ExtractMaxLengthOfInputs()
|
||||
result = MathMax(result, mHCLength);
|
||||
result = MathMax(result, maFastLength);
|
||||
result = MathMax(result, maSlowLength);
|
||||
result = MathMax(result, maBondLength);
|
||||
result = MathMax(result, maBandLength);
|
||||
result = MathMax(result, atrLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1039,63 +1112,63 @@ void DefineBuffers()
|
||||
PlotIndexSetDouble(zigzagBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
|
||||
//
|
||||
// MA Bond ...
|
||||
// MA Band ...
|
||||
|
||||
//
|
||||
ENUM_DRAW_TYPE maBondDrawType = showMABond ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE maBandDrawType = showMABand ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Upper Bond ...
|
||||
// Upper Band ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maBondUpperBuffer, true);
|
||||
SetIndexBuffer(maBondUpperBufferIndex, maBondUpperBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(maBandUpperBuffer, true);
|
||||
SetIndexBuffer(maBandUpperBufferIndex, maBandUpperBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||
PlotIndexSetDouble(maBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
PlotIndexSetInteger(maBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||
PlotIndexSetInteger(maBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||
PlotIndexSetInteger(maBandUpperBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||
PlotIndexSetDouble(maBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
|
||||
//
|
||||
// Lower Bond ...
|
||||
// Lower Band ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maBondLowerBuffer, true);
|
||||
SetIndexBuffer(maBondLowerBufferIndex, maBondLowerBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(maBandLowerBuffer, true);
|
||||
SetIndexBuffer(maBandLowerBufferIndex, maBandLowerBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(maBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
||||
PlotIndexSetInteger(maBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
||||
PlotIndexSetInteger(maBondLowerBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||
PlotIndexSetDouble(maBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
PlotIndexSetInteger(maBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||
PlotIndexSetInteger(maBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||
PlotIndexSetInteger(maBandLowerBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||
PlotIndexSetDouble(maBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
|
||||
//
|
||||
// XPB Bond ...
|
||||
// XPB Band ...
|
||||
|
||||
//
|
||||
// Upper Bond ...
|
||||
// Upper Band ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondUpperBuffer, true);
|
||||
SetIndexBuffer(pbBondUpperBufferIndex, pbBondUpperBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(pbBandUpperBuffer, true);
|
||||
SetIndexBuffer(pbBandUpperBufferIndex, pbBandUpperBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(pbBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
||||
PlotIndexSetInteger(pbBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
||||
PlotIndexSetDouble(pbBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(pbBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||
PlotIndexSetInteger(pbBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||
PlotIndexSetDouble(pbBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// Lower Bond ...
|
||||
// Lower Band ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondLowerBuffer, true);
|
||||
SetIndexBuffer(pbBondLowerBufferIndex, pbBondLowerBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(pbBandLowerBuffer, true);
|
||||
SetIndexBuffer(pbBandLowerBufferIndex, pbBandLowerBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(pbBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
||||
PlotIndexSetInteger(pbBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
||||
PlotIndexSetDouble(pbBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(pbBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||
PlotIndexSetInteger(pbBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||
PlotIndexSetDouble(pbBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
@@ -1131,29 +1204,54 @@ void DefineBuffers()
|
||||
SetIndexBuffer(hkCloseBufferIndex, hkCloseBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
// XHK Bond ...
|
||||
// XHK Band ...
|
||||
//
|
||||
ENUM_DRAW_TYPE hkBondDrawType = showHKBond ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE hkBandDrawType = showHKBand ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
ArraySetAsSeries(hkBondUpperBuffer, true);
|
||||
SetIndexBuffer(hkBondUpperBufferIndex, hkBondUpperBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(hkBandUpperBuffer, true);
|
||||
SetIndexBuffer(hkBandUpperBufferIndex, hkBandUpperBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(hkBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showHKBond);
|
||||
PlotIndexSetInteger(hkBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, hkBondDrawType);
|
||||
PlotIndexSetDouble(hkBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(hkBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showHKBand);
|
||||
PlotIndexSetInteger(hkBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, hkBandDrawType);
|
||||
PlotIndexSetDouble(hkBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
ArraySetAsSeries(hkBondLowerBuffer, true);
|
||||
SetIndexBuffer(hkBondLowerBufferIndex, hkBondLowerBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(hkBandLowerBuffer, true);
|
||||
SetIndexBuffer(hkBandLowerBufferIndex, hkBandLowerBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(hkBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showHKBond);
|
||||
PlotIndexSetInteger(hkBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, hkBondDrawType);
|
||||
PlotIndexSetDouble(hkBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
PlotIndexSetInteger(hkBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showHKBand);
|
||||
PlotIndexSetInteger(hkBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, hkBandDrawType);
|
||||
PlotIndexSetDouble(hkBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// XATR Band ...
|
||||
//
|
||||
ENUM_DRAW_TYPE atrBandDrawType = showATRBand ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
ArraySetAsSeries(atrBandUpperBuffer, true);
|
||||
SetIndexBuffer(atrBandUpperBufferIndex, atrBandUpperBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(atrBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showATRBand);
|
||||
PlotIndexSetInteger(atrBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, atrBandDrawType);
|
||||
PlotIndexSetDouble(atrBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
ArraySetAsSeries(atrBandLowerBuffer, true);
|
||||
SetIndexBuffer(atrBandLowerBufferIndex, atrBandLowerBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(atrBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showATRBand);
|
||||
PlotIndexSetInteger(atrBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, atrBandDrawType);
|
||||
PlotIndexSetDouble(atrBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
@@ -1250,12 +1348,27 @@ void DefineBuffers()
|
||||
// XPB Data ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondRawUpperBuffer, true);
|
||||
SetIndexBuffer(pbBondRawUpperBufferIndex, pbBondRawUpperBuffer, INDICATOR_CALCULATIONS);
|
||||
ArraySetAsSeries(pbBandRawUpperBuffer, true);
|
||||
SetIndexBuffer(pbBandRawUpperBufferIndex, pbBandRawUpperBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondRawLowerBuffer, true);
|
||||
SetIndexBuffer(pbBondRawLowerBufferIndex, pbBondRawLowerBuffer, INDICATOR_CALCULATIONS);
|
||||
ArraySetAsSeries(pbBandRawLowerBuffer, true);
|
||||
SetIndexBuffer(pbBandRawLowerBufferIndex, pbBandRawLowerBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// XATR Data ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(atrBuffer, true);
|
||||
SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(atrBandRawUpperBuffer, true);
|
||||
SetIndexBuffer(atrBandRawUpperBufferIndex, atrBandRawUpperBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(atrBandRawLowerBuffer, true);
|
||||
SetIndexBuffer(atrBandRawLowerBufferIndex, atrBandRawLowerBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
}
|
||||
@@ -1418,11 +1531,11 @@ bool InitRequirements()
|
||||
}
|
||||
|
||||
//
|
||||
// MA Bond Upper ...
|
||||
// MA Band Upper ...
|
||||
maUpperHandler = iMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
maBondLength,
|
||||
maBandLength,
|
||||
0,
|
||||
maMethod,
|
||||
PRICE_HIGH //
|
||||
@@ -1434,11 +1547,11 @@ bool InitRequirements()
|
||||
}
|
||||
|
||||
//
|
||||
// MA Bond Lower ...
|
||||
// MA Band Lower ...
|
||||
maLowerHandler = iMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
maBondLength,
|
||||
maBandLength,
|
||||
0,
|
||||
maMethod,
|
||||
PRICE_LOW //
|
||||
@@ -1463,6 +1576,19 @@ bool InitRequirements()
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// ATR ...
|
||||
atrHandler = iATR(
|
||||
_Symbol,
|
||||
_Period,
|
||||
atrLength //
|
||||
);
|
||||
result = atrHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mDrawer = new XCPOIDrawer();
|
||||
|
||||
@@ -1620,6 +1746,19 @@ void CalculateValues(
|
||||
tickVolume //
|
||||
);
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
CalculateATR(
|
||||
barIndex,
|
||||
prevCalculated,
|
||||
ratesTotal,
|
||||
open,
|
||||
high,
|
||||
close,
|
||||
low,
|
||||
tickVolume //
|
||||
);
|
||||
|
||||
//
|
||||
// Fast MA ...
|
||||
double iFastMa = maFastBuffer[barIndex];
|
||||
@@ -1718,15 +1857,15 @@ void CalculateValues(
|
||||
double iPBLower = MathMin(close[barIndex], open[barIndex]);
|
||||
|
||||
//
|
||||
pbBondUpperBuffer[barIndex] = iPBUpper;
|
||||
pbBondRawUpperBuffer[barIndex] = iPBUpper;
|
||||
pbBandUpperBuffer[barIndex] = iPBUpper;
|
||||
pbBandRawUpperBuffer[barIndex] = iPBUpper;
|
||||
|
||||
//
|
||||
pbBondLowerBuffer[barIndex] = iPBLower;
|
||||
pbBondRawLowerBuffer[barIndex] = iPBLower;
|
||||
pbBandLowerBuffer[barIndex] = iPBLower;
|
||||
pbBandRawLowerBuffer[barIndex] = iPBLower;
|
||||
|
||||
//
|
||||
if (IsXValid(iPBMethod) && maBondLength > 0)
|
||||
if (IsXValid(iPBMethod) && maBandLength > 0)
|
||||
{
|
||||
//
|
||||
// XPB Upper ...
|
||||
@@ -1734,9 +1873,9 @@ void CalculateValues(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
maBondLength,
|
||||
pbBondRawUpperBuffer,
|
||||
pbBondUpperBuffer,
|
||||
maBandLength,
|
||||
pbBandRawUpperBuffer,
|
||||
pbBandUpperBuffer,
|
||||
iPBMethod //
|
||||
);
|
||||
|
||||
@@ -1746,9 +1885,9 @@ void CalculateValues(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
maBondLength,
|
||||
pbBondRawLowerBuffer,
|
||||
pbBondLowerBuffer,
|
||||
maBandLength,
|
||||
pbBandRawLowerBuffer,
|
||||
pbBandLowerBuffer,
|
||||
iPBMethod //
|
||||
);
|
||||
}
|
||||
@@ -2334,8 +2473,8 @@ void CalculateHKBar(
|
||||
}
|
||||
|
||||
//
|
||||
hkBondUpperBuffer[barIndex] = hkHighBuffer[barIndex];
|
||||
hkBondLowerBuffer[barIndex] = hkLowBuffer[barIndex];
|
||||
hkBandUpperBuffer[barIndex] = hkHighBuffer[barIndex];
|
||||
hkBandLowerBuffer[barIndex] = hkLowBuffer[barIndex];
|
||||
|
||||
//
|
||||
// Calculate HK Color ...
|
||||
@@ -2351,6 +2490,93 @@ void CalculateHKBar(
|
||||
: hideColorIDX;
|
||||
}
|
||||
|
||||
//
|
||||
void CalculateATR(
|
||||
int barIndex,
|
||||
const int prevCalculated,
|
||||
const int ratesTotal,
|
||||
const double &open[],
|
||||
const double &high[],
|
||||
const double &close[],
|
||||
const double &low[],
|
||||
const long &tickVolume[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int lastBarIndex = barIndex + 1;
|
||||
bool isFirstBar =
|
||||
startCalculationForLastBars > 0
|
||||
? barIndex == startCalculationForLastBars
|
||||
: barIndex == firstBarIndex;
|
||||
|
||||
//
|
||||
double iAtr = atrBuffer[barIndex];
|
||||
double iAppliedAtr = atrMultiplier <= 0
|
||||
? iAtr
|
||||
: atrMultiplier * iAtr;
|
||||
double iUpperPrice = GetAppliedPrice(
|
||||
atrUpperPriceType,
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
barIndex //
|
||||
);
|
||||
double iLowerPrice = GetAppliedPrice(
|
||||
atrLowerPriceType,
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
barIndex //
|
||||
);
|
||||
double iPriceMid = iLowerPrice + ((iUpperPrice - iLowerPrice) / 2);
|
||||
|
||||
//
|
||||
double iUpperAtr = iPriceMid + iAppliedAtr;
|
||||
double iLowerAtr = iPriceMid - iAppliedAtr;
|
||||
|
||||
//
|
||||
atrBandRawUpperBuffer[barIndex] = iUpperAtr;
|
||||
atrBandRawLowerBuffer[barIndex] = iLowerAtr;
|
||||
|
||||
//
|
||||
// Check Can Smooth Atr ...
|
||||
if (IsXValid(atrSmoothingMode) &&
|
||||
atrSmoothingLength > 0)
|
||||
{
|
||||
//
|
||||
// Upper ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
atrSmoothingLength,
|
||||
atrBandRawUpperBuffer,
|
||||
atrBandUpperBuffer,
|
||||
atrSmoothingMode //
|
||||
);
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
atrSmoothingLength,
|
||||
atrBandRawLowerBuffer,
|
||||
atrBandLowerBuffer,
|
||||
atrSmoothingMode //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
atrBandUpperBuffer[barIndex] = iUpperAtr;
|
||||
atrBandLowerBuffer[barIndex] = iLowerAtr;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void CalculateCycleRanges(
|
||||
int barIndex,
|
||||
|
||||
Reference in New Issue
Block a user