mirror of
https://github.com/raa251/Liquidity_Predator.git
synced 2026-07-06 13:42:02 +00:00
83 lines
No EOL
3.9 KiB
MQL5
83 lines
No EOL
3.9 KiB
MQL5
void M_SM_LIQUIDITY_ACTIVATED()
|
|
{
|
|
if(M_FiltersOK())
|
|
{
|
|
int NrCLDs = MathMin(nCandlesLookbackFVG, 97);
|
|
for(int i = 1; i <= NrCLDs; i++) // Bei 1 anfangen, da 0 noch nicht geschlossen is
|
|
{
|
|
// Direction Buy
|
|
if(stGVL.Candle[i+1].open > stGVL.Candle[i+1].close && stGVL.eCurrentDirection == DIR_LONG) // middle candle is bearish
|
|
{
|
|
// Gap between Candle i and i+2 existing and is big enough
|
|
bool Condition1 = stGVL.Candle[i+2].low > stGVL.Candle[i].high + stGVL.fMinSizeFVG_Price;
|
|
|
|
// Gap between Candle i and i+2 is not too big
|
|
bool Condition2 = stGVL.Candle[i+2].low - stGVL.Candle[i].high < stGVL.fMaxSizeFVG_Price || stGVL.fMaxSizeFVG_Price == 0;
|
|
|
|
// FVG is above current liquidity
|
|
bool Condition3 = stGVL.Candle[i].high > stGVL.CurrentLiquidity;
|
|
|
|
if(Condition1 && Condition2 && Condition3)
|
|
{ // fair value gap
|
|
stGVL.LastFVGTop = stGVL.Candle[i+2].low;
|
|
stGVL.LastFVGBottom = stGVL.Candle[i].high;
|
|
stGVL.LastFVGIndex = i + 1;
|
|
|
|
datetime barTime = iTime(_Symbol, PERIOD_CURRENT, 0);
|
|
stGVL.Rect_ActFVG_Number = stGVL.Rect_ActFVG_Number + 1;
|
|
M_CreateBox(stGVL.Rect_FVG, stGVL.Rect_ActFVG_Number, barTime - 60 * stGVL.LastFVGIndex, barTime, stGVL.LastFVGTop, stGVL.LastFVGBottom, clrYellow);
|
|
|
|
string Message = "FVG for buy found, TOP=" + DoubleToString(stGVL.LastFVGTop) + " BOTTOM=" + DoubleToString(stGVL.LastFVGBottom) + " Index=" + IntegerToString(stGVL.LastFVGIndex);
|
|
M_LogInfo(Message);
|
|
stGVL.nStateMachine = SM_WAIT_FVG_INVERTED;
|
|
break; // Fair value gap found - exit
|
|
}
|
|
}
|
|
// Direction Sell
|
|
else if(stGVL.Candle[i+1].close > stGVL.Candle[i+1].open && stGVL.eCurrentDirection == DIR_SHORT) // Middle Candle is bullish
|
|
{
|
|
// Gap between Candle i and i+2 existing and is big enough
|
|
bool Condition1 = stGVL.Candle[i+2].high < stGVL.Candle[i].low - stGVL.fMinSizeFVG_Price;
|
|
|
|
// Gap between Candle i and i+2 is not too big
|
|
bool Condition2 = stGVL.Candle[i].low - stGVL.Candle[i+2].high < stGVL.fMaxSizeFVG_Price || stGVL.fMaxSizeFVG_Price == 0;
|
|
|
|
// FVG is below current liquidity
|
|
bool Condition3 = stGVL.Candle[i].low < stGVL.CurrentLiquidity;
|
|
|
|
if(Condition1 && Condition2 && Condition3)
|
|
{ // fair value gap
|
|
stGVL.LastFVGTop = stGVL.Candle[i].low;
|
|
stGVL.LastFVGBottom = stGVL.Candle[i+2].high;
|
|
stGVL.LastFVGIndex = i + 1;
|
|
|
|
datetime barTime = iTime(_Symbol, PERIOD_CURRENT, 0);
|
|
stGVL.Rect_ActFVG_Number = stGVL.Rect_ActFVG_Number + 1;
|
|
M_CreateBox(stGVL.Rect_FVG, stGVL.Rect_ActFVG_Number, barTime - 60 * stGVL.LastFVGIndex, barTime, stGVL.LastFVGTop, stGVL.LastFVGBottom, clrYellow);
|
|
|
|
string Message = "FVG for sell found, TOP=" + DoubleToString(stGVL.LastFVGTop) + " BOTTOM=" + DoubleToString(stGVL.LastFVGBottom) + " Index=" + IntegerToString(stGVL.LastFVGIndex);
|
|
M_LogInfo(Message);
|
|
|
|
stGVL.nStateMachine = SM_WAIT_FVG_INVERTED;
|
|
break; // Fair value gap found - exit
|
|
}
|
|
}
|
|
|
|
if(NrCLDs == i) // Last loop run through, no FVG found
|
|
{
|
|
string Message = "No FVG found in last " + IntegerToString(NrCLDs) + " Candles!";
|
|
M_LogWarning(Message);
|
|
|
|
if(bStratOne)
|
|
{
|
|
stGVL.nStateMachine = SM_S1_WAIT_FVG_CREATED;
|
|
}
|
|
else
|
|
{
|
|
stGVL.nStateMachine = SM_RESET;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} |