mirror of
https://github.com/raa251/Liquidity_Predator.git
synced 2026-07-06 13:42:02 +00:00
77 lines
No EOL
4.1 KiB
MQL5
77 lines
No EOL
4.1 KiB
MQL5
void M_SM_S1_WAIT_FVG_CREATED()
|
|
{
|
|
// Direction Buy
|
|
if(stGVL.Candle[2].close > stGVL.CurrentLiquidity + stGVL.nS1MaxDiffFVGLiquCross_Price && stGVL.nS1MaxDiffFVGLiquCross_Price != 0 && stGVL.eCurrentDirection == DIR_LONG)
|
|
{
|
|
M_LogInfo("Strat1, Abort because price is too far away from liquidity");
|
|
stGVL.nStateMachine = SM_RESET;
|
|
}
|
|
if(stGVL.CurrentLiquidity - stGVL.Candle[0].low > stGVL.nS1MaxDiffTakeout_Price && stGVL.nS1MaxDiffTakeout_Price != 0 && stGVL.eCurrentDirection == DIR_LONG)
|
|
{
|
|
M_LogInfo("Strat1, Buy-Liquidity got taken out " + DoubleToString(stGVL.CurrentLiquidity - stGVL.Candle[0].low));
|
|
stGVL.nStateMachine = SM_RESET;
|
|
}
|
|
if(stGVL.Candle[2].open < stGVL.Candle[2].close && stGVL.eCurrentDirection == DIR_LONG) // middle candle is bullish
|
|
{
|
|
// Gap between Candle i and i+2 existing and is big enough
|
|
bool Condition1 = stGVL.Candle[3].high + stGVL.fMinSizeFVG_Price < stGVL.Candle[1].low;
|
|
|
|
// Gap between Candle i and i+2 is not too big
|
|
bool Condition2 = stGVL.Candle[1].low - stGVL.Candle[3].high < stGVL.fMaxSizeFVG_Price || stGVL.fMaxSizeFVG_Price == 0;
|
|
|
|
// FVG is above current liquidity
|
|
bool Condition3 = stGVL.Candle[3].high > stGVL.CurrentLiquidity;
|
|
|
|
if(Condition1 && Condition2 && Condition3)
|
|
{ // fair value gap
|
|
stGVL.LastFVGTop = stGVL.Candle[1].low;
|
|
stGVL.LastFVGBottom = stGVL.Candle[3].high;
|
|
stGVL.LastFVGIndex = 2;
|
|
|
|
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 = "Strat1, FVG for buy found, TOP=" + DoubleToString(stGVL.LastFVGTop) + " BOTTOM=" + DoubleToString(stGVL.LastFVGBottom) + " Index=" + IntegerToString(stGVL.LastFVGIndex);
|
|
M_LogInfo(Message);
|
|
stGVL.nStateMachine = SM_S1_WAIT_FVG_INVERTED;
|
|
}
|
|
}
|
|
// Direction Sell
|
|
else if(stGVL.Candle[2].close < stGVL.CurrentLiquidity - stGVL.nS1MaxDiffFVGLiquCross_Price && stGVL.nS1MaxDiffFVGLiquCross_Price != 0 && stGVL.eCurrentDirection == DIR_SHORT)
|
|
{
|
|
M_LogInfo("Strat1, Abort because price is too far away from liquidity");
|
|
stGVL.nStateMachine = SM_RESET;
|
|
}
|
|
else if(stGVL.Candle[0].high - stGVL.CurrentLiquidity > stGVL.nS1MaxDiffTakeout_Price && stGVL.nS1MaxDiffTakeout_Price != 0 && stGVL.eCurrentDirection == DIR_SHORT)
|
|
{
|
|
M_LogInfo("Strat1, Sell-Liquidity got taken out " + DoubleToString(stGVL.Candle[0].high - stGVL.CurrentLiquidity));
|
|
stGVL.nStateMachine = SM_RESET;
|
|
}
|
|
else if(stGVL.Candle[2].open > stGVL.Candle[2].close && stGVL.eCurrentDirection == DIR_SHORT) // middle candle is bearish
|
|
{
|
|
// Gap between Candle i and i+2 existing and is big enough
|
|
bool Condition1 = stGVL.Candle[1].high + stGVL.fMinSizeFVG_Price < stGVL.Candle[3].low;
|
|
|
|
// Gap between Candle i and i+2 is not too big
|
|
bool Condition2 = stGVL.Candle[3].low - stGVL.Candle[1].high < stGVL.fMaxSizeFVG_Price || stGVL.fMaxSizeFVG_Price == 0;
|
|
|
|
// FVG is above current liquidity
|
|
bool Condition3 = stGVL.Candle[3].low < stGVL.CurrentLiquidity;
|
|
|
|
if(Condition1 && Condition2 && Condition3)
|
|
{ // fair value gap
|
|
stGVL.LastFVGTop = stGVL.Candle[3].low;
|
|
stGVL.LastFVGBottom = stGVL.Candle[1].high;
|
|
stGVL.LastFVGIndex = 2;
|
|
|
|
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 = "Strat1, FVG for sell found, TOP=" + DoubleToString(stGVL.LastFVGTop) + " BOTTOM=" + DoubleToString(stGVL.LastFVGBottom) + " Index=" + IntegerToString(stGVL.LastFVGIndex);
|
|
M_LogInfo(Message);
|
|
stGVL.nStateMachine = SM_S1_WAIT_FVG_INVERTED;
|
|
}
|
|
}
|
|
} |