Sniffer

MQL5 Experts

Spécifications

//+------------------------------------------------------------------+
//|                                           ICT_SMC_CRT_EA.mq5    |
//|                    Automated SMC / ICT / CRT Execution Engine   |
//+------------------------------------------------------------------+
#property copyright "Automated SMC Engine"
#property version   "1.00"
#property strict

#include <Trade\Trade.mqh>

//--- Trade Object
CTrade trade;

//--- Inputs
input group "=== Risk & Money Management ==="
input double   InpRiskPercent      = 1.0;      // Risk % per trade (e.g., 1.0 = 1%)
input double   InpRiskReward       = 3.0;      // Target Risk : Reward Ratio (1:3)
input double   InpSLBufferPips     = 2.0;      // SL Buffer past sweep extreme (in Pips)
input ulong    InpMagicNumber      = 888111;   // Unique Magic Number for this EA

input group "=== Confluence Strategy Filters ==="
input bool     InpUseSMC           = true;     // Enable SMC Imbalance (FVG) Filter
input bool     InpUseCRT           = true;     // Enable CRT Range Expansion
input int      InpPivotStrength    = 5;        // Pivot Strength (Bars Left & Right)
input double   InpMinFvgPips       = 1.5;      // Min Fair Value Gap Size (in Pips)

input group "=== Session & Trend Filters ==="
input bool     InpFilterTrend      = true;     // Filter Entries with 200 EMA
input int      InpEmaPeriod        = 200;      // Dynamic Trend EMA Period
input bool     InpFilterSessions   = true;     // Active Session Filter (London/NY)
input int      InpLondonStartHour  = 7;        // Session Start UTC (7 AM London)
input int      InpNYEndHour        = 17;       // Session End UTC (5 PM NY)

//--- Global Variables
int      emaHandle = INVALID_HANDLE;
datetime lastTradeTime = 0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   trade.SetExpertMagicNumber(InpMagicNumber);

   if(InpFilterTrend)
   {
      emaHandle = iMA(_Symbol, _Period, InpEmaPeriod, 0, MODE_EMA, PRICE_CLOSE);
      if(emaHandle == INVALID_HANDLE)
      {
         Print("Error initializing EMA handle for EA.");
         return(INIT_FAILED);
      }
   }

   Print("ICT/SMC/CRT Expert Advisor initialized successfully.");
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   if(emaHandle != INVALID_HANDLE) IndicatorRelease(emaHandle);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   // Process only on new bar close to prevent over-trading
   static datetime lastBarTime = 0;
   datetime currentBarTime = iTime(_Symbol, _Period, 0);
   if(currentBarTime == lastBarTime) return;
   lastBarTime = currentBarTime;

   // Check if we already have an open position with our Magic Number
   if(HasOpenPosition()) return;

   // Ensure price bar arrays are ready
   MqlRates rates[];
   ArraySetAsSeries(rates, true);
   int copied = CopyRates(_Symbol, _Period, 0, InpPivotStrength * 2 + InpEmaPeriod + 10, rates);
   if(copied < InpPivotStrength * 2 + InpEmaPeriod + 10) return;

   // Index 1 represents the most recently CLOSED candle
   int i = 1;

   // 1. Session Filter Check
   if(InpFilterSessions && !IsInActiveSession(rates[i].time)) return;

   // Get EMA Data
   double emaVal = 0.0;
   if(InpFilterTrend)
   {
      double emaArray[];
      ArraySetAsSeries(emaArray, true);
      if(CopyBuffer(emaHandle, 0, 0, 5, emaArray) <= 0) return;
      emaVal = emaArray[i];
   }

   double pipFactor = (_Digits == 3 || _Digits == 5) ? 10.0 * _Point : _Point;

   // 2. Identify Structural Swing Levels
   double swingLow  = FindRecentSwingLow(rates, i + 1, InpPivotStrength, copied);
   double swingHigh = FindRecentSwingHigh(rates, i + 1, InpPivotStrength, copied);

   // --- BULLISH BUY SETUP ---
   if(swingLow > 0.0 && rates[i].low < swingLow && rates[i].close > swingLow)
   {
      bool trendValid = !InpFilterTrend || (rates[i].close > emaVal);
      bool fvgValid   = !InpUseSMC || IsBullishFVG(rates, i, pipFactor);
      bool crtValid   = !InpUseCRT || IsCRTSweepBullish(rates, i);

      if(trendValid && fvgValid && crtValid)
      {
         double entry = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
         double sl    = rates[i].low - (InpSLBufferPips * pipFactor);
         double risk  = entry - sl;
         double tp    = entry + (risk * InpRiskReward);

         double lotSize = CalculateLotSize(risk);
         if(lotSize > 0)
         {
            trade.Buy(lotSize, _Symbol, entry, sl, tp, "SMC Bullish Sweep EA");
         }
      }
   }

   // --- BEARISH SELL SETUP ---
   if(swingHigh > 0.0 && rates[i].high > swingHigh && rates[i].close < swingHigh)
   {
      bool trendValid = !InpFilterTrend || (rates[i].close < emaVal);
      bool fvgValid   = !InpUseSMC || IsBearishFVG(rates, i, pipFactor);
      bool crtValid   = !InpUseCRT || IsCRTSweepBearish(rates, i);

      if(trendValid && fvgValid && crtValid)
      {
         double entry = SymbolInfoDouble(_Symbol, SYMBOL_BID);
         double sl    = rates[i].high + (InpSLBufferPips * pipFactor);
         double risk  = sl - entry;
         double tp    = entry - (risk * InpRiskReward);

         double lotSize = CalculateLotSize(risk);
         if(lotSize > 0)
         {
            trade.Sell(lotSize, _Symbol, entry, sl, tp, "SMC Bearish Sweep EA");
         }
      }
   }
}

