Gold_Breakout_Ultimate_EA.mq5

MQL5 专家 积分 策略优化

指定

//+------------------------------------------------------------------+
//|                 Gold_Breakout_Ultimate_EA.mq5                    |
//|                   الإصدار النهائي - خالي من أيقونة               |
//+------------------------------------------------------------------+
#property copyright "Elite Trader"
#property version   "1.13"
#property strict

// تم حذف سطر #property icon عمداً لتجنب خطأ الملف المفقود

#include <Trade/Trade.mqh>

// ==================== إعدادات المدخلات ====================
input double InpRiskPercent = 1.5;          // نسبة المخاطرة من الرصيد (%)
input double InpFixedLots = 0.0;            // حجم عقد ثابت (0 = استخدام النسبة)
input int    InpBreakoutBars = 20;          // عدد الشموع لتحديد المنطقة
input double InpBufferPercent = 0.15;       // هامش التمويه (لتقليل الإشارات الخادعة)
input int    InpRSIPeriod = 14;             // فترة مؤشر RSI
input int    InpMAPeriod = 200;             // المتوسط المتحرك للاتجاه العام
input double InpATRFilter = 0.4;            // نسبة ATR للفلتر (0 = إلغاء)
input double InpTakeProfitRatio = 2.0;      // مضاعف وقف الخسارة للهدف الأول
input double InpPartialPercent = 50.0;      // نسبة الإغلاق الجزئي عند الهدف الأول (%)
input double InpTrailingATR = 1.8;          // تفعيل التريلنج بعد هذا المضاعف من ATR
input bool   InpUseTimeFilter = true;       // تفعيل فلتر تجنب أوقات الأخبار
input int    InpCooldownBars = 3;           // عدد الشموع للانتظار بعد الصفقة الخاسرة

// ==================== المتغيرات العامة ====================
double Resistance_Level, Support_Level;
double ATR_Value, MA_Value, RSI_Value;
datetime lastBarTime;
int ATR_Handle, RSI_Handle, MA_Handle;
bool isBuyCooldown = false, isSellCooldown = false;
int barsAfterLoss = 0;
double lastTradeResult = 0;
CTrade trade;

