Last works ...
This commit is contained in:
+194
-57
@@ -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 maBandLength = 21; // MA Bond Length
|
||||
input int maBondLength = 21; // MA Bond Length
|
||||
input int zigzagDepth = 12; // ZigZag Depth
|
||||
input int zigzagDeviation = 5; // ZigZag Deviation
|
||||
input int zigzagBackStep = 3; // ZigZag Back Step
|
||||
@@ -101,7 +101,7 @@ 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 showMABand = true; // Show MA Bond
|
||||
input bool showMABond = true; // Show MA Bond
|
||||
input bool showHKBond = true; // Show HK Bond
|
||||
input bool showZigZag = true; // Show ZigZag
|
||||
input bool showFiboZone = true; // Show Fibo Zone
|
||||
@@ -138,8 +138,8 @@ input int valeArrowCode = 159; // Vales Arrow Code
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 40
|
||||
#property indicator_plots 14
|
||||
#property indicator_buffers 44
|
||||
#property indicator_plots 16
|
||||
|
||||
//
|
||||
// Plot Buffers ...
|
||||
@@ -286,9 +286,9 @@ double zigzagBuffer[];
|
||||
// MA Upper ...
|
||||
|
||||
//
|
||||
#define maUpperBufferIndex 12
|
||||
#define maUpperBufferPlotIndex 9
|
||||
double maUpperBuffer[];
|
||||
#define maBondUpperBufferIndex 12
|
||||
#define maBondUpperBufferPlotIndex 9
|
||||
double maBondUpperBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label10 "UpperMA"
|
||||
@@ -300,9 +300,9 @@ double maUpperBuffer[];
|
||||
// MA Lower ...
|
||||
|
||||
//
|
||||
#define maLowerBufferIndex 13
|
||||
#define maLowerBufferPlotIndex 10
|
||||
double maLowerBuffer[];
|
||||
#define maBondLowerBufferIndex 13
|
||||
#define maBondLowerBufferPlotIndex 10
|
||||
double maBondLowerBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label11 "LowerMA"
|
||||
@@ -361,11 +361,39 @@ double hkBondLowerBuffer[];
|
||||
#property indicator_color14 clrMagenta
|
||||
#property indicator_width14 3
|
||||
|
||||
//
|
||||
// PB Upper ...
|
||||
|
||||
//
|
||||
#define pbBondUpperBufferIndex 21
|
||||
double pbBondUpperBuffer[];
|
||||
|
||||
//
|
||||
#define pbBondUpperBufferPlotIndex 14
|
||||
#property indicator_label15 "UpperPB"
|
||||
#property indicator_type15 DRAW_LINE
|
||||
#property indicator_color15 clrRoyalBlue
|
||||
#property indicator_width15 3
|
||||
|
||||
//
|
||||
// PB Lower ...
|
||||
|
||||
//
|
||||
#define pbBondLowerBufferIndex 22
|
||||
double pbBondLowerBuffer[];
|
||||
|
||||
//
|
||||
#define pbBondLowerBufferPlotIndex 15
|
||||
#property indicator_label16 "LowerPB"
|
||||
#property indicator_type16 DRAW_LINE
|
||||
#property indicator_color16 clrOrangeRed
|
||||
#property indicator_width16 3
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
//
|
||||
#define mLastBufferIndex 20
|
||||
#define mLastBufferIndex 22
|
||||
|
||||
//
|
||||
// MA ...
|
||||
@@ -470,6 +498,17 @@ double hkRawLowBuffer[];
|
||||
#define hkRawCloseBufferIndex mLastBufferIndex + 19
|
||||
double hkRawCloseBuffer[];
|
||||
|
||||
//
|
||||
// XPB Data ...
|
||||
|
||||
//
|
||||
#define pbBondRawUpperBufferIndex mLastBufferIndex + 20
|
||||
double pbBondRawUpperBuffer[];
|
||||
|
||||
//
|
||||
#define pbBondRawLowerBufferIndex mLastBufferIndex + 21
|
||||
double pbBondRawLowerBuffer[];
|
||||
|
||||
//
|
||||
// Variables, Properties and etc ...
|
||||
|
||||
@@ -529,6 +568,9 @@ datetime lastZigZagPeakTime = NULL;
|
||||
double lastZigZagVale = 0;
|
||||
datetime lastZigZagValeTime = NULL;
|
||||
|
||||
//
|
||||
ENUM_X_MA_METHOD iPBMethod = X_MA_MODE_NONE;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
@@ -550,6 +592,10 @@ int OnInit()
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Price Buffer Smoothing Method ...
|
||||
iPBMethod = ToXMaMethod(maMethod);
|
||||
|
||||
//
|
||||
has = InitCycles();
|
||||
if (!has)
|
||||
@@ -723,8 +769,8 @@ 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, maUpperBuffer);
|
||||
int copiedMALowers = CopyBuffer(maLowerHandler, MAIN_LINE, 0, limit, maLowerBuffer);
|
||||
int copiedMAUppers = CopyBuffer(maUpperHandler, MAIN_LINE, 0, limit, maBondUpperBuffer);
|
||||
int copiedMALowers = CopyBuffer(maLowerHandler, MAIN_LINE, 0, limit, maBondLowerBuffer);
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
@@ -800,7 +846,7 @@ bool ValidateInputs()
|
||||
// MA ...
|
||||
maFastLength >= 2 &&
|
||||
maSlowLength >= 2 &&
|
||||
maBandLength >= 2 &&
|
||||
maBondLength >= 2 &&
|
||||
maSlowLength > maFastLength &&
|
||||
//
|
||||
// SAR ...
|
||||
@@ -847,7 +893,7 @@ int ExtractMaxLengthOfInputs()
|
||||
result = MathMax(result, mHCLength);
|
||||
result = MathMax(result, maFastLength);
|
||||
result = MathMax(result, maSlowLength);
|
||||
result = MathMax(result, maBandLength);
|
||||
result = MathMax(result, maBondLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -873,10 +919,6 @@ void DefineBuffers()
|
||||
ArraySetAsSeries(maFastColorBuffer, true);
|
||||
SetIndexBuffer(maFastColorBufferIndex, maFastColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maFastStateBuffer, true);
|
||||
SetIndexBuffer(maFastStateBufferIndex, maFastStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// Slow MA ...
|
||||
|
||||
@@ -892,10 +934,6 @@ void DefineBuffers()
|
||||
ArraySetAsSeries(maSlowColorBuffer, true);
|
||||
SetIndexBuffer(maSlowColorBufferIndex, maSlowColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maSlowStateBuffer, true);
|
||||
SetIndexBuffer(maSlowStateBufferIndex, maSlowStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// SAR ...
|
||||
|
||||
@@ -912,10 +950,6 @@ void DefineBuffers()
|
||||
ArraySetAsSeries(sarColorBuffer, true);
|
||||
SetIndexBuffer(sarColorBufferIndex, sarColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(sarStateBuffer, true);
|
||||
SetIndexBuffer(sarStateBufferIndex, sarStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// PEAK / VALE ...
|
||||
|
||||
@@ -1008,35 +1042,60 @@ void DefineBuffers()
|
||||
// MA Bond ...
|
||||
|
||||
//
|
||||
ENUM_DRAW_TYPE maBandDrawType = showMABand ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE maBondDrawType = showMABond ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// MA Upper Bond ...
|
||||
// Upper Bond ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maUpperBuffer, true);
|
||||
SetIndexBuffer(maUpperBufferIndex, maUpperBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(maBondUpperBuffer, true);
|
||||
SetIndexBuffer(maBondUpperBufferIndex, maBondUpperBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(maUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||
PlotIndexSetInteger(maUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||
|
||||
PlotIndexSetInteger(maUpperBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||
PlotIndexSetDouble(maUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||
PlotIndexSetDouble(maBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
|
||||
//
|
||||
// MA Lower Bond ...
|
||||
// Lower Bond ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maLowerBuffer, true);
|
||||
SetIndexBuffer(maLowerBufferIndex, maLowerBuffer, INDICATOR_DATA);
|
||||
ArraySetAsSeries(maBondLowerBuffer, true);
|
||||
SetIndexBuffer(maBondLowerBufferIndex, maBondLowerBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(maLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||
PlotIndexSetInteger(maLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||
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(maLowerBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||
PlotIndexSetDouble(maLowerBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||
//
|
||||
// XPB Bond ...
|
||||
|
||||
//
|
||||
// Upper Bond ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondUpperBuffer, true);
|
||||
SetIndexBuffer(pbBondUpperBufferIndex, pbBondUpperBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(pbBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
||||
PlotIndexSetInteger(pbBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
||||
PlotIndexSetDouble(pbBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// Lower Bond ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondLowerBuffer, true);
|
||||
SetIndexBuffer(pbBondLowerBufferIndex, pbBondLowerBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(pbBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
||||
PlotIndexSetInteger(pbBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
||||
PlotIndexSetDouble(pbBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
@@ -1073,20 +1132,44 @@ void DefineBuffers()
|
||||
|
||||
//
|
||||
// XHK Bond ...
|
||||
//
|
||||
ENUM_DRAW_TYPE hkBondDrawType = showHKBond ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Upper ...
|
||||
ArraySetAsSeries(hkBondUpperBuffer, true);
|
||||
SetIndexBuffer(hkBondUpperBufferIndex, hkBondUpperBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(hkBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showHKBond);
|
||||
PlotIndexSetInteger(hkBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, hkBondDrawType);
|
||||
PlotIndexSetDouble(hkBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// Lower ...
|
||||
ArraySetAsSeries(hkBondLowerBuffer, true);
|
||||
SetIndexBuffer(hkBondLowerBufferIndex, hkBondLowerBuffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(hkBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showHKBond);
|
||||
PlotIndexSetInteger(hkBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, hkBondDrawType);
|
||||
PlotIndexSetDouble(hkBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||
|
||||
//
|
||||
// Data Buffers ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maFastStateBuffer, true);
|
||||
SetIndexBuffer(maFastStateBufferIndex, maFastStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(maSlowStateBuffer, true);
|
||||
SetIndexBuffer(maSlowStateBufferIndex, maSlowStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(sarStateBuffer, true);
|
||||
SetIndexBuffer(sarStateBufferIndex, sarStateBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// CYCLES ...
|
||||
|
||||
@@ -1095,44 +1178,44 @@ void DefineBuffers()
|
||||
|
||||
//
|
||||
ArraySetAsSeries(sHHBuffer, true);
|
||||
SetIndexBuffer(sHHBufferIndex, sHHBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(sHHBufferIndex, sHHBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(sLLBuffer, true);
|
||||
SetIndexBuffer(sLLBufferIndex, sLLBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(sLLBufferIndex, sLLBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// MC ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mHHBuffer, true);
|
||||
SetIndexBuffer(mHHBufferIndex, mHHBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(mHHBufferIndex, mHHBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mLLBuffer, true);
|
||||
SetIndexBuffer(mLLBufferIndex, mLLBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(mLLBufferIndex, mLLBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// LC ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(lHHBuffer, true);
|
||||
SetIndexBuffer(lHHBufferIndex, lHHBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(lHHBufferIndex, lHHBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(lLLBuffer, true);
|
||||
SetIndexBuffer(lLLBufferIndex, lLLBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(lLLBufferIndex, lLLBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// HC ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hHHBuffer, true);
|
||||
SetIndexBuffer(hHHBufferIndex, hHHBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(hHHBufferIndex, hHHBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hLLBuffer, true);
|
||||
SetIndexBuffer(hLLBufferIndex, hLLBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(hLLBufferIndex, hLLBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// Highs ...
|
||||
@@ -1149,19 +1232,30 @@ void DefineBuffers()
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawHighBuffer, true);
|
||||
SetIndexBuffer(hkRawHighBufferIndex, hkRawHighBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(hkRawHighBufferIndex, hkRawHighBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawOpenBuffer, true);
|
||||
SetIndexBuffer(hkRawOpenBufferIndex, hkRawOpenBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(hkRawOpenBufferIndex, hkRawOpenBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawLowBuffer, true);
|
||||
SetIndexBuffer(hkRawLowBufferIndex, hkRawLowBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(hkRawLowBufferIndex, hkRawLowBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hkRawCloseBuffer, true);
|
||||
SetIndexBuffer(hkRawCloseBufferIndex, hkRawCloseBuffer, INDICATOR_DATA);
|
||||
SetIndexBuffer(hkRawCloseBufferIndex, hkRawCloseBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
// XPB Data ...
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondRawUpperBuffer, true);
|
||||
SetIndexBuffer(pbBondRawUpperBufferIndex, pbBondRawUpperBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(pbBondRawLowerBuffer, true);
|
||||
SetIndexBuffer(pbBondRawLowerBufferIndex, pbBondRawLowerBuffer, INDICATOR_CALCULATIONS);
|
||||
|
||||
//
|
||||
}
|
||||
@@ -1328,7 +1422,7 @@ bool InitRequirements()
|
||||
maUpperHandler = iMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
maBandLength,
|
||||
maBondLength,
|
||||
0,
|
||||
maMethod,
|
||||
PRICE_HIGH //
|
||||
@@ -1344,7 +1438,7 @@ bool InitRequirements()
|
||||
maLowerHandler = iMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
maBandLength,
|
||||
maBondLength,
|
||||
0,
|
||||
maMethod,
|
||||
PRICE_LOW //
|
||||
@@ -1615,6 +1709,49 @@ void CalculateValues(
|
||||
fiboUpperBuffer[barIndex] = iFiboUp;
|
||||
fiboMiddleBuffer[barIndex] = iFiboMid;
|
||||
fiboLowerBuffer[barIndex] = iFiboLo;
|
||||
|
||||
//
|
||||
// XPB ...
|
||||
|
||||
//
|
||||
double iPBUpper = MathMax(close[barIndex], open[barIndex]);
|
||||
double iPBLower = MathMin(close[barIndex], open[barIndex]);
|
||||
|
||||
//
|
||||
pbBondUpperBuffer[barIndex] = iPBUpper;
|
||||
pbBondRawUpperBuffer[barIndex] = iPBUpper;
|
||||
|
||||
//
|
||||
pbBondLowerBuffer[barIndex] = iPBLower;
|
||||
pbBondRawLowerBuffer[barIndex] = iPBLower;
|
||||
|
||||
//
|
||||
if (IsXValid(iPBMethod) && maBondLength > 0)
|
||||
{
|
||||
//
|
||||
// XPB Upper ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
maBondLength,
|
||||
pbBondRawUpperBuffer,
|
||||
pbBondUpperBuffer,
|
||||
iPBMethod //
|
||||
);
|
||||
|
||||
//
|
||||
// XPB Lower ...
|
||||
iMAOnBuffer(
|
||||
ratesTotal,
|
||||
prevCalculated,
|
||||
barIndex,
|
||||
maBondLength,
|
||||
pbBondRawLowerBuffer,
|
||||
pbBondLowerBuffer,
|
||||
iPBMethod //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user