Add support for Golden Zone inside XPV indicator and it's Helper ...

This commit is contained in:
2025-03-08 22:00:36 +03:30
parent e0e081628a
commit 3b7ce3816a
9 changed files with 682 additions and 132 deletions
+275
View File
@@ -0,0 +1,275 @@
//+------------------------------------------------------------------+
//| OrderBlockDetector.mq5|
//| Copyright 2023, MetaQuotes Software Corp. |
//| https://www.mql5.com|
//+------------------------------------------------------------------+
#property strict
//
// Input Parameters
input int ConsolidationPeriod = 20; // Bars for consolidation detection
input int AtrPeriod = 14; // ATR period for volatility
input double AtrMultiplier = 2.0; // Threshold multiplier (ATR * multiplier)
input int VolumeThreshold = 1000; // Minimum volume for breakout
input bool RequireRetest = true; // Retest confirmation required?
input int VpvrBars = 50; // Bars for VPVR calculation
input int TrendCheckPeriod = 30; // Bars for trend structure analysis
input int MACDFast = 12; // MACD Fast EMA period
input int MACDSlow = 26; // MACD Slow EMA period
input int MACDSignal = 9; // MACD Signal period
input int RSIPeriod = 14; // RSI period
input double RSILevel = 50; // RSI threshold level
// Global Variables
int ObjectId = 0;
string Prefix = "OrderBlock_";
//
enum ENUM_X_DIRECTION
{
X_DIRECTION_NONE,
X_DIRECTION_BULISH,
X_DIRECTION_BEARISH,
};
//
int atrHandler = INVALID_HANDLE;
double atrBuffer[];
//
int rsiHandler = INVALID_HANDLE;
double rsiBuffer[];
//
int macdHandler = INVALID_HANDLE;
double macdMainBuffer[];
double macdSignalBuffer[];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//
ArraySetAsSeries(atrBuffer, true);
atrHandler = iATR(_Symbol, _Period, AtrPeriod);
//
ArraySetAsSeries(rsiBuffer, true);
rsiHandler = iRSI(_Symbol, _Period, RSIPeriod, PRICE_CLOSE);
//
ArraySetAsSeries(macdMainBuffer, true);
ArraySetAsSeries(macdSignalBuffer, true);
macdHandler = iMACD(_Symbol, _Period, MACDFast, MACDSlow, MACDSignal, PRICE_CLOSE);
//
ObjectsDeleteAll(0, Prefix);
return (INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//
IndicatorRelease(atrHandler);
ObjectsDeleteAll(0, Prefix);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
DetectOrderBlocks();
}
//+------------------------------------------------------------------+
//| Detect Order Blocks with ATR Dynamic Threshold |
//+------------------------------------------------------------------+
void DetectOrderBlocks()
{
double high, low, vpvrPrice, atr, dynamicThreshold;
datetime startTime, endTime;
bool isBullish, isBearish;
int bars = Bars(_Symbol, _Period);
for (int i = ConsolidationPeriod; i < bars; i++)
{
//
// Get consolidation range
high = iHigh(_Symbol, _Period, iHighest(_Symbol, _Period, MODE_HIGH, ConsolidationPeriod, i));
low = iLow(_Symbol, _Period, iLowest(_Symbol, _Period, MODE_LOW, ConsolidationPeriod, i));
double range = high - low;
//
// Calculate dynamic threshold using ATR
CopyBuffer(atrHandler, MAIN_LINE, i, 2, atrBuffer);
atr = atrBuffer[0];
dynamicThreshold = atr * AtrMultiplier;
// Check if consolidation range is within ATR-based threshold
if (range <= dynamicThreshold)
{
// VPVR Integration
vpvrPrice = CalculateVPVR(i, ConsolidationPeriod);
bool validVPVR = (vpvrPrice > low && vpvrPrice < high);
// Check breakout direction
isBullish = iClose(_Symbol, _Period, i - ConsolidationPeriod) > high;
isBearish = iClose(_Symbol, _Period, i - ConsolidationPeriod) < low;
// Trend Verification
ENUM_X_DIRECTION trend = CheckTrendStructure(TrendCheckPeriod);
// MACD/RSI Verification
bool macdValid = CheckMACD(trend);
bool rsiValid = CheckRSI(trend);
// Validate all conditions
if ((isBullish || isBearish) && validVPVR &&
(trend != -1) && macdValid && rsiValid)
{
double breakoutVolume = (double)iVolume(_Symbol, _Period, i - ConsolidationPeriod);
if (breakoutVolume < VolumeThreshold)
continue;
// Define order block time window
startTime = iTime(_Symbol, _Period, i);
endTime = iTime(_Symbol, _Period, i + ConsolidationPeriod);
// Check retest (if required)
if (RequireRetest)
{
bool retestFound = false;
for (int j = i - ConsolidationPeriod; j > 0; j--)
{
if ((isBullish && iLow(_Symbol, _Period, j) <= low && iLow(_Symbol, _Period, j) >= high) ||
(isBearish && iHigh(_Symbol, _Period, j) >= high && iHigh(_Symbol, _Period, j) <= low))
{
retestFound = true;
break;
}
}
if (!retestFound)
continue;
}
// Draw order block with ATR annotation
string name = Prefix + IntegerToString(ObjectId++);
DrawOrderBlock(name, startTime, endTime, low, high,
isBullish ? clrGreen : clrRed, vpvrPrice, dynamicThreshold);
}
}
}
}
//+------------------------------------------------------------------+
//| Trend Detection using Price Structure |
//+------------------------------------------------------------------+
ENUM_X_DIRECTION CheckTrendStructure(int period)
{
int currentStart = 1;
int previousStart = period + 1;
double currentHigh = iHigh(_Symbol, _Period, iHighest(_Symbol, _Period, MODE_HIGH, period, currentStart));
double previousHigh = iHigh(_Symbol, _Period, iHighest(_Symbol, _Period, MODE_HIGH, period, previousStart));
double currentLow = iLow(_Symbol, _Period, iLowest(_Symbol, _Period, MODE_LOW, period, currentStart));
double previousLow = iLow(_Symbol, _Period, iLowest(_Symbol, _Period, MODE_LOW, period, previousStart));
if (currentHigh > previousHigh && currentLow > previousLow)
return (X_DIRECTION_BULISH); // Uptrend
else if (currentHigh < previousHigh && currentLow < previousLow)
return (X_DIRECTION_BEARISH); // Downtrend
else
return (X_DIRECTION_NONE); // No clear trend
}
//+------------------------------------------------------------------+
//| MACD Trend Verification |
//+------------------------------------------------------------------+
bool CheckMACD(ENUM_X_DIRECTION trend)
{
//
CopyBuffer(macdHandler, MAIN_LINE, 0, 1, macdMainBuffer);
CopyBuffer(macdHandler, SIGNAL_LINE, 0, 1, macdSignalBuffer);
double macdMain = macdMainBuffer[0];
double macdSignal = macdSignalBuffer[0];
//
if (trend == X_DIRECTION_BULISH)
return (macdMain > macdSignal);
if (trend == X_DIRECTION_BEARISH)
return (macdMain < macdSignal);
return (false);
}
//+------------------------------------------------------------------+
//| RSI Trend Verification |
//+------------------------------------------------------------------+
bool CheckRSI(ENUM_X_DIRECTION trend)
{
//
CopyBuffer(rsiHandler, MAIN_LINE, 0, 1, rsiBuffer);
double rsiValue = rsiBuffer[0];
//
if (trend == X_DIRECTION_BULISH)
return (rsiValue > RSILevel);
if (trend == X_DIRECTION_BEARISH)
return (rsiValue < RSILevel);
return (false);
}
//+------------------------------------------------------------------+
//| Calculate VPVR High Volume Node |
//+------------------------------------------------------------------+
double CalculateVPVR(int startIdx, int period)
{
double maxVolume = 0;
double vpvrPrice = 0;
double price, volume;
for (int i = startIdx; i < startIdx + period; i++)
{
price = (iHigh(_Symbol, _Period, i) + iLow(_Symbol, _Period, i)) / 2;
volume = (double)iVolume(_Symbol, _Period, i);
if (volume > maxVolume)
{
maxVolume = volume;
vpvrPrice = price;
}
}
return (vpvrPrice);
}
//+------------------------------------------------------------------+
//| Draw Order Block with ATR Annotation |
//+------------------------------------------------------------------+
void DrawOrderBlock(string name, datetime startTime, datetime endTime,
double bottom, double top, color clr, double vpvrPrice, double atrThreshold)
{
// Draw rectangle
ObjectCreate(0, name + "_rect", OBJ_RECTANGLE, 0, startTime, top, endTime, bottom);
ObjectSetInteger(0, name + "_rect", OBJPROP_COLOR, clr);
ObjectSetInteger(0, name + "_rect", OBJPROP_FILL, true);
ObjectSetInteger(0, name + "_rect", OBJPROP_BACK, true);
ObjectSetInteger(0, name + "_rect", OBJPROP_WIDTH, 2);
// Draw VPVR marker
if (vpvrPrice > 0)
{
ObjectCreate(0, name + "_vpvr", OBJ_HLINE, 0, 0, vpvrPrice);
ObjectSetInteger(0, name + "_vpvr", OBJPROP_COLOR, clrYellow);
ObjectSetInteger(0, name + "_vpvr", OBJPROP_WIDTH, 1);
}
// Add ATR threshold label
string atrLabel = StringFormat("ATR Threshold: %.5f", atrThreshold);
ObjectCreate(0, name + "_atr", OBJ_TEXT, 0, startTime, top);
ObjectSetString(0, name + "_atr", OBJPROP_TEXT, atrLabel);
ObjectSetInteger(0, name + "_atr", OBJPROP_COLOR, clrWhite);
}
//+------------------------------------------------------------------+
+12
View File
@@ -2403,6 +2403,18 @@ class XCX121Helper : public XCBase
// Deconstructor ... // Deconstructor ...
~XCX121Helper() ~XCX121Helper()
{ {
//
mInputs.Clean();
xpvInputs.Clean();
xhkInputs.Clean();
xatrInputs.Clean();
xdonInputs.Clean();
xstrInputs.Clean();
xcheInputs.Clean();
x3maInputs.Clean();
xvwapInputs.Clean();
xtrendInputs.Clean();
// //
delete xpvHelper; delete xpvHelper;
delete xhkHelper; delete xhkHelper;
+185 -11
View File
@@ -35,16 +35,18 @@ enum ENUM_X121_XPV_BUFFERS
X121_XPV_PEAK_LINE = 0, X121_XPV_PEAK_LINE = 0,
X121_XPV_VALE_LINE = 1, X121_XPV_VALE_LINE = 1,
X121_XPV_SAR_LINE = 2, X121_XPV_SAR_LINE = 2,
X121_XPV_C_HH_LINE = 3, X121_XPV_PEAK_GOLDEN_ZONE_LINE = 3,
X121_XPV_C_LL_LINE = 4, X121_XPV_VALE_GOLDEN_ZONE_LINE = 4,
X121_XPV_S_HH_LINE = 5, X121_XPV_C_HH_LINE = 5,
X121_XPV_S_LL_LINE = 6, X121_XPV_C_LL_LINE = 6,
X121_XPV_M_HH_LINE = 7, X121_XPV_S_HH_LINE = 7,
X121_XPV_M_LL_LINE = 8, X121_XPV_S_LL_LINE = 8,
X121_XPV_L_HH_LINE = 9, X121_XPV_M_HH_LINE = 9,
X121_XPV_L_LL_LINE = 10, X121_XPV_M_LL_LINE = 10,
X121_XPV_H_HH_LINE = 11, X121_XPV_L_HH_LINE = 11,
X121_XPV_H_LL_LINE = 12, X121_XPV_L_LL_LINE = 12,
X121_XPV_H_HH_LINE = 13,
X121_XPV_H_LL_LINE = 14,
}; };
// //
@@ -78,6 +80,7 @@ struct X121XPVInputs
// Boundary Detection ... // Boundary Detection ...
ENUM_SERIESMODE hhMode; // Highest High Calculation Method ENUM_SERIESMODE hhMode; // Highest High Calculation Method
ENUM_SERIESMODE llMode; // Lowest Low Calculation Method ENUM_SERIESMODE llMode; // Lowest Low Calculation Method
ENUM_X_FIBO_LEVELS goldenZoneLevel; // Golden Zone Detection
// //
// Parabolic Sar Detection ... // Parabolic Sar Detection ...
@@ -96,6 +99,7 @@ struct X121XPVInputs
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
// //
// Constructor(s) ... // Constructor(s) ...
@@ -136,6 +140,7 @@ struct X121XPVInputs
// Boundary Detection ... // Boundary Detection ...
hhMode = MODE_HIGH; hhMode = MODE_HIGH;
llMode = MODE_LOW; llMode = MODE_LOW;
goldenZoneLevel = X_FIBO_LEVEL_382;
// //
sarStep = 0; sarStep = 0;
@@ -153,6 +158,7 @@ struct X121XPVInputs
showSar = false; showSar = false;
showPeaks = false; showPeaks = false;
showVales = false; showVales = false;
showGoldenZones = true;
// //
ZeroMemory(this); ZeroMemory(this);
@@ -186,6 +192,7 @@ struct X121XPVInputs
// Boundary Detection ... // Boundary Detection ...
hhMode = MODE_HIGH; hhMode = MODE_HIGH;
llMode = MODE_LOW; llMode = MODE_LOW;
goldenZoneLevel = X_FIBO_LEVEL_382;
// //
sarStep = 0.02; sarStep = 0.02;
@@ -203,6 +210,7 @@ struct X121XPVInputs
showSar = true; showSar = true;
showPeaks = true; showPeaks = true;
showVales = true; showVales = true;
showGoldenZones = true;
} }
// //
@@ -261,6 +269,8 @@ struct X121XPVConditions
// Buffers ... // Buffers ...
double peaksBuffer[]; double peaksBuffer[];
double valesBuffer[]; double valesBuffer[];
double peaksGoldenBuffer[];
double valesGoldenBuffer[];
double sarBuffer[]; double sarBuffer[];
double cHHBuffer[]; double cHHBuffer[];
double cLLBuffer[]; double cLLBuffer[];
@@ -331,6 +341,8 @@ struct X121XPVConditions
// //
Clean(peaksBuffer); Clean(peaksBuffer);
Clean(valesBuffer); Clean(valesBuffer);
Clean(peaksGoldenBuffer);
Clean(valesGoldenBuffer);
Clean(sarBuffer); Clean(sarBuffer);
Clean(cHHBuffer); Clean(cHHBuffer);
Clean(cLLBuffer); Clean(cLLBuffer);
@@ -350,6 +362,8 @@ struct X121XPVConditions
// //
ArraySetAsSeries(peaksBuffer, true); ArraySetAsSeries(peaksBuffer, true);
ArraySetAsSeries(valesBuffer, true); ArraySetAsSeries(valesBuffer, true);
ArraySetAsSeries(peaksGoldenBuffer, true);
ArraySetAsSeries(valesGoldenBuffer, true);
ArraySetAsSeries(sarBuffer, true); ArraySetAsSeries(sarBuffer, true);
ArraySetAsSeries(cHHBuffer, true); ArraySetAsSeries(cHHBuffer, true);
ArraySetAsSeries(cLLBuffer, true); ArraySetAsSeries(cLLBuffer, true);
@@ -541,6 +555,8 @@ class XCX121XPVHelper : public XCBaseHelper
// //
Clean(peaksBuffer); Clean(peaksBuffer);
Clean(valesBuffer); Clean(valesBuffer);
Clean(peaksGoldenBuffer);
Clean(valesGoldenBuffer);
Clean(sarBuffer); Clean(sarBuffer);
Clean(cHHBuffer); Clean(cHHBuffer);
Clean(cLLBuffer); Clean(cLLBuffer);
@@ -579,6 +595,8 @@ class XCX121XPVHelper : public XCBaseHelper
// //
ArraySetAsSeries(peaksBuffer, true); ArraySetAsSeries(peaksBuffer, true);
ArraySetAsSeries(valesBuffer, true); ArraySetAsSeries(valesBuffer, true);
ArraySetAsSeries(peaksGoldenBuffer, true);
ArraySetAsSeries(valesGoldenBuffer, true);
ArraySetAsSeries(sarBuffer, true); ArraySetAsSeries(sarBuffer, true);
ArraySetAsSeries(cHHBuffer, true); ArraySetAsSeries(cHHBuffer, true);
ArraySetAsSeries(cLLBuffer, true); ArraySetAsSeries(cLLBuffer, true);
@@ -629,6 +647,7 @@ class XCX121XPVHelper : public XCBaseHelper
"", "",
mInputs.hhMode, mInputs.hhMode,
mInputs.llMode, mInputs.llMode,
mInputs.goldenZoneLevel,
// //
// SAr Detection ... // SAr Detection ...
"", "",
@@ -645,7 +664,8 @@ class XCX121XPVHelper : public XCBaseHelper
// //
mInputs.showSar, mInputs.showSar,
mInputs.showPeaks, mInputs.showPeaks,
mInputs.showVales mInputs.showVales,
mInputs.showGoldenZones
// //
); );
result = mHandler != INVALID_HANDLE; result = mHandler != INVALID_HANDLE;
@@ -843,6 +863,110 @@ class XCX121XPVHelper : public XCBaseHelper
); );
} }
//
// GOLDEN PEAKS ...
//
double GetPeakGoldenZone(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(peaksGoldenBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return peaksGoldenBuffer[barIndex];
}
//
int CopyPeakGoldenZone(
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,
peaksGoldenBuffer,
buffer,
forceClean
//
);
}
//
// GOLDEN VALES ...
//
double GetValeGoldenZone(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(valesGoldenBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return valesGoldenBuffer[barIndex];
}
//
int CopyValeGoldenZone(
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,
valesGoldenBuffer,
buffer,
forceClean
//
);
}
// //
// //
// //
@@ -1929,6 +2053,20 @@ class XCX121XPVHelper : public XCBaseHelper
conditions.valesBuffer // conditions.valesBuffer //
); );
//
CopyPeakGoldenZone(
zIndex,
loopback,
conditions.peaksGoldenBuffer //
);
//
CopyValeGoldenZone(
zIndex,
loopback,
conditions.valesGoldenBuffer //
);
// //
CopyCHH( CopyCHH(
zIndex, zIndex,
@@ -2102,6 +2240,8 @@ class XCX121XPVHelper : public XCBaseHelper
// Buffers ... // Buffers ...
double peaksBuffer[]; double peaksBuffer[];
double valesBuffer[]; double valesBuffer[];
double peaksGoldenBuffer[];
double valesGoldenBuffer[];
double sarBuffer[]; double sarBuffer[];
double cHHBuffer[]; double cHHBuffer[];
double cLLBuffer[]; double cLLBuffer[];
@@ -2158,6 +2298,28 @@ class XCX121XPVHelper : public XCBaseHelper
// //
); );
//
// GOLDEN PEAKS ...
CopyBuffer(
mHandler,
X121_XPV_PEAK_GOLDEN_ZONE_LINE,
0,
maxRequiredBars,
peaksGoldenBuffer
//
);
//
// GOLDEN VALES ...
CopyBuffer(
mHandler,
X121_XPV_VALE_GOLDEN_ZONE_LINE,
0,
maxRequiredBars,
valesGoldenBuffer
//
);
// //
// CURRENT ... // CURRENT ...
@@ -2301,6 +2463,18 @@ class XCX121XPVHelper : public XCBaseHelper
maxAllowed // maxAllowed //
); );
//
CleanupArray(
peaksGoldenBuffer,
maxAllowed //
);
//
CleanupArray(
valesGoldenBuffer,
maxAllowed //
);
// //
CleanupArray( CleanupArray(
sarBuffer, sarBuffer,
+75 -3
View File
@@ -60,6 +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 group "Sar Detection"; input group "Sar Detection";
@@ -80,6 +81,7 @@ input int valesArrowCode = 159; // Vales 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
// //
// Buffers ... // Buffers ...
@@ -94,8 +96,8 @@ input bool showVales = true; // Show Vales
#property indicator_chart_window #property indicator_chart_window
// //
#property indicator_buffers 13 #property indicator_buffers 15
#property indicator_plots 3 #property indicator_plots 5
// //
// Plot Buffers ... // Plot Buffers ...
@@ -136,11 +138,33 @@ double sarBuffer[];
#property indicator_color3 clrYellow #property indicator_color3 clrYellow
#property indicator_width3 1 #property indicator_width3 1
//
#define peaksGoldenZoneBufferIndex 3
double peaksGoldenZoneBuffer[];
//
#property indicator_label4 "X121 PEAKGZ"
#property indicator_type4 DRAW_LINE
#property indicator_color4 clrGold
#property indicator_style4 STYLE_DOT
#property indicator_width4 1
//
#define valesGoldenZoneBufferIndex 4
double valesGoldenZoneBuffer[];
//
#property indicator_label5 "X121 VALEGZ"
#property indicator_type5 DRAW_LINE
#property indicator_color5 clrGold
#property indicator_style5 STYLE_DOT
#property indicator_width5 1
// //
// Data Buffers ... // Data Buffers ...
// //
int mLastBufferIndex = 2; int mLastBufferIndex = 4;
// //
// CURRENT ... // CURRENT ...
@@ -529,6 +553,34 @@ void DefineBuffers()
PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode); PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode);
//
// Golden Zones ...
//
ENUM_DRAW_TYPE goldenZonesDrawType = showGoldenZones ? DRAW_LINE : DRAW_NONE;
//
// PEAK Golden Zone ...
//
ArraySetAsSeries(peaksGoldenZoneBuffer, true);
SetIndexBuffer(peaksGoldenZoneBufferIndex, peaksGoldenZoneBuffer, INDICATOR_DATA);
//
PlotIndexSetInteger(peaksGoldenZoneBufferIndex, PLOT_SHOW_DATA, showGoldenZones);
PlotIndexSetInteger(peaksGoldenZoneBufferIndex, PLOT_DRAW_TYPE, goldenZonesDrawType);
//
// VALE Golden Zone ...
//
ArraySetAsSeries(valesGoldenZoneBuffer, true);
SetIndexBuffer(valesGoldenZoneBufferIndex, valesGoldenZoneBuffer, INDICATOR_DATA);
//
PlotIndexSetInteger(valesGoldenZoneBufferIndex, PLOT_SHOW_DATA, showGoldenZones);
PlotIndexSetInteger(valesGoldenZoneBufferIndex, PLOT_DRAW_TYPE, goldenZonesDrawType);
// //
// Data Buffers ... // Data Buffers ...
@@ -997,6 +1049,26 @@ void CalculatePeaksAndVales(int barIndex)
? sValue ? sValue
: lastVale; : lastVale;
valesBuffer[barIndex] = iVale; valesBuffer[barIndex] = iVale;
//
// Peaks Golden Zone ...
double iPeakGoldenZone = GetFibonacciLevel(
iPeak,
iVale,
goldenZoneLevel,
X_DIRECTION_BULLISH //
);
peaksGoldenZoneBuffer[barIndex] = iPeakGoldenZone;
//
// Vales Golden Zone ...
double iValeGoldenZone = GetFibonacciLevel(
iPeak,
iVale,
goldenZoneLevel,
X_DIRECTION_BEARISH //
);
valesGoldenZoneBuffer[barIndex] = iValeGoldenZone;
} }
// //
@@ -653,7 +653,6 @@ class XC121SMCCycleHelper : public XCBase
color mVolumesColor = clrGreen; // volumes color color mVolumesColor = clrGreen; // volumes color
// //
ChartSetInteger(chartId, CHART_MODE, mMode);
ChartSetInteger(chartId, CHART_SHOW_BID_LINE, mShowBidLine); ChartSetInteger(chartId, CHART_SHOW_BID_LINE, mShowBidLine);
ChartSetInteger(chartId, CHART_SHOW_ASK_LINE, mShowAskLine); ChartSetInteger(chartId, CHART_SHOW_ASK_LINE, mShowAskLine);
ChartSetInteger(chartId, CHART_SHOW_GRID, mShowGrid); ChartSetInteger(chartId, CHART_SHOW_GRID, mShowGrid);
@@ -663,16 +662,20 @@ class XC121SMCCycleHelper : public XCBase
ChartSetInteger(chartId, CHART_QUICK_NAVIGATION, mQuickNavigation); ChartSetInteger(chartId, CHART_QUICK_NAVIGATION, mQuickNavigation);
ChartSetInteger(chartId, CHART_COLOR_FOREGROUND, mForeGroundColor); ChartSetInteger(chartId, CHART_COLOR_FOREGROUND, mForeGroundColor);
ChartSetInteger(chartId, CHART_COLOR_BACKGROUND, mBackGroundColor); ChartSetInteger(chartId, CHART_COLOR_BACKGROUND, mBackGroundColor);
ChartSetInteger(chartId, CHART_COLOR_CHART_UP, mUpColor);
ChartSetInteger(chartId, CHART_COLOR_CHART_DOWN, mDownColor);
ChartSetInteger(chartId, CHART_COLOR_CANDLE_BULL, mBullishColor);
ChartSetInteger(chartId, CHART_COLOR_CANDLE_BEAR, mBearishColor);
ChartSetInteger(chartId, CHART_COLOR_GRID, mGridColor); ChartSetInteger(chartId, CHART_COLOR_GRID, mGridColor);
ChartSetInteger(chartId, CHART_COLOR_BID, mBidLineColor); ChartSetInteger(chartId, CHART_COLOR_BID, mBidLineColor);
ChartSetInteger(chartId, CHART_COLOR_ASK, mAskLineColor); ChartSetInteger(chartId, CHART_COLOR_ASK, mAskLineColor);
ChartSetInteger(chartId, CHART_COLOR_STOP_LEVEL, mStopColor); ChartSetInteger(chartId, CHART_COLOR_STOP_LEVEL, mStopColor);
ChartSetInteger(chartId, CHART_COLOR_CHART_LINE, mLineColor);
ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor); ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor);
//
// For Enabling XCC ...
// ChartSetInteger(chartId, CHART_MODE, mMode);
// ChartSetInteger(chartId, CHART_COLOR_CHART_UP, mUpColor);
// ChartSetInteger(chartId, CHART_COLOR_CHART_DOWN, mDownColor);
// ChartSetInteger(chartId, CHART_COLOR_CANDLE_BULL, mBullishColor);
// ChartSetInteger(chartId, CHART_COLOR_CANDLE_BEAR, mBearishColor);
// ChartSetInteger(chartId, CHART_COLOR_CHART_LINE, mLineColor);
} }
// //
@@ -63,6 +63,7 @@ class XC121SMCExpert : public XCBaseExpert
// Constructor(s) ... // Constructor(s) ...
XC121SMCExpert() XC121SMCExpert()
{ {
mShowCandles = false;
} }
// //
@@ -1185,6 +1186,7 @@ class XC121SMCExpert : public XCBaseExpert
// //
X121XCCInputs xccInputs; X121XCCInputs xccInputs;
xccInputs.Default(); xccInputs.Default();
xccInputs.showCandles = mShowCandles;
xccHelper = new XCX121XCCHelper(); xccHelper = new XCX121XCCHelper();
result = xccHelper.Init( result = xccHelper.Init(
_Symbol, _Symbol,
@@ -1905,6 +1907,9 @@ class XC121SMCExpert : public XCBaseExpert
// //
// Props ... // Props ...
//
bool mShowCandles; // Show Candles ...
// //
// Signalling Props ... // Signalling Props ...
bool mAllowLong; // Allow Long Signals ... bool mAllowLong; // Allow Long Signals ...
@@ -282,29 +282,30 @@ class XCX121SMCXWZSignalDetector : public XCBase
// Detect Signal Box ... // Detect Signal Box ...
// //
// TODO: Check This ... bool isZoneActivated =
// bool isZoneActivated =
// hasWorkingZone &&
// hasWaitingZones &&
// workingZone.IsZoneActivated(
// activatedZoneIDX,
// activatedFVGIDX,
// provider,
// zIndex //
// );
//
hasSignalBox =
hasWorkingZone && hasWorkingZone &&
hasWaitingBoxes && hasWaitingZones &&
workingZone.IsBoxActivated( workingZone.IsZoneActivated(
signalBox, activatedZoneIDX,
activatedFVGIDX,
signalBoxDir, signalBoxDir,
signalProvider, signalProvider,
provider, provider,
zIndex // zIndex //
); );
//
// hasSignalBox =
// hasWorkingZone &&
// hasWaitingBoxes &&
// workingZone.IsBoxActivated(
// signalBox,
// signalBoxDir,
// signalProvider,
// provider,
// zIndex //
// );
// //
if (hasSignalBox) if (hasSignalBox)
{ {
+27 -20
View File
@@ -470,8 +470,7 @@ struct X121SMCStrategyXWZWorkingZone
// //
// Detect OB FVG ... // Detect OB FVG ...
if (false && if (hasNewOrderBlock)
hasNewOrderBlock)
{ {
// //
XOHCL obStartedBar; XOHCL obStartedBar;
@@ -483,8 +482,7 @@ struct X121SMCStrategyXWZWorkingZone
); );
// //
has = isOBStarted && has = isOBStarted;
isOBStartedBodyOut;
if (has) if (has)
{ {
// //
@@ -534,21 +532,21 @@ struct X121SMCStrategyXWZWorkingZone
ob // ob //
) )
// //
|| // ||
// // //
(isBullish // (isBullish
? IsAboveDiff( // ? IsAboveDiff(
iFVG, // iFVG,
ob, // ob,
true // Ignore Inside ... // true // Ignore Inside ...
) // )
: IsBelowDiff( // : IsBelowDiff(
iFVG, // iFVG,
ob, // ob,
true // Ignore Inside ... // true // Ignore Inside ...
) // )
// // //
) // )
// //
; ;
@@ -610,6 +608,10 @@ struct X121SMCStrategyXWZWorkingZone
// //
// //
//
bool lookingOthers = false;
if (lookingOthers)
{
// //
// Check New Order Block Detection Analyse ... // Check New Order Block Detection Analyse ...
XBoxZone analyseOBBox; XBoxZone analyseOBBox;
@@ -691,6 +693,7 @@ struct X121SMCStrategyXWZWorkingZone
// //
analyseOBBox.Clean(); analyseOBBox.Clean();
ZeroMemory(analyseOB); ZeroMemory(analyseOB);
}
// //
// //
@@ -1051,10 +1054,14 @@ struct X121SMCStrategyXWZWorkingZone
// //
// Combine Result ... // Combine Result ...
result = isPVPassed; // result = isPVPassed;
// || isPVPassed // || isPVPassed
// || isPV50Passed // || isPV50Passed
// || isRejected; // || isRejected;
//
result = isPVPassed;
if (result) if (result)
{ {
// //
@@ -762,16 +762,17 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// XPV ... // XPV ...
x121Inputs.xpvInputs.showSar = showAll || false; 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.showGoldenZones = showAll || true;
// //
// XHK ... // XHK ...
// //
x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false; x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false;
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false; x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true;
// //
// XATR ... // XATR ...
@@ -806,9 +807,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// X3MA ... // X3MA ...
x121Inputs.x3maInputs.showX3MaFast = showAll || true; x121Inputs.x3maInputs.showX3MaFast = showAll || false;
x121Inputs.x3maInputs.showX3MaMid = showAll || true; x121Inputs.x3maInputs.showX3MaMid = showAll || false;
x121Inputs.x3maInputs.showX3MaSlow = showAll || true; x121Inputs.x3maInputs.showX3MaSlow = showAll || false;
// //
// Initialize Cycle Helpers ... // Initialize Cycle Helpers ...