//+------------------------------------------------------------------+
//| دالة التهيئة                                                     |
//+------------------------------------------------------------------+
int OnInit()
{
   ATR_Handle = iATR(_Symbol, _Period, 14);
   RSI_Handle = iRSI(_Symbol, _Period, InpRSIPeriod, PRICE_CLOSE);
   MA_Handle = iMA(_Symbol, _Period, InpMAPeriod, 0, MODE_SMA, PRICE_CLOSE);
   
   if(ATR_Handle == INVALID_HANDLE || RSI_Handle == INVALID_HANDLE || MA_Handle == INVALID_HANDLE)
   {
      Print("خطأ في تهيئة المؤشرات");
      return(INIT_FAILED);
   }
   
   lastBarTime = iTime(_Symbol, _Period, 0);
   Print("✅ روبوت الذهب جاهز على ", _Symbol);
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| دالة التحديث لكل شمعة جديدة                                     |
//+------------------------------------------------------------------+
void OnTick()
{
   if(lastBarTime == iTime(_Symbol, _Period, 0))
      return;
   lastBarTime = iTime(_Symbol, _Period, 0);

   UpdateIndicators();
   CalculateZones();
   DrawZones();
   ManageOpenPositions();
   CheckForEntry();
}

//+------------------------------------------------------------------+
//| تحديث قيم المؤشرات                                              |
//+------------------------------------------------------------------+
void UpdateIndicators()
{
   double atr_arr[1], rsi_arr[1], ma_arr[1];
   CopyBuffer(ATR_Handle, 0, 0, 1, atr_arr);
   CopyBuffer(RSI_Handle, 0, 0, 1, rsi_arr);
   CopyBuffer(MA_Handle, 0, 0, 1, ma_arr);
   ATR_Value = atr_arr[0];
   RSI_Value = rsi_arr[0];
   MA_Value = ma_arr[0];
   if(ATR_Value == 0) ATR_Value = 0.1; // حماية
}

//+------------------------------------------------------------------+
//| حساب مناطق الدعم والمقاومة                                      |
//+------------------------------------------------------------------+
void CalculateZones()
{
   int start = 1;
   double high = iHigh(_Symbol, _Period, iHighest(_Symbol, _Period, MODE_HIGH, InpBreakoutBars, start));
   double low  = iLow(_Symbol, _Period, iLowest(_Symbol, _Period, MODE_LOW, InpBreakoutBars, start));
   double buffer = (high - low) * (InpBufferPercent / 100);
   Resistance_Level = high + buffer;
   Support_Level = low - buffer;
}

//+------------------------------------------------------------------+
//| رسم الخطوط على الشارت                                            |
//+------------------------------------------------------------------+
void DrawZones()
{
   ObjectCreate(0, "UBS_Res", OBJ_HLINE, 0, 0, Resistance_Level);
   ObjectSetInteger(0, "UBS_Res", OBJPROP_COLOR, clrRed);
   ObjectCreate(0, "UBS_Supp", OBJ_HLINE, 0, 0, Support_Level);
   ObjectSetInteger(0, "UBS_Supp", OBJPROP_COLOR, clrGreen);
}

//+------------------------------------------------------------------+
//| منطق الدخول (مع فلاتر الخبرة والـ ATR)                          |
//+------------------------------------------------------------------+
void CheckForEntry()
{
   if(InpUseTimeFilter && IsNewsTime())
      return;

   double close_cur = iClose(_Symbol, _Period, 0);
   double close_prev = iClose(_Symbol, _Period, 1);
   double open_cur = iOpen(_Symbol, _Period, 0);

   if(InpATRFilter > 0)
   {
      double range = MathAbs(close_cur - open_cur);
      if(range < (ATR_Value * InpATRFilter)) return;
   }

   // شراء
   if(!isBuyCooldown && close_prev <= Resistance_Level && close_cur > Resistance_Level && RSI_Value > 50)
   {
      if(!IsPositionExist(POSITION_TYPE_BUY))
      {
         double sl = Support_Level - (ATR_Value * 0.5);
         double tp = close_cur + ( (close_cur - sl) * InpTakeProfitRatio );
         OpenOrder(ORDER_TYPE_BUY, sl, tp);
         Print("🟢 شراء عند الاختراق");
      }
   }

   // بيع
   if(!isSellCooldown && close_prev >= Support_Level && close_cur < Support_Level && RSI_Value < 50)
   {
      if(!IsPositionExist(POSITION_TYPE_SELL))
      {
         double sl = Resistance_Level + (ATR_Value * 0.5);
         double tp = close_cur - ( (sl - close_cur) * InpTakeProfitRatio );
         OpenOrder(ORDER_TYPE_SELL, sl, tp);
         Print("🔴 بيع عند الكسر");
      }
   }
}

//+------------------------------------------------------------------+
//| إدارة الصفقات (الإغلاق الجزئي والتريلنج)                       |
//+------------------------------------------------------------------+
void ManageOpenPositions()
{
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);
      if(PositionSelectByTicket(ticket))
      {
         if(PositionGetString(POSITION_SYMBOL) != _Symbol) continue;
         
         double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);
         double currentSL = PositionGetDouble(POSITION_SL);
         double currentTP = PositionGetDouble(POSITION_TP);
         ENUM_POSITION_TYPE type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
         
         double distance = 0;
         if(type == POSITION_TYPE_BUY)
            distance = (SymbolInfoDouble(_Symbol, SYMBOL_BID) - openPrice) / ATR_Value;
         else
            distance = (openPrice - SymbolInfoDouble(_Symbol, SYMBOL_ASK)) / ATR_Value;
         
         // إغلاق جزئي عند الهدف الأول
         if(distance >= (InpTakeProfitRatio * 0.75) && currentTP == 0)
         {
            if(InpPartialPercent > 0)
            {
               double lots = PositionGetDouble(POSITION_VOLUME);
               double closeLots = lots * (InpPartialPercent / 100);
               if(closeLots > 0.01)
               {
                  trade.PositionClosePartial(ticket, NormalizeLots(closeLots));
               }
            }
            trade.PositionModify(ticket, openPrice, 0);
         }
         
         // تفعيل التريلنج
         if(distance >= InpTrailingATR)
         {
            double newSL = 0;
            if(type == POSITION_TYPE_BUY)
               newSL = SymbolInfoDouble(_Symbol, SYMBOL_BID) - (ATR_Value * 0.8);
            else
               newSL = SymbolInfoDouble(_Symbol, SYMBOL_ASK) + (ATR_Value * 0.8);
            
            if((type == POSITION_TYPE_BUY && newSL > currentSL) ||
               (type == POSITION_TYPE_SELL && newSL < currentSL))
            {
               trade.PositionModify(ticket, newSL, currentTP);
            }
         }
      }
   }
}

