Sniffer

MQL5 エキスパート

指定

//+------------------------------------------------------------------+
//|                                           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;
}
//+------------------------------------------------------------------+

応答済み

1
開発者 1
評価
(17)
プロジェクト
21
19%
仲裁
5
40% / 40%
期限切れ
0
2
開発者 2
評価
(20)
プロジェクト
28
39%
仲裁
8
25% / 38%
期限切れ
2
7%
取り込み中
パブリッシュした人: 8 articles, 35 codes
3
開発者 3
評価
(1)
プロジェクト
1
0%
仲裁
1
0% / 100%
期限切れ
0
4
開発者 4
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
5
開発者 5
評価
(1)
プロジェクト
1
0%
仲裁
0
期限切れ
1
100%
6
開発者 6
評価
(20)
プロジェクト
29
3%
仲裁
4
0% / 100%
期限切れ
5
17%
7
開発者 7
評価
(2)
プロジェクト
3
67%
仲裁
0
期限切れ
0
仕事中
パブリッシュした人: 2 codes
8
開発者 8
評価
(42)
プロジェクト
112
56%
仲裁
2
50% / 0%
期限切れ
3
3%
パブリッシュした人: 1 code
9
開発者 9
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
10
開発者 10
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
11
開発者 11
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
12
開発者 12
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
13
開発者 13
評価
(369)
プロジェクト
455
55%
仲裁
24
54% / 17%
期限切れ
31
7%
取り込み中
14
開発者 14
評価
(7)
プロジェクト
6
0%
仲裁
4
25% / 75%
期限切れ
2
33%
15
開発者 15
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
16
開発者 16
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
17
開発者 17
評価
(555)
プロジェクト
847
61%
仲裁
33
27% / 45%
期限切れ
24
3%
パブリッシュした人: 1 code
類似した注文
VEE STRATEGY ROBOT 30 - 200 USD
//+------------------------------------------------------------------+ //| M5 Trend Pullback EA | //| Exness / MT5 | //| Forex + XAUUSD | //| Risk: 0.5% per trade | //+------------------------------------------------------------------+ #property strict #property version "1.00" #property description "M5 EMA50/EMA200 + RSI + ATR Trend Pullback EA" #include <Trade/Trade.mqh> CTrade trade;
Purpose Develop a transparent and conservative Expert Advisor for MetaTrader 5. Profit is not guaranteed; acceptance is based on correct implementation, risk controls and reproducible testing. 1. Platform and instruments - Native MQL5 Expert Advisor for MetaTrader 5. - Symbols: EURUSD and USDJPY. - Working timeframe: H1. Higher-timeframe trend filter: H4. - Must support standard broker symbol suffixes/prefixes and
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

プロジェクト情報

予算
100+ USD

依頼者

出された注文1
裁定取引数0