Liquidity_Predator/Liquidity_Predator.mq5

167 lines
7.5 KiB
MQL5
Raw Permalink Normal View History

2026-01-31 07:59:15 +01:00
// Original Liquidity Predator by raphix251
// Include all mqh files
// Libraries
2026-02-11 19:32:33 +01:00
#include "IncludeLibrarys.mqh"
2026-01-31 07:59:15 +01:00
//--- INPUT PARAMETERS
2026-02-09 19:57:29 +01:00
// Money Management parameters
input string Section_MoneyManagement = ""; // ---MONEY MANAGEMENT---
2026-03-16 16:09:49 +01:00
input double fRiskPerTrade = 1; // Risk per trade
input int nMaxTradesPerDay = 5; // Maximum trades per day
input double fRiskReward = 2.0; // Risk reward ratio position 1
input bool bRunnerPosition = false; // Runner position (closing when EMAs cross)
2026-06-09 21:41:18 +02:00
input double fPercentageRunner = 50; // Percentage runner position
2026-03-16 19:35:17 +01:00
input int nDistanceMoveRunnerSLTP1 = 0; // Distance to move SL of runner to TP1
2026-03-31 19:32:30 +02:00
input double fLossPerLot = 0; // Loss per lot in dollar
2026-03-16 16:09:49 +01:00
input int nMaxSpread = 0; // Maximum spread in points
input double nMaxDailyProfit = 0; // Maximum daily profit in percent
2026-05-09 08:09:47 +02:00
input int nMaxDaysWithoutTrade = 20; // Maximum days without trade(opens trade to keep account alive)
2026-02-09 19:57:29 +01:00
// Strategy parameters
input string Section_Strategy = ""; // ---STRATEGY---
input double nMoveBeAtProfit = 75; // Move break even at profit
input int nMaxLiqus = 5; // Maximale liquidities
input ENUM_TIMEFRAMES eLiquTimeframe = PERIOD_M15; // Liquidity timeframe
input int fMaxDiffTakeOut = 11; // Maximum difference before take out
input int fMinSizeFVG = 0; // Minimum size of fair value gap
input int fMaxSizeFVG = 20; // Maximum size of fair value gap
input int nCandlesLookbackFVG = 5; // Number of candles to look back for fair value gap
input int fMinStopLossSize = 20; // Minimum stoploss size
input int fMaxStopLossSize = 50; // Maximum stoploss size
input int nMaxCandlesLiquEntry = 5; // Maximum candles between liquidity cross and entry
input int nMaxDiffFVGEntry = 0; // Maximum difference between FVG and Entry
2026-03-26 19:13:50 +01:00
input bool bNoWigsInOppositeDir = false; // No wicks in opposite direction between liquidity cross and entry
input int nMinWigSizePercent = 90; // Minimum wick size of candle in percent
2026-04-30 15:51:09 +02:00
//Strategy 1
2026-05-03 13:07:17 +02:00
input bool bStratOne = true; // Strat 1 - Enabled
input int nS1MaxDiffFVGLiquCross = 0; // Strat 1 - Maximum difference FVG Liqu Cross
2026-04-30 15:51:09 +02:00
input int nS1MaxDiffTakeout = 0; // Strat 1 - Maximum difference takeout
2026-04-30 16:53:46 +02:00
input int nS1OrderExpiration = 0; // Strat 1 - Order expiration time[s]
2026-02-09 19:57:29 +01:00
// Candles before liquidity
input string Section_Candle_Patterns = ""; // ---CANDLES BEFORE LIQUIDITY---
input bool bCheckStrongMomentum = false; // Check momentum
input int nCandlesMomentum = 3; // Number of candles to check for momentum
2026-03-26 19:13:50 +01:00
input bool bCheckWigs = false; // Check wicks
input int nCandlesWigs = 5; // Number of candles to check for wicks
2026-02-09 19:57:29 +01:00
// Time filter parameters
input string Section_TimeFilter = ""; // ---TIME FILTER---
2026-03-26 19:13:50 +01:00
input int nStartTime = 8; // Start time
input int nEndTime = 20; // End time
2026-02-09 19:57:29 +01:00
// News filter parameters
input string Section_NewsFilter = ""; // ---NEWS FILTER---
input int nNewsMinutesBefore = 30; // No entries before news in minutes
input int nNewsMinutesAfter = 10; // No entries after news in minutes
input ENUM_CALENDAR_EVENT_IMPORTANCE eNewsImportance = CALENDAR_IMPORTANCE_NONE; // Minimum news importance
2026-04-21 20:17:09 +02:00
input string sNewsCurrency1 = "USD"; // News currency to look for
input string sNewsCurrency2 = ""; // News currency to look for
input string sNewsCurrency3 = ""; // News currency to look for
input string sNewsCurrency4 = ""; // News currency to look for
input string sNewsCurrency5 = ""; // News currency to look for
2026-01-31 07:59:15 +01:00
2026-02-09 19:57:29 +01:00
// RSI filter parameters
input string Section_TrendFilter = ""; // ---RSI FILTER---
input bool bRSIActive = false; // RSI filter active
input ENUM_TIMEFRAMES eRSITimeframe = PERIOD_CURRENT; // RSI timeframe
input int nRSILength = 14; // RSI length
input int nRSIRange = 15; // RSI range (50 +- parameter)
2026-01-31 07:59:15 +01:00
2026-02-27 14:33:14 +01:00
// EMA filter parameters
input string Section_EMAFilter = ""; // ---EMA FILTER---
input bool bEMAActive = false; // EMA filter active
input ENUM_TIMEFRAMES eEMATimeframe = PERIOD_CURRENT; // EMA timeframe
input int nSmallEMALength = 20; // Small EMA length
input int nBigEMALength = 50; // Big EMA length
2026-03-01 09:46:44 +01:00
input int nMinDiffEMA = 0; // Minimum difference between small and big EMA
2026-06-19 11:12:04 +02:00
input int nEMAShift_CurrTF = 0; // EMA shift current TF
input int nEMAShift_HTF = 0; // EMA shift higher TF
2026-02-27 14:33:14 +01:00
2026-01-31 07:59:15 +01:00
// Debug
input string Section_Debug = ""; // ---DEBUG---
input bool bOptimizationRun = false; // Optimization run (only for testing purpose)
input datetime dtDebugTime; // Debug time breakpoint (only for testing purpose)
2026-01-31 07:59:15 +01:00
// Global Vars
stGlobalVars stGVL;
E_DIRECTION eCurrentDirection;
CTrade Trade;
int nMaxCandles;
2026-06-19 11:12:04 +02:00
int nMaxEMAArraySize;
datetime tmpDebugTime;
2026-01-31 07:59:15 +01:00
int OnInit()
{
//---
M_Points2Price();
M_InitializeArrays();
2026-02-05 18:57:59 +01:00
nMaxCandles = MathMax(nCandlesLookbackFVG + 3, nMaxCandlesLiquEntry);
if(nMaxCandlesLiquEntry==0 || nCandlesLookbackFVG==0)
2026-01-31 07:59:15 +01:00
{
nMaxCandles = 100;
}
nMaxCandles = MathMin(nMaxCandles, 100); // We can maximum have 100 candles
2026-06-19 11:12:04 +02:00
nMaxEMAArraySize = 2;
nMaxEMAArraySize = MathMax(nMaxEMAArraySize, 2 + nEMAShift_CurrTF);
nMaxEMAArraySize = MathMax(nMaxEMAArraySize, 2 + nEMAShift_HTF);
tmpDebugTime = dtDebugTime;
2026-02-09 19:57:29 +01:00
M_RSI_INIT();
2026-02-11 17:37:48 +01:00
2026-02-27 14:33:14 +01:00
M_EMA_INIT();
2026-02-11 17:37:48 +01:00
M_SetLineNames();
2026-02-12 17:44:40 +01:00
M_SetBoxNames();
M_CreateLabel("FilterLabel",5,10);
2026-03-30 17:58:35 +02:00
M_CreateLabel("GMTTime",5,40);
M_CreateLabel("ServerTime",5,80);
2026-01-31 07:59:15 +01:00
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
2026-02-09 19:57:29 +01:00
IndicatorRelease(stGVL.rsiHandle);
2026-01-31 07:59:15 +01:00
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
M_GetCandleData(PERIOD_M1, stGVL.Candle, nMaxCandles);
M_GetCandleData(eLiquTimeframe, stGVL.Candle_HTF, 5); // We need candles 1-4, 0 is the actual open candle
2026-01-31 07:59:15 +01:00
2026-03-30 17:58:35 +02:00
M_DetermineTimes();
2026-01-31 07:59:15 +01:00
M_StateMachine();
2026-05-09 08:09:47 +02:00
2026-01-31 07:59:15 +01:00
if(stGVL.dtTimeCurrent_M1 != stGVL.dtTimeLast_M1)
{
2026-02-11 17:37:48 +01:00
M_NewBar_M1();
2026-01-31 07:59:15 +01:00
stGVL.dtTimeLast_M1 = stGVL.dtTimeCurrent_M1;
}
if(stGVL.dtTimeCurrent_HTF != stGVL.dtTimeLast_HTF)
2026-01-31 07:59:15 +01:00
{
M_NewBar_HTF();
stGVL.dtTimeLast_HTF = stGVL.dtTimeCurrent_HTF;
2026-01-31 07:59:15 +01:00
}
2026-05-09 08:09:47 +02:00
if(stGVL.bDemandKeepAccountAliveTrade)
{
M_KeepAliveTrade();
}
2026-01-31 07:59:15 +01:00
}
//+------------------------------------------------------------------+