//+------------------------------------------------------------------+
//| تنفيذ الأمر                                                      |
//+------------------------------------------------------------------+
void OpenOrder(ENUM_ORDER_TYPE type, double sl_price, double tp_price)
{
   double lots = InpFixedLots;
   if(lots == 0)
   {
      double riskMoney = AccountInfoDouble(ACCOUNT_BALANCE) * (InpRiskPercent / 100);
      double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
      double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
      double price = (type == ORDER_TYPE_BUY) ? SymbolInfoDouble(_Symbol, SYMBOL_ASK) : SymbolInfoDouble(_Symbol, SYMBOL_BID);
      double slPoints = MathAbs(sl_price - price) / _Point;
      double riskPerLot = slPoints * tickValue * (tickSize / _Point);
      if(riskPerLot > 0) lots = riskMoney / riskPerLot;
      lots = NormalizeLots(lots);
   }

   double price = (type == ORDER_TYPE_BUY) ? SymbolInfoDouble(_Symbol, SYMBOL_ASK) : SymbolInfoDouble(_Symbol, SYMBOL_BID);
   trade.PositionOpen(_Symbol, type, lots, price, sl_price, tp_price, "Gold EA");
}

//+------------------------------------------------------------------+
//| دوال مساعدة                                                      |
//+------------------------------------------------------------------+
bool IsPositionExist(ENUM_POSITION_TYPE type)
{
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      if(PositionSelectByTicket(PositionGetTicket(i)))
         if(PositionGetString(POSITION_SYMBOL) == _Symbol && PositionGetInteger(POSITION_TYPE) == type)
            return true;
   }
   return false;
}

double NormalizeLots(double lots)
{
   double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
   if(step == 0) step = 0.01;
   double normalized = MathRound(lots / step) * step;
   normalized = NormalizeDouble(normalized, 2);
   if(normalized < SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN)) normalized = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
   if(normalized > SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX)) normalized = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
   return normalized;
}

بول إز نيوزتايم()
{
   datetime now = TimeCurrent();
   MqlDateTime dt;
TimeToStruct (الآن، dt);
   // تجنب التداول من 13:30 إلى 15:30 بتوقيت السيرفر
إذا (dt.hour == 13 && dt.min >= 30) أعاد true;
إذا (dt.hour == 14) أعاد true;
إذا (dt.hour == 15 && dt.min < 30) أعد true;
العودة خاطئة؛
}

//+------------------------------------------------------------------+
//| دالة التدمير (تنظيف)                                            |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
إذا(ATR_Handle != INVALID_HANDLE) IndicatorRelease(ATR_Handle);
إذا(RSI_Handle != INVALID_HANDLE) IndicatorRelease(RSI_Handle);
   if(MA_Handle != INVALID_HANDLE) IndicatorRelease(MA_Handle);
ObjectsDeleteAll (0, "UBS_");
Print(" 🛑 تم إيقاف الروبوت وتنظيف الشارت");
}

反馈