//+------------------------------------------------------------------+
//| Dynamic Lot Size Calculation Based on % Risk                     |
//+------------------------------------------------------------------+
double CalculateLotSize(double riskInPoints)
{
   if(riskInPoints <= 0) return 0.0;

   double balance     = AccountInfoDouble(ACCOUNT_BALANCE);
   double riskAmount   = balance * (InpRiskPercent / 100.0);
   double tickValue    = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
   double tickSize     = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);

   if(tickSize <= 0 || tickValue <= 0) return 0.0;

   double lotStep      = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
   double minLot       = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
   double maxLot       = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);

   double rawLot       = riskAmount / ((riskInPoints / tickSize) * tickValue);
   double customLot    = MathFloor(rawLot / lotStep) * lotStep;

   return MathMax(minLot, MathMin(maxLot, customLot));
}

//+------------------------------------------------------------------+
//| Check if open positions exist for this Magic Number              |
//+------------------------------------------------------------------+
bool HasOpenPosition()
{
   for(int k = PositionsTotal() - 1; k >= 0; k--)
   {
      if(PositionGetSymbol(k) == _Symbol)
      {
         if(PositionGetInteger(POSITION_MAGIC) == InpMagicNumber)
            return true;
      }
   }
   return false;
}

//+------------------------------------------------------------------+
//| Helper Confluence Checks                                         |
//+------------------------------------------------------------------+
bool IsInActiveSession(datetime barTime)
{
   MqlDateTime dt;
   TimeToStruct(barTime, dt);
   return (dt.hour >= InpLondonStartHour && dt.hour <= InpNYEndHour);
}

bool IsBullishFVG(const MqlRates &rates[], int i, double pipFactor)
{
   return ((rates[i].low - rates[i + 2].high) >= (InpMinFvgPips * pipFactor));
}

bool IsBearishFVG(const MqlRates &rates[], int i, double pipFactor)
{
   return ((rates[i + 2].low - rates[i].high) >= (InpMinFvgPips * pipFactor));
}

bool IsCRTSweepBullish(const MqlRates &rates[], int i)
{
   return (rates[i].low < rates[i + 1].low && rates[i].close > rates[i + 1].low);
}

bool IsCRTSweepBearish(const MqlRates &rates[], int i)
{
   return (rates[i].high > rates[i + 1].high && rates[i].close < rates[i + 1].high);
}

double FindRecentSwingLow(const MqlRates &rates[], int startIdx, int strength, int totalBars)
{
   for(int k = startIdx; k <= totalBars - strength - 1; k++)
   {
      bool isPivot = true;
      for(int j = 1; j <= strength; j++)
      {
         if(rates[k].low >= rates[k - j].low || rates[k].low >= rates[k + j].low)
         {
            isPivot = false;
            break;
         }
      }
      if(isPivot) return rates[k].low;
   }
   return 0.0;
}

double FindRecentSwingHigh(const MqlRates &rates[], int startIdx, int strength, int totalBars)
{
   for(int k = startIdx; k <= totalBars - strength - 1; k++)
   {
      bool isPivot = true;
      for(int j = 1; j <= strength; j++)
      {
         if(rates[k].high <= rates[k - j].high || rates[k].high <= rates[k + j].high)
         {
            isPivot = false;
            break;
         }
      }
      if(isPivot) return rates[k].high;
   }
   return 0.0;
}
//+------------------------------------------------------------------+

Répondu

