last ...
This commit is contained in:
@@ -1,286 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ForexSessionDetector.mq5 |
|
||||
//| Copyright 2023, MetaQuotes Software Corp. |
|
||||
//| https://www.metaquotes.net/ |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2023, MetaQuotes Software Corp."
|
||||
#property link "https://www.metaquotes.net/"
|
||||
#property version "1.00"
|
||||
#property indicator_chart_window
|
||||
#property indicator_buffers 0
|
||||
#property indicator_plots 0
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Session Times |
|
||||
//+------------------------------------------------------------------+
|
||||
input color SydneyColor = clrRoyalBlue; // Sydney session color
|
||||
input color TokyoColor = clrGreen; // Tokyo session color
|
||||
input color LondonColor = clrRed; // London session color
|
||||
input color NewYorkColor = clrDodgerBlue; // New York session color
|
||||
input int TextSize = 8; // Font size
|
||||
input bool ShowHighLow = true; // Show High/Low prices
|
||||
input bool ShowSessionTimes = true; // Show Session Times
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Global Variables |
|
||||
//+------------------------------------------------------------------+
|
||||
struct SessionInfo
|
||||
{
|
||||
string name;
|
||||
int startHour;
|
||||
int startMinute;
|
||||
int endHour;
|
||||
int endMinute;
|
||||
color clr;
|
||||
datetime sessionStart;
|
||||
datetime sessionEnd;
|
||||
double high;
|
||||
double low;
|
||||
bool active;
|
||||
};
|
||||
|
||||
SessionInfo sessions[4];
|
||||
string fontFace = "Arial";
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
// Initialize session information
|
||||
sessions[0].name = "Sydney";
|
||||
sessions[0].startHour = 22;
|
||||
sessions[0].startMinute = 0;
|
||||
sessions[0].endHour = 6;
|
||||
sessions[0].endMinute = 0;
|
||||
sessions[0].clr = SydneyColor;
|
||||
|
||||
sessions[1].name = "Tokyo";
|
||||
sessions[1].startHour = 0;
|
||||
sessions[1].startMinute = 0;
|
||||
sessions[1].endHour = 9;
|
||||
sessions[1].endMinute = 0;
|
||||
sessions[1].clr = TokyoColor;
|
||||
|
||||
sessions[2].name = "London";
|
||||
sessions[2].startHour = 8;
|
||||
sessions[2].startMinute = 0;
|
||||
sessions[2].endHour = 17;
|
||||
sessions[2].endMinute = 0;
|
||||
sessions[2].clr = LondonColor;
|
||||
|
||||
sessions[3].name = "New York";
|
||||
sessions[3].startHour = 13;
|
||||
sessions[3].startMinute = 0;
|
||||
sessions[3].endHour = 22;
|
||||
sessions[3].endMinute = 0;
|
||||
sessions[3].clr = NewYorkColor;
|
||||
|
||||
return (INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator iteration function |
|
||||
//+------------------------------------------------------------------+
|
||||
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[])
|
||||
{
|
||||
// Clear previous objects
|
||||
ObjectsDeleteAll(0, "Session_");
|
||||
|
||||
// Process each session
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ProcessSession(i, time, high, low, rates_total);
|
||||
}
|
||||
|
||||
return (rates_total);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Process a single session |
|
||||
//+------------------------------------------------------------------+
|
||||
void ProcessSession(int sessionIndex, const datetime &time[], const double &high[], const double &low[], int rates_total)
|
||||
{
|
||||
SessionInfo session = sessions[sessionIndex];
|
||||
|
||||
// Find current session start and end times
|
||||
datetime currentTime = TimeCurrent();
|
||||
MqlDateTime currentTimeStruct;
|
||||
TimeToStruct(currentTime, currentTimeStruct);
|
||||
|
||||
datetime sessionStart, sessionEnd;
|
||||
|
||||
// Handle sessions that span midnight
|
||||
if (session.startHour > session.endHour)
|
||||
{
|
||||
// Session spans midnight (e.g., Sydney 22:00-6:00)
|
||||
if (currentTimeStruct.hour >= session.startHour || currentTimeStruct.hour < session.endHour)
|
||||
{
|
||||
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||
if (currentTimeStruct.hour < session.startHour)
|
||||
sessionStart -= 86400; // Previous day
|
||||
sessionEnd = sessionStart + (session.endHour - session.startHour) * 3600 + (session.endMinute - session.startMinute) * 60;
|
||||
if (sessionEnd <= sessionStart)
|
||||
sessionEnd += 86400;
|
||||
session.active = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||
sessionEnd = sessionStart + (session.endHour - session.startHour) * 3600 + (session.endMinute - session.startMinute) * 60;
|
||||
if (sessionEnd <= sessionStart)
|
||||
sessionEnd += 86400;
|
||||
session.active = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal session (doesn't span midnight)
|
||||
if (currentTimeStruct.hour >= session.startHour && currentTimeStruct.hour < session.endHour)
|
||||
{
|
||||
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||
sessionEnd = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.endHour, session.endMinute, 0);
|
||||
session.active = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionStart = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.startHour, session.startMinute, 0);
|
||||
sessionEnd = StructToTime(currentTimeStruct.year, currentTimeStruct.mon, currentTimeStruct.day, session.endHour, session.endMinute, 0);
|
||||
session.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
session.sessionStart = sessionStart;
|
||||
session.sessionEnd = sessionEnd;
|
||||
|
||||
// Find high/low for the session
|
||||
int startIndex = iBarShift(NULL, 0, sessionStart);
|
||||
int endIndex = iBarShift(NULL, 0, sessionEnd);
|
||||
|
||||
if (startIndex == -1 || endIndex == -1)
|
||||
return;
|
||||
|
||||
session.high = high[ArrayMaximum(high, endIndex, startIndex - endIndex + 1)];
|
||||
session.low = low[ArrayMinimum(low, endIndex, startIndex - endIndex + 1)];
|
||||
|
||||
// Draw session information on chart
|
||||
DrawSessionInfo(session, startIndex, endIndex, sessionIndex);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Get chart window price max |
|
||||
//+------------------------------------------------------------------+
|
||||
double GetWindowPriceMax()
|
||||
{
|
||||
double maxPrice;
|
||||
ChartGetDouble(0, CHART_PRICE_MAX, 0, maxPrice);
|
||||
return maxPrice;
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Get chart window price min |
|
||||
//+------------------------------------------------------------------+
|
||||
double GetWindowPriceMin()
|
||||
{
|
||||
double minPrice;
|
||||
ChartGetDouble(0, CHART_PRICE_MIN, 0, minPrice);
|
||||
return minPrice;
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Draw session information on chart |
|
||||
//+------------------------------------------------------------------+
|
||||
void DrawSessionInfo(SessionInfo &session, int startIndex, int endIndex, int sessionIndex)
|
||||
{
|
||||
string objName;
|
||||
color textColor = session.clr;
|
||||
double priceMax = GetWindowPriceMax();
|
||||
double priceMin = GetWindowPriceMin();
|
||||
|
||||
// Draw vertical lines for session start/end
|
||||
objName = "Session_" + session.name + "_Start";
|
||||
ObjectCreate(0, objName, OBJ_VLINE, 0, session.sessionStart, 0);
|
||||
ObjectSetInteger(0, objName, OBJPROP_COLOR, session.clr);
|
||||
ObjectSetInteger(0, objName, OBJPROP_STYLE, STYLE_DOT);
|
||||
ObjectSetInteger(0, objName, OBJPROP_WIDTH, 1);
|
||||
ObjectSetInteger(0, objName, OBJPROP_BACK, true);
|
||||
|
||||
objName = "Session_" + session.name + "_End";
|
||||
ObjectCreate(0, objName, OBJ_VLINE, 0, session.sessionEnd, 0);
|
||||
ObjectSetInteger(0, objName, OBJPROP_COLOR, session.clr);
|
||||
ObjectSetInteger(0, objName, OBJPROP_STYLE, STYLE_DOT);
|
||||
ObjectSetInteger(0, objName, OBJPROP_WIDTH, 1);
|
||||
ObjectSetInteger(0, objName, OBJPROP_BACK, true);
|
||||
|
||||
// Draw session name label
|
||||
if (ShowSessionTimes)
|
||||
{
|
||||
objName = "Session_" + session.name + "_Label";
|
||||
ObjectCreate(0, objName, OBJ_TEXT, 0, session.sessionStart, priceMax - (priceMax - priceMin) * 0.1 * (sessionIndex + 1));
|
||||
ObjectSetString(0, objName, OBJPROP_TEXT, session.name + " " + TimeToString(session.sessionStart, TIME_MINUTES) + " - " + TimeToString(session.sessionEnd, TIME_MINUTES));
|
||||
ObjectSetInteger(0, objName, OBJPROP_COLOR, textColor);
|
||||
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, TextSize);
|
||||
ObjectSetString(0, objName, OBJPROP_FONT, fontFace);
|
||||
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, ANCHOR_LEFT_UPPER);
|
||||
ObjectSetInteger(0, objName, OBJPROP_BACK, false);
|
||||
}
|
||||
|
||||
// Draw high/low prices if enabled
|
||||
if (ShowHighLow)
|
||||
{
|
||||
objName = "Session_" + session.name + "_High";
|
||||
ObjectCreate(0, objName, OBJ_TEXT, 0, session.sessionStart + (session.sessionEnd - session.sessionStart) / 2, session.high);
|
||||
ObjectSetString(0, objName, OBJPROP_TEXT, "H: " + DoubleToString(session.high, _Digits));
|
||||
ObjectSetInteger(0, objName, OBJPROP_COLOR, textColor);
|
||||
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, TextSize);
|
||||
ObjectSetString(0, objName, OBJPROP_FONT, fontFace);
|
||||
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, ANCHOR_LOWER);
|
||||
ObjectSetInteger(0, objName, OBJPROP_BACK, false);
|
||||
|
||||
objName = "Session_" + session.name + "_Low";
|
||||
ObjectCreate(0, objName, OBJ_TEXT, 0, session.sessionStart + (session.sessionEnd - session.sessionStart) / 2, session.low);
|
||||
ObjectSetString(0, objName, OBJPROP_TEXT, "L: " + DoubleToString(session.low, _Digits));
|
||||
ObjectSetInteger(0, objName, OBJPROP_COLOR, textColor);
|
||||
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, TextSize);
|
||||
ObjectSetString(0, objName, OBJPROP_FONT, fontFace);
|
||||
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, ANCHOR_UPPER);
|
||||
ObjectSetInteger(0, objName, OBJPROP_BACK, false);
|
||||
}
|
||||
|
||||
// Highlight active session
|
||||
if (session.active)
|
||||
{
|
||||
objName = "Session_" + session.name + "_Background";
|
||||
ObjectCreate(0, objName, OBJ_RECTANGLE, 0, session.sessionStart, priceMax, session.sessionEnd, priceMin);
|
||||
ObjectSetInteger(0, objName, OBJPROP_COLOR, session.clr);
|
||||
ObjectSetInteger(0, objName, OBJPROP_BGCOLOR, session.clr);
|
||||
ObjectSetInteger(0, objName, OBJPROP_BACK, true);
|
||||
ObjectSetInteger(0, objName, OBJPROP_FILL, true);
|
||||
ObjectSetInteger(0, objName, OBJPROP_WIDTH, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Create datetime from components |
|
||||
//+------------------------------------------------------------------+
|
||||
datetime StructToTime(int year, int month, int day, int hour, int minute, int second)
|
||||
{
|
||||
MqlDateTime mdt;
|
||||
mdt.year = year;
|
||||
mdt.mon = month;
|
||||
mdt.day = day;
|
||||
mdt.hour = hour;
|
||||
mdt.min = minute;
|
||||
mdt.sec = second;
|
||||
return StructToTime(mdt);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -421,6 +421,535 @@ int AddGuard(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool TestDetectSignal(
|
||||
XCXCAEAHelper *helper,
|
||||
XCXCAEAPOIDrawer *drawer,
|
||||
XBoxZone &box,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XCAEAConditions &conditions,
|
||||
int barIndex = 0,
|
||||
int loopback = 10 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
conditions.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
loopback = NormalizeInt(loopback, 5);
|
||||
|
||||
//
|
||||
// Retrieve Some Requirements ...
|
||||
string symbol = helper.GetSymbol();
|
||||
ENUM_TIMEFRAMES period = helper.GetPeriod();
|
||||
double points = GetPoints(symbol);
|
||||
|
||||
//
|
||||
// Retrieve Conditions for Processing ...
|
||||
result = helper.GetConditions(
|
||||
conditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define IDXses ...
|
||||
int zIDX = barIndex;
|
||||
int cIDX = zIDX + 1;
|
||||
int pIDX = cIDX + 1;
|
||||
int p2IDX = pIDX + 1;
|
||||
int p3IDX = p2IDX + 1;
|
||||
int p4IDX = p3IDX + 1;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
XOHCL p3Bar;
|
||||
XOHCL p4Bar;
|
||||
result = zBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
zIDX //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
zBar.GetPreviousBar(cBar);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
result =
|
||||
result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
result =
|
||||
result &&
|
||||
p2Bar.GetPreviousBar(p3Bar);
|
||||
result =
|
||||
result &&
|
||||
p3Bar.GetPreviousBar(p4Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
p3Bar.Clean();
|
||||
p4Bar.Clean();
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Bars Conditions ...
|
||||
|
||||
//
|
||||
// Score ...
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
conditions.GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
|
||||
//
|
||||
bool isScoreBullish =
|
||||
bullishScore > bearishScore;
|
||||
|
||||
//
|
||||
bool isScoreBearish =
|
||||
bearishScore > bullishScore;
|
||||
|
||||
//
|
||||
bool isScoreNeutural = MathAbs(bullishScore - bearishScore) == 0;
|
||||
|
||||
//
|
||||
// Calculating Range Volumes ...
|
||||
|
||||
//
|
||||
double bullishVolume = 0;
|
||||
double bearishVolume = 0;
|
||||
helper.barAnalyser.CalculateRangeVolume(
|
||||
cBar,
|
||||
bullishVolume,
|
||||
bearishVolume,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
bool isVolumeNeutural = MathAbs(bullishVolume - bearishVolume) == 0;
|
||||
|
||||
//
|
||||
// Reading Values ...
|
||||
|
||||
//
|
||||
// PEAK ...
|
||||
double zPeak = conditions.peakBuffer[zIDX];
|
||||
double cPeak = conditions.peakBuffer[cIDX];
|
||||
double pPeak = conditions.peakBuffer[pIDX];
|
||||
double p2Peak = conditions.peakBuffer[p2IDX];
|
||||
double p3Peak = conditions.peakBuffer[p3IDX];
|
||||
double p4Peak = conditions.peakBuffer[p4IDX];
|
||||
|
||||
//
|
||||
// VALE ...
|
||||
double zVale = conditions.valeBuffer[zIDX];
|
||||
double cVale = conditions.valeBuffer[cIDX];
|
||||
double pVale = conditions.valeBuffer[pIDX];
|
||||
double p2Vale = conditions.valeBuffer[p2IDX];
|
||||
double p3Vale = conditions.valeBuffer[p3IDX];
|
||||
double p4Vale = conditions.valeBuffer[p4IDX];
|
||||
|
||||
//
|
||||
// SWING Low ...
|
||||
double zSWL = conditions.swingLowBuffer[zIDX];
|
||||
double cSWL = conditions.swingLowBuffer[cIDX];
|
||||
double pSWL = conditions.swingLowBuffer[pIDX];
|
||||
double p2SWL = conditions.swingLowBuffer[p2IDX];
|
||||
double p3SWL = conditions.swingLowBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// SWING High ...
|
||||
double zSWH = conditions.swingHighBuffer[zIDX];
|
||||
double cSWH = conditions.swingHighBuffer[cIDX];
|
||||
double pSWH = conditions.swingHighBuffer[pIDX];
|
||||
double p2SWH = conditions.swingHighBuffer[p2IDX];
|
||||
double p3SWH = conditions.swingHighBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// SUPPORT ...
|
||||
double zSupport = conditions.supportBuffer[zIDX];
|
||||
double cSupport = conditions.supportBuffer[cIDX];
|
||||
double pSupport = conditions.supportBuffer[pIDX];
|
||||
double p2Support = conditions.supportBuffer[p2IDX];
|
||||
double p3Support = conditions.supportBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// RESISTANCE ...
|
||||
double zResistance = conditions.resistanceBuffer[zIDX];
|
||||
double cResistance = conditions.resistanceBuffer[cIDX];
|
||||
double pResistance = conditions.resistanceBuffer[pIDX];
|
||||
double p2Resistance = conditions.resistanceBuffer[p2IDX];
|
||||
double p3Resistance = conditions.resistanceBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// MAH ...
|
||||
double zMAH = conditions.mahBuffer[zIDX];
|
||||
double cMAH = conditions.mahBuffer[cIDX];
|
||||
double pMAH = conditions.mahBuffer[pIDX];
|
||||
double p2MAH = conditions.mahBuffer[p2IDX];
|
||||
double p3MAH = conditions.mahBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// MAL ...
|
||||
double zMAL = conditions.malBuffer[zIDX];
|
||||
double cMAL = conditions.malBuffer[cIDX];
|
||||
double pMAL = conditions.malBuffer[pIDX];
|
||||
double p2MAL = conditions.malBuffer[p2IDX];
|
||||
double p3MAL = conditions.malBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// MAC ...
|
||||
double zMAC = conditions.macBuffer[zIDX];
|
||||
double cMAC = conditions.macBuffer[cIDX];
|
||||
double pMAC = conditions.macBuffer[pIDX];
|
||||
double p2MAC = conditions.macBuffer[p2IDX];
|
||||
double p3MAC = conditions.macBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// FIBO Level 1 ...
|
||||
double zFib1 = conditions.fiboLevel1Buffer[zIDX];
|
||||
double cFib1 = conditions.fiboLevel1Buffer[cIDX];
|
||||
double pFib1 = conditions.fiboLevel1Buffer[pIDX];
|
||||
double p2Fib1 = conditions.fiboLevel1Buffer[p2IDX];
|
||||
double p3Fib1 = conditions.fiboLevel1Buffer[p3IDX];
|
||||
|
||||
//
|
||||
// FIBO Level 2 ...
|
||||
double zFib2 = conditions.fiboLevel2Buffer[zIDX];
|
||||
double cFib2 = conditions.fiboLevel2Buffer[cIDX];
|
||||
double pFib2 = conditions.fiboLevel2Buffer[pIDX];
|
||||
double p2Fib2 = conditions.fiboLevel2Buffer[p2IDX];
|
||||
double p3Fib2 = conditions.fiboLevel2Buffer[p3IDX];
|
||||
|
||||
//
|
||||
// FIBO Level 3 ...
|
||||
double zFib3 = conditions.fiboLevel3Buffer[zIDX];
|
||||
double cFib3 = conditions.fiboLevel3Buffer[cIDX];
|
||||
double pFib3 = conditions.fiboLevel3Buffer[pIDX];
|
||||
double p2Fib3 = conditions.fiboLevel3Buffer[p2IDX];
|
||||
double p3Fib3 = conditions.fiboLevel3Buffer[p3IDX];
|
||||
|
||||
//
|
||||
// FIBO Level 4 ...
|
||||
double zFib4 = conditions.fiboLevel4Buffer[zIDX];
|
||||
double cFib4 = conditions.fiboLevel4Buffer[cIDX];
|
||||
double pFib4 = conditions.fiboLevel4Buffer[pIDX];
|
||||
double p2Fib4 = conditions.fiboLevel4Buffer[p2IDX];
|
||||
double p3Fib4 = conditions.fiboLevel4Buffer[p3IDX];
|
||||
|
||||
//
|
||||
// FIBO Level 5 ...
|
||||
double zFib5 = conditions.fiboLevel5Buffer[zIDX];
|
||||
double cFib5 = conditions.fiboLevel5Buffer[cIDX];
|
||||
double pFib5 = conditions.fiboLevel5Buffer[pIDX];
|
||||
double p2Fib5 = conditions.fiboLevel5Buffer[p2IDX];
|
||||
double p3Fib5 = conditions.fiboLevel5Buffer[p3IDX];
|
||||
|
||||
//
|
||||
// Create Custom Conditions ...
|
||||
|
||||
//
|
||||
// Bar and Fibo Conditions ...
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
|
||||
//
|
||||
// Strong Reversal ...
|
||||
bool isZBarOnFiboStrongBearish = zBar.low > zFib5;
|
||||
bool isCBarOnFiboStrongBearish = cBar.low > cFib5;
|
||||
bool isPBarOnFiboStrongBearish = pBar.low > pFib5;
|
||||
bool isP2BarOnFiboStrongBearish = p2Bar.low > p2Fib5;
|
||||
bool isP3BarOnFiboStrongBearish = p3Bar.low > p3Fib5;
|
||||
|
||||
//
|
||||
// Golden Zone Reversal ...
|
||||
bool isZBarOnFiboGoldenBearish = zBar.low > zFib3 &&
|
||||
zBar.high < zFib4;
|
||||
bool isCBarOnFiboGoldenBearish = cBar.low > cFib3 &&
|
||||
cBar.high < cFib4;
|
||||
bool isPBarOnFiboGoldenBearish = pBar.low > pFib3 &&
|
||||
pBar.high < pFib4;
|
||||
bool isP2BarOnFiboGoldenBearish = p2Bar.low > p2Fib3 &&
|
||||
p2Bar.high < p2Fib4;
|
||||
bool isP3BarOnFiboGoldenBearish = p3Bar.low > p3Fib3 &&
|
||||
p3Bar.high < p3Fib4;
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
|
||||
//
|
||||
// Strong Reversal ...
|
||||
bool isZBarOnFiboStrongBullish = zBar.high < zFib1;
|
||||
bool isCBarOnFiboStrongBullish = cBar.high < cFib1;
|
||||
bool isPBarOnFiboStrongBullish = pBar.high < pFib1;
|
||||
bool isP2BarOnFiboStrongBullish = p2Bar.high < p2Fib1;
|
||||
bool isP3BarOnFiboStrongBullish = p3Bar.high < p3Fib1;
|
||||
|
||||
//
|
||||
// Golden Zone Reversal ...
|
||||
bool isZBarOnFiboGoldenBullish = zBar.low > zFib2 &&
|
||||
zBar.high < zFib3;
|
||||
bool isCBarOnFiboGoldenBullish = cBar.low > cFib2 &&
|
||||
cBar.high < cFib3;
|
||||
bool isPBarOnFiboGoldenBullish = pBar.low > pFib2 &&
|
||||
pBar.high < pFib3;
|
||||
bool isP2BarOnFiboGoldenBullish = p2Bar.low > p2Fib2 &&
|
||||
p2Bar.high < p2Fib3;
|
||||
bool isP3BarOnFiboGoldenBullish = p3Bar.low > p3Fib2 &&
|
||||
p3Bar.high < p3Fib3;
|
||||
|
||||
//
|
||||
// Score and Volume Conditions ...
|
||||
|
||||
//
|
||||
bool isScoreVolumeNeutural = isScoreNeutural ||
|
||||
isVolumeNeutural;
|
||||
|
||||
//
|
||||
bool isScoreVolumeNeuturalInFiboStrongBullish =
|
||||
isScoreNeutural &&
|
||||
isCBarOnFiboStrongBullish;
|
||||
bool isScoreVolumeNeuturalInFiboGoldenBullish =
|
||||
isScoreNeutural &&
|
||||
isCBarOnFiboGoldenBullish;
|
||||
|
||||
//
|
||||
bool isScoreVolumeNeuturalInFiboStrongBearish =
|
||||
isScoreNeutural &&
|
||||
isCBarOnFiboStrongBearish;
|
||||
bool isScoreVolumeNeuturalInFiboGoldenBearish =
|
||||
isScoreNeutural &&
|
||||
isCBarOnFiboGoldenBearish;
|
||||
|
||||
//
|
||||
bool isScoreVolumeNeuturalBullishPowered =
|
||||
isScoreVolumeNeuturalInFiboStrongBullish ||
|
||||
isScoreVolumeNeuturalInFiboGoldenBullish;
|
||||
bool isScoreVolumeNeuturalBearishPowered =
|
||||
isScoreVolumeNeuturalInFiboStrongBearish ||
|
||||
isScoreVolumeNeuturalInFiboGoldenBearish;
|
||||
|
||||
//
|
||||
// PEAK and VALES ...
|
||||
|
||||
//
|
||||
// PEAK Pivot ...
|
||||
bool isZIsPeakPivot =
|
||||
zPeak == cPeak &&
|
||||
zPeak == zSWH &&
|
||||
zPeak == zResistance &&
|
||||
isZBarOnFiboStrongBearish;
|
||||
bool isCIsPeakPivot =
|
||||
cPeak == pPeak &&
|
||||
cPeak == cSWH &&
|
||||
cPeak == cResistance &&
|
||||
isCBarOnFiboStrongBearish;
|
||||
bool isPIsPeakPivot =
|
||||
pPeak == p2Peak &&
|
||||
pPeak == pSWH &&
|
||||
pPeak == pResistance &&
|
||||
isPBarOnFiboStrongBearish;
|
||||
bool isP2IsPeakPivot =
|
||||
p2Peak == p3Peak &&
|
||||
p2Peak == p2SWH &&
|
||||
p2Peak == p2Resistance &&
|
||||
isP2BarOnFiboStrongBearish;
|
||||
bool isP3IsPeakPivot =
|
||||
p3Peak == p4Peak &&
|
||||
p3Peak == p3SWH &&
|
||||
p3Peak == p3Resistance &&
|
||||
isP3BarOnFiboStrongBearish;
|
||||
|
||||
//
|
||||
// VALE Pivot ...
|
||||
bool isZIsValePivot =
|
||||
zVale == cVale &&
|
||||
zVale == zSWL &&
|
||||
zVale == zSupport &&
|
||||
isZBarOnFiboStrongBullish;
|
||||
bool isCIsValePivot =
|
||||
cVale == pVale &&
|
||||
cVale == cSWL &&
|
||||
cVale == cSupport &&
|
||||
isCBarOnFiboStrongBullish;
|
||||
bool isPIsValePivot =
|
||||
pVale == p2Vale &&
|
||||
pVale == pSWL &&
|
||||
pVale == pSupport &&
|
||||
isPBarOnFiboStrongBullish;
|
||||
bool isP2IsValePivot =
|
||||
p2Vale == p3Vale &&
|
||||
p2Vale == p2SWL &&
|
||||
p2Vale == p2Support &&
|
||||
isP2BarOnFiboStrongBullish;
|
||||
bool isP3IsValePivot =
|
||||
p3Vale == p4Vale &&
|
||||
p3Vale == p3SWL &&
|
||||
p3Vale == p3Support &&
|
||||
isP3BarOnFiboStrongBullish;
|
||||
|
||||
//
|
||||
// Testing Conditions ...
|
||||
|
||||
//
|
||||
// Score and Volume Conditions ...
|
||||
if (isScoreVolumeNeuturalBullishPowered ||
|
||||
isScoreVolumeNeuturalBearishPowered)
|
||||
{
|
||||
//
|
||||
ENUM_X_DIRECTION iScoreVolumeDir =
|
||||
isScoreVolumeNeuturalBullishPowered
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
int timeOffset = (int)cBar.time;
|
||||
string iName = ToString(iScoreVolumeDir) + "_SCVM_" + ToString(timeOffset);
|
||||
color iColor = isScoreVolumeNeuturalBullishPowered
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
ENUM_LINE_STYLE iStyle = STYLE_DOT;
|
||||
|
||||
//
|
||||
// CChartObjectVLine *iObj;
|
||||
// iObj = new CChartObjectVLine();
|
||||
// has = iObj.Create(
|
||||
// 0,
|
||||
// iName,
|
||||
// 0,
|
||||
// cBar.time //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// iObj.Color(iColor);
|
||||
// iObj.Style(iStyle);
|
||||
// }
|
||||
|
||||
// //
|
||||
// Print("Conditions Finder ...");
|
||||
}
|
||||
|
||||
//
|
||||
// PVPivot Conditions ...
|
||||
if (isCIsPeakPivot ||
|
||||
isCIsValePivot)
|
||||
{
|
||||
//
|
||||
ENUM_X_DIRECTION iPVPivotDir =
|
||||
isCIsValePivot
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
int timeOffset = (int)cBar.time;
|
||||
string iName = ToString(iPVPivotDir) + "_PVPVT_" + ToString(timeOffset);
|
||||
color iColor = isCIsValePivot
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
ENUM_LINE_STYLE iStyle = STYLE_DOT;
|
||||
|
||||
// //
|
||||
// CChartObjectVLine *iObj;
|
||||
// iObj = new CChartObjectVLine();
|
||||
// has = iObj.Create(
|
||||
// 0,
|
||||
// iName,
|
||||
// 0,
|
||||
// cBar.time //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// iObj.Color(iColor);
|
||||
// iObj.Style(iStyle);
|
||||
// }
|
||||
|
||||
// //
|
||||
// Print("Conditions Finder ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Summarise Result ...
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Do Signal Preparing ...
|
||||
|
||||
//
|
||||
// Check Box is Prepared or Not ...
|
||||
result = box.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Cleaning Up ...
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
p3Bar.Clean();
|
||||
p4Bar.Clean();
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
conditions.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Cond 2 ...
|
||||
// - a PV Box is Sweep Liquidity;
|
||||
@@ -431,7 +960,6 @@ int AddGuard(
|
||||
//
|
||||
bool DetectXCAEAConditions(
|
||||
XCXCAEAPOIDrawer *drawer,
|
||||
ENUM_X_DIRECTION trend,
|
||||
XBoxZone &pivots[],
|
||||
XCAEAConditions &conditions,
|
||||
XBoxZone &pivotBox,
|
||||
|
||||
@@ -127,24 +127,24 @@ class XCXCAEASignaller : XCBase
|
||||
inputs.x3maInputs.showSlow = false;
|
||||
inputs.x3maInputs.showMedium = false;
|
||||
|
||||
//
|
||||
inputs.caInputs.showMAH = true;
|
||||
inputs.caInputs.showMAL = true;
|
||||
inputs.caInputs.showMAC = true;
|
||||
inputs.caInputs.showSwings = true;
|
||||
inputs.caInputs.showFiboLevel1 = true;
|
||||
inputs.caInputs.showFiboLevel2 = true;
|
||||
inputs.caInputs.showFiboLevel3 = true;
|
||||
inputs.caInputs.showFiboLevel4 = true;
|
||||
inputs.caInputs.showFiboLevel5 = true;
|
||||
inputs.caInputs.showPeaksAndVales = true;
|
||||
|
||||
//
|
||||
inputs.caInputs.showKI = false;
|
||||
inputs.caInputs.showTKI = false;
|
||||
inputs.caInputs.showSar = false;
|
||||
inputs.caInputs.showMAH = true;
|
||||
inputs.caInputs.showMAL = false;
|
||||
inputs.caInputs.showMAC = true;
|
||||
inputs.caInputs.showVidya = false;
|
||||
inputs.caInputs.showTrend = true;
|
||||
inputs.caInputs.showSwings = false;
|
||||
inputs.caInputs.showLongCycle = false;
|
||||
inputs.caInputs.showHindCycle = false;
|
||||
inputs.caInputs.showFiboLevel1 = false;
|
||||
inputs.caInputs.showFiboLevel2 = false;
|
||||
inputs.caInputs.showFiboLevel3 = false;
|
||||
inputs.caInputs.showShortCycle = false;
|
||||
inputs.caInputs.showMediumCycle = false;
|
||||
inputs.caInputs.showPeaksAndVales = true;
|
||||
inputs.caInputs.showTrend = false;
|
||||
inputs.caInputs.showPeakAndValeGolden = false;
|
||||
inputs.caInputs.showSupportAndResistance = false;
|
||||
|
||||
@@ -471,100 +471,111 @@ class XCXCAEASignaller : XCBase
|
||||
|
||||
//
|
||||
// Detecting Pivots ...
|
||||
detector.Detect(
|
||||
zIndex //
|
||||
);
|
||||
// detector.Detect(
|
||||
// zIndex //
|
||||
// );
|
||||
|
||||
//
|
||||
// Validate Pivots ...
|
||||
detector.Validate(
|
||||
unAvailableBoxes,
|
||||
zIndex //
|
||||
);
|
||||
// detector.Validate(
|
||||
// unAvailableBoxes,
|
||||
// zIndex //
|
||||
// );
|
||||
|
||||
//
|
||||
if (detector.pivotDetectionLoopbac > 100)
|
||||
{
|
||||
detector.pivotDetectionLoopbac = 100;
|
||||
}
|
||||
// if (detector.pivotDetectionLoopbac > 100)
|
||||
// {
|
||||
// detector.pivotDetectionLoopbac = 100;
|
||||
// }
|
||||
|
||||
//
|
||||
// Draw Founded Pivots ...
|
||||
// drawer.Draw(cTime);
|
||||
|
||||
//
|
||||
drawer.DrawPeakPivots(cTime);
|
||||
drawer.DrawValePivots(cTime);
|
||||
drawer.DrawFVGBullishPivots(cTime);
|
||||
drawer.DrawFVGBearishPivots(cTime);
|
||||
// drawer.DrawPeakPivots(cTime);
|
||||
// drawer.DrawValePivots(cTime);
|
||||
// drawer.DrawFVGBullishPivots(cTime);
|
||||
// drawer.DrawFVGBearishPivots(cTime);
|
||||
// drawer.DrawTrendBullishPivots(cTime);
|
||||
// drawer.DrawTrendBearishPivots(cTime);
|
||||
|
||||
//
|
||||
// Retrieve Valid Pviots ...
|
||||
pivotsCount = detector.FillPivots(pivots);
|
||||
hasPivots = IsValidSize(pivotsCount);
|
||||
// pivotsCount = detector.FillPivots(pivots);
|
||||
// hasPivots = IsValidSize(pivotsCount);
|
||||
|
||||
//
|
||||
// Filter UnAvailable Boxes ...
|
||||
if (hasPivots)
|
||||
{
|
||||
//
|
||||
// Remove UnAvailable Boxes ...
|
||||
has = HasChild(unAvailableBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = ArraySize(unAvailableBoxes);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = unAvailableBoxes[i];
|
||||
// if (hasPivots)
|
||||
// {
|
||||
// //
|
||||
// // Remove UnAvailable Boxes ...
|
||||
// has = HasChild(unAvailableBoxes);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// count = ArraySize(unAvailableBoxes);
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// XBoxZone iBox = unAvailableBoxes[i];
|
||||
|
||||
//
|
||||
has = FindBoxIndex(
|
||||
idx,
|
||||
iBox,
|
||||
pivots //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
pivots,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// //
|
||||
// has = FindBoxIndex(
|
||||
// idx,
|
||||
// iBox,
|
||||
// pivots //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// ArrayRemove(
|
||||
// pivots,
|
||||
// idx,
|
||||
// 1 //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
hasPivots = HasChild(pivots);
|
||||
pivotsCount = ArraySize(pivots);
|
||||
}
|
||||
// //
|
||||
// hasPivots = HasChild(pivots);
|
||||
// pivotsCount = ArraySize(pivots);
|
||||
// }
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// Detect Sinal Box ...
|
||||
hasSignalBox = DetectXCAEAConditions(
|
||||
drawer,
|
||||
trend,
|
||||
pivots,
|
||||
conditions,
|
||||
pivotBox,
|
||||
signalBox,
|
||||
targets,
|
||||
additionalSL,
|
||||
signalBoxDir,
|
||||
TestDetectSignal(
|
||||
helper,
|
||||
drawer,
|
||||
signalBox,
|
||||
signalBoxDir,
|
||||
conditions,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
// //
|
||||
// // Detect Sinal Box ...
|
||||
// hasSignalBox = DetectXCAEAConditions(
|
||||
// drawer,
|
||||
// trend,
|
||||
// pivots,
|
||||
// conditions,
|
||||
// pivotBox,
|
||||
// signalBox,
|
||||
// targets,
|
||||
// additionalSL,
|
||||
// signalBoxDir,
|
||||
// helper,
|
||||
// zIndex,
|
||||
// loopback //
|
||||
// );
|
||||
|
||||
//
|
||||
// Make Pivot Box UnAvailable ...
|
||||
if (pivotBox.IsValid())
|
||||
|
||||
Reference in New Issue
Block a user