1
开发者 1
等级
(18)
项目
22
18%
仲裁
8
38% / 38%
逾期
3
14%
工作中
2
开发者 2
等级
(8)
项目
8
0%
仲裁
2
50% / 0%
逾期
1
13%
工作中
3
开发者 3
等级
项目
1
0%
仲裁
0
逾期
0
空闲
4
开发者 4
等级
(13)
项目
20
45%
仲裁
6
33% / 17%
逾期
2
10%
已载入
发布者: 7 文章, 35 代码
5
开发者 5
等级
(396)
项目
511
23%
仲裁
60
57% / 25%
逾期
60
12%
工作中
6
开发者 6
等级
(3)
项目
4
0%
仲裁
1
100% / 0%
逾期
1
25%
空闲
7
开发者 7
等级
项目
0
0%
仲裁
0
逾期
0
空闲
8
开发者 8
等级
项目
1
0%
仲裁
0
逾期
0
空闲
9
开发者 9
等级
(3)
项目
8
63%
仲裁
0
逾期
0
工作中
10
开发者 10
等级
(1)
项目
1
0%
仲裁
0
逾期
0
空闲
发布者: 1 代码
11
开发者 11
等级
(3)
项目
3
33%
仲裁
0
逾期
0
已载入
12
开发者 12
等级
(28)
项目
34
35%
仲裁
0
逾期
2
6%
空闲
13
开发者 13
等级
(1)
项目
1
0%
仲裁
0
逾期
0
空闲
14
开发者 14
等级
项目
0
0%
仲裁
0
逾期
0
空闲
15
开发者 15
等级
(83)
项目
95
32%
仲裁
9
22% / 56%
逾期
5
5%
工作中
16
开发者 16
等级
(3)
项目
2
0%
仲裁
1
0% / 100%
逾期
0
空闲
17
开发者 17
等级
项目
0
0%
仲裁
0
逾期
0
空闲
发布者: 1 代码
18
开发者 18
等级
(1)
项目
1
0%
仲裁
1
0% / 100%
逾期
0
工作中
19
开发者 19
等级
项目
0
0%
仲裁
0
逾期
0
空闲
20
开发者 20
等级
项目
0
0%
仲裁
0
逾期
0
空闲
发布者: 1 代码
相似订单
I want to Build a EA Robot that combine from my trading style and any conditions we can discussion. My trading style information below. 1 Set Up , 1 Rule , 1 Trade , 1 Session , 1 Target
Ich möchte einen professionellen Expert Advisor (EA) für MetaTrader 5 entwickeln lassen, der sich funktional am ThunderGold Scalper orientiert. Instrument: XAUUSD / GOLD Zeitrahmen: M15 Plattform: MetaTrader 5 / MQL5 Der EA soll eine eigene, nachprogrammierte Strategie verwenden und keine geschützten Quellcodes oder proprietären Dateien des Originalprodukts kopieren. Gewünschte Funktionen: automatischer Handel auf
I need a fully automated Expert Advisor (EA) written in MQL5 for MetaTrader 5. The EA must work directly inside MT5 and must NOT require TradingView, PineConnector, webhooks, or another external connector to place trades. Trading Instrument Primary symbol: XAGUSD (Silver) My broker may display the symbol as XAGUSD-ECN, so the EA should work with the broker’s available XAGUSD symbol. Main entry timeframe: 5-minute
RECHERCHE DÉVELOPPEUR MQL5 — PARTENARIAT 50/50 Objectif : développer un EA de trading automatisé en 11 jours maximum pour participer à plusieurs concours de trading démo. Je recherche un développeur MQL5 expérimenté, capable de développer, tester et optimiser un EA proprement, avec une vraie maîtrise de la gestion du risque. CONCOURS VISÉS 🥇 XM — Weekly Demo Contest - Concours récurrent - Prize pool annoncé : 25 000
GoldTrade EA 89+ USD
//+------------------------------------------------------------------+ //| XAUUSD Wolfe + SMC Quick Profit EA | //| MT5 / MQL5 | //+------------------------------------------------------------------+ #property strict #include <Trade/Trade.mqh> CTrade trade; //================================================================== // INPUTS //================================================================== //--- General
can you help me with I have an indicator that I built and I work with PickMyTrade. The entries come through the alerts I get from Trading View . Trading View needs to send an alert and PickMyTrade executes a trade at that exact same second. Now, I have a problem in Trading View with the synchronization between the alert and the signal. I have a box that I built for a trade. It needs to output the box and get an
Looking for a developer in NinjaTrader For coding Inst - ES,NQ Chart type - Tick, range, volume & time Brief- Fib levels mapped on chart which act as entries, tgts and stops all based on candle close. (Maybe) use MACD for filtering direction. Daily manual input of the TWO fib Anchor levels is part of the strategy. I need a well experienced developer to bid and before biding check the attached file well. the PDF and
I Have an existing Mql5 Expert advisor (source code), I want a professional programmer to help me Modify the EA... so that it can stop taking new trades once it Gets to a Pacific Lots Size or Floating loss
I Have an existing Mql5 Expert advisor (source code), I want a professional programmer to help me Modify the EA... so that it can stop taking new trades once it Gets to a Pacific Lots Size or Floating loss
take your time better make it for days and have good bot than never benefits both of us. Make the bot have zero errors and backtest it for a 2 year period

项目信息

预算
68+ USD
截止日期
 15  33 天

客户

所下订单1
仲裁计数0