1
Développeur 1
Évaluation
(17)
Projets
21
19%
Arbitrage
5
40% / 40%
En retard
0
Gratuit
2
Développeur 2
Évaluation
(20)
Projets
28
39%
Arbitrage
8
25% / 38%
En retard
2
7%
Chargé
Publié : 8 articles, 35 codes
3
Développeur 3
Évaluation
(1)
Projets
1
0%
Arbitrage
1
0% / 100%
En retard
0
Gratuit
4
Développeur 4
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
5
Développeur 5
Évaluation
(1)
Projets
1
0%
Arbitrage
0
En retard
1
100%
Gratuit
6
Développeur 6
Évaluation
(20)
Projets
29
3%
Arbitrage
4
0% / 100%
En retard
5
17%
Gratuit
7
Développeur 7
Évaluation
(2)
Projets
3
67%
Arbitrage
0
En retard
0
Travail
Publié : 2 codes
8
Développeur 8
Évaluation
(42)
Projets
112
56%
Arbitrage
2
50% / 0%
En retard
3
3%
Gratuit
Publié : 1 code
9
Développeur 9
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
Commandes similaires
Please may someone assist me with the indicator attached, it has a SERIOUS BUG issue in the sense that when I load it, and activate the template (attached as well) MT4 ALWAYS freezes and then eventually disconnects automatically, ALL THE TIME. It even gets worse to an extent that after disconnecting a number of times mt4 ends up not loading anymore, UNTIL I remove the indicator. Please I WILL NEED A DEMO (FOR A DAY)
I’m looking for an experienced NinjaTrader 8 developer to build an automated strategy using the Imbalance Profile Lidar indicator by ninZa.co on MNQ DEC26 with a 3000-volume chart . Requirements: Enter Long when a blue absorption dot appears below price with an absorption value. Enter Short when a pink absorption dot appears above price with an absorption value. Stop loss: 15 ticks behind the signal dot price . Take
Ola, Tenho um Bot mas parou de funcionar, preciso de programador que desenvolva o mesmo configurações. Envio o antigo bot para pegar as configurações e realizar outro modelo. Hello, I have a bot that has stopped working, and I need a programmer to develop one with the same settings. I can send the old bot so you can extract the settings and build a new version
I have a simple EA that trades based on pending orders I need it to be converted to cTrader am looking for expert developer that have experience in ctrader that can convert metatrader 5 robot to ctrader
SPECIAL BAR EA 30+ USD
Hello Dear Coders , Here is a strategy with calculations on a specific bar ,sould be implemented carefully. Calculation on the bar needs math at some degree . trade numbers and trade results should be written right below the specific bar . Vague points should be cleared before starting coding. below is the %80 of full strategy and its explanations , the full will be given after selecting developer. POSITIONS ON A
Hello, I'm looking to develop a Forex Expert Advisor (EA) for MetaTrader 5 (MT5). I have an existing strategy and I'm looking for a complete solution developed from scratch. The main requirements are: Strategy research and development profitable trading objectives. Automated Forex trading with clearly defined entry and exit rules. Risk management, including stop-loss, take-profit, and position sizing. Backtesting and
Hello Developers, I am looking for an experienced MQL5 developer to build a custom Expert Advisor (EA) for MetaTrader 5 (MT5) based on ICT (Inner Circle Trader) concepts and Support/Resistance price action. Key Features & Strategy Requirements: 1. Market Structure & Price Action: - Identify Support and Resistance zones automatically. - Detect Break of Structure (BOS) and Change of Character (CHoCH). - Identify
A video of the front end project is attached or uploaded in the link for view, the project is to build web app trader for login of mt4 / mt5 login and trades, the Web app is still under development your ideas matter in this project feel free to share ideal regards this project if you are good in Visual studio 2022 VS code and have handled C++ projects before on multiple situation this project might be yours. UI/UX
I am looking for an experienced MQL5 developer to build a fully automated MT5 Expert Advisor for XAUUSD. The trading rules are already defined. I need the developer to implement them accurately in MQL5, not redesign the strategy. Main requirements: XAUUSD Multi-timeframe logic: H1 direction, M15 setup, M5 entry Entry only after candle-close confirmation No repainting / closed-bar logic Configurable Stop Loss and Take
I’m looking for a professional and experienced developer to build an automated Pocket Option trading bot. Requirements: Trade OTC stocks, crypto, and currencies. AI-assisted market analysis and trade signals. Automatic entry/exit based on the implemented strategy. Execute 5 trades, then pause for 10 minutes before continuing. Adjustable trade amount. Configurable risk management, including stop-loss/take-profit where

Informations sur le projet

Budget
100+ USD

Client

Commandes passées1
Nombre d'arbitrages0