fix xpv and add support for providing fractals based Supports and Resistances ...
This commit is contained in:
@@ -0,0 +1,121 @@
|
|||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| Support and Resistance.mq5 |
|
||||||
|
//| https://t.me/ForexEaPremium |
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
#property copyright "https://t.me/ForexEaPremium"
|
||||||
|
#property version "2.02"
|
||||||
|
|
||||||
|
#property description "Blue and red support and resistance levels displayed directly on the chart."
|
||||||
|
#property description "Alerts for close above resistance and close below support."
|
||||||
|
|
||||||
|
#property indicator_chart_window
|
||||||
|
#property indicator_buffers 2
|
||||||
|
#property indicator_plots 2
|
||||||
|
#property indicator_color1 clrRed
|
||||||
|
#property indicator_type1 DRAW_ARROW
|
||||||
|
#property indicator_width1 2
|
||||||
|
#property indicator_label1 "Resistance"
|
||||||
|
#property indicator_color2 clrBlue
|
||||||
|
#property indicator_type2 DRAW_ARROW
|
||||||
|
#property indicator_width2 2
|
||||||
|
#property indicator_label2 "Support"
|
||||||
|
|
||||||
|
enum enum_candle_to_check
|
||||||
|
{
|
||||||
|
Current,
|
||||||
|
Previous
|
||||||
|
};
|
||||||
|
|
||||||
|
input bool EnableNativeAlerts = false;
|
||||||
|
input bool EnableEmailAlerts = false;
|
||||||
|
input bool EnablePushAlerts = false;
|
||||||
|
input enum_candle_to_check TriggerCandle = Previous;
|
||||||
|
|
||||||
|
double Resistance[];
|
||||||
|
double Support[];
|
||||||
|
|
||||||
|
int myFractal;
|
||||||
|
|
||||||
|
datetime LastAlertTime = D'01.01.1970';
|
||||||
|
|
||||||
|
void OnInit()
|
||||||
|
{
|
||||||
|
PlotIndexSetInteger(0, PLOT_ARROW, 119);
|
||||||
|
PlotIndexSetInteger(1, PLOT_ARROW, 119);
|
||||||
|
|
||||||
|
SetIndexBuffer(0, Resistance);
|
||||||
|
SetIndexBuffer(1, Support);
|
||||||
|
|
||||||
|
ArraySetAsSeries(Resistance, true);
|
||||||
|
ArraySetAsSeries(Support, true);
|
||||||
|
|
||||||
|
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 5);
|
||||||
|
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, 5);
|
||||||
|
|
||||||
|
myFractal = iFractals(NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int OnCalculate(const int rates_total,
|
||||||
|
const int prev_calculated,
|
||||||
|
const datetime &Time[],
|
||||||
|
const double &open[],
|
||||||
|
const double &High[],
|
||||||
|
const double &Low[],
|
||||||
|
const double &Close[],
|
||||||
|
const long &tick_volume[],
|
||||||
|
const long &volume[],
|
||||||
|
const int &spread[])
|
||||||
|
{
|
||||||
|
ArraySetAsSeries(High, true);
|
||||||
|
ArraySetAsSeries(Low, true);
|
||||||
|
ArraySetAsSeries(Close, true);
|
||||||
|
ArraySetAsSeries(Time, true);
|
||||||
|
|
||||||
|
//Get the values of the Fractals indicator before entering the cycle.
|
||||||
|
double FractalUpperBuffer[];
|
||||||
|
double FractalLowerBuffer[];
|
||||||
|
|
||||||
|
CopyBuffer(myFractal, 0, 0, rates_total, FractalUpperBuffer);
|
||||||
|
CopyBuffer(myFractal, 1, 0, rates_total, FractalLowerBuffer);
|
||||||
|
|
||||||
|
ArraySetAsSeries(FractalUpperBuffer, true);
|
||||||
|
ArraySetAsSeries(FractalLowerBuffer, true);
|
||||||
|
|
||||||
|
for (int i = rates_total - 2; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (FractalUpperBuffer[i] != EMPTY_VALUE) Resistance[i] = High[i];
|
||||||
|
else Resistance[i] = Resistance[i + 1];
|
||||||
|
|
||||||
|
if (FractalLowerBuffer[i] != EMPTY_VALUE) Support[i] = Low[i];
|
||||||
|
else Support[i] = Support[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alerts
|
||||||
|
if (((TriggerCandle > 0) && (Time[0] > LastAlertTime)) || (TriggerCandle == 0))
|
||||||
|
{
|
||||||
|
string Text, TextNative;
|
||||||
|
// Resistance.
|
||||||
|
if ((Close[TriggerCandle] > Resistance[TriggerCandle]) && (Close[TriggerCandle + 1] <= Resistance[TriggerCandle]))
|
||||||
|
{
|
||||||
|
Text = "S&R: " + Symbol() + " - " + StringSubstr(EnumToString((ENUM_TIMEFRAMES)Period()), 7) + " - Closed above Resistance: " + DoubleToString(Resistance[TriggerCandle], _Digits) + ".";
|
||||||
|
TextNative = "S&R: Closed above Resistance: " + DoubleToString(Resistance[TriggerCandle], _Digits) + ".";
|
||||||
|
if (EnableNativeAlerts) Alert(TextNative);
|
||||||
|
if (EnableEmailAlerts) SendMail("S&R Alert", Text);
|
||||||
|
if (EnablePushAlerts) SendNotification(Text);
|
||||||
|
LastAlertTime = Time[0];
|
||||||
|
}
|
||||||
|
// Support.
|
||||||
|
if ((Close[TriggerCandle] < Support[TriggerCandle]) && (Close[TriggerCandle + 1] >= Support[TriggerCandle]))
|
||||||
|
{
|
||||||
|
Text = "S&R: " + Symbol() + " - " + StringSubstr(EnumToString((ENUM_TIMEFRAMES)Period()), 7) + " - Closed below Support: " + DoubleToString(Support[TriggerCandle], _Digits) + ".";
|
||||||
|
TextNative = "S&R: Closed below Support: " + DoubleToString(Support[TriggerCandle], _Digits) + ".";
|
||||||
|
if (EnableNativeAlerts) Alert(TextNative);
|
||||||
|
if (EnableEmailAlerts) SendMail("S&R Alert", Text);
|
||||||
|
if (EnablePushAlerts) SendNotification(Text);
|
||||||
|
LastAlertTime = Time[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rates_total;
|
||||||
|
}
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
@@ -229,6 +229,7 @@ struct X121Conditions
|
|||||||
double xhkSMLowBuffer[];
|
double xhkSMLowBuffer[];
|
||||||
double x3maFastBuffer[];
|
double x3maFastBuffer[];
|
||||||
double x3maSlowBuffer[];
|
double x3maSlowBuffer[];
|
||||||
|
double supportsBuffer[];
|
||||||
double downTrendBuffer[];
|
double downTrendBuffer[];
|
||||||
double vwapPriceBuffer[];
|
double vwapPriceBuffer[];
|
||||||
double xhkRawLowBuffer[];
|
double xhkRawLowBuffer[];
|
||||||
@@ -245,12 +246,15 @@ struct X121Conditions
|
|||||||
double atrLowerRawBuffer[];
|
double atrLowerRawBuffer[];
|
||||||
double donLowUpperBuffer[];
|
double donLowUpperBuffer[];
|
||||||
double donLowLowerBuffer[];
|
double donLowLowerBuffer[];
|
||||||
|
double resistancesBuffer[];
|
||||||
double vwapMidStateBuffer[];
|
double vwapMidStateBuffer[];
|
||||||
double donOpenUpperBuffer[];
|
double donOpenUpperBuffer[];
|
||||||
double donOpenLowerBuffer[];
|
double donOpenLowerBuffer[];
|
||||||
double donHighUpperBuffer[];
|
double donHighUpperBuffer[];
|
||||||
double donHighLowerBuffer[];
|
double donHighLowerBuffer[];
|
||||||
double x3maMidStateBuffer[];
|
double x3maMidStateBuffer[];
|
||||||
|
double fractalsUpperBuffer[];
|
||||||
|
double fractalsLowerBuffer[];
|
||||||
double vwapFastStateBuffer[];
|
double vwapFastStateBuffer[];
|
||||||
double vwapSlowStateBuffer[];
|
double vwapSlowStateBuffer[];
|
||||||
double donCloseUpperBuffer[];
|
double donCloseUpperBuffer[];
|
||||||
@@ -665,6 +669,7 @@ struct X121Conditions
|
|||||||
Clean(xhkSMLowBuffer);
|
Clean(xhkSMLowBuffer);
|
||||||
Clean(x3maFastBuffer);
|
Clean(x3maFastBuffer);
|
||||||
Clean(x3maSlowBuffer);
|
Clean(x3maSlowBuffer);
|
||||||
|
Clean(supportsBuffer);
|
||||||
Clean(downTrendBuffer);
|
Clean(downTrendBuffer);
|
||||||
Clean(vwapPriceBuffer);
|
Clean(vwapPriceBuffer);
|
||||||
Clean(xhkRawLowBuffer);
|
Clean(xhkRawLowBuffer);
|
||||||
@@ -681,19 +686,21 @@ struct X121Conditions
|
|||||||
Clean(atrLowerRawBuffer);
|
Clean(atrLowerRawBuffer);
|
||||||
Clean(donLowUpperBuffer);
|
Clean(donLowUpperBuffer);
|
||||||
Clean(donLowLowerBuffer);
|
Clean(donLowLowerBuffer);
|
||||||
|
Clean(resistancesBuffer);
|
||||||
Clean(vwapMidStateBuffer);
|
Clean(vwapMidStateBuffer);
|
||||||
Clean(donOpenUpperBuffer);
|
Clean(donOpenUpperBuffer);
|
||||||
Clean(donOpenLowerBuffer);
|
Clean(donOpenLowerBuffer);
|
||||||
Clean(donHighUpperBuffer);
|
Clean(donHighUpperBuffer);
|
||||||
Clean(donHighLowerBuffer);
|
Clean(donHighLowerBuffer);
|
||||||
Clean(x3maMidStateBuffer);
|
Clean(x3maMidStateBuffer);
|
||||||
|
Clean(fractalsUpperBuffer);
|
||||||
|
Clean(fractalsLowerBuffer);
|
||||||
Clean(vwapFastStateBuffer);
|
Clean(vwapFastStateBuffer);
|
||||||
Clean(vwapSlowStateBuffer);
|
Clean(vwapSlowStateBuffer);
|
||||||
Clean(donCloseUpperBuffer);
|
Clean(donCloseUpperBuffer);
|
||||||
Clean(donCloseLowerBuffer);
|
Clean(donCloseLowerBuffer);
|
||||||
Clean(x3maFastStateBuffer);
|
Clean(x3maFastStateBuffer);
|
||||||
Clean(x3maSlowStateBuffer);
|
Clean(x3maSlowStateBuffer);
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(maBuffer, true);
|
ArraySetAsSeries(maBuffer, true);
|
||||||
ArraySetAsSeries(rsiBuffer, true);
|
ArraySetAsSeries(rsiBuffer, true);
|
||||||
@@ -743,6 +750,7 @@ struct X121Conditions
|
|||||||
ArraySetAsSeries(xhkSMLowBuffer, true);
|
ArraySetAsSeries(xhkSMLowBuffer, true);
|
||||||
ArraySetAsSeries(x3maFastBuffer, true);
|
ArraySetAsSeries(x3maFastBuffer, true);
|
||||||
ArraySetAsSeries(x3maSlowBuffer, true);
|
ArraySetAsSeries(x3maSlowBuffer, true);
|
||||||
|
ArraySetAsSeries(supportsBuffer, true);
|
||||||
ArraySetAsSeries(downTrendBuffer, true);
|
ArraySetAsSeries(downTrendBuffer, true);
|
||||||
ArraySetAsSeries(vwapPriceBuffer, true);
|
ArraySetAsSeries(vwapPriceBuffer, true);
|
||||||
ArraySetAsSeries(xhkRawLowBuffer, true);
|
ArraySetAsSeries(xhkRawLowBuffer, true);
|
||||||
@@ -759,12 +767,15 @@ struct X121Conditions
|
|||||||
ArraySetAsSeries(atrLowerRawBuffer, true);
|
ArraySetAsSeries(atrLowerRawBuffer, true);
|
||||||
ArraySetAsSeries(donLowUpperBuffer, true);
|
ArraySetAsSeries(donLowUpperBuffer, true);
|
||||||
ArraySetAsSeries(donLowLowerBuffer, true);
|
ArraySetAsSeries(donLowLowerBuffer, true);
|
||||||
|
ArraySetAsSeries(resistancesBuffer, true);
|
||||||
ArraySetAsSeries(vwapMidStateBuffer, true);
|
ArraySetAsSeries(vwapMidStateBuffer, true);
|
||||||
ArraySetAsSeries(donOpenUpperBuffer, true);
|
ArraySetAsSeries(donOpenUpperBuffer, true);
|
||||||
ArraySetAsSeries(donOpenLowerBuffer, true);
|
ArraySetAsSeries(donOpenLowerBuffer, true);
|
||||||
ArraySetAsSeries(donHighUpperBuffer, true);
|
ArraySetAsSeries(donHighUpperBuffer, true);
|
||||||
ArraySetAsSeries(donHighLowerBuffer, true);
|
ArraySetAsSeries(donHighLowerBuffer, true);
|
||||||
ArraySetAsSeries(x3maMidStateBuffer, true);
|
ArraySetAsSeries(x3maMidStateBuffer, true);
|
||||||
|
ArraySetAsSeries(fractalsUpperBuffer, true);
|
||||||
|
ArraySetAsSeries(fractalsLowerBuffer, true);
|
||||||
ArraySetAsSeries(vwapFastStateBuffer, true);
|
ArraySetAsSeries(vwapFastStateBuffer, true);
|
||||||
ArraySetAsSeries(vwapSlowStateBuffer, true);
|
ArraySetAsSeries(vwapSlowStateBuffer, true);
|
||||||
ArraySetAsSeries(donCloseUpperBuffer, true);
|
ArraySetAsSeries(donCloseUpperBuffer, true);
|
||||||
@@ -3185,6 +3196,18 @@ class XCX121Helper : public XCBase
|
|||||||
conditions.valesBuffer //
|
conditions.valesBuffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
xpvConditions.supportsBuffer,
|
||||||
|
conditions.supportsBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
xpvConditions.resistancesBuffer,
|
||||||
|
conditions.resistancesBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
Copy(
|
Copy(
|
||||||
xpvConditions.peaksGoldenBuffer,
|
xpvConditions.peaksGoldenBuffer,
|
||||||
@@ -3263,6 +3286,18 @@ class XCX121Helper : public XCBase
|
|||||||
conditions.hLLBuffer //
|
conditions.hLLBuffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
xpvConditions.fractalsUpperBuffer,
|
||||||
|
conditions.fractalsUpperBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
xpvConditions.fractalsLowerBuffer,
|
||||||
|
conditions.fractalsLowerBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Conditions ...
|
// Conditions ...
|
||||||
|
|
||||||
|
|||||||
@@ -37,16 +37,20 @@ enum ENUM_X121_XPV_BUFFERS
|
|||||||
X121_XPV_SAR_LINE = 2,
|
X121_XPV_SAR_LINE = 2,
|
||||||
X121_XPV_PEAK_GOLDEN_ZONE_LINE = 3,
|
X121_XPV_PEAK_GOLDEN_ZONE_LINE = 3,
|
||||||
X121_XPV_VALE_GOLDEN_ZONE_LINE = 4,
|
X121_XPV_VALE_GOLDEN_ZONE_LINE = 4,
|
||||||
X121_XPV_C_HH_LINE = 5,
|
X121_XPV_SUPPORT_LINE = 5,
|
||||||
X121_XPV_C_LL_LINE = 6,
|
X121_XPV_RESISTANCE_LINE = 6,
|
||||||
X121_XPV_S_HH_LINE = 7,
|
X121_XPV_C_HH_LINE = 7,
|
||||||
X121_XPV_S_LL_LINE = 8,
|
X121_XPV_C_LL_LINE = 8,
|
||||||
X121_XPV_M_HH_LINE = 9,
|
X121_XPV_S_HH_LINE = 9,
|
||||||
X121_XPV_M_LL_LINE = 10,
|
X121_XPV_S_LL_LINE = 10,
|
||||||
X121_XPV_L_HH_LINE = 11,
|
X121_XPV_M_HH_LINE = 11,
|
||||||
X121_XPV_L_LL_LINE = 12,
|
X121_XPV_M_LL_LINE = 12,
|
||||||
X121_XPV_H_HH_LINE = 13,
|
X121_XPV_L_HH_LINE = 13,
|
||||||
X121_XPV_H_LL_LINE = 14,
|
X121_XPV_L_LL_LINE = 14,
|
||||||
|
X121_XPV_H_HH_LINE = 15,
|
||||||
|
X121_XPV_H_LL_LINE = 16,
|
||||||
|
X121_XPV_FRACTALS_UPPER_LINE = 17,
|
||||||
|
X121_XPV_FRACTALS_LOWER_LINE = 18,
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -91,15 +95,19 @@ struct X121XPVInputs
|
|||||||
int startCalculationForLastBars; // Calculate Last n Bars
|
int startCalculationForLastBars; // Calculate Last n Bars
|
||||||
|
|
||||||
//
|
//
|
||||||
int sarArrowCode; // Parabolic Sar Arrow Code
|
int sarArrowCode; // Parabolic Sar Arrow Code
|
||||||
int peaksArrowCode; // Peaks Arrow Code
|
int peaksArrowCode; // Peaks Arrow Code
|
||||||
int valesArrowCode; // Vales Arrow Code
|
int valesArrowCode; // Vales Arrow Code
|
||||||
|
int supportsArrowCode; // Supports Arrow Code
|
||||||
|
int resistancesArrowCode; // Resistances Arrow Code
|
||||||
|
|
||||||
//
|
//
|
||||||
bool showSar; // Show Parabolic Sar
|
bool showSar; // Show Parabolic Sar
|
||||||
bool showPeaks; // Show Peaks
|
bool showPeaks; // Show Peaks
|
||||||
bool showVales; // Show Vales
|
bool showVales; // Show Vales
|
||||||
bool showGoldenZones; // Show Golden Zones
|
bool showGoldenZones; // Show Golden Zones
|
||||||
|
bool showSupports; // Show Supports
|
||||||
|
bool showResistances; // Show Resistances
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor(s) ...
|
// Constructor(s) ...
|
||||||
@@ -153,12 +161,16 @@ struct X121XPVInputs
|
|||||||
sarArrowCode = 0;
|
sarArrowCode = 0;
|
||||||
peaksArrowCode = 0;
|
peaksArrowCode = 0;
|
||||||
valesArrowCode = 0;
|
valesArrowCode = 0;
|
||||||
|
supportsArrowCode = 0;
|
||||||
|
resistancesArrowCode = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
showSar = false;
|
showSar = false;
|
||||||
showPeaks = false;
|
showPeaks = false;
|
||||||
showVales = false;
|
showVales = false;
|
||||||
showGoldenZones = true;
|
showGoldenZones = false;
|
||||||
|
showSupports = false;
|
||||||
|
showResistances = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
ZeroMemory(this);
|
ZeroMemory(this);
|
||||||
@@ -205,12 +217,16 @@ struct X121XPVInputs
|
|||||||
sarArrowCode = 159;
|
sarArrowCode = 159;
|
||||||
peaksArrowCode = 159;
|
peaksArrowCode = 159;
|
||||||
valesArrowCode = 159;
|
valesArrowCode = 159;
|
||||||
|
supportsArrowCode = 159;
|
||||||
|
resistancesArrowCode = 159;
|
||||||
|
|
||||||
//
|
//
|
||||||
showSar = true;
|
showSar = true;
|
||||||
showPeaks = true;
|
showPeaks = true;
|
||||||
showVales = true;
|
showVales = true;
|
||||||
showGoldenZones = true;
|
showGoldenZones = true;
|
||||||
|
showSupports = true;
|
||||||
|
showResistances = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -271,6 +287,8 @@ struct X121XPVConditions
|
|||||||
double valesBuffer[];
|
double valesBuffer[];
|
||||||
double peaksGoldenBuffer[];
|
double peaksGoldenBuffer[];
|
||||||
double valesGoldenBuffer[];
|
double valesGoldenBuffer[];
|
||||||
|
double supportsBuffer[];
|
||||||
|
double resistancesBuffer[];
|
||||||
double sarBuffer[];
|
double sarBuffer[];
|
||||||
double cHHBuffer[];
|
double cHHBuffer[];
|
||||||
double cLLBuffer[];
|
double cLLBuffer[];
|
||||||
@@ -282,6 +300,8 @@ struct X121XPVConditions
|
|||||||
double lLLBuffer[];
|
double lLLBuffer[];
|
||||||
double hHHBuffer[];
|
double hHHBuffer[];
|
||||||
double hLLBuffer[];
|
double hLLBuffer[];
|
||||||
|
double fractalsUpperBuffer[];
|
||||||
|
double fractalsLowerBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Conditions ...
|
// Conditions ...
|
||||||
@@ -343,6 +363,8 @@ struct X121XPVConditions
|
|||||||
Clean(valesBuffer);
|
Clean(valesBuffer);
|
||||||
Clean(peaksGoldenBuffer);
|
Clean(peaksGoldenBuffer);
|
||||||
Clean(valesGoldenBuffer);
|
Clean(valesGoldenBuffer);
|
||||||
|
Clean(supportsBuffer);
|
||||||
|
Clean(resistancesBuffer);
|
||||||
Clean(sarBuffer);
|
Clean(sarBuffer);
|
||||||
Clean(cHHBuffer);
|
Clean(cHHBuffer);
|
||||||
Clean(cLLBuffer);
|
Clean(cLLBuffer);
|
||||||
@@ -354,6 +376,8 @@ struct X121XPVConditions
|
|||||||
Clean(lLLBuffer);
|
Clean(lLLBuffer);
|
||||||
Clean(hHHBuffer);
|
Clean(hHHBuffer);
|
||||||
Clean(hLLBuffer);
|
Clean(hLLBuffer);
|
||||||
|
Clean(fractalsUpperBuffer);
|
||||||
|
Clean(fractalsLowerBuffer);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clean(bullishTrendBuffer);
|
// Clean(bullishTrendBuffer);
|
||||||
@@ -364,6 +388,8 @@ struct X121XPVConditions
|
|||||||
ArraySetAsSeries(valesBuffer, true);
|
ArraySetAsSeries(valesBuffer, true);
|
||||||
ArraySetAsSeries(peaksGoldenBuffer, true);
|
ArraySetAsSeries(peaksGoldenBuffer, true);
|
||||||
ArraySetAsSeries(valesGoldenBuffer, true);
|
ArraySetAsSeries(valesGoldenBuffer, true);
|
||||||
|
ArraySetAsSeries(supportsBuffer, true);
|
||||||
|
ArraySetAsSeries(resistancesBuffer, true);
|
||||||
ArraySetAsSeries(sarBuffer, true);
|
ArraySetAsSeries(sarBuffer, true);
|
||||||
ArraySetAsSeries(cHHBuffer, true);
|
ArraySetAsSeries(cHHBuffer, true);
|
||||||
ArraySetAsSeries(cLLBuffer, true);
|
ArraySetAsSeries(cLLBuffer, true);
|
||||||
@@ -375,6 +401,8 @@ struct X121XPVConditions
|
|||||||
ArraySetAsSeries(lLLBuffer, true);
|
ArraySetAsSeries(lLLBuffer, true);
|
||||||
ArraySetAsSeries(hHHBuffer, true);
|
ArraySetAsSeries(hHHBuffer, true);
|
||||||
ArraySetAsSeries(hLLBuffer, true);
|
ArraySetAsSeries(hLLBuffer, true);
|
||||||
|
ArraySetAsSeries(fractalsUpperBuffer, true);
|
||||||
|
ArraySetAsSeries(fractalsLowerBuffer, true);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Conditions ...
|
// Conditions ...
|
||||||
@@ -393,6 +421,7 @@ struct X121XPVConditions
|
|||||||
isNewPeakUnderLast = false;
|
isNewPeakUnderLast = false;
|
||||||
isRejectedPrevPeak = false;
|
isRejectedPrevPeak = false;
|
||||||
isBreakedUpPrevPeak = false;
|
isBreakedUpPrevPeak = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
isNewVale = false;
|
isNewVale = false;
|
||||||
isNewValeOverLast = false;
|
isNewValeOverLast = false;
|
||||||
@@ -557,6 +586,8 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
Clean(valesBuffer);
|
Clean(valesBuffer);
|
||||||
Clean(peaksGoldenBuffer);
|
Clean(peaksGoldenBuffer);
|
||||||
Clean(valesGoldenBuffer);
|
Clean(valesGoldenBuffer);
|
||||||
|
Clean(supportsBuffer);
|
||||||
|
Clean(resistancesBuffer);
|
||||||
Clean(sarBuffer);
|
Clean(sarBuffer);
|
||||||
Clean(cHHBuffer);
|
Clean(cHHBuffer);
|
||||||
Clean(cLLBuffer);
|
Clean(cLLBuffer);
|
||||||
@@ -568,6 +599,8 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
Clean(lLLBuffer);
|
Clean(lLLBuffer);
|
||||||
Clean(hHHBuffer);
|
Clean(hHHBuffer);
|
||||||
Clean(hLLBuffer);
|
Clean(hLLBuffer);
|
||||||
|
Clean(fractalsUpperBuffer);
|
||||||
|
Clean(fractalsLowerBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -597,6 +630,8 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
ArraySetAsSeries(valesBuffer, true);
|
ArraySetAsSeries(valesBuffer, true);
|
||||||
ArraySetAsSeries(peaksGoldenBuffer, true);
|
ArraySetAsSeries(peaksGoldenBuffer, true);
|
||||||
ArraySetAsSeries(valesGoldenBuffer, true);
|
ArraySetAsSeries(valesGoldenBuffer, true);
|
||||||
|
ArraySetAsSeries(supportsBuffer, true);
|
||||||
|
ArraySetAsSeries(resistancesBuffer, true);
|
||||||
ArraySetAsSeries(sarBuffer, true);
|
ArraySetAsSeries(sarBuffer, true);
|
||||||
ArraySetAsSeries(cHHBuffer, true);
|
ArraySetAsSeries(cHHBuffer, true);
|
||||||
ArraySetAsSeries(cLLBuffer, true);
|
ArraySetAsSeries(cLLBuffer, true);
|
||||||
@@ -608,6 +643,8 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
ArraySetAsSeries(lLLBuffer, true);
|
ArraySetAsSeries(lLLBuffer, true);
|
||||||
ArraySetAsSeries(hHHBuffer, true);
|
ArraySetAsSeries(hHHBuffer, true);
|
||||||
ArraySetAsSeries(hLLBuffer, true);
|
ArraySetAsSeries(hLLBuffer, true);
|
||||||
|
ArraySetAsSeries(fractalsUpperBuffer, true);
|
||||||
|
ArraySetAsSeries(fractalsLowerBuffer, true);
|
||||||
|
|
||||||
//
|
//
|
||||||
mInputs = inputs;
|
mInputs = inputs;
|
||||||
@@ -661,11 +698,15 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
mInputs.sarArrowCode,
|
mInputs.sarArrowCode,
|
||||||
mInputs.peaksArrowCode,
|
mInputs.peaksArrowCode,
|
||||||
mInputs.valesArrowCode,
|
mInputs.valesArrowCode,
|
||||||
|
mInputs.supportsArrowCode,
|
||||||
|
mInputs.resistancesArrowCode,
|
||||||
//
|
//
|
||||||
mInputs.showSar,
|
mInputs.showSar,
|
||||||
mInputs.showPeaks,
|
mInputs.showPeaks,
|
||||||
mInputs.showVales,
|
mInputs.showVales,
|
||||||
mInputs.showGoldenZones
|
mInputs.showGoldenZones,
|
||||||
|
mInputs.showSupports,
|
||||||
|
mInputs.showResistances
|
||||||
//
|
//
|
||||||
);
|
);
|
||||||
result = mHandler != INVALID_HANDLE;
|
result = mHandler != INVALID_HANDLE;
|
||||||
@@ -863,6 +904,110 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// SUPPORTS ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetSupport(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(supportsBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return supportsBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopySupport(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
supportsBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// RESISTANCES ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetResistance(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(resistancesBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return resistancesBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyResistance(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
resistancesBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// GOLDEN PEAKS ...
|
// GOLDEN PEAKS ...
|
||||||
|
|
||||||
@@ -1734,6 +1879,110 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetFractalsUpper(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(fractalsUpperBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return fractalsUpperBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyFractalsUpper(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
fractalsUpperBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double GetFractalsLower(
|
||||||
|
int barIndex // Bar Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(fractalsLowerBuffer);
|
||||||
|
if (barIndex >= count)
|
||||||
|
{
|
||||||
|
barIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return fractalsLowerBuffer[barIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CopyFractalsLower(
|
||||||
|
int start, // Start
|
||||||
|
int count, // Number of Items for read
|
||||||
|
double &buffer[], // Dest Buffer
|
||||||
|
bool forceClean = true // Force To Clean buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update Calculations ...
|
||||||
|
Calculate();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy Items ...
|
||||||
|
return Copy(
|
||||||
|
start,
|
||||||
|
count,
|
||||||
|
fractalsLowerBuffer,
|
||||||
|
buffer,
|
||||||
|
forceClean
|
||||||
|
//
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tools Function ...
|
// Tools Function ...
|
||||||
|
|
||||||
@@ -2053,6 +2302,20 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
conditions.valesBuffer //
|
conditions.valesBuffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopySupport(
|
||||||
|
zIndex,
|
||||||
|
loopback,
|
||||||
|
conditions.supportsBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopyResistance(
|
||||||
|
zIndex,
|
||||||
|
loopback,
|
||||||
|
conditions.resistancesBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
CopyPeakGoldenZone(
|
CopyPeakGoldenZone(
|
||||||
zIndex,
|
zIndex,
|
||||||
@@ -2137,6 +2400,20 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
conditions.hLLBuffer //
|
conditions.hLLBuffer //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopyFractalsUpper(
|
||||||
|
zIndex,
|
||||||
|
loopback,
|
||||||
|
conditions.fractalsUpperBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CopyFractalsLower(
|
||||||
|
zIndex,
|
||||||
|
loopback,
|
||||||
|
conditions.fractalsLowerBuffer //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Conditions ...
|
// Conditions ...
|
||||||
|
|
||||||
@@ -2240,6 +2517,8 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
// Buffers ...
|
// Buffers ...
|
||||||
double peaksBuffer[];
|
double peaksBuffer[];
|
||||||
double valesBuffer[];
|
double valesBuffer[];
|
||||||
|
double supportsBuffer[];
|
||||||
|
double resistancesBuffer[];
|
||||||
double peaksGoldenBuffer[];
|
double peaksGoldenBuffer[];
|
||||||
double valesGoldenBuffer[];
|
double valesGoldenBuffer[];
|
||||||
double sarBuffer[];
|
double sarBuffer[];
|
||||||
@@ -2253,6 +2532,8 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
double lLLBuffer[];
|
double lLLBuffer[];
|
||||||
double hHHBuffer[];
|
double hHHBuffer[];
|
||||||
double hLLBuffer[];
|
double hLLBuffer[];
|
||||||
|
double fractalsUpperBuffer[];
|
||||||
|
double fractalsLowerBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
void Calculate(
|
void Calculate(
|
||||||
@@ -2298,6 +2579,28 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
//
|
//
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// SUPPORTS ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_XPV_SUPPORT_LINE,
|
||||||
|
0,
|
||||||
|
maxRequiredBars,
|
||||||
|
supportsBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// RESISTANCES ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_XPV_RESISTANCE_LINE,
|
||||||
|
0,
|
||||||
|
maxRequiredBars,
|
||||||
|
resistancesBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// GOLDEN PEAKS ...
|
// GOLDEN PEAKS ...
|
||||||
CopyBuffer(
|
CopyBuffer(
|
||||||
@@ -2444,6 +2747,28 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
hLLBuffer
|
hLLBuffer
|
||||||
//
|
//
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS Upper ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_XPV_FRACTALS_UPPER_LINE,
|
||||||
|
0,
|
||||||
|
maxRequiredBars,
|
||||||
|
fractalsUpperBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS Lower ...
|
||||||
|
CopyBuffer(
|
||||||
|
mHandler,
|
||||||
|
X121_XPV_FRACTALS_LOWER_LINE,
|
||||||
|
0,
|
||||||
|
maxRequiredBars,
|
||||||
|
fractalsLowerBuffer
|
||||||
|
//
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2475,6 +2800,18 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
maxAllowed //
|
maxAllowed //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
supportsBuffer,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
resistancesBuffer,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
CleanupArray(
|
CleanupArray(
|
||||||
sarBuffer,
|
sarBuffer,
|
||||||
@@ -2541,6 +2878,18 @@ class XCX121XPVHelper : public XCBaseHelper
|
|||||||
maxAllowed //
|
maxAllowed //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
fractalsUpperBuffer,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
fractalsLowerBuffer,
|
||||||
|
maxAllowed //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period
|
|||||||
input group "Boundary Detection";
|
input group "Boundary Detection";
|
||||||
input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method
|
input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method
|
||||||
input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
|
input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
|
||||||
input ENUM_X_FIBO_LEVELS goldenZoneLevel = X_FIBO_LEVEL_382; // Golden Zone Detection
|
input ENUM_X_FIBO_LEVELS goldenZoneLevel = X_FIBO_LEVEL_236; // Golden Zone Detection
|
||||||
|
|
||||||
//
|
//
|
||||||
input group "Sar Detection";
|
input group "Sar Detection";
|
||||||
@@ -76,12 +76,16 @@ input int startCalculationForLastBars = 1000; // Calculate Last n Bars
|
|||||||
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
|
||||||
input int peaksArrowCode = 159; // Peaks Arrow Code
|
input int peaksArrowCode = 159; // Peaks Arrow Code
|
||||||
input int valesArrowCode = 159; // Vales Arrow Code
|
input int valesArrowCode = 159; // Vales Arrow Code
|
||||||
|
input int supportsArrowCode = 159; // Supports Arrow Code
|
||||||
|
input int resistancesArrowCode = 159; // Resistances Arrow Code
|
||||||
|
|
||||||
//
|
//
|
||||||
input bool showSar = true; // Show Parabolic Sar
|
input bool showSar = true; // Show Parabolic Sar
|
||||||
input bool showPeaks = true; // Show Peaks
|
input bool showPeaks = true; // Show Peaks
|
||||||
input bool showVales = true; // Show Vales
|
input bool showVales = true; // Show Vales
|
||||||
input bool showGoldenZones = true; // Show Golden Zones
|
input bool showGoldenZones = true; // Show Golden Zones
|
||||||
|
input bool showSupports = true; // Show Supports
|
||||||
|
input bool showResistances = true; // Show Resistances
|
||||||
|
|
||||||
//
|
//
|
||||||
// Buffers ...
|
// Buffers ...
|
||||||
@@ -96,8 +100,8 @@ input bool showGoldenZones = true; // Show Golden Zones
|
|||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 15
|
#property indicator_buffers 19
|
||||||
#property indicator_plots 5
|
#property indicator_plots 7
|
||||||
|
|
||||||
//
|
//
|
||||||
// Plot Buffers ...
|
// Plot Buffers ...
|
||||||
@@ -112,7 +116,7 @@ double peaksBuffer[];
|
|||||||
//
|
//
|
||||||
#property indicator_label1 "X121 PEAKS"
|
#property indicator_label1 "X121 PEAKS"
|
||||||
#property indicator_type1 DRAW_ARROW
|
#property indicator_type1 DRAW_ARROW
|
||||||
#property indicator_color1 clrAqua
|
#property indicator_color1 clrMagenta
|
||||||
#property indicator_width1 1
|
#property indicator_width1 1
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -125,7 +129,7 @@ double valesBuffer[];
|
|||||||
//
|
//
|
||||||
#property indicator_label2 "X121 VALES"
|
#property indicator_label2 "X121 VALES"
|
||||||
#property indicator_type2 DRAW_ARROW
|
#property indicator_type2 DRAW_ARROW
|
||||||
#property indicator_color2 clrMagenta
|
#property indicator_color2 clrAqua
|
||||||
#property indicator_width2 1
|
#property indicator_width2 1
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -160,11 +164,31 @@ double valesGoldenZoneBuffer[];
|
|||||||
#property indicator_style5 STYLE_DOT
|
#property indicator_style5 STYLE_DOT
|
||||||
#property indicator_width5 1
|
#property indicator_width5 1
|
||||||
|
|
||||||
|
//
|
||||||
|
#define supportsBufferIndex 5
|
||||||
|
double supportsBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_label6 "X121 SUPRT"
|
||||||
|
#property indicator_type6 DRAW_ARROW
|
||||||
|
#property indicator_color6 clrLime
|
||||||
|
#property indicator_width6 1
|
||||||
|
|
||||||
|
//
|
||||||
|
#define resistancesBufferIndex 6
|
||||||
|
double resistancesBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#property indicator_label7 "X121 RESIS"
|
||||||
|
#property indicator_type7 DRAW_ARROW
|
||||||
|
#property indicator_color7 clrRed
|
||||||
|
#property indicator_width7 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
|
|
||||||
//
|
//
|
||||||
int mLastBufferIndex = 4;
|
int mLastBufferIndex = 6;
|
||||||
|
|
||||||
//
|
//
|
||||||
// CURRENT ...
|
// CURRENT ...
|
||||||
@@ -221,6 +245,17 @@ double hHHBuffer[];
|
|||||||
#define hLLBufferIndex mLastBufferIndex + 10
|
#define hLLBufferIndex mLastBufferIndex + 10
|
||||||
double hLLBuffer[];
|
double hLLBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support and Resistances ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define fractalsUpperBufferIndex mLastBufferIndex + 11
|
||||||
|
double fractalsUpperBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define fractalsLowerBufferIndex mLastBufferIndex + 12
|
||||||
|
double fractalsLowerBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variables, Properties and etc ...
|
// Variables, Properties and etc ...
|
||||||
|
|
||||||
@@ -235,6 +270,10 @@ int maxLength;
|
|||||||
// SAR Handler ...
|
// SAR Handler ...
|
||||||
int sarHandler = INVALID_HANDLE;
|
int sarHandler = INVALID_HANDLE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS Handler ...
|
||||||
|
int fractalHandler = INVALID_HANDLE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// XMarketCycle sc;
|
// XMarketCycle sc;
|
||||||
int mSCLength = 0;
|
int mSCLength = 0;
|
||||||
@@ -289,6 +328,18 @@ int OnInit()
|
|||||||
return INIT_FAILED;
|
return INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fractal ...
|
||||||
|
fractalHandler = iFractals(
|
||||||
|
_Symbol,
|
||||||
|
_Period //
|
||||||
|
);
|
||||||
|
isInited = fractalHandler != INVALID_HANDLE;
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
return INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if (!InitMarketCycles())
|
if (!InitMarketCycles())
|
||||||
{
|
{
|
||||||
@@ -336,6 +387,7 @@ void OnDeinit(const int reason)
|
|||||||
|
|
||||||
//
|
//
|
||||||
IndicatorRelease(sarHandler);
|
IndicatorRelease(sarHandler);
|
||||||
|
IndicatorRelease(fractalHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -385,11 +437,18 @@ int OnCalculate(
|
|||||||
// SAR ...
|
// SAR ...
|
||||||
int sarCalculatedBars = BarsCalculated(sarHandler);
|
int sarCalculatedBars = BarsCalculated(sarHandler);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS ...
|
||||||
|
int fractalsCalculatedBars = BarsCalculated(fractalHandler);
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isPassedRequiredCalculatedBars =
|
bool isPassedRequiredCalculatedBars =
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
sarCalculatedBars >= maxLength
|
sarCalculatedBars >= maxLength &&
|
||||||
|
//
|
||||||
|
// FRACTALS ...
|
||||||
|
fractalsCalculatedBars >= maxLength
|
||||||
//
|
//
|
||||||
;
|
;
|
||||||
if (!isPassedRequiredCalculatedBars)
|
if (!isPassedRequiredCalculatedBars)
|
||||||
@@ -409,12 +468,21 @@ int OnCalculate(
|
|||||||
// SAR ...
|
// SAR ...
|
||||||
int copiedSars = CopyBuffer(sarHandler, 0, 0, limit, sarBuffer);
|
int copiedSars = CopyBuffer(sarHandler, 0, 0, limit, sarBuffer);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS ...
|
||||||
|
int copiedFractalsUppers = CopyBuffer(fractalHandler, UPPER_LINE, 0, limit + 1, fractalsUpperBuffer);
|
||||||
|
int copiedFractalsLowers = CopyBuffer(fractalHandler, LOWER_LINE, 0, limit + 1, fractalsLowerBuffer);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Copied Items ...
|
// Validate Copied Items ...
|
||||||
bool isPassedRequiredCopiedItems =
|
bool isPassedRequiredCopiedItems =
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
copiedSars > 0
|
copiedSars > 0 &&
|
||||||
|
//
|
||||||
|
// FRACTALS ...
|
||||||
|
copiedFractalsUppers > 0 &&
|
||||||
|
copiedFractalsLowers > 0
|
||||||
//
|
//
|
||||||
;
|
;
|
||||||
if (!isPassedRequiredCopiedItems)
|
if (!isPassedRequiredCopiedItems)
|
||||||
@@ -514,7 +582,7 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(peaksBufferIndex, PLOT_DRAW_TYPE, peaksDrawType);
|
PlotIndexSetInteger(peaksBufferIndex, PLOT_DRAW_TYPE, peaksDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetDouble(peaksBufferIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(peaksBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
PlotIndexSetInteger(peaksBufferIndex, PLOT_ARROW, peaksArrowCode);
|
PlotIndexSetInteger(peaksBufferIndex, PLOT_ARROW, peaksArrowCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -532,7 +600,7 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(valesBufferIndex, PLOT_DRAW_TYPE, valesDrawType);
|
PlotIndexSetInteger(valesBufferIndex, PLOT_DRAW_TYPE, valesDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetDouble(valesBufferIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(valesBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
PlotIndexSetInteger(valesBufferIndex, PLOT_ARROW, valesArrowCode);
|
PlotIndexSetInteger(valesBufferIndex, PLOT_ARROW, valesArrowCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -550,9 +618,45 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(sarBufferIndex, PLOT_DRAW_TYPE, sarDrawType);
|
PlotIndexSetInteger(sarBufferIndex, PLOT_DRAW_TYPE, sarDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode);
|
PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_DRAW_TYPE supportsDrawType = showSupports ? DRAW_ARROW : DRAW_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(supportsBuffer, true);
|
||||||
|
SetIndexBuffer(supportsBufferIndex, supportsBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(supportsBufferIndex, PLOT_SHOW_DATA, showSupports);
|
||||||
|
PlotIndexSetInteger(supportsBufferIndex, PLOT_DRAW_TYPE, supportsDrawType);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetDouble(supportsBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(supportsBufferIndex, PLOT_ARROW, supportsArrowCode);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Resistances...
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_DRAW_TYPE resistancesDrawType = showResistances ? DRAW_ARROW : DRAW_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(resistancesBuffer, true);
|
||||||
|
SetIndexBuffer(resistancesBufferIndex, resistancesBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(resistancesBufferIndex, PLOT_SHOW_DATA, showResistances);
|
||||||
|
PlotIndexSetInteger(resistancesBufferIndex, PLOT_DRAW_TYPE, resistancesDrawType);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetDouble(resistancesBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
|
PlotIndexSetInteger(resistancesBufferIndex, PLOT_ARROW, resistancesArrowCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Golden Zones ...
|
// Golden Zones ...
|
||||||
|
|
||||||
@@ -638,6 +742,17 @@ void DefineBuffers()
|
|||||||
//
|
//
|
||||||
ArraySetAsSeries(hLLBuffer, true);
|
ArraySetAsSeries(hLLBuffer, true);
|
||||||
SetIndexBuffer(hLLBufferIndex, hLLBuffer, INDICATOR_CALCULATIONS);
|
SetIndexBuffer(hLLBufferIndex, hLLBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FRACTALS ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(fractalsUpperBuffer, true);
|
||||||
|
SetIndexBuffer(fractalsUpperBufferIndex, fractalsUpperBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(fractalsLowerBuffer, true);
|
||||||
|
SetIndexBuffer(fractalsLowerBufferIndex, fractalsLowerBuffer, INDICATOR_CALCULATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -689,6 +804,19 @@ void CalculateBuffers(
|
|||||||
//
|
//
|
||||||
// Calculate Peaks and Vales ...
|
// Calculate Peaks and Vales ...
|
||||||
CalculatePeaksAndVales(bar_index);
|
CalculatePeaksAndVales(bar_index);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Support nad Resistance ...
|
||||||
|
CalculateSupportAndResistance(
|
||||||
|
bar_index,
|
||||||
|
prevCalculated,
|
||||||
|
ratesTotal,
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
close,
|
||||||
|
low,
|
||||||
|
tickVolume //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -853,6 +981,16 @@ void FillBuffersZero(int barIndex)
|
|||||||
//
|
//
|
||||||
// SARS ...
|
// SARS ...
|
||||||
sarBuffer[barIndex] = EMPTY_VALUE;
|
sarBuffer[barIndex] = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support and Resistances ...
|
||||||
|
supportsBuffer[barIndex] = EMPTY_VALUE;
|
||||||
|
resistancesBuffer[barIndex] = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fractals ...
|
||||||
|
fractalsUpperBuffer[barIndex] = EMPTY_VALUE;
|
||||||
|
fractalsLowerBuffer[barIndex] = EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1069,6 +1207,51 @@ void CalculatePeaksAndVales(int barIndex)
|
|||||||
X_DIRECTION_BEARISH //
|
X_DIRECTION_BEARISH //
|
||||||
);
|
);
|
||||||
valesGoldenZoneBuffer[barIndex] = iValeGoldenZone;
|
valesGoldenZoneBuffer[barIndex] = iValeGoldenZone;
|
||||||
|
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate Support nad Resistances ...
|
||||||
|
*
|
||||||
|
* @param bar_index: int, Specified Bar Index ...
|
||||||
|
* @param prevCalculated: int, Provides Previous Calculated Bars ...
|
||||||
|
* @param ratesTotal: int, Provides All Availabled Bars ...
|
||||||
|
* @param open: double Collection, Provides Open Prices Time Series ...
|
||||||
|
* @param high: double Collection, Provides High Prices Time Series ...
|
||||||
|
* @param close: double Collection, Provides Close Prices Time Series ...
|
||||||
|
* @param low: double Collection, Provides Low Prices Time Series ...
|
||||||
|
* @param tickVolume: long Collection, Provides Ticks Volume Prices Time Series ...
|
||||||
|
*/
|
||||||
|
void CalculateSupportAndResistance(
|
||||||
|
int bar_index, // Selected Bar Index
|
||||||
|
const int prevCalculated,
|
||||||
|
const int ratesTotal,
|
||||||
|
const double &open[],
|
||||||
|
const double &high[],
|
||||||
|
const double &close[],
|
||||||
|
const double &low[],
|
||||||
|
const long &tickVolume[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iUpperFractalsPrev = fractalsUpperBuffer[bar_index + 1];
|
||||||
|
double iLowerFractalsPrev = fractalsLowerBuffer[bar_index + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
double iHigh = high[bar_index];
|
||||||
|
double iLow = low[bar_index];
|
||||||
|
|
||||||
|
//
|
||||||
|
double iSupport = iLowerFractalsPrev != EMPTY_VALUE
|
||||||
|
? iLow
|
||||||
|
: supportsBuffer[bar_index + 1];
|
||||||
|
double iResistance = iUpperFractalsPrev != EMPTY_VALUE
|
||||||
|
? iHigh
|
||||||
|
: resistancesBuffer[bar_index + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
supportsBuffer[bar_index] = iSupport;
|
||||||
|
resistancesBuffer[bar_index] = iResistance;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
@@ -2041,7 +2041,7 @@ class XCTwoBarZone : public XCZone
|
|||||||
mType = type;
|
mType = type;
|
||||||
mEndBar = endBar;
|
mEndBar = endBar;
|
||||||
mStartBar = startBar;
|
mStartBar = startBar;
|
||||||
|
|
||||||
//
|
//
|
||||||
int startIndex = startBar.Index();
|
int startIndex = startBar.Index();
|
||||||
int endIndex = endBar.Index();
|
int endIndex = endBar.Index();
|
||||||
@@ -5338,6 +5338,43 @@ struct XBoxZone
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Box Age ...
|
||||||
|
*
|
||||||
|
* @param forPeriod: ENUM_TIMEFRAMES member ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetAge(
|
||||||
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid(forPeriod))
|
||||||
|
{
|
||||||
|
forPeriod = period;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = iBarShift(
|
||||||
|
symbol,
|
||||||
|
forPeriod,
|
||||||
|
from //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Unique Identifier ...
|
* Retrieve Unique Identifier ...
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -765,6 +765,42 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DetectTreand(
|
||||||
|
ENUM_X_DIRECTION &dir //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Overal ...
|
||||||
|
ENUM_X_DIRECTION overal;
|
||||||
|
bool hasOveral = DetectOveralDirection(overal);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Waiting Boxes ...
|
||||||
|
ENUM_X_DIRECTION boxDir = X_DIRECTION_NONE;
|
||||||
|
XBoxZone tmpBoxes[];
|
||||||
|
Copy(
|
||||||
|
waitingBoxes,
|
||||||
|
tmpBoxes //
|
||||||
|
);
|
||||||
|
int count = ArraySize(tmpBoxes);
|
||||||
|
bool has = IsValidSize(count);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update all Collections Members To Time ...
|
* Update all Collections Members To Time ...
|
||||||
*
|
*
|
||||||
@@ -1021,7 +1057,8 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
ENUM_X_DIRECTION overalTrend;
|
ENUM_X_DIRECTION overalTrend;
|
||||||
bool hasTrend = DetectOveralTrend(overalTrend);
|
bool hasTrend = DetectOveralDirection(overalTrend);
|
||||||
|
|
||||||
if (hasTrend)
|
if (hasTrend)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -795,6 +795,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
x121Inputs.xpvInputs.showSar = showAll || true;
|
x121Inputs.xpvInputs.showSar = showAll || true;
|
||||||
x121Inputs.xpvInputs.showPeaks = showAll || true;
|
x121Inputs.xpvInputs.showPeaks = showAll || true;
|
||||||
x121Inputs.xpvInputs.showVales = showAll || true;
|
x121Inputs.xpvInputs.showVales = showAll || true;
|
||||||
|
x121Inputs.xpvInputs.showSupports = showAll || true;
|
||||||
|
x121Inputs.xpvInputs.showResistances = showAll || true;
|
||||||
x121Inputs.xpvInputs.showGoldenZones = showAll || true;
|
x121Inputs.xpvInputs.showGoldenZones = showAll || true;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user