cleanup backup folder ...
This commit is contained in:
@@ -1,245 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Valid_Break_Detector |
|
||||
//| Copyright 2023, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2023, MetaQuotes Software Corp."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
#property description "Detects Valid Breakouts of Zones with Rejection Confirmation"
|
||||
|
||||
// Input Parameters
|
||||
input double LotSize = 0.1; // Lot size for trades
|
||||
input int StopLoss = 50; // Stop Loss in points
|
||||
input int TakeProfit = 100; // Take Profit in points
|
||||
input bool RequireVolumeSpike = true; // Enable volume spike filter
|
||||
input double VolumeThreshold = 1.5; // Minimum volume increase factor
|
||||
input bool RequireCloseBeyond = true; // Require candle close beyond the zone
|
||||
input int RejectionConfirmationCandles = 2; // Number of candles to confirm rejection
|
||||
|
||||
// Global Variables
|
||||
int MagicNumber = 789101;
|
||||
|
||||
//
|
||||
double _Ask = 0;
|
||||
double _Bid = 0;
|
||||
|
||||
// Zone Boundaries
|
||||
double ZoneHigh = 0;
|
||||
double ZoneLow = 0;
|
||||
|
||||
//
|
||||
double maBuffer[];
|
||||
int maHandler = INVALID_HANDLE;
|
||||
|
||||
// Breakout Status
|
||||
bool BullishBreakoutDetected = false;
|
||||
bool BearishBreakoutDetected = false;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
ArraySetAsSeries(maBuffer, true);
|
||||
maHandler = iMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
14,
|
||||
0,
|
||||
MODE_SMA,
|
||||
VOLUME_TICK //
|
||||
);
|
||||
if (maHandler == INVALID_HANDLE)
|
||||
{
|
||||
return (INIT_FAILED);
|
||||
}
|
||||
|
||||
//
|
||||
Print("Valid Break Detector EA Initialized");
|
||||
return (INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert deinitialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
IndicatorRelease(maHandler);
|
||||
Print("Valid Break Detector EA Deinitialized");
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert tick function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
_Ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||||
_Bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||||
CopyBuffer(maHandler, MAIN_LINE, 0, 14, maBuffer);
|
||||
|
||||
// Define the zone dynamically (e.g., based on recent highs/lows)
|
||||
DefineZone();
|
||||
|
||||
// Check for valid break of the zone
|
||||
CheckValidBreak();
|
||||
|
||||
// Confirm rejection after breakout
|
||||
if (BullishBreakoutDetected || BearishBreakoutDetected)
|
||||
ConfirmRejection();
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Function to define the zone dynamically |
|
||||
//+------------------------------------------------------------------+
|
||||
void DefineZone()
|
||||
{
|
||||
// Example: Define zone based on recent highs and lows
|
||||
ZoneHigh = iHigh(_Symbol, _Period, 1); // Recent high
|
||||
ZoneLow = iLow(_Symbol, _Period, 2); // Recent low
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Function to check for a valid break of the zone |
|
||||
//+------------------------------------------------------------------+
|
||||
void CheckValidBreak()
|
||||
{
|
||||
double currentPrice = _Bid;
|
||||
|
||||
// Check if price breaks above the zone
|
||||
if (!BullishBreakoutDetected && currentPrice > ZoneHigh)
|
||||
{
|
||||
if (IsValidBreak(ZoneHigh, true))
|
||||
{
|
||||
Print("Potential Bullish Break Above Zone Detected at ", TimeToString(TimeCurrent(), TIME_DATE));
|
||||
BullishBreakoutDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if price breaks below the zone
|
||||
if (!BearishBreakoutDetected && currentPrice < ZoneLow)
|
||||
{
|
||||
if (IsValidBreak(ZoneLow, false))
|
||||
{
|
||||
Print("Potential Bearish Break Below Zone Detected at ", TimeToString(TimeCurrent(), TIME_DATE));
|
||||
BearishBreakoutDetected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Function to validate the breakout |
|
||||
//+------------------------------------------------------------------+
|
||||
bool IsValidBreak(double zoneLevel, bool isAbove)
|
||||
{
|
||||
// Check if the candle closed beyond the zone
|
||||
if (RequireCloseBeyond)
|
||||
{
|
||||
double closePrice = iClose(_Symbol, _Period, 1);
|
||||
if ((isAbove && closePrice <= zoneLevel) || (!isAbove && closePrice >= zoneLevel))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for a volume spike
|
||||
if (RequireVolumeSpike)
|
||||
{
|
||||
double currentVolume = (double) iVolume(_Symbol, _Period, 1);
|
||||
double averageVolume = maBuffer[1];
|
||||
if (currentVolume < VolumeThreshold * averageVolume)
|
||||
return false;
|
||||
}
|
||||
|
||||
// All conditions met, valid breakout
|
||||
return true;
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Function to confirm rejection |
|
||||
//+------------------------------------------------------------------+
|
||||
void ConfirmRejection()
|
||||
{
|
||||
double currentPrice = _Bid;
|
||||
|
||||
if (BullishBreakoutDetected)
|
||||
{
|
||||
// Check if price rejects lower levels and confirms bullish breakout
|
||||
bool confirmed = true;
|
||||
for (int i = 1; i <= RejectionConfirmationCandles; i++)
|
||||
{
|
||||
double closePrice = iClose(_Symbol, _Period, i);
|
||||
if (closePrice < ZoneHigh)
|
||||
{
|
||||
confirmed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (confirmed)
|
||||
{
|
||||
Print("Bullish Breakout Confirmed at ", TimeToString(TimeCurrent(), TIME_DATE));
|
||||
PlaceTrade(ORDER_TYPE_BUY, "Confirmed Bullish Breakout Buy");
|
||||
BullishBreakoutDetected = false; // Reset breakout status
|
||||
}
|
||||
}
|
||||
|
||||
if (BearishBreakoutDetected)
|
||||
{
|
||||
// Check if price rejects higher levels and confirms bearish breakout
|
||||
bool confirmed = true;
|
||||
for (int i = 1; i <= RejectionConfirmationCandles; i++)
|
||||
{
|
||||
double closePrice = iClose(_Symbol, _Period, i);
|
||||
if (closePrice > ZoneLow)
|
||||
{
|
||||
confirmed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (confirmed)
|
||||
{
|
||||
Print("Bearish Breakout Confirmed at ", TimeToString(TimeCurrent(), TIME_DATE));
|
||||
PlaceTrade(ORDER_TYPE_SELL, "Confirmed Bearish Breakout Sell");
|
||||
BearishBreakoutDetected = false; // Reset breakout status
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Function to place a trade |
|
||||
//+------------------------------------------------------------------+
|
||||
void PlaceTrade(int orderType, string comment)
|
||||
{
|
||||
double price = (orderType == ORDER_TYPE_BUY) ? _Ask : _Bid;
|
||||
double sl = (orderType == ORDER_TYPE_BUY) ? price - StopLoss * Point() : price + StopLoss * Point();
|
||||
double tp = (orderType == ORDER_TYPE_BUY) ? price + TakeProfit * Point() : price - TakeProfit * Point();
|
||||
|
||||
MqlTradeRequest request;
|
||||
MqlTradeResult result;
|
||||
|
||||
ZeroMemory(request);
|
||||
ZeroMemory(result);
|
||||
|
||||
request.action = TRADE_ACTION_DEAL;
|
||||
request.symbol = _Symbol;
|
||||
request.volume = LotSize;
|
||||
request.type = orderType;
|
||||
request.price = price;
|
||||
request.sl = sl;
|
||||
request.tp = tp;
|
||||
request.deviation = 10;
|
||||
request.magic = MagicNumber;
|
||||
request.comment = comment;
|
||||
|
||||
if (!OrderSend(request, result))
|
||||
{
|
||||
Print("Error placing order: ", result.retcode);
|
||||
}
|
||||
else
|
||||
{
|
||||
Print(comment, " Order placed successfully.");
|
||||
}
|
||||
}
|
||||
@@ -1,830 +0,0 @@
|
||||
//
|
||||
bool HasSenario1Conditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XBoxZone &box,
|
||||
XBoxZone &holderBox,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XBoxZone &waitingBoxes[],
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Fil Selected Data ...
|
||||
XPOIState cState;
|
||||
X121Conditions cXConditions;
|
||||
XPOIStateEvents cStateEvents;
|
||||
XC121SMCCycleHelper *cHelper;
|
||||
X121SMCCycleConditions cConditions;
|
||||
result = provider.SelectCycle(
|
||||
cycle,
|
||||
cState,
|
||||
cStateEvents,
|
||||
cXConditions,
|
||||
cHelper,
|
||||
cConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
Parse(cXConditions);
|
||||
|
||||
//
|
||||
// Fil Selected Data ...
|
||||
XPOIState chState;
|
||||
X121Conditions chXConditions;
|
||||
XPOIStateEvents chStateEvents;
|
||||
XC121SMCCycleHelper *chHelper;
|
||||
X121SMCCycleConditions chConditions;
|
||||
if (holderCycle != X_CYCLE_NONE)
|
||||
{
|
||||
//
|
||||
result = provider.SelectCycle(
|
||||
holderCycle,
|
||||
chState,
|
||||
chStateEvents,
|
||||
chXConditions,
|
||||
chHelper,
|
||||
chConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
chState.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
chStateEvents.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Parse(chXConditions);
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Waiting Baoxes Exists ...
|
||||
result = HasChild(waitingBoxes);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCPOIDrawer *drawer = provider
|
||||
.visionCycleHelper
|
||||
.mPOIDrawer;
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
holderBox.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
int zIDX = barIndex;
|
||||
int cIDX = zIDX + 1;
|
||||
int pIDX = cIDX + 1;
|
||||
int ppIDX = pIDX + 1;
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
XOHCL pBar;
|
||||
|
||||
//
|
||||
// Initial Bars ...
|
||||
result = zBar.Init(
|
||||
cState.symbol,
|
||||
cState.period,
|
||||
barIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
zBar.GetPreviousBar(cBar);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
chState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Inside Box ...
|
||||
XBoxZone insideBox;
|
||||
count = ArraySize(waitingBoxes);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = waitingBoxes[i];
|
||||
bool isBullish = iBox.IsBullish();
|
||||
double iMid = iBox.lower + ((iBox.upper - iBox.lower) / 2);
|
||||
|
||||
//
|
||||
has =
|
||||
//
|
||||
isBullish
|
||||
? cBar.low < iMid &&
|
||||
cBar.low > iBox.lower
|
||||
: cBar.high > iMid &&
|
||||
cBar.high < iBox.upper
|
||||
//
|
||||
;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
insideBox = iBox;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
has = insideBox.IsValid();
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION iBarPosDir;
|
||||
bool isBarValidForDir = cHelper
|
||||
.mBarAnalyser
|
||||
.IsValidForPosition(
|
||||
cBar,
|
||||
iBarPosDir //
|
||||
);
|
||||
bool isBarValidForBullish =
|
||||
isBarValidForDir &&
|
||||
IsBullish(iBarPosDir);
|
||||
bool isBarValidForBearish =
|
||||
isBarValidForDir &&
|
||||
IsBearish(iBarPosDir);
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
has = drawer.DrawBox(
|
||||
insideBox,
|
||||
iObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Print("Dec Scores:");
|
||||
Print("-------------");
|
||||
Print("Bull: ", provider.decisionBullishScore);
|
||||
Print("Bear: ", provider.decisionBearishScore);
|
||||
Print("-------------");
|
||||
Print("Anal Scores:");
|
||||
Print("-------------");
|
||||
Print("Bull: ", provider.analyseBullishScore);
|
||||
Print("Bear: ", provider.analyseBearishScore);
|
||||
Print("-------------");
|
||||
Print("Bar Valid For: " + ToString(iBarPosDir));
|
||||
Print("-------------");
|
||||
Print(ToString(insideBox.dir), " Inside ...");
|
||||
Print("-------------");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = has;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
chState.Clean();
|
||||
insideBox.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detecting Signal Conditions ...
|
||||
|
||||
//
|
||||
// Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
insideBox.IsBullish() &&
|
||||
isBarValidForBullish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
insideBox.IsBearish() &&
|
||||
isBarValidForBearish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Filling Requirements ...
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
box.dir = dir;
|
||||
box.to = TimeCurrent();
|
||||
box.from = insideBox.from;
|
||||
box.upper = insideBox.upper;
|
||||
box.lower = insideBox.lower;
|
||||
box.symbol = cXConditions.symbol;
|
||||
box.period = cXConditions.period;
|
||||
}
|
||||
|
||||
//
|
||||
// Check All Conditions ...
|
||||
result =
|
||||
box.IsValid() &&
|
||||
HasDirection(dir) &&
|
||||
(isBullish ||
|
||||
isBearish);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
chState.Clean();
|
||||
insideBox.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
cXConditions.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chStateEvents.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Checking a Box Exists in Collections or not ...
|
||||
*
|
||||
* @param box: XBoxZone instance reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsExists(XBoxZone &box)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Check Validation ...
|
||||
result = box.IsValid() &&
|
||||
(HasWaitingBoxes() ||
|
||||
HasBreakedBoxes() ||
|
||||
HasUnavailableBoxes());
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
// Check Index in Waiting Boxes ...
|
||||
has = HasWaitingBoxes();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
box,
|
||||
waitingBoxes //
|
||||
);
|
||||
result = IsValidIndex(idx);
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Index in Breaked Boxes ...
|
||||
has = HasBreakedBoxes();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
box,
|
||||
breakedBoxes //
|
||||
);
|
||||
result = IsValidIndex(idx);
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Index in Unavailable Boxes ...
|
||||
has = HasUnavailableBoxes();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
idx = FindIndex(
|
||||
box,
|
||||
unavailableBoxes //
|
||||
);
|
||||
result = IsValidIndex(idx);
|
||||
if (result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Detect Signal Boxes ...
|
||||
*
|
||||
* @param cycle: ENUM_X_CYCLES member ...
|
||||
* @param provider: X121SMCStrategySignalProviderData instance reference ...
|
||||
* @param barIndex: int ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectSignalBoxes(
|
||||
ENUM_X_CYCLES cycle,
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Select Cycle ...
|
||||
XPOIState cState;
|
||||
XPOIStateEvents cStateEvents;
|
||||
X121Conditions cXConditions;
|
||||
XC121SMCCycleHelper *cHelper;
|
||||
X121SMCCycleConditions cConditions;
|
||||
result = provider.SelectCycle(
|
||||
cycle,
|
||||
cState,
|
||||
cStateEvents,
|
||||
cXConditions,
|
||||
cHelper,
|
||||
cConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select Rejection Boxes ...
|
||||
|
||||
// //
|
||||
// // Select Validate Rejection Boxes ...
|
||||
// XBoxZone rejections[];
|
||||
// int count = cHelper
|
||||
// .DetectRejections(
|
||||
// rejections,
|
||||
// barIndex //
|
||||
// );
|
||||
|
||||
// //
|
||||
// result = IsValidSize(count);
|
||||
// if (result)
|
||||
// {
|
||||
// //
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(rejections[i]);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// rejections[i],
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Select Order Blocks ...
|
||||
// if (cStateEvents.hasNewOrderBlock)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.orderBlocks);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCOrderBlock *iOB = cState.orderBlocks[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iOB //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Select Fair Value Gaps ...
|
||||
// if (cStateEvents.hasNewFairValueGap)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.fairValueGaps);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCFVG *iOB = cState.fairValueGaps[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iOB //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Select Supply/Demand Zones ...
|
||||
// if (cStateEvents.hasNewSupplyZone)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.supplyZones);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCSupplyZone *iSupply = cState.supplyZones[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iSupply //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (cStateEvents.hasNewDemandZone)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.demandZones);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCDemandZone *iDemand = cState.demandZones[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iDemand //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Select Support/Resistance Zones ...
|
||||
// if (cStateEvents.hasNewSupportZone)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.supportZones);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCSupportZone *iSupport = cState.supportZones[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iSupport //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (cStateEvents.hasNewResistanceZone)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.resistanceZones);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCResistanceZone *iResistance = cState.resistanceZones[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iResistance //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
count = CountWaitingBoxes();
|
||||
result = IsValidSize(count);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validating Waiting Boxes and Detect Breaked Boxes ...
|
||||
*
|
||||
* @param barIndex: int ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int ValidateWaitingBoxes(
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
if (barIndex == 0)
|
||||
{
|
||||
barIndex = 1;
|
||||
}
|
||||
|
||||
//
|
||||
has = HasWaitingBoxes();
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int removeIDX[];
|
||||
result = CountWaitingBoxes();
|
||||
for (int i = 0; i < result; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
XBoxZone iBox = waitingBoxes[i];
|
||||
bool isInite = iBar
|
||||
.Init(
|
||||
iBox.symbol,
|
||||
iBox.period,
|
||||
iBox.from //
|
||||
);
|
||||
|
||||
//
|
||||
has = isInite &&
|
||||
IsBoxBreaked(
|
||||
iBox,
|
||||
iBar.Index() - 1,
|
||||
barIndex,
|
||||
period //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
i,
|
||||
removeIDX //
|
||||
);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iBox,
|
||||
breakedBoxes //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
has = HasChild(removeIDX);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
removeIDX,
|
||||
waitingBoxes //
|
||||
);
|
||||
}
|
||||
Clean(removeIDX);
|
||||
|
||||
//
|
||||
result = CountWaitingBoxes();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,121 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| 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;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -1,584 +0,0 @@
|
||||
|
||||
//
|
||||
// Configurations ...
|
||||
bool useSharpChange = false;
|
||||
bool useOrderBlockFVG = false;
|
||||
|
||||
//
|
||||
// Select Order Blocks ...
|
||||
if (useOrderBlockFVG)
|
||||
{
|
||||
//
|
||||
if (obStateEvents.hasNewOrderBlock)
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(obState.orderBlocks);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCFVG *iFVG = NULL;
|
||||
XCOrderBlock *iOB = obState.orderBlocks[idx];
|
||||
bool isBullish = iOB.IsBullish();
|
||||
|
||||
//
|
||||
// Detecting Inside FVG ...
|
||||
has = fvgState.HasFairValueGaps();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCFVG *tmpFVGs[];
|
||||
count = fvgState.CountFairValueGaps();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCFVG *jFVG = fvgState.fairValueGaps[i];
|
||||
|
||||
//
|
||||
bool isDirPassed = jFVG.GetDirection() == iOB.GetDirection();
|
||||
bool isFromPassed = jFVG.From() >= iOB.From();
|
||||
bool isPlacePassed = IsInsideOrDiff(
|
||||
jFVG,
|
||||
iOB,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
has = isDirPassed &&
|
||||
isFromPassed &&
|
||||
isPlacePassed;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
jFVG,
|
||||
tmpFVGs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(jFVG);
|
||||
}
|
||||
|
||||
//
|
||||
// Selecting iFVG Based on Direction of OB ...
|
||||
has = HasChild(tmpFVGs);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
idx =
|
||||
isBullish
|
||||
? GetLowest(tmpFVGs)
|
||||
: GetHighest(tmpFVGs);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
iFVG = tmpFVGs[idx];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpFVGs);
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iOBBox;
|
||||
XBoxZone iFVGBox;
|
||||
if (iFVG != NULL)
|
||||
{
|
||||
//
|
||||
has = ToBox(
|
||||
iFVGBox,
|
||||
iFVG //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
has = ToBox(
|
||||
iOBBox,
|
||||
iOB //
|
||||
);
|
||||
|
||||
//
|
||||
has = iOBBox.IsValid() &&
|
||||
iFVGBox.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XSignalBox iSignalBox;
|
||||
|
||||
//
|
||||
iSignalBox.ob = iOBBox;
|
||||
iSignalBox.fvg = iFVGBox;
|
||||
|
||||
//
|
||||
// Here We Check Waiting Box Contains Other Zones ...
|
||||
// Like Support/Resistances ...
|
||||
bool forceVerification = false;
|
||||
if (forceVerification)
|
||||
{
|
||||
//
|
||||
XBoxZone iVerificationBox;
|
||||
XBoxZone tmpBoxes[];
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
ToBox(
|
||||
provider.decisionState.supportZones,
|
||||
tmpBoxes //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
ToBox(
|
||||
provider.decisionState.resistanceZones,
|
||||
tmpBoxes //
|
||||
);
|
||||
}
|
||||
has = HasChild(tmpBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
while (HasChild(tmpBoxes))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(tmpBoxes);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Select Box ...
|
||||
XBoxZone iBox = tmpBoxes[idx];
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Box ...
|
||||
bool isValidPassed = !IsBoxValid(
|
||||
iBox,
|
||||
barIndex //
|
||||
);
|
||||
bool isDirPassed = iBox.dir == iOBBox.dir;
|
||||
bool isPlacePassed =
|
||||
IsBoxInside(
|
||||
iBox,
|
||||
iOBBox //
|
||||
)
|
||||
//
|
||||
&&
|
||||
//
|
||||
(!iFVGBox.IsValid()
|
||||
? true
|
||||
: IsBoxInsideOr(
|
||||
iBox,
|
||||
iFVGBox //
|
||||
));
|
||||
|
||||
//
|
||||
has =
|
||||
isDirPassed &&
|
||||
isValidPassed &&
|
||||
isPlacePassed;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iVerificationBox = iBox;
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
has = iVerificationBox.IsValid();
|
||||
Clean(tmpBoxes);
|
||||
iVerificationBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iSignalBox,
|
||||
waitingBoxes //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iSignalBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
iOBBox.Clean();
|
||||
iFVGBox.Clean();
|
||||
ZeroMemory(iOB);
|
||||
ZeroMemory(iFVG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Other Senario for Waiting Boxes ...
|
||||
if (useSharpChange)
|
||||
{
|
||||
//
|
||||
if (obStateEvents.hasNewSharp)
|
||||
{
|
||||
//
|
||||
XBoxZone currSharp;
|
||||
XBoxZone prevSharp;
|
||||
XBoxZone sharpConsolidation;
|
||||
|
||||
//
|
||||
// Retrieve Current Sharp ...
|
||||
XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer;
|
||||
XBoxZone tmpBoxes[];
|
||||
Copy(
|
||||
obState.sharps,
|
||||
tmpBoxes //
|
||||
);
|
||||
idx = GetYoungest(tmpBoxes);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
currSharp = tmpBoxes[idx];
|
||||
bool isBullish = currSharp.IsBullish();
|
||||
|
||||
//
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
while (HasChild(tmpBoxes))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(tmpBoxes);
|
||||
has = IsValidIndex(idx);
|
||||
|
||||
//
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[idx];
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
if (iBox.dir == currSharp.dir)
|
||||
{
|
||||
//
|
||||
prevSharp = iBox;
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
}
|
||||
Clean(tmpBoxes);
|
||||
|
||||
//
|
||||
// Preparing Sharp Consolidation Box ...
|
||||
has = currSharp.IsValid() &&
|
||||
prevSharp.IsValid() &&
|
||||
prevSharp.lower < currSharp.upper;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
sharpConsolidation.type = "XSHCNZ";
|
||||
sharpConsolidation.dir = currSharp.dir;
|
||||
sharpConsolidation.symbol = currSharp.symbol;
|
||||
sharpConsolidation.period = currSharp.period;
|
||||
|
||||
//
|
||||
sharpConsolidation.from = prevSharp.to;
|
||||
sharpConsolidation.to = currSharp.from;
|
||||
|
||||
//
|
||||
int toIDX = GetBarIndex(
|
||||
currSharp.symbol,
|
||||
currSharp.period,
|
||||
sharpConsolidation.to //
|
||||
);
|
||||
int fromIDX = GetBarIndex(
|
||||
currSharp.symbol,
|
||||
currSharp.period,
|
||||
sharpConsolidation.from //
|
||||
);
|
||||
int length = fromIDX - toIDX;
|
||||
|
||||
//
|
||||
XOHCL toBar;
|
||||
has = toBar.Init(
|
||||
sharpConsolidation.symbol,
|
||||
sharpConsolidation.period,
|
||||
toIDX //
|
||||
);
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
double upper = toBar.FindHighest(
|
||||
length,
|
||||
MODE_HIGH //
|
||||
);
|
||||
|
||||
//
|
||||
double lower = toBar.FindLowest(
|
||||
length,
|
||||
MODE_LOW //
|
||||
);
|
||||
|
||||
//
|
||||
sharpConsolidation.upper = upper;
|
||||
sharpConsolidation.lower = lower;
|
||||
}
|
||||
|
||||
//
|
||||
has = sharpConsolidation.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XSignalBox iBox;
|
||||
|
||||
//
|
||||
iBox.ob = sharpConsolidation;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iBox,
|
||||
waitingBoxes //
|
||||
);
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
|
||||
// //
|
||||
// XCBoxObject *iCBoxObj;
|
||||
// XCBoxObject *iPBoxObj;
|
||||
// provider.visionCycleHelper.mPOIDrawer.DrawBox(
|
||||
// currSharp,
|
||||
// iCBoxObj //
|
||||
// );
|
||||
// provider.visionCycleHelper.mPOIDrawer.DrawBox(
|
||||
// prevSharp,
|
||||
// iPBoxObj //
|
||||
// );
|
||||
}
|
||||
|
||||
//
|
||||
currSharp.Clean();
|
||||
prevSharp.Clean();
|
||||
sharpConsolidation.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Exists Box ...
|
||||
// XBoxZone fvgs[];
|
||||
// count = ArraySize(waitingBoxes);
|
||||
// has = IsValidSize(count);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// bool isSharpBox = waitingBoxes[i].ob.type == "XSHCNZ";
|
||||
// if (!isSharpBox)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isBullish = waitingBoxes[i].ob.IsBullish();
|
||||
|
||||
// //
|
||||
// // Extract Inside FVGS ...
|
||||
// if (isBullish)
|
||||
// {
|
||||
// //
|
||||
// ToBox(
|
||||
// fvgState.bullishFairValueGaps,
|
||||
// fvgs //
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// ToBox(
|
||||
// fvgState.bearishFairValueGaps,
|
||||
// fvgs //
|
||||
// );
|
||||
// }
|
||||
// has = HasChild(fvgs);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// int removeds[];
|
||||
// int iFVGsCount = ArraySize(fvgs);
|
||||
// for (int j = 0; j < iFVGsCount; j++)
|
||||
// {
|
||||
// //
|
||||
// XBoxZone iFVGBox = fvgs[j];
|
||||
// bool isFromPassed = iFVGBox.from >= waitingBoxes[i].ob.from;
|
||||
// bool isBoundaryPassed =
|
||||
// isBullish
|
||||
// ? iFVGBox.lower < waitingBoxes[i].ob.upper
|
||||
// : iFVGBox.upper > waitingBoxes[i].ob.lower;
|
||||
|
||||
// //
|
||||
// has = isFromPassed &&
|
||||
// isBoundaryPassed;
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// j,
|
||||
// removeds //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// CleanupArray(
|
||||
// removeds,
|
||||
// fvgs //
|
||||
// );
|
||||
// Clean(removeds);
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Select FVG ...
|
||||
// has = HasChild(fvgs);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// idx = isBullish
|
||||
// ? GetLowest(fvgs)
|
||||
// : GetHighest(fvgs);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// waitingBoxes[i].fvg = fvgs[idx];
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// waitingBoxes[i].fvg.Clean();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Clean(fvgs);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (signalProvider == X121SMC_XWZ_PROVIDER_XHKMA)
|
||||
{
|
||||
//
|
||||
iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 0;
|
||||
|
||||
//
|
||||
// Prepare Box fro SL ...
|
||||
iSL = pivot;
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
|
||||
//
|
||||
// Fix rf Reward ...
|
||||
rfRewar = 2;
|
||||
}
|
||||
else if (signalProvider == X121SMC_XWZ_PROVIDER_XREJECTED_BOX)
|
||||
{
|
||||
//
|
||||
iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 0;
|
||||
|
||||
//
|
||||
Clean(sls);
|
||||
|
||||
//
|
||||
// Prepare Box fro SL ...
|
||||
iSL = signalBox.lower + ((signalBox.upper - signalBox.lower) / 2);
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
|
||||
//
|
||||
// Fix rf Reward ...
|
||||
rfRewar = 2;
|
||||
}
|
||||
else if (signalProvider == X121SMC_XWZ_PROVIDER_XACTIVATED_BOX)
|
||||
{
|
||||
//
|
||||
iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 0;
|
||||
|
||||
//
|
||||
Clean(sls);
|
||||
|
||||
//
|
||||
// Prepare Box fro SL ...
|
||||
iSL = pivot;
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
|
||||
//
|
||||
// Fix rf Reward ...
|
||||
rfRewar = 2;
|
||||
}
|
||||
else if (signalProvider == X121SMC_XWZ_PROVIDER_XBREAKED_BOX)
|
||||
{
|
||||
//
|
||||
iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 0;
|
||||
|
||||
//
|
||||
Clean(sls);
|
||||
|
||||
//
|
||||
// Prepare Box fro SL ...
|
||||
iSL = pivot;
|
||||
Add(
|
||||
iSL,
|
||||
sls //
|
||||
);
|
||||
|
||||
//
|
||||
// Fix rf Reward ...
|
||||
rfRewar = 2;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,520 +0,0 @@
|
||||
|
||||
//
|
||||
int DrawOrderBlock(
|
||||
XCOrderBlock *zone,
|
||||
XCBaseObject *&objects[],
|
||||
//
|
||||
bool drawStartedBar = true,
|
||||
bool drawActivatedBar = true,
|
||||
bool drawBreakedBar = true,
|
||||
bool drawWorkedBar = true,
|
||||
//
|
||||
int widthStartedBar = 1,
|
||||
color clrStartedBar = clrYellow,
|
||||
ENUM_LINE_STYLE styleStartedBar = STYLE_SOLID,
|
||||
//
|
||||
int widthActivatedBar = 1,
|
||||
color clrActivatedBar = clrLime,
|
||||
ENUM_LINE_STYLE styleActivatedBar = STYLE_SOLID,
|
||||
//
|
||||
int widthBreakedBar = 1,
|
||||
color clrBreakedBar = clrRed,
|
||||
ENUM_LINE_STYLE styleBreakedBar = STYLE_SOLID,
|
||||
//
|
||||
int widthWorkedBar = 1,
|
||||
color clrWorkedBar = clrAqua,
|
||||
ENUM_LINE_STYLE styleWorkedBar = STYLE_SOLID
|
||||
//
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(objects);
|
||||
|
||||
//
|
||||
if (zone == NULL ||
|
||||
!zone.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION zoneDir = zone.GetDirection();
|
||||
|
||||
//
|
||||
// Started Bar ...
|
||||
XOHCL startedBar;
|
||||
bool isBodyOut = false;
|
||||
bool isStarted = zone
|
||||
.IsStarted(
|
||||
zoneDir,
|
||||
startedBar,
|
||||
isBodyOut //
|
||||
);
|
||||
if (isStarted)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = startedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
startedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthStartedBar);
|
||||
iBarObj.LowShadowWidth(widthStartedBar);
|
||||
iBarObj.HighShadowWidth(widthStartedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleStartedBar);
|
||||
iBarObj.LowShadowStyle(styleStartedBar);
|
||||
iBarObj.HighShadowStyle(styleStartedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrStartedBar);
|
||||
iBarObj.LowShadowColor(clrStartedBar);
|
||||
iBarObj.HighShadowColor(clrStartedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Activated Bar ...
|
||||
XOHCL activatedBar;
|
||||
bool isBodyIn = false;
|
||||
bool isActivated = zone
|
||||
.IsActivated(
|
||||
zoneDir,
|
||||
activatedBar,
|
||||
isBodyIn,
|
||||
false // Force Body Out Started ...
|
||||
);
|
||||
if (isActivated)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = activatedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
activatedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthActivatedBar);
|
||||
iBarObj.LowShadowWidth(widthActivatedBar);
|
||||
iBarObj.HighShadowWidth(widthActivatedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleActivatedBar);
|
||||
iBarObj.LowShadowStyle(styleActivatedBar);
|
||||
iBarObj.HighShadowStyle(styleActivatedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrActivatedBar);
|
||||
iBarObj.LowShadowColor(clrActivatedBar);
|
||||
iBarObj.HighShadowColor(clrActivatedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Breaked Bar ...
|
||||
XOHCL breakedBar;
|
||||
isBodyOut = false;
|
||||
bool isBreaked = zone
|
||||
.IsBreaked(
|
||||
zoneDir,
|
||||
breakedBar,
|
||||
isBodyOut,
|
||||
false, // Ignore Start ...
|
||||
false // Force Body Out Started ...
|
||||
);
|
||||
if (isBreaked)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = breakedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
breakedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthBreakedBar);
|
||||
iBarObj.LowShadowWidth(widthBreakedBar);
|
||||
iBarObj.HighShadowWidth(widthBreakedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleBreakedBar);
|
||||
iBarObj.LowShadowStyle(styleBreakedBar);
|
||||
iBarObj.HighShadowStyle(styleBreakedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrBreakedBar);
|
||||
iBarObj.LowShadowColor(clrBreakedBar);
|
||||
iBarObj.HighShadowColor(clrBreakedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Worked Bar ...
|
||||
XOHCL workedBar;
|
||||
isBodyOut = false;
|
||||
bool isWorked = zone
|
||||
.IsWorked(
|
||||
zoneDir,
|
||||
workedBar,
|
||||
isBodyOut,
|
||||
false, // Ignore Activation ...
|
||||
false, // Force Body Out Started ...
|
||||
false // Force Body In Activated ...
|
||||
);
|
||||
if (isWorked)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = workedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
workedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthWorkedBar);
|
||||
iBarObj.LowShadowWidth(widthWorkedBar);
|
||||
iBarObj.HighShadowWidth(widthWorkedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleWorkedBar);
|
||||
iBarObj.LowShadowStyle(styleWorkedBar);
|
||||
iBarObj.HighShadowStyle(styleWorkedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrWorkedBar);
|
||||
iBarObj.LowShadowColor(clrWorkedBar);
|
||||
iBarObj.HighShadowColor(clrWorkedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
bool isCreated = CreateOrderBlock(
|
||||
zone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(objects);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int DrawFairValueGap(
|
||||
XCFVG *zone,
|
||||
XCBaseObject *&objects[],
|
||||
//
|
||||
bool drawStartedBar = true,
|
||||
bool drawActivatedBar = true,
|
||||
bool drawBreakedBar = true,
|
||||
bool drawWorkedBar = true,
|
||||
//
|
||||
int widthStartedBar = 1,
|
||||
color clrStartedBar = clrYellow,
|
||||
ENUM_LINE_STYLE styleStartedBar = STYLE_SOLID,
|
||||
//
|
||||
int widthActivatedBar = 1,
|
||||
color clrActivatedBar = clrLime,
|
||||
ENUM_LINE_STYLE styleActivatedBar = STYLE_SOLID,
|
||||
//
|
||||
int widthBreakedBar = 1,
|
||||
color clrBreakedBar = clrRed,
|
||||
ENUM_LINE_STYLE styleBreakedBar = STYLE_SOLID,
|
||||
//
|
||||
int widthWorkedBar = 1,
|
||||
color clrWorkedBar = clrAqua,
|
||||
ENUM_LINE_STYLE styleWorkedBar = STYLE_SOLID
|
||||
//
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(objects);
|
||||
|
||||
//
|
||||
if (zone == NULL ||
|
||||
!zone.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION zoneDir = zone.GetDirection();
|
||||
|
||||
//
|
||||
// Started Bar ...
|
||||
XOHCL startedBar;
|
||||
bool isBodyOut = false;
|
||||
bool isStarted = zone
|
||||
.IsStarted(
|
||||
zoneDir,
|
||||
startedBar,
|
||||
isBodyOut //
|
||||
);
|
||||
if (isStarted)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = startedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
startedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthStartedBar);
|
||||
iBarObj.LowShadowWidth(widthStartedBar);
|
||||
iBarObj.HighShadowWidth(widthStartedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleStartedBar);
|
||||
iBarObj.LowShadowStyle(styleStartedBar);
|
||||
iBarObj.HighShadowStyle(styleStartedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrStartedBar);
|
||||
iBarObj.LowShadowColor(clrStartedBar);
|
||||
iBarObj.HighShadowColor(clrStartedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Activated Bar ...
|
||||
XOHCL activatedBar;
|
||||
bool isBodyIn = false;
|
||||
bool isActivated = zone
|
||||
.IsActivated(
|
||||
zoneDir,
|
||||
activatedBar,
|
||||
isBodyIn,
|
||||
false // Force Body Out Started ...
|
||||
);
|
||||
if (isActivated)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = activatedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
activatedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthActivatedBar);
|
||||
iBarObj.LowShadowWidth(widthActivatedBar);
|
||||
iBarObj.HighShadowWidth(widthActivatedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleActivatedBar);
|
||||
iBarObj.LowShadowStyle(styleActivatedBar);
|
||||
iBarObj.HighShadowStyle(styleActivatedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrActivatedBar);
|
||||
iBarObj.LowShadowColor(clrActivatedBar);
|
||||
iBarObj.HighShadowColor(clrActivatedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Breaked Bar ...
|
||||
XOHCL breakedBar;
|
||||
isBodyOut = false;
|
||||
bool isBreaked = zone
|
||||
.IsBreaked(
|
||||
zoneDir,
|
||||
breakedBar,
|
||||
isBodyOut,
|
||||
false, // Ignore Start ...
|
||||
false // Force Body Out Started ...
|
||||
);
|
||||
if (isBreaked)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = breakedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
breakedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthBreakedBar);
|
||||
iBarObj.LowShadowWidth(widthBreakedBar);
|
||||
iBarObj.HighShadowWidth(widthBreakedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleBreakedBar);
|
||||
iBarObj.LowShadowStyle(styleBreakedBar);
|
||||
iBarObj.HighShadowStyle(styleBreakedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrBreakedBar);
|
||||
iBarObj.LowShadowColor(clrBreakedBar);
|
||||
iBarObj.HighShadowColor(clrBreakedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Worked Bar ...
|
||||
XOHCL workedBar;
|
||||
isBodyOut = false;
|
||||
bool isWorked = zone
|
||||
.IsWorked(
|
||||
zoneDir,
|
||||
workedBar,
|
||||
isBodyOut,
|
||||
false, // Ignore Activation ...
|
||||
false, // Force Body Out Started ...
|
||||
false // Force Body In Activated ...
|
||||
);
|
||||
if (isWorked)
|
||||
{
|
||||
//
|
||||
datetime iBarTo = workedBar.NextAt();
|
||||
|
||||
//
|
||||
XCOHCLObject *iBarObj;
|
||||
bool isCreated = CreateBar(
|
||||
workedBar,
|
||||
iBarObj,
|
||||
iBarTo //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iBarObj.BodyWidth(widthWorkedBar);
|
||||
iBarObj.LowShadowWidth(widthWorkedBar);
|
||||
iBarObj.HighShadowWidth(widthWorkedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyStyle(styleWorkedBar);
|
||||
iBarObj.LowShadowStyle(styleWorkedBar);
|
||||
iBarObj.HighShadowStyle(styleWorkedBar);
|
||||
|
||||
//
|
||||
iBarObj.BodyColor(clrWorkedBar);
|
||||
iBarObj.LowShadowColor(clrWorkedBar);
|
||||
iBarObj.HighShadowColor(clrWorkedBar);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iBarObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XCBaseObject *iObj;
|
||||
bool isCreated = CreateFairValueGap(
|
||||
zone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
objects //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(objects);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,543 +0,0 @@
|
||||
//
|
||||
bool HasSenario1Conditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XBoxZone &box,
|
||||
XBoxZone &holderBox,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Fil Selected Data ...
|
||||
XPOIState cState;
|
||||
X121Conditions cXConditions;
|
||||
XC121SMCCycleHelper *cHelper;
|
||||
X121SMCCycleConditions cConditions;
|
||||
result = provider.SelectCycle(
|
||||
cycle,
|
||||
cState,
|
||||
cXConditions,
|
||||
cHelper,
|
||||
cConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
Parse(cXConditions);
|
||||
|
||||
//
|
||||
// Fil Selected Data ...
|
||||
XPOIState chState;
|
||||
X121Conditions chXConditions;
|
||||
XC121SMCCycleHelper *chHelper;
|
||||
X121SMCCycleConditions chConditions;
|
||||
if (holderCycle != X_CYCLE_NONE)
|
||||
{
|
||||
//
|
||||
result = provider.SelectCycle(
|
||||
holderCycle,
|
||||
chState,
|
||||
chXConditions,
|
||||
chHelper,
|
||||
chConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
chState.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Parse(chXConditions);
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
holderBox.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
int zIDX = barIndex;
|
||||
int cIDX = zIDX + 1;
|
||||
int pIDX = cIDX + 1;
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
XOHCL pBar;
|
||||
|
||||
//
|
||||
// Initial Bars ...
|
||||
result = zBar.Init(
|
||||
cState.symbol,
|
||||
cState.period,
|
||||
barIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
zBar.GetPreviousBar(cBar);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
chState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detecting Signal Conditions ...
|
||||
|
||||
//
|
||||
bool isX3MAFastRejectUp =
|
||||
//
|
||||
cBar.low < cXConditions.x3maFastBuffer[cIDX] &&
|
||||
cBar.GetDown() > cXConditions.x3maFastBuffer[cIDX]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isX3MAFastRejectDown =
|
||||
//
|
||||
cBar.high > cXConditions.x3maFastBuffer[cIDX] &&
|
||||
cBar.GetUp() < cXConditions.x3maFastBuffer[cIDX]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Find Breaker Bar ...
|
||||
datetime nearCloseOverX3MAFast = cHelper.GetNearestCloseOverX3MAFast(cBar);
|
||||
datetime nearCloseUnderX3MAFast = cHelper.GetNearestCloseUnderX3MAFast(cBar);
|
||||
bool hasNearestCloseOverX3MAFast =
|
||||
IsValid(nearCloseOverX3MAFast) &&
|
||||
IsValid(nearCloseUnderX3MAFast)
|
||||
? nearCloseOverX3MAFast > nearCloseUnderX3MAFast
|
||||
: IsValid(nearCloseOverX3MAFast)
|
||||
? true
|
||||
: false;
|
||||
bool hasNearestCloseUnderX3MAFast =
|
||||
IsValid(nearCloseOverX3MAFast) &&
|
||||
IsValid(nearCloseUnderX3MAFast)
|
||||
? nearCloseUnderX3MAFast > nearCloseOverX3MAFast
|
||||
: IsValid(nearCloseUnderX3MAFast)
|
||||
? true
|
||||
: false;
|
||||
|
||||
//
|
||||
// Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
cBar.IsBullish() &&
|
||||
isX3MAFastRejectUp &&
|
||||
cXConditions.isSMHKBullish &&
|
||||
hasNearestCloseOverX3MAFast &&
|
||||
cXConditions.xhkSMOpenBuffer[cIDX] < cXConditions.x3maMidBuffer[cIDX]
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
cBar.IsBearish() &&
|
||||
isX3MAFastRejectDown &&
|
||||
cXConditions.isSMHKBearish &&
|
||||
hasNearestCloseUnderX3MAFast &&
|
||||
cXConditions.xhkSMOpenBuffer[cIDX] > cXConditions.x3maMidBuffer[cIDX]
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Filling Requirements ...
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
box.dir = dir;
|
||||
box.to = TimeCurrent();
|
||||
box.symbol = cXConditions.symbol;
|
||||
box.period = cXConditions.period;
|
||||
|
||||
//
|
||||
int fromIDX = -1;
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
fromIDX = GetBarIndex(
|
||||
cBar.symbol,
|
||||
cBar.period,
|
||||
nearCloseOverX3MAFast //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
fromIDX = GetBarIndex(
|
||||
cBar.symbol,
|
||||
cBar.period,
|
||||
nearCloseUnderX3MAFast //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidIndex(fromIDX))
|
||||
{
|
||||
//
|
||||
box.from = iTime(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
fromIDX //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
box.from = pBar.time;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Holder Box ...
|
||||
XBoxZone tmpBoxes[];
|
||||
if (chState.IsValid())
|
||||
{
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
// Demand Zones ...
|
||||
XBoxZone tmp[];
|
||||
ToBox(
|
||||
chState.demandZones,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bullish Order Blocks ...
|
||||
ToBox(
|
||||
chState.bullishOrderBlocks,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bullish Fair Value Gaps ...
|
||||
ToBox(
|
||||
chState.bullishFairValueGaps,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Supply Zones ...
|
||||
XBoxZone tmp[];
|
||||
ToBox(
|
||||
chState.supplyZones,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bearish Order Blocks ...
|
||||
ToBox(
|
||||
chState.bearishOrderBlocks,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bearish Fair Value Gaps ...
|
||||
ToBox(
|
||||
chState.bearishFairValueGaps,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
has = HasChild(tmpBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
while (HasChild(tmpBoxes))
|
||||
{
|
||||
//
|
||||
idx = GetOldest(tmpBoxes);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[idx];
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
has = IsBoxInside(
|
||||
box,
|
||||
iBox //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
holderBox = iBox;
|
||||
holderBox.to = TimeCurrent();
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
|
||||
//
|
||||
// Fix Box Upper and Lower based on Strategy ...
|
||||
|
||||
//
|
||||
double points = GetPoints(box.symbol);
|
||||
double minPointsDiff = points * 20;
|
||||
|
||||
//
|
||||
double prefferSL = 0;
|
||||
|
||||
//
|
||||
// Other SL Conditions ...
|
||||
if (prefferSL <= 0)
|
||||
{
|
||||
//
|
||||
prefferSL = cHelper
|
||||
.mX121Helper
|
||||
.xhkHelper
|
||||
.GetSMHKOpen(fromIDX);
|
||||
}
|
||||
|
||||
//
|
||||
if (prefferSL > 0)
|
||||
{
|
||||
//
|
||||
box.upper =
|
||||
isBullish
|
||||
? zBar.open
|
||||
: prefferSL;
|
||||
|
||||
//
|
||||
box.lower =
|
||||
isBullish
|
||||
? prefferSL
|
||||
: zBar.open;
|
||||
}
|
||||
|
||||
//
|
||||
if (box.IsValid())
|
||||
{
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
bool isCreated = cHelper.mPOIDrawer.DrawBox(
|
||||
box,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iObj.BoxWidth(2);
|
||||
iObj.BoxFill(true);
|
||||
iObj.BoxStyle(STYLE_DOT);
|
||||
|
||||
//
|
||||
Print("Signal ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Conditions to Force Has Holder Box ...
|
||||
|
||||
// //
|
||||
// result =
|
||||
// result &&
|
||||
// holderBox.IsValid() &&
|
||||
// dir == holderBox.dir;
|
||||
|
||||
// //
|
||||
// if (!result)
|
||||
// {
|
||||
// //
|
||||
// isBullish = false;
|
||||
// isBearish = false;
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
// Check All Conditions ...
|
||||
result =
|
||||
box.IsValid() &&
|
||||
HasDirection(dir) &&
|
||||
(isBullish ||
|
||||
isBearish);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
chState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Detecting Signal Conditions ...
|
||||
|
||||
//
|
||||
// Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
provider.visionXConditions.isSMHKBullish &&
|
||||
provider.decisionXConditions.isSarBullish &&
|
||||
provider.decisionXConditions.isVWapFastBullish &&
|
||||
provider.decisionXConditions.isX3MaFastBullish &&
|
||||
provider.consolidationXConditions.isSMHKBullish &&
|
||||
provider.decisionXConditions.isSMHKSwitchedToBullish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
provider.visionXConditions.isSMHKBearish &&
|
||||
provider.decisionXConditions.isSarBearish &&
|
||||
provider.decisionXConditions.isVWapFastBearish &&
|
||||
provider.decisionXConditions.isX3MaFastBearish &&
|
||||
provider.consolidationXConditions.isSMHKBearish &&
|
||||
provider.decisionXConditions.isSMHKSwitchedToBearish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,197 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Forex Sessions and Day Range Indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Your Name"
|
||||
#property link "https://www.example.com"
|
||||
#property version "1.00"
|
||||
#property indicator_chart_window
|
||||
|
||||
#include <Arrays\ArrayObj.mqh>
|
||||
|
||||
struct SessionInfo {
|
||||
string name;
|
||||
int startHour; // Standard start hour (GMT)
|
||||
int startMinute;
|
||||
int endHour; // Standard end hour (GMT)
|
||||
int endMinute;
|
||||
bool *isDST(datetime); // DST check function
|
||||
int dstAdjustment; // Hours to add during DST
|
||||
};
|
||||
|
||||
SessionInfo sessions[] = {
|
||||
{"Sydney", 21, 0, 5, 0, IsSydneyDST, 1},
|
||||
{"Tokyo", 23, 0, 8, 0, IsTokyoDST, 0},
|
||||
{"London", 7, 0, 15, 0, IsLondonDST, 1},
|
||||
{"New York", 12, 0, 17, 0, IsNewYorkDST, 1}
|
||||
};
|
||||
|
||||
bool sessionActive[];
|
||||
double sessionHigh[];
|
||||
double sessionLow[];
|
||||
datetime sessionStartTime[];
|
||||
datetime sessionEndTime[];
|
||||
|
||||
double dayHigh = 0;
|
||||
double dayLow = 0;
|
||||
datetime dayStartTime;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit() {
|
||||
ArrayResize(sessionActive, ArraySize(sessions));
|
||||
ArrayResize(sessionHigh, ArraySize(sessions));
|
||||
ArrayResize(sessionLow, ArraySize(sessions));
|
||||
ArrayResize(sessionStartTime, ArraySize(sessions));
|
||||
ArrayResize(sessionEndTime, ArraySize(sessions));
|
||||
|
||||
for(int i=0; i<ArraySize(sessions); i++) {
|
||||
sessionActive[i] = false;
|
||||
sessionHigh[i] = 0;
|
||||
sessionLow[i] = 0;
|
||||
sessionStartTime[i] = 0;
|
||||
sessionEndTime[i] = 0;
|
||||
}
|
||||
|
||||
dayHigh = 0;
|
||||
dayLow = 0;
|
||||
dayStartTime = 0;
|
||||
|
||||
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[]) {
|
||||
datetime currentTime = TimeCurrent();
|
||||
|
||||
// Check each session
|
||||
for(int i=0; i<ArraySize(sessions); i++) {
|
||||
SessionInfo session = sessions[i];
|
||||
bool dstActive = session.isDST(currentTime);
|
||||
int adjStartHour = session.startHour + (dstActive ? session.dstAdjustment : 0);
|
||||
int adjEndHour = session.endHour + (dstActive ? session.dstAdjustment : 0);
|
||||
|
||||
datetime todayStart = StringToTime(TimeToString(currentTime, TIME_DATE) + " " +
|
||||
IntegerToString(adjStartHour) + ":" +
|
||||
IntegerToString(session.startMinute));
|
||||
datetime todayEnd = StringToTime(TimeToString(currentTime, TIME_DATE) + " " +
|
||||
IntegerToString(adjEndHour) + ":" +
|
||||
IntegerToString(session.endMinute));
|
||||
|
||||
// Handle sessions spanning midnight
|
||||
if(adjEndHour < adjStartHour) {
|
||||
todayEnd += 24 * 3600;
|
||||
}
|
||||
|
||||
if(currentTime >= todayStart && currentTime < todayEnd) {
|
||||
if(!sessionActive[i]) {
|
||||
sessionActive[i] = true;
|
||||
sessionStartTime[i] = todayStart;
|
||||
sessionEndTime[i] = todayEnd;
|
||||
sessionHigh[i] = Bid;
|
||||
sessionLow[i] = Ask;
|
||||
} else {
|
||||
if(Bid > sessionHigh[i]) sessionHigh[i] = Bid;
|
||||
if(Ask < sessionLow[i]) sessionLow[i] = Ask;
|
||||
}
|
||||
} else {
|
||||
sessionActive[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check day range
|
||||
bool dstActiveNY = IsNewYorkDST(currentTime);
|
||||
int dayStartHour = dstActiveNY ? 21 : 22;
|
||||
datetime todayDayStart = StringToTime(TimeToString(currentTime, TIME_DATE) + " " +
|
||||
IntegerToString(dayStartHour) + ":00");
|
||||
|
||||
if(currentTime < todayDayStart) {
|
||||
todayDayStart -= 24 * 3600;
|
||||
}
|
||||
|
||||
if(dayStartTime != todayDayStart) {
|
||||
dayStartTime = todayDayStart;
|
||||
dayHigh = Bid;
|
||||
dayLow = Ask;
|
||||
} else {
|
||||
if(Bid > dayHigh) dayHigh = Bid;
|
||||
if(Ask < dayLow) dayLow = Ask;
|
||||
}
|
||||
|
||||
// Display information on chart
|
||||
string comment = "Active Forex Sessions:\n";
|
||||
for(int i=0; i<ArraySize(sessions); i++) {
|
||||
if(sessionActive[i]) {
|
||||
comment += sessions[i].name + " Session\n" +
|
||||
"High: " + DoubleToString(sessionHigh[i], _Digits) + "\n" +
|
||||
"Low: " + DoubleToString(sessionLow[i], _Digits) + "\n";
|
||||
}
|
||||
}
|
||||
comment += "\nDay Range:\n" +
|
||||
"High: " + DoubleToString(dayHigh, _Digits) + "\n" +
|
||||
"Low: " + DoubleToString(dayLow, _Digits);
|
||||
Comment(comment);
|
||||
|
||||
return(rates_total);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| DST Check Functions |
|
||||
//+------------------------------------------------------------------+
|
||||
bool IsLondonDST(datetime time) {
|
||||
int year = TimeYear(time);
|
||||
datetime march31 = StringToTime(year + ".03.31 00:00");
|
||||
int lastSundayMarch = TimeDay(march31) - (TimeDayOfWeek(march31) % 7);
|
||||
datetime dstStart = StringToTime(year + ".03." + IntegerToString(lastSundayMarch) + " 01:00");
|
||||
|
||||
datetime oct31 = StringToTime(year + ".10.31 00:00");
|
||||
int lastSundayOct = TimeDay(oct31) - (TimeDayOfWeek(oct31) % 7);
|
||||
datetime dstEnd = StringToTime(year + ".10." + IntegerToString(lastSundayOct) + " 01:00");
|
||||
|
||||
return time >= dstStart && time < dstEnd;
|
||||
}
|
||||
|
||||
bool IsNewYorkDST(datetime time) {
|
||||
int year = TimeYear(time);
|
||||
datetime march1 = StringToTime(year + ".03.01 00:00");
|
||||
int dayOfWeekMarch1 = TimeDayOfWeek(march1);
|
||||
int secondSundayMarch = 1 + (7 - dayOfWeekMarch1) % 7 + 7;
|
||||
datetime dstStart = StringToTime(year + ".03." + IntegerToString(secondSundayMarch) + " 07:00");
|
||||
|
||||
datetime nov1 = StringToTime(year + ".11.01 00:00");
|
||||
int dayOfWeekNov1 = TimeDayOfWeek(nov1);
|
||||
int firstSundayNov = 1 + (7 - dayOfWeekNov1) % 7;
|
||||
datetime dstEnd = StringToTime(year + ".11." + IntegerToString(firstSundayNov) + " 06:00");
|
||||
|
||||
return time >= dstStart && time < dstEnd;
|
||||
}
|
||||
|
||||
bool IsSydneyDST(datetime time) {
|
||||
int year = TimeYear(time);
|
||||
datetime oct1 = StringToTime(year + ".10.01 00:00");
|
||||
int dayOfWeekOct1 = TimeDayOfWeek(oct1);
|
||||
int firstSundayOct = 1 + (7 - dayOfWeekOct1) % 7;
|
||||
datetime dstStart = StringToTime(year + ".10." + IntegerToString(firstSundayOct) + " 13:00");
|
||||
|
||||
datetime apr1 = StringToTime(year + ".04.01 00:00");
|
||||
int dayOfWeekApr1 = TimeDayOfWeek(apr1);
|
||||
int firstSundayApr = 1 + (7 - dayOfWeekApr1) % 7;
|
||||
datetime dstEnd = StringToTime(year + ".04." + IntegerToString(firstSundayApr) + " 15:00");
|
||||
|
||||
return time >= dstStart && time < dstEnd;
|
||||
}
|
||||
|
||||
bool IsTokyoDST(datetime time) {
|
||||
return false;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,377 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| x-saherelm.xpoi.test.ea.mq5 |
|
||||
//| SaherElm IT Center |
|
||||
//| https://www.saherelm.ir |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.x-poi.class.mq5"
|
||||
#include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
||||
#include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
|
||||
#include "../Libraries/x-saherelm.x-poi.state.lib.mq5"
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||
|
||||
//
|
||||
// Global Variables ...
|
||||
|
||||
//
|
||||
XCPOIDrawer *mPOIDrawer;
|
||||
|
||||
//
|
||||
XCPOIDetector *mPOIDetector;
|
||||
XBarTracker mBarTracker;
|
||||
XCBarAnalyser *mBarAnalyser;
|
||||
|
||||
//
|
||||
bool useDetector = true;
|
||||
bool useBarAnalyser = false;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
mPOIDetector = new XCPOIDetector(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
//
|
||||
mPOIDrawer = new XCPOIDrawer();
|
||||
|
||||
//
|
||||
mBarAnalyser = new XCBarAnalyser();
|
||||
|
||||
//
|
||||
mBarTracker.Init(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
//
|
||||
return (INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert deinitialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
// ZeroMemory(mPOIDrawer);
|
||||
// ZeroMemory(mPOIDetector);
|
||||
ZeroMemory(mBarAnalyser);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert tick function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
DetectBarAnalyser();
|
||||
|
||||
//
|
||||
DetectPOIState();
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom Functions |
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* Detect POI(s) Using Bar Analyser Class ...
|
||||
*/
|
||||
void DetectBarAnalyser()
|
||||
{
|
||||
//
|
||||
if (!useBarAnalyser)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if (!mBarTracker.IsNewBar())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
bool isInited = zBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
0 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
isInited = zBar.GetPreviousBar(cBar);
|
||||
if (!isInited)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int rootIDX = -1;
|
||||
XOHCL selectedBar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
|
||||
//
|
||||
// Check Big Change in Price ...
|
||||
bool isBigChange = mBarAnalyser.IsSharp(
|
||||
zBar, // Bar ...
|
||||
dir, // Change Direction ...
|
||||
rootIDX, // Change Root IDX ...
|
||||
X_PRICE_CLOSE, // Price Change Type ...
|
||||
true, // Force Use Body for Range Calculation ...
|
||||
1.0 // Range Extend Multiplier ...
|
||||
);
|
||||
if (isBigChange)
|
||||
{
|
||||
Print("Big Price Change Detected: ", ToString(dir));
|
||||
}
|
||||
|
||||
//
|
||||
// Check Big Change in Price ...
|
||||
bool isSpike = mBarAnalyser.IsSpike(
|
||||
zBar, // Bar ...
|
||||
dir, // Change Direction ...
|
||||
rootIDX, // Root Index ...
|
||||
X_PRICE_CLOSE, // Price Change Type ...
|
||||
true, // Force Use Body for Range Calculation ...
|
||||
1.0, // Range Extend Multiplier ...
|
||||
3 // Same Bars ...
|
||||
);
|
||||
if (isSpike)
|
||||
{
|
||||
Print("Spike Detected: ", ToString(dir));
|
||||
}
|
||||
|
||||
//
|
||||
// Check Doji Pattern ...
|
||||
bool isDoji = mBarAnalyser.IsDoji(
|
||||
cBar,
|
||||
dir //
|
||||
);
|
||||
if (isDoji)
|
||||
{
|
||||
Print(ToString(dir), " Doji Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Hammer Pattern ...
|
||||
bool isHammer = mBarAnalyser.IsHammer(
|
||||
cBar,
|
||||
dir //
|
||||
);
|
||||
if (isHammer)
|
||||
{
|
||||
Print(ToString(dir), " Hammer Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Engulf Pattern ...
|
||||
bool isEngulfed = mBarAnalyser.IsEngulfed(
|
||||
cBar,
|
||||
dir //
|
||||
);
|
||||
if (isEngulfed)
|
||||
{
|
||||
Print(ToString(dir), " Engulfed Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Momentum Pattern ...
|
||||
bool isMomentum = mBarAnalyser.IsMomentum(
|
||||
cBar,
|
||||
dir //
|
||||
);
|
||||
if (isMomentum)
|
||||
{
|
||||
Print(ToString(dir), " Momentum Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Pullback Pattern ...
|
||||
bool isPullback = mBarAnalyser.IsPullback(
|
||||
cBar,
|
||||
dir //
|
||||
);
|
||||
if (isMomentum)
|
||||
{
|
||||
Print(ToString(dir), " Pullback Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Swing Pattern ...
|
||||
bool isSwing = mBarAnalyser.IsSwing(
|
||||
cBar,
|
||||
dir //
|
||||
);
|
||||
if (isSwing)
|
||||
{
|
||||
Print(ToString(dir), " Swing Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Swing Pattern ...
|
||||
bool isRejected = mBarAnalyser.IsRejected(
|
||||
cBar,
|
||||
dir //
|
||||
);
|
||||
if (isRejected)
|
||||
{
|
||||
Print(ToString(dir), " Rejected Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Support ...
|
||||
bool isSupport = mBarAnalyser.HasSupport(
|
||||
cBar,
|
||||
selectedBar //
|
||||
);
|
||||
if (isSupport)
|
||||
{
|
||||
Print(ToString(dir), " Support Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Resistance ...
|
||||
bool isResistance = mBarAnalyser.HasResistance(
|
||||
cBar,
|
||||
selectedBar //
|
||||
);
|
||||
if (isResistance)
|
||||
{
|
||||
Print(ToString(dir), " Resistance Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Fair Value Gap ...
|
||||
XOHCL toBar;
|
||||
XOHCL fromBar;
|
||||
bool hasFVG = mBarAnalyser.HasFairValueGap(
|
||||
zBar,
|
||||
fromBar,
|
||||
toBar,
|
||||
dir,
|
||||
3 //
|
||||
);
|
||||
if (hasFVG)
|
||||
{
|
||||
Print(ToString(dir), " FairValueGap Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Check Order Block ...
|
||||
bool hasOB = mBarAnalyser.HasOrderBlock(
|
||||
zBar,
|
||||
selectedBar,
|
||||
dir,
|
||||
true,
|
||||
true,
|
||||
true //
|
||||
);
|
||||
if (hasOB)
|
||||
{
|
||||
Print(ToString(dir), " OrderBlock Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect POI(s) Using POIDetector Class ...
|
||||
*/
|
||||
void DetectPOIState()
|
||||
{
|
||||
//
|
||||
if (!useDetector)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if (!mBarTracker.IsNewBar())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_XPOI_EVENTS poiEvents[];
|
||||
XPOIStateEvents poiEventNotifier;
|
||||
mPOIDetector.Update(
|
||||
poiEvents,
|
||||
0 //
|
||||
);
|
||||
poiEventNotifier.Init(poiEvents);
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
mPOIDetector.GetState(state);
|
||||
|
||||
//
|
||||
bool showBullishPOIs = true;
|
||||
bool showBearishPOIs = true;
|
||||
|
||||
//
|
||||
XCBaseObject *stateObjects[];
|
||||
mPOIDrawer.DrawState(
|
||||
state,
|
||||
stateObjects,
|
||||
//
|
||||
// Bullish ...
|
||||
showBullishPOIs && false, // SwingLows
|
||||
showBullishPOIs && false, // DemandZones
|
||||
showBullishPOIs && false, // SupportZones
|
||||
showBullishPOIs && false, // BullishSharps
|
||||
showBullishPOIs && false, // BullishSpikes
|
||||
showBullishPOIs && false, // BullishPullbacks
|
||||
showBullishPOIs && false, // BullishMomentums
|
||||
showBullishPOIs && false, // BullishRejections
|
||||
showBullishPOIs && false, // BullishOrderBlocks
|
||||
showBullishPOIs && false, // BullishFairValueGaps
|
||||
showBullishPOIs && false, // BullishConsolidationZones
|
||||
//
|
||||
// Bearish ...
|
||||
showBearishPOIs && false, // SwingHighs
|
||||
showBearishPOIs && false, // SupplyZones
|
||||
showBearishPOIs && false, // ResistanceZones
|
||||
showBearishPOIs && false, // BearishSharps
|
||||
showBearishPOIs && false, // BearishSpikes
|
||||
showBearishPOIs && false, // BearishPullbacks
|
||||
showBearishPOIs && false, // BearishMomentums
|
||||
showBearishPOIs && false, // BearishRejections
|
||||
showBearishPOIs && false, // BearishOrderBlocks
|
||||
showBearishPOIs && false, // BearishFairValueGaps
|
||||
showBearishPOIs && false // BearishConsolidationZones
|
||||
);
|
||||
|
||||
//
|
||||
Clean(poiEvents);
|
||||
poiEventNotifier.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
//+------------------------------------------------------------------+
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user