last works ...
This commit is contained in:
@@ -635,6 +635,32 @@ class XCBaseHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizing Bar Index ...
|
||||||
|
*
|
||||||
|
* @param barIndex: int, Provided Bar Index ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int NormalizeBarIndex(int barIndex)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = barIndex;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = CountBars() - 1;
|
||||||
|
result = NormalizeInt(result, 0, count - 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private ...
|
// Private ...
|
||||||
private:
|
private:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -100,7 +100,7 @@ input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
|
|||||||
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
||||||
input int maFastLength = 7; // Fast MA Length
|
input int maFastLength = 7; // Fast MA Length
|
||||||
input int maSlowLength = 20; // Slow MA Length
|
input int maSlowLength = 20; // Slow MA Length
|
||||||
input int maBandLength = 7; // MA Band Length
|
input int maBondLength = 7; // MA Bond Length
|
||||||
input int zigzagDepth = 12; // ZigZag Depth
|
input int zigzagDepth = 12; // ZigZag Depth
|
||||||
input int zigzagDeviation = 5; // ZigZag Deviation
|
input int zigzagDeviation = 5; // ZigZag Deviation
|
||||||
input int zigzagBackStep = 3; // ZigZag Back Step
|
input int zigzagBackStep = 3; // ZigZag Back Step
|
||||||
@@ -126,7 +126,8 @@ input bool showSAR = true; // Show Sar
|
|||||||
input bool showBars = true; // Show Bars
|
input bool showBars = true; // Show Bars
|
||||||
input bool showMAFast = true; // Show MA Fast
|
input bool showMAFast = true; // Show MA Fast
|
||||||
input bool showMASlow = true; // Show MA Slow
|
input bool showMASlow = true; // Show MA Slow
|
||||||
input bool showMABand = true; // Show MA Band
|
input bool showMABond = true; // Show MA Bond
|
||||||
|
input bool showHKBond = true; // Show HK Bond
|
||||||
input bool showBarTime = true; // Show Bar Time
|
input bool showBarTime = true; // Show Bar Time
|
||||||
input bool showZigZag = true; // Show ZigZag
|
input bool showZigZag = true; // Show ZigZag
|
||||||
input bool showFiboZone = true; // Show Fibo Zone
|
input bool showFiboZone = true; // Show Fibo Zone
|
||||||
@@ -303,7 +304,7 @@ int OnInit()
|
|||||||
fimaInputs.maAppliedTo = maAppliedTo;
|
fimaInputs.maAppliedTo = maAppliedTo;
|
||||||
fimaInputs.maFastLength = maFastLength;
|
fimaInputs.maFastLength = maFastLength;
|
||||||
fimaInputs.maSlowLength = maSlowLength;
|
fimaInputs.maSlowLength = maSlowLength;
|
||||||
fimaInputs.maBandLength = maBandLength;
|
fimaInputs.maBondLength = maBondLength;
|
||||||
fimaInputs.zigzagDepth = zigzagDepth;
|
fimaInputs.zigzagDepth = zigzagDepth;
|
||||||
fimaInputs.zigzagDeviation = zigzagDeviation;
|
fimaInputs.zigzagDeviation = zigzagDeviation;
|
||||||
fimaInputs.zigzagBackStep = zigzagBackStep;
|
fimaInputs.zigzagBackStep = zigzagBackStep;
|
||||||
@@ -317,7 +318,8 @@ int OnInit()
|
|||||||
fimaInputs.showSAR = showSAR;
|
fimaInputs.showSAR = showSAR;
|
||||||
fimaInputs.showMAFast = showMAFast;
|
fimaInputs.showMAFast = showMAFast;
|
||||||
fimaInputs.showMASlow = showMASlow;
|
fimaInputs.showMASlow = showMASlow;
|
||||||
fimaInputs.showMABand = showMABand;
|
fimaInputs.showMABond = showMABond;
|
||||||
|
fimaInputs.showHKBond = showHKBond;
|
||||||
fimaInputs.showZigZag = showZigZag;
|
fimaInputs.showZigZag = showZigZag;
|
||||||
fimaInputs.showFiboZone = showFiboZone;
|
fimaInputs.showFiboZone = showFiboZone;
|
||||||
fimaInputs.startCalculationForLastBars = startCalculationForLastBars;
|
fimaInputs.startCalculationForLastBars = startCalculationForLastBars;
|
||||||
|
|||||||
@@ -35,54 +35,56 @@ enum ENUM_XFIMA_BUFFERS
|
|||||||
{
|
{
|
||||||
XFIMA_MA_FAST_LINE = 0,
|
XFIMA_MA_FAST_LINE = 0,
|
||||||
XFIMA_MA_FAST_COLOR_LINE = 1,
|
XFIMA_MA_FAST_COLOR_LINE = 1,
|
||||||
XFIMA_MA_FAST_STATE_LINE = 19,
|
XFIMA_MA_FAST_STATE_LINE = 21,
|
||||||
XFIMA_MA_SLOW_LINE = 2,
|
XFIMA_MA_SLOW_LINE = 2,
|
||||||
XFIMA_MA_SLOW_COLOR_LINE = 3,
|
XFIMA_MA_SLOW_COLOR_LINE = 3,
|
||||||
XFIMA_MA_SLOW_STATE_LINE = 20,
|
XFIMA_MA_SLOW_STATE_LINE = 22,
|
||||||
XFIMA_SAR_LINE = 4,
|
XFIMA_SAR_LINE = 4,
|
||||||
XFIMA_SAR_COLOR_LINE = 5,
|
XFIMA_SAR_COLOR_LINE = 5,
|
||||||
XFIMA_SAR_STATE_LINE = 21,
|
XFIMA_SAR_STATE_LINE = 23,
|
||||||
XFIMA_PEAK_LINE = 6,
|
XFIMA_PEAK_LINE = 6,
|
||||||
XFIMA_VALE_LINE = 7,
|
XFIMA_VALE_LINE = 7,
|
||||||
XFIMA_FIBO_UPPER_LINE = 8,
|
XFIMA_FIBO_UPPER_LINE = 8,
|
||||||
XFIMA_FIBO_MIDDLE_LINE = 9,
|
XFIMA_FIBO_MIDDLE_LINE = 9,
|
||||||
XFIMA_FIBO_LOWER_LINE = 10,
|
XFIMA_FIBO_LOWER_LINE = 10,
|
||||||
XFIMA_ZIGZAG_LINE = 11,
|
XFIMA_ZIGZAG_LINE = 11,
|
||||||
XFIMA_MA_BAND_UPPER_LINE = 12,
|
XFIMA_MA_BOND_UPPER_LINE = 12,
|
||||||
XFIMA_MA_BAND_LOWER_LINE = 13,
|
XFIMA_MA_BOND_LOWER_LINE = 13,
|
||||||
XFIMA_ZIGZAG_HIGHS_LINE = 30,
|
XFIMA_ZIGZAG_HIGHS_LINE = 32,
|
||||||
XFIMA_ZIGZAG_HIGHS_TIME_LINE = 31,
|
XFIMA_ZIGZAG_HIGHS_TIME_LINE = 33,
|
||||||
XFIMA_ZIGZAG_LOWS_LINE = 32,
|
XFIMA_ZIGZAG_LOWS_LINE = 34,
|
||||||
XFIMA_ZIGZAG_LOWS_TIME_LINE = 33,
|
XFIMA_ZIGZAG_LOWS_TIME_LINE = 35,
|
||||||
//
|
//
|
||||||
XFIMA_HK_OPEN_LINE = 14,
|
XFIMA_HK_OPEN_LINE = 14,
|
||||||
XFIMA_HK_HIGH_LINE = 15,
|
XFIMA_HK_HIGH_LINE = 15,
|
||||||
XFIMA_HK_LOW_LINE = 16,
|
XFIMA_HK_LOW_LINE = 16,
|
||||||
XFIMA_HK_CLOSE_LINE = 17,
|
XFIMA_HK_CLOSE_LINE = 17,
|
||||||
XFIMA_HK_COLOR_LINE = 18,
|
XFIMA_HK_COLOR_LINE = 18,
|
||||||
XFIMA_HK_RAW_OPEN_LINE = 34,
|
XFIMA_HK_BOND_UPPER_LINE = 19,
|
||||||
XFIMA_HK_RAW_HIGH_LINE = 35,
|
XFIMA_HK_BOND_LOWER_LINE = 20,
|
||||||
XFIMA_HK_RAW_LOW_LINE = 36,
|
XFIMA_HK_RAW_OPEN_LINE = 36,
|
||||||
XFIMA_HK_RAW_CLOSE_LINE = 37,
|
XFIMA_HK_RAW_HIGH_LINE = 37,
|
||||||
// 19 Ma Fast State
|
XFIMA_HK_RAW_LOW_LINE = 38,
|
||||||
// 20 Ma Slow State
|
XFIMA_HK_RAW_CLOSE_LINE = 39,
|
||||||
// 21 Sar State
|
// 21 Ma Fast State
|
||||||
XFIMA_SC_HH_LINE = 22,
|
// 22 Ma Slow State
|
||||||
XFIMA_SC_LL_LINE = 23,
|
// 23 Sar State
|
||||||
XFIMA_MC_HH_LINE = 24,
|
XFIMA_SC_HH_LINE = 24,
|
||||||
XFIMA_MC_LL_LINE = 25,
|
XFIMA_SC_LL_LINE = 25,
|
||||||
XFIMA_LC_HH_LINE = 26,
|
XFIMA_MC_HH_LINE = 26,
|
||||||
XFIMA_LC_LL_LINE = 27,
|
XFIMA_MC_LL_LINE = 27,
|
||||||
XFIMA_HC_HH_LINE = 28,
|
XFIMA_LC_HH_LINE = 28,
|
||||||
XFIMA_HC_LL_LINE = 29,
|
XFIMA_LC_LL_LINE = 29,
|
||||||
// 30 ZigZag Highs
|
XFIMA_HC_HH_LINE = 30,
|
||||||
// 31 ZigZag Highs Time
|
XFIMA_HC_LL_LINE = 31,
|
||||||
// 32 ZigZag Lows
|
// 32 ZigZag Highs
|
||||||
// 33 ZigZag Lows Time
|
// 33 ZigZag Highs Time
|
||||||
// 34 HK Raw Open
|
// 34 ZigZag Lows
|
||||||
// 35 HK Raw High
|
// 35 ZigZag Lows Time
|
||||||
// 36 HK Raw Low
|
// 36 HK Raw Open
|
||||||
// 37 HK Raw Close
|
// 37 HK Raw High
|
||||||
|
// 38 HK Raw Low
|
||||||
|
// 39 HK Raw Close
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -113,7 +115,7 @@ struct XFIMAInputs
|
|||||||
ENUM_APPLIED_PRICE maAppliedTo; // MA Applied To
|
ENUM_APPLIED_PRICE maAppliedTo; // MA Applied To
|
||||||
int maFastLength; // Fast MA Length
|
int maFastLength; // Fast MA Length
|
||||||
int maSlowLength; // Slow MA Length
|
int maSlowLength; // Slow MA Length
|
||||||
int maBandLength; // MA Band Length
|
int maBondLength; // MA Bond Length
|
||||||
int zigzagDepth; // ZigZag Depth
|
int zigzagDepth; // ZigZag Depth
|
||||||
int zigzagDeviation; // ZigZag Deviation
|
int zigzagDeviation; // ZigZag Deviation
|
||||||
int zigzagBackStep; // ZigZag Back Step
|
int zigzagBackStep; // ZigZag Back Step
|
||||||
@@ -130,7 +132,8 @@ struct XFIMAInputs
|
|||||||
bool showSAR; // Show Sar
|
bool showSAR; // Show Sar
|
||||||
bool showMAFast; // Show MA Fast
|
bool showMAFast; // Show MA Fast
|
||||||
bool showMASlow; // Show MA Slow
|
bool showMASlow; // Show MA Slow
|
||||||
bool showMABand; // Show MA Band
|
bool showMABond; // Show MA Bond
|
||||||
|
bool showHKBond; // Show HK Bond
|
||||||
bool showZigZag; // Show ZigZag
|
bool showZigZag; // Show ZigZag
|
||||||
bool showFiboZone; // Show Fibo Zone
|
bool showFiboZone; // Show Fibo Zone
|
||||||
int startCalculationForLastBars; // Calculate Last n Bars
|
int startCalculationForLastBars; // Calculate Last n Bars
|
||||||
@@ -180,7 +183,7 @@ struct XFIMAInputs
|
|||||||
maAppliedTo = PRICE_CLOSE; // MA Applied To
|
maAppliedTo = PRICE_CLOSE; // MA Applied To
|
||||||
maFastLength = 7; // Fast MA Length
|
maFastLength = 7; // Fast MA Length
|
||||||
maSlowLength = 20; // Slow MA Length
|
maSlowLength = 20; // Slow MA Length
|
||||||
maBandLength = 7; // MA Band Length
|
maBondLength = 7; // MA Bond Length
|
||||||
zigzagDepth = 12; // ZigZag Depth
|
zigzagDepth = 12; // ZigZag Depth
|
||||||
zigzagDeviation = 5; // ZigZag Deviation
|
zigzagDeviation = 5; // ZigZag Deviation
|
||||||
zigzagBackStep = 3; // ZigZag Back Step
|
zigzagBackStep = 3; // ZigZag Back Step
|
||||||
@@ -197,7 +200,8 @@ struct XFIMAInputs
|
|||||||
showSAR = true; // Show Sar
|
showSAR = true; // Show Sar
|
||||||
showMAFast = true; // Show MA Fast
|
showMAFast = true; // Show MA Fast
|
||||||
showMASlow = true; // Show MA Slow
|
showMASlow = true; // Show MA Slow
|
||||||
showMABand = true; // Show MA Band
|
showMABond = true; // Show MA Bond
|
||||||
|
showHKBond = true; // Show HK Bond
|
||||||
showZigZag = true; // Show ZigZag
|
showZigZag = true; // Show ZigZag
|
||||||
showFiboZone = true; // Show Fibo Zone
|
showFiboZone = true; // Show Fibo Zone
|
||||||
startCalculationForLastBars = 1500; // Calculate Last n Bars
|
startCalculationForLastBars = 1500; // Calculate Last n Bars
|
||||||
@@ -216,7 +220,8 @@ struct XFIMAInputs
|
|||||||
showSAR = false;
|
showSAR = false;
|
||||||
showMAFast = false;
|
showMAFast = false;
|
||||||
showMASlow = false;
|
showMASlow = false;
|
||||||
showMABand = false;
|
showMABond = false;
|
||||||
|
showHKBond = false;
|
||||||
showZigZag = false;
|
showZigZag = false;
|
||||||
showFiboZone = false;
|
showFiboZone = false;
|
||||||
}
|
}
|
||||||
@@ -234,7 +239,7 @@ struct XFIMAInputs
|
|||||||
// MA ...
|
// MA ...
|
||||||
maFastLength >= 2 &&
|
maFastLength >= 2 &&
|
||||||
maSlowLength >= 2 &&
|
maSlowLength >= 2 &&
|
||||||
maBandLength >= 2 &&
|
maBondLength >= 2 &&
|
||||||
maSlowLength > maFastLength &&
|
maSlowLength > maFastLength &&
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
@@ -289,8 +294,8 @@ struct XFIMAConditions
|
|||||||
double maSlowBuffer[];
|
double maSlowBuffer[];
|
||||||
double maSlowColorBuffer[];
|
double maSlowColorBuffer[];
|
||||||
double maSlowStateBuffer[];
|
double maSlowStateBuffer[];
|
||||||
double maBandUpperBuffer[];
|
double maBondUpperBuffer[];
|
||||||
double maBandLowerBuffer[];
|
double maBondLowerBuffer[];
|
||||||
double sarBuffer[];
|
double sarBuffer[];
|
||||||
double sarColorBuffer[];
|
double sarColorBuffer[];
|
||||||
double sarStateBuffer[];
|
double sarStateBuffer[];
|
||||||
@@ -357,8 +362,8 @@ struct XFIMAConditions
|
|||||||
SpecifiedClean(maSlowBuffer);
|
SpecifiedClean(maSlowBuffer);
|
||||||
SpecifiedClean(maSlowColorBuffer);
|
SpecifiedClean(maSlowColorBuffer);
|
||||||
SpecifiedClean(maSlowStateBuffer);
|
SpecifiedClean(maSlowStateBuffer);
|
||||||
SpecifiedClean(maBandUpperBuffer);
|
SpecifiedClean(maBondUpperBuffer);
|
||||||
SpecifiedClean(maBandLowerBuffer);
|
SpecifiedClean(maBondLowerBuffer);
|
||||||
SpecifiedClean(sarBuffer);
|
SpecifiedClean(sarBuffer);
|
||||||
SpecifiedClean(sarColorBuffer);
|
SpecifiedClean(sarColorBuffer);
|
||||||
SpecifiedClean(sarStateBuffer);
|
SpecifiedClean(sarStateBuffer);
|
||||||
@@ -399,8 +404,8 @@ struct XFIMAConditions
|
|||||||
ArraySetAsSeries(maSlowBuffer, true);
|
ArraySetAsSeries(maSlowBuffer, true);
|
||||||
ArraySetAsSeries(maSlowColorBuffer, true);
|
ArraySetAsSeries(maSlowColorBuffer, true);
|
||||||
ArraySetAsSeries(maSlowStateBuffer, true);
|
ArraySetAsSeries(maSlowStateBuffer, true);
|
||||||
ArraySetAsSeries(maBandUpperBuffer, true);
|
ArraySetAsSeries(maBondUpperBuffer, true);
|
||||||
ArraySetAsSeries(maBandLowerBuffer, true);
|
ArraySetAsSeries(maBondLowerBuffer, true);
|
||||||
ArraySetAsSeries(sarBuffer, true);
|
ArraySetAsSeries(sarBuffer, true);
|
||||||
ArraySetAsSeries(sarColorBuffer, true);
|
ArraySetAsSeries(sarColorBuffer, true);
|
||||||
ArraySetAsSeries(sarStateBuffer, true);
|
ArraySetAsSeries(sarStateBuffer, true);
|
||||||
@@ -554,7 +559,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
mInputs.maAppliedTo,
|
mInputs.maAppliedTo,
|
||||||
mInputs.maFastLength,
|
mInputs.maFastLength,
|
||||||
mInputs.maSlowLength,
|
mInputs.maSlowLength,
|
||||||
mInputs.maBandLength,
|
mInputs.maBondLength,
|
||||||
mInputs.zigzagDepth,
|
mInputs.zigzagDepth,
|
||||||
mInputs.zigzagDeviation,
|
mInputs.zigzagDeviation,
|
||||||
mInputs.zigzagBackStep,
|
mInputs.zigzagBackStep,
|
||||||
@@ -569,7 +574,8 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
mInputs.showSAR,
|
mInputs.showSAR,
|
||||||
mInputs.showMAFast,
|
mInputs.showMAFast,
|
||||||
mInputs.showMASlow,
|
mInputs.showMASlow,
|
||||||
mInputs.showMABand,
|
mInputs.showMABond,
|
||||||
|
mInputs.showHKBond,
|
||||||
mInputs.showZigZag,
|
mInputs.showZigZag,
|
||||||
mInputs.showFiboZone,
|
mInputs.showFiboZone,
|
||||||
mInputs.startCalculationForLastBars,
|
mInputs.startCalculationForLastBars,
|
||||||
@@ -703,17 +709,17 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
CopyMABandUpper(
|
CopyMABondUpper(
|
||||||
zIndex,
|
zIndex,
|
||||||
loopback,
|
loopback,
|
||||||
conditions.maBandUpperBuffer //
|
conditions.maBondUpperBuffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
CopyMABandLower(
|
CopyMABondLower(
|
||||||
zIndex,
|
zIndex,
|
||||||
loopback,
|
loopback,
|
||||||
conditions.maBandLowerBuffer //
|
conditions.maBondLowerBuffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1158,6 +1164,444 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Peak Happens over Last ...
|
||||||
|
*
|
||||||
|
* @param barIndex: int, Specified Bar Index ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsPeakOverLast(int barIndex = 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeBarIndex(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Values ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iPeak = GetPeak(barIndex);
|
||||||
|
double pPeak = GetPeak(barIndex + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = NotEmptyZero(iPeak) &&
|
||||||
|
iPeak > pPeak;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Vale Happens over Last ...
|
||||||
|
*
|
||||||
|
* @param barIndex: int, Specified Bar Index ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsValeOverLast(int barIndex = 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeBarIndex(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Values ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iVale = GetVale(barIndex);
|
||||||
|
double pVale = GetVale(barIndex + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = NotEmptyZero(iVale) &&
|
||||||
|
iVale > pVale;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Peak Happens under Last ...
|
||||||
|
*
|
||||||
|
* @param barIndex: int, Specified Bar Index ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsPeakUnderLast(int barIndex = 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeBarIndex(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Values ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iPeak = GetPeak(barIndex);
|
||||||
|
double pPeak = GetPeak(barIndex + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = NotEmptyZero(iPeak) &&
|
||||||
|
iPeak < pPeak;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Vale Happens under Last ...
|
||||||
|
*
|
||||||
|
* @param barIndex: int, Specified Bar Index ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsValeUnderLast(int barIndex = 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeBarIndex(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Values ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iVale = GetVale(barIndex);
|
||||||
|
double pVale = GetVale(barIndex + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = NotEmptyZero(iVale) &&
|
||||||
|
iVale < pVale;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Fibo Section is Changed or not ...
|
||||||
|
*
|
||||||
|
* @param dir: reference to hold section change direction ...
|
||||||
|
* @param barIndex: int, Specified Bar Index ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsFiboSectionChanged(
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeBarIndex(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Values ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iFiboUpper = GetFiboUpper(barIndex);
|
||||||
|
double pFiboUpper = GetFiboUpper(barIndex + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
double iFiboMiddle = GetFiboMiddle(barIndex);
|
||||||
|
double pFiboMiddle = GetFiboMiddle(barIndex + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
double iFiboLower = GetFiboLower(barIndex);
|
||||||
|
double pFiboLower = GetFiboLower(barIndex + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish = iFiboLower >= pFiboMiddle &&
|
||||||
|
iFiboMiddle >= pFiboUpper;
|
||||||
|
isBearish = iFiboUpper <= pFiboMiddle &&
|
||||||
|
iFiboMiddle <= pFiboLower;
|
||||||
|
result = (isBullish && !isBearish) ||
|
||||||
|
(isBearish && !isBullish);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasFiboPush(
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
int barIndex = 0,
|
||||||
|
int validationLength = 5 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeBarIndex(barIndex);
|
||||||
|
validationLength = NormalizeInt(validationLength, 3);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define Requirements ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
double iFiboUpper = EMPTY_VALUE;
|
||||||
|
double pFiboUpper = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
double iFiboMiddle = EMPTY_VALUE;
|
||||||
|
double pFiboMiddle = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
double iFiboLower = EMPTY_VALUE;
|
||||||
|
double pFiboLower = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Zone Validation ...
|
||||||
|
int start = barIndex;
|
||||||
|
int end = start + validationLength;
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Reading Values ...
|
||||||
|
|
||||||
|
//
|
||||||
|
iFiboUpper = GetFiboUpper(i);
|
||||||
|
pFiboUpper = GetFiboUpper(i + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
iFiboMiddle = GetFiboMiddle(i);
|
||||||
|
pFiboMiddle = GetFiboMiddle(i + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
iFiboLower = GetFiboLower(i);
|
||||||
|
pFiboLower = GetFiboLower(i + 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = iFiboUpper == pFiboUpper;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = iBar.Init(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iFiboUpper = GetFiboUpper(barIndex);
|
||||||
|
iFiboMiddle = GetFiboMiddle(barIndex);
|
||||||
|
iFiboLower = GetFiboLower(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish = iBar.IsBullish() &&
|
||||||
|
iBar.close > iFiboLower &&
|
||||||
|
iBar.low < iFiboLower;
|
||||||
|
isBearish = iBar.IsBearish() &&
|
||||||
|
iBar.close < iFiboUpper &&
|
||||||
|
iBar.high > iFiboUpper;
|
||||||
|
result = (isBullish && !isBearish) ||
|
||||||
|
(isBearish && !isBullish);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
iBar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Last Fibo Section Changed till Loopback Length ...
|
||||||
|
*
|
||||||
|
* @param lastBarIndex: int, reference to hold Detected Bar Index ...
|
||||||
|
* @param dir: ENUM_X_DIRECTION, reference to detected Direction ...
|
||||||
|
* @param barIndex: int, Specified Bar Index ...
|
||||||
|
* @param maxAllowedLoopbackLength: int, Max Allowed Loopback Bars ...
|
||||||
|
* @param forDir: ENUM_X_DIRECTION, Specified Section Change Direction Looking for ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool GetLastFiboSectionChanged(
|
||||||
|
int &lastBarIndex,
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
int barIndex = 0,
|
||||||
|
int maxAllowedLoopbackLength = 100,
|
||||||
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
lastBarIndex = -1;
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeBarIndex(barIndex);
|
||||||
|
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int start = barIndex + 1;
|
||||||
|
int end = start + maxAllowedLoopbackLength;
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = IsFiboSectionChanged(dir, i);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate By forDir ...
|
||||||
|
if (HasDirection(forDir))
|
||||||
|
{
|
||||||
|
result = dir == forDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
lastBarIndex = -1;
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
lastBarIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = HasDirection(dir) &&
|
||||||
|
IsValidIndex(lastBarIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extractions ...
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract Specified Kind of Pivots ...
|
* Extract Specified Kind of Pivots ...
|
||||||
*
|
*
|
||||||
@@ -2641,19 +3085,19 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
// Upper MA ...
|
// Upper MA ...
|
||||||
|
|
||||||
//
|
//
|
||||||
double GetMABandUpper(
|
double GetMABondUpper(
|
||||||
int barIndex // Bar Index
|
int barIndex // Bar Index
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
return ReadValue(
|
return ReadValue(
|
||||||
(int)XFIMA_MA_BAND_UPPER_LINE,
|
(int)XFIMA_MA_BOND_UPPER_LINE,
|
||||||
barIndex //
|
barIndex //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
int CopyMABandUpper(
|
int CopyMABondUpper(
|
||||||
int start, // Start
|
int start, // Start
|
||||||
int count, // Number of Items for read
|
int count, // Number of Items for read
|
||||||
double &buffer[], // Dest Buffer
|
double &buffer[], // Dest Buffer
|
||||||
@@ -2663,7 +3107,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
//
|
//
|
||||||
return ReadValues(
|
return ReadValues(
|
||||||
buffer,
|
buffer,
|
||||||
(int)XFIMA_MA_BAND_UPPER_LINE,
|
(int)XFIMA_MA_BOND_UPPER_LINE,
|
||||||
start,
|
start,
|
||||||
count,
|
count,
|
||||||
asSeries //
|
asSeries //
|
||||||
@@ -2674,19 +3118,19 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
// Lower MA ...
|
// Lower MA ...
|
||||||
|
|
||||||
//
|
//
|
||||||
double GetMABandLower(
|
double GetMABondLower(
|
||||||
int barIndex // Bar Index
|
int barIndex // Bar Index
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
return ReadValue(
|
return ReadValue(
|
||||||
(int)XFIMA_MA_BAND_LOWER_LINE,
|
(int)XFIMA_MA_BOND_LOWER_LINE,
|
||||||
barIndex //
|
barIndex //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
int CopyMABandLower(
|
int CopyMABondLower(
|
||||||
int start, // Start
|
int start, // Start
|
||||||
int count, // Number of Items for read
|
int count, // Number of Items for read
|
||||||
double &buffer[], // Dest Buffer
|
double &buffer[], // Dest Buffer
|
||||||
@@ -2696,7 +3140,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
//
|
//
|
||||||
return ReadValues(
|
return ReadValues(
|
||||||
buffer,
|
buffer,
|
||||||
(int)XFIMA_MA_BAND_LOWER_LINE,
|
(int)XFIMA_MA_BOND_LOWER_LINE,
|
||||||
start,
|
start,
|
||||||
count,
|
count,
|
||||||
asSeries //
|
asSeries //
|
||||||
@@ -3417,6 +3861,210 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Raw ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Raw Open ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetHKRawOpen(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValue(
|
||||||
|
(int)XFIMA_HK_RAW_OPEN_LINE,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyHKRawOpen(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool asSeries = true // As Series Flag
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValues(
|
||||||
|
buffer,
|
||||||
|
(int)XFIMA_HK_RAW_OPEN_LINE,
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
asSeries //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Raw High ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetHKRawHigh(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValue(
|
||||||
|
(int)XFIMA_HK_RAW_HIGH_LINE,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyHKRawHigh(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool asSeries = true // As Series Flag
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValues(
|
||||||
|
buffer,
|
||||||
|
(int)XFIMA_HK_RAW_HIGH_LINE,
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
asSeries //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Raw Low ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetHKRawLow(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValue(
|
||||||
|
(int)XFIMA_HK_RAW_LOW_LINE,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyHKRawLow(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool asSeries = true // As Series Flag
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValues(
|
||||||
|
buffer,
|
||||||
|
(int)XFIMA_HK_RAW_LOW_LINE,
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
asSeries //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Raw Close ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetHKRawClose(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValue(
|
||||||
|
(int)XFIMA_HK_RAW_CLOSE_LINE,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyHKRawClose(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool asSeries = true // As Series Flag
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValues(
|
||||||
|
buffer,
|
||||||
|
(int)XFIMA_HK_RAW_CLOSE_LINE,
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
asSeries //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Bond ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Bond Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetHKBondUpper(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValue(
|
||||||
|
(int)XFIMA_HK_BOND_UPPER_LINE,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyHKBondUpper(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool asSeries = true // As Series Flag
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValues(
|
||||||
|
buffer,
|
||||||
|
(int)XFIMA_HK_BOND_UPPER_LINE,
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
asSeries //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Bond Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetHKBondLower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValue(
|
||||||
|
(int)XFIMA_HK_BOND_LOWER_LINE,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyHKBondLower(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool asSeries = true // As Series Flag
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ReadValues(
|
||||||
|
buffer,
|
||||||
|
(int)XFIMA_HK_BOND_LOWER_LINE,
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
asSeries //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Protected ...
|
// Protected ...
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ input double sarMax = 0.2; // SAR Maximum
|
|||||||
input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
|
input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
|
||||||
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
||||||
input int maFastLength = 7; // Fast MA Length
|
input int maFastLength = 7; // Fast MA Length
|
||||||
input int maSlowLength = 20; // Slow MA Length
|
input int maSlowLength = 21; // Slow MA Length
|
||||||
input int maBandLength = 7; // MA Band Length
|
input int maBandLength = 21; // MA Bond Length
|
||||||
input int zigzagDepth = 12; // ZigZag Depth
|
input int zigzagDepth = 12; // ZigZag Depth
|
||||||
input int zigzagDeviation = 5; // ZigZag Deviation
|
input int zigzagDeviation = 5; // ZigZag Deviation
|
||||||
input int zigzagBackStep = 3; // ZigZag Back Step
|
input int zigzagBackStep = 3; // ZigZag Back Step
|
||||||
@@ -101,7 +101,8 @@ input bool showHK = true; // Show HK
|
|||||||
input bool showSAR = true; // Show Sar
|
input bool showSAR = true; // Show Sar
|
||||||
input bool showMAFast = true; // Show MA Fast
|
input bool showMAFast = true; // Show MA Fast
|
||||||
input bool showMASlow = true; // Show MA Slow
|
input bool showMASlow = true; // Show MA Slow
|
||||||
input bool showMABand = true; // Show MA Band
|
input bool showMABand = true; // Show MA Bond
|
||||||
|
input bool showHKBond = true; // Show HK Bond
|
||||||
input bool showZigZag = true; // Show ZigZag
|
input bool showZigZag = true; // Show ZigZag
|
||||||
input bool showFiboZone = true; // Show Fibo Zone
|
input bool showFiboZone = true; // Show Fibo Zone
|
||||||
|
|
||||||
@@ -137,8 +138,8 @@ input int valeArrowCode = 159; // Vales Arrow Code
|
|||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 38
|
#property indicator_buffers 40
|
||||||
#property indicator_plots 12
|
#property indicator_plots 14
|
||||||
|
|
||||||
//
|
//
|
||||||
// Plot Buffers ...
|
// Plot Buffers ...
|
||||||
@@ -282,7 +283,7 @@ double zigzagBuffer[];
|
|||||||
#property indicator_width9 2
|
#property indicator_width9 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Upper Boundary ...
|
// MA Upper ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define maUpperBufferIndex 12
|
#define maUpperBufferIndex 12
|
||||||
@@ -292,11 +293,11 @@ double maUpperBuffer[];
|
|||||||
//
|
//
|
||||||
#property indicator_label10 "UpperMA"
|
#property indicator_label10 "UpperMA"
|
||||||
#property indicator_type10 DRAW_LINE
|
#property indicator_type10 DRAW_LINE
|
||||||
#property indicator_color10 clrAqua
|
#property indicator_color10 clrLime
|
||||||
#property indicator_width10 3
|
#property indicator_width10 3
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Lower Boundary ...
|
// MA Lower ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define maLowerBufferIndex 13
|
#define maLowerBufferIndex 13
|
||||||
@@ -306,7 +307,7 @@ double maLowerBuffer[];
|
|||||||
//
|
//
|
||||||
#property indicator_label11 "LowerMA"
|
#property indicator_label11 "LowerMA"
|
||||||
#property indicator_type11 DRAW_LINE
|
#property indicator_type11 DRAW_LINE
|
||||||
#property indicator_color11 clrMagenta
|
#property indicator_color11 clrRed
|
||||||
#property indicator_width11 3
|
#property indicator_width11 3
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -338,11 +339,33 @@ double hkColorBuffer[];
|
|||||||
#property indicator_type12 DRAW_COLOR_CANDLES
|
#property indicator_type12 DRAW_COLOR_CANDLES
|
||||||
#property indicator_color12 CLR_NONE, clrAqua, clrMagenta, clrGray
|
#property indicator_color12 CLR_NONE, clrAqua, clrMagenta, clrGray
|
||||||
|
|
||||||
|
//
|
||||||
|
#define hkBondUpperBufferIndex 19
|
||||||
|
double hkBondUpperBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define hkBondUpperBufferPlotIndex 12
|
||||||
|
#property indicator_label13 "UpperHK"
|
||||||
|
#property indicator_type13 DRAW_LINE
|
||||||
|
#property indicator_color13 clrAqua
|
||||||
|
#property indicator_width13 3
|
||||||
|
|
||||||
|
//
|
||||||
|
#define hkBondLowerBufferIndex 20
|
||||||
|
double hkBondLowerBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define hkBondLowerBufferPlotIndex 13
|
||||||
|
#property indicator_label14 "LowerHK"
|
||||||
|
#property indicator_type14 DRAW_LINE
|
||||||
|
#property indicator_color14 clrMagenta
|
||||||
|
#property indicator_width14 3
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define mLastBufferIndex 18
|
#define mLastBufferIndex 20
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA ...
|
// MA ...
|
||||||
@@ -982,13 +1005,13 @@ void DefineBuffers()
|
|||||||
PlotIndexSetDouble(zigzagBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(zigzagBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Band ...
|
// MA Bond ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_DRAW_TYPE maBandDrawType = showMABand ? DRAW_LINE : DRAW_NONE;
|
ENUM_DRAW_TYPE maBandDrawType = showMABand ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Upper Band ...
|
// MA Upper Bond ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(maUpperBuffer, true);
|
ArraySetAsSeries(maUpperBuffer, true);
|
||||||
@@ -1002,7 +1025,7 @@ void DefineBuffers()
|
|||||||
PlotIndexSetDouble(maUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(maUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Lower Band ...
|
// MA Lower Bond ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(maLowerBuffer, true);
|
ArraySetAsSeries(maLowerBuffer, true);
|
||||||
@@ -1048,6 +1071,19 @@ void DefineBuffers()
|
|||||||
ArraySetAsSeries(hkCloseBuffer, true);
|
ArraySetAsSeries(hkCloseBuffer, true);
|
||||||
SetIndexBuffer(hkCloseBufferIndex, hkCloseBuffer, INDICATOR_DATA);
|
SetIndexBuffer(hkCloseBufferIndex, hkCloseBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XHK Bond ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
ArraySetAsSeries(hkBondUpperBuffer, true);
|
||||||
|
SetIndexBuffer(hkBondUpperBufferIndex, hkBondUpperBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
ArraySetAsSeries(hkBondLowerBuffer, true);
|
||||||
|
SetIndexBuffer(hkBondLowerBufferIndex, hkBondLowerBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
|
|
||||||
@@ -1288,7 +1324,7 @@ bool InitRequirements()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Band Upper ...
|
// MA Bond Upper ...
|
||||||
maUpperHandler = iMA(
|
maUpperHandler = iMA(
|
||||||
_Symbol,
|
_Symbol,
|
||||||
_Period,
|
_Period,
|
||||||
@@ -1304,7 +1340,7 @@ bool InitRequirements()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Band Lower ...
|
// MA Bond Lower ...
|
||||||
maLowerHandler = iMA(
|
maLowerHandler = iMA(
|
||||||
_Symbol,
|
_Symbol,
|
||||||
_Period,
|
_Period,
|
||||||
@@ -2160,6 +2196,10 @@ void CalculateHKBar(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
hkBondUpperBuffer[barIndex] = hkHighBuffer[barIndex];
|
||||||
|
hkBondLowerBuffer[barIndex] = hkLowBuffer[barIndex];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate HK Color ...
|
// Calculate HK Color ...
|
||||||
double iHKColorValue =
|
double iHKColorValue =
|
||||||
|
|||||||
@@ -3850,6 +3850,28 @@ void ValidateBoxes(
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateToTime(
|
||||||
|
XBoxZone &zones[],
|
||||||
|
datetime toTime = NULL//
|
||||||
|
) {
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
toTime = NormalizeTime(toTime);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = HasChild(zones);
|
||||||
|
if (!has) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(zones);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
zones[i].to = toTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Bar to Pivot ...
|
* Converts a Bar to Pivot ...
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -415,8 +415,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve MA Band for Validation ...
|
// Retrieve MA Band for Validation ...
|
||||||
double iMABandUpper = fimaConditions.maBandUpperBuffer[0];
|
double iMABandUpper = fimaConditions.maBondUpperBuffer[0];
|
||||||
double iMABandLower = fimaConditions.maBandLowerBuffer[0];
|
double iMABandLower = fimaConditions.maBondLowerBuffer[0];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate by Edge Price ...
|
// Validate by Edge Price ...
|
||||||
@@ -578,6 +578,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// XBoxZone iBox;
|
// XBoxZone iBox;
|
||||||
// XCBoxObject *iBoxObj;
|
// XCBoxObject *iBoxObj;
|
||||||
|
|
||||||
|
//
|
||||||
|
// poiDrawer.RemoveDraws();
|
||||||
|
|
||||||
// //
|
// //
|
||||||
// has = iStructure.pvAnalysis.HasSupportBox(iBox);
|
// has = iStructure.pvAnalysis.HasSupportBox(iBox);
|
||||||
// if (has)
|
// if (has)
|
||||||
@@ -608,21 +611,71 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Draw Zones ...
|
||||||
|
// has = HasChild(iStructure.supports);
|
||||||
|
// if (has) {
|
||||||
|
// //
|
||||||
|
// CArrayObj *iSupportObjs;
|
||||||
|
// poiDrawer.DrawBoxes(
|
||||||
|
// iStructure.supports,
|
||||||
|
// iSupportObjs,
|
||||||
|
// true //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// has = HasChild(iStructure.resistances);
|
||||||
|
// if (has) {
|
||||||
|
// //
|
||||||
|
// CArrayObj *iResistanceObjs;
|
||||||
|
// poiDrawer.DrawBoxes(
|
||||||
|
// iStructure.resistances,
|
||||||
|
// iResistanceObjs,
|
||||||
|
// true //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detecte Fibo Section Changes ...
|
||||||
|
|
||||||
|
//
|
||||||
|
has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
|
||||||
|
has = has &&
|
||||||
|
IsXBullish(iDir) &&
|
||||||
|
fimaHelper.IsValeOverLast(iBar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
|
||||||
|
has = has &&
|
||||||
|
IsXBearish(iDir) &&
|
||||||
|
fimaHelper.IsPeakUnderLast(iBar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
has = fimaHelper.HasFiboPush(iDir, iBar.Index(), 5);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
Print("Draw Zones ...");
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Disable Signallers ...
|
// Disable Signallers ...
|
||||||
has = false;
|
has = false;
|
||||||
|
iDir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Strategy 1 ...
|
// Strategy 1 ...
|
||||||
// Works on Support or Resistances Areas ...
|
// Works on Support or Resistances Areas ...
|
||||||
has = Strategy1HasSignal(
|
// has = Strategy1HasSignal(
|
||||||
iBar,
|
// iBar,
|
||||||
iZone,
|
// iZone,
|
||||||
iTargets,
|
// iTargets,
|
||||||
iDir,
|
// iDir,
|
||||||
iFIMAConditions,
|
// iFIMAConditions,
|
||||||
iStructure //
|
// iStructure //
|
||||||
);
|
// );
|
||||||
|
|
||||||
//
|
//
|
||||||
// Strategy 2 ...
|
// Strategy 2 ...
|
||||||
|
|||||||
@@ -476,6 +476,138 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ExtractXFIMAZones(
|
||||||
|
XBoxZone &zones[],
|
||||||
|
int barIndex = 0,
|
||||||
|
int requiredNumberOfZones = 50,
|
||||||
|
double shadowMultiplier = 4,
|
||||||
|
int maxAllowedLoopbackLength = 1500 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
XClean(zones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeInt(barIndex, 0);
|
||||||
|
shadowMultiplier = NormalizeDouble(shadowMultiplier, 2);
|
||||||
|
requiredNumberOfZones = NormalizeInt(requiredNumberOfZones, 5);
|
||||||
|
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has =
|
||||||
|
fimaHelper != NULL &&
|
||||||
|
fimaHelper.IsValid();
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create a Loop ...
|
||||||
|
XOHCL iBar;
|
||||||
|
XBoxZone iBox;
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
double iUpper = EMPTY_VALUE;
|
||||||
|
double iLower = EMPTY_VALUE;
|
||||||
|
double iHKUpper = EMPTY_VALUE;
|
||||||
|
double iHKLower = EMPTY_VALUE;
|
||||||
|
double iMAUpper = EMPTY_VALUE;
|
||||||
|
double iMALower = EMPTY_VALUE;
|
||||||
|
string symbol = fimaHelper.GetSymbol();
|
||||||
|
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
||||||
|
ENUM_TIMEFRAMES period = fimaHelper.GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
int start = barIndex;
|
||||||
|
int idx = start - 1;
|
||||||
|
int end = start + maxAllowedLoopbackLength;
|
||||||
|
while (ArraySize(zones) < requiredNumberOfZones && idx < end)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx++;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Indexed Bar ...
|
||||||
|
has = iBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
idx //
|
||||||
|
);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Bars ...
|
||||||
|
iMAUpper = fimaHelper.GetMABondUpper(idx);
|
||||||
|
iMALower = fimaHelper.GetMABondLower(idx);
|
||||||
|
iHKUpper = fimaHelper.GetHKBondUpper(idx);
|
||||||
|
iHKLower = fimaHelper.GetHKBondLower(idx);
|
||||||
|
|
||||||
|
//
|
||||||
|
iUpper = MathMax(iMAUpper, iHKUpper);
|
||||||
|
iLower = MathMin(iMALower, iHKLower);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar State ...
|
||||||
|
has =
|
||||||
|
NotEmptyZero(iUpper) &&
|
||||||
|
NotEmptyZero(iLower);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Direction of Zone ...
|
||||||
|
isBullish = iBar.low < iLower;
|
||||||
|
isBearish = iBar.high > iUpper;
|
||||||
|
has = (isBullish && !isBearish) ||
|
||||||
|
(isBearish && !isBullish);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Shadow Multiplier ...
|
||||||
|
has =
|
||||||
|
isBullish
|
||||||
|
? iBar.GetLowShadow() > iBar.GetHighShadow() * shadowMultiplier
|
||||||
|
: iBar.GetHighShadow() > iBar.GetLowShadow() * shadowMultiplier;
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iDir = isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
iBar.Clean();
|
||||||
|
iBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(zones);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy ...
|
* Destroy ...
|
||||||
*/
|
*/
|
||||||
@@ -1434,6 +1566,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
//
|
//
|
||||||
// OBS ...
|
// OBS ...
|
||||||
CheckZones(forBar, obs);
|
CheckZones(forBar, obs);
|
||||||
|
UpdateToTime(obs, forBar.time);
|
||||||
Copy(
|
Copy(
|
||||||
obs,
|
obs,
|
||||||
structure.obs //
|
structure.obs //
|
||||||
@@ -1442,6 +1575,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
//
|
//
|
||||||
// FVGS ...
|
// FVGS ...
|
||||||
CheckZones(forBar, fvgs);
|
CheckZones(forBar, fvgs);
|
||||||
|
UpdateToTime(fvgs, forBar.time);
|
||||||
Copy(
|
Copy(
|
||||||
fvgs,
|
fvgs,
|
||||||
structure.fvgs //
|
structure.fvgs //
|
||||||
@@ -1450,6 +1584,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
//
|
//
|
||||||
// SUPPORTS ...
|
// SUPPORTS ...
|
||||||
CheckZones(forBar, supports);
|
CheckZones(forBar, supports);
|
||||||
|
UpdateToTime(supports, forBar.time);
|
||||||
Copy(
|
Copy(
|
||||||
supports,
|
supports,
|
||||||
structure.supports //
|
structure.supports //
|
||||||
@@ -1458,6 +1593,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
//
|
//
|
||||||
// RESISTANCES ...
|
// RESISTANCES ...
|
||||||
CheckZones(forBar, resistances);
|
CheckZones(forBar, resistances);
|
||||||
|
UpdateToTime(resistances, forBar.time);
|
||||||
Copy(
|
Copy(
|
||||||
resistances,
|
resistances,
|
||||||
structure.resistances //
|
structure.resistances //
|
||||||
|
|||||||
Reference in New Issue
Block a user