Gold_Breakout_Ultimate_EA.mq5

MQL5 EA 통합 Strategy optimization

명시

//+------------------------------------------------------------------+
//|                 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 코드
21
개발자 21
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
비슷한 주문
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