Make it work -Expert advisor

MQL5 Experts

Spécifications

//+------------------------------------------------------------------+
//| EMA + Resistance Break & First Retest EA - ATR SL/TP - Risk 3%   |
//| Fully working MT4 EA                                             |
//+------------------------------------------------------------------+
#property strict

//---- Inputs
input double RiskPercent = 3.0;
input int ATR_Period = 14;
input double SL_ATR_Multiplier = 1.5;
input double TP_ATR_Multiplier = 2.0;
input int StopLossPipsFallback = 50;  // Fallback if ATR fails
input int TakeProfitPipsFallback = 100;
input int H4_MA_Period = 9;
input int FastEMA = 5;
input int SlowEMA = 13;
input int ResistanceLookback = 50;      // H4 candles to scan for resistance
input int ResistanceBufferPips = 10;    // Entry buffer around resistance
input string ResistanceLineName = "H4_Resistance";
input bool DrawSLTP = true;

//---- Session Settings (Broker Time)
input int LondonStartHour = 8;
input int LondonEndHour   = 17;
input int NYStartHour     = 13;
input int NYEndHour       = 22;

//---- Other Settings
input int MagicNumber = 12345;
input bool EnableSell = true;

//---- Globals
datetime lastCandleTime = 0;
int lastTradeSession = -1;   // 0=London, 1=NY
int lastTradeDay = -1;
bool firstRetestDone = false;

//+------------------------------------------------------------------+
//| Get current session                                              |
//+------------------------------------------------------------------+
int GetCurrentSession()
{
   int hour = TimeHour(TimeCurrent());
   if(hour >= LondonStartHour && hour < LondonEndHour) return 0; // London
   if(hour >= NYStartHour && hour < NYEndHour) return 1; // NY
   return -1; // No session
}

//+------------------------------------------------------------------+
//| Check if trading allowed in this session                          |
//+------------------------------------------------------------------+
bool CanTradeSession()
{
   int session = GetCurrentSession();
   if(session == -1) return false;

   int day = TimeDay(TimeCurrent());

   // Reset first retest on new session
   if(session != lastTradeSession || day != lastTradeDay)
   {
      firstRetestDone = false;
   }

   // Allow trade if first retest not done yet
   if(firstRetestDone) return false;

   return true;
}

//+------------------------------------------------------------------+
//| Get lot size based on risk                                        |
//+------------------------------------------------------------------+
double GetLotSize(double stopLossPips)
{
   double riskAmount = AccountBalance() * RiskPercent / 100.0;
   double pipValue = MarketInfo(Symbol(), MODE_TICKVALUE);

   double lot = riskAmount / (stopLossPips * pipValue);

   double minLot = MarketInfo(Symbol(), MODE_MINLOT);
   double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);
   double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);

   lot = MathFloor(lot / lotStep) * lotStep;
   lot = MathMax(minLot, MathMin(lot, maxLot));

   return NormalizeDouble(lot, 2);
}

//+------------------------------------------------------------------+
//| Check if trade is open                                            |
//+------------------------------------------------------------------+
bool IsTradeOpen()
{
   for(int i=0; i<OrdersTotal(); i++)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
            return true;
   }
   return false;
}

//+------------------------------------------------------------------+
//| Register trade session                                            |
//+------------------------------------------------------------------+
void RegisterTrade()
{
   lastTradeSession = GetCurrentSession();
   lastTradeDay = TimeDay(TimeCurrent());
   firstRetestDone = true;
}

//+------------------------------------------------------------------+
//| Get last H4 resistance                                           |
//+------------------------------------------------------------------+
double GetLastH4Resistance()
{
   double resistance = 0;
   for(int i=2; i<=ResistanceLookback; i++)
   {
      double high = iHigh(Symbol(), PERIOD_H4, i);
      if(high > resistance) resistance = high;
   }
   return resistance;
}

//+------------------------------------------------------------------+
//| Draw resistance line                                              |
//+------------------------------------------------------------------+
void DrawResistanceLine(double price)
{
   if(ObjectFind(ResistanceLineName) == -1)
   {
      ObjectCreate(ResistanceLineName, OBJ_HLINE, 0, 0, price);
      ObjectSet(ResistanceLineName, OBJPROP_COLOR, clrRed);
      ObjectSet(ResistanceLineName, OBJPROP_WIDTH, 2);
      ObjectSet(ResistanceLineName, OBJPROP_STYLE, STYLE_DASH);
   }
   else ObjectSet(ResistanceLineName, OBJPROP_PRICE1, price);
}

//+------------------------------------------------------------------+
//| Draw SL/TP lines on chart                                         |
//+------------------------------------------------------------------+
void DrawSLTPLines(double slPrice, double tpPrice)
{
   if(!DrawSLTP) return;

   string slName = "ATR_SL";
   string tpName = "ATR_TP";

   // SL
   if(ObjectFind(slName) == -1)
      ObjectCreate(slName, OBJ_HLINE, 0, 0, slPrice);
   ObjectSet(slName, OBJPROP_COLOR, clrRed);
   ObjectSet(slName, OBJPROP_WIDTH, 2);
   ObjectSet(slName, OBJPROP_STYLE, STYLE_DASH);
   ObjectSet(slName, OBJPROP_PRICE1, slPrice);

   // TP
   if(ObjectFind(tpName) == -1)
      ObjectCreate(tpName, OBJ_HLINE, 0, 0, tpPrice);
   ObjectSet(tpName, OBJPROP_COLOR, clrLime);
   ObjectSet(tpName, OBJPROP_WIDTH, 2);
   ObjectSet(tpName, OBJPROP_STYLE, STYLE_DASH);
   ObjectSet(tpName, OBJPROP_PRICE1, tpPrice);
}

//+------------------------------------------------------------------+
//| Get ATR distance                                                  |
//+------------------------------------------------------------------+
double GetATRDistance(int atrPeriod, double multiplier)
{
   double atr = iATR(Symbol(), PERIOD_H4, atrPeriod, 1);
   return atr * multiplier;
}

//+------------------------------------------------------------------+
//| OnTick                                                           |
//+------------------------------------------------------------------+
void OnTick()
{
   int session = GetCurrentSession();
   if(session == -1 || !CanTradeSession()) return;

   datetime currentCandle = iTime(Symbol(), PERIOD_M30, 0);
   if(currentCandle == lastCandleTime) return;
   lastCandleTime = currentCandle;

   if(IsTradeOpen()) return;

   double pip = (Digits==3||Digits==5)?Point*10:Point;

   //--- H4 trend
   double h4_ma = iMA(Symbol(), PERIOD_H4, H4_MA_Period, 0, MODE_EMA, PRICE_CLOSE, 1);
   double h4_price = iClose(Symbol(), PERIOD_H4, 1);

   //--- EMA crossover M30
   double emaFast_1 = iMA(Symbol(), PERIOD_M30, FastEMA, 0, MODE_EMA, PRICE_CLOSE, 1);
   double emaFast_2 = iMA(Symbol(), PERIOD_M30, FastEMA, 0, MODE_EMA, PRICE_CLOSE, 2);
   double emaSlow_1 = iMA(Symbol(), PERIOD_M30, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, 1);
   double emaSlow_2 = iMA(Symbol(), PERIOD_M30, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, 2);

   //--- Resistance
   double resistance = GetLastH4Resistance();
   DrawResistanceLine(resistance);
   double h4_close = iClose(Symbol(), PERIOD_H4, 1);
   double buffer = ResistanceBufferPips * pip;

   bool h4BreakConfirmed = h4_close > resistance;
   bool priceRetest = MathAbs(Bid - resistance) <= buffer;

   //--- ATR SL/TP
   double atrSL = GetATRDistance(ATR_Period, SL_ATR_Multiplier);
   double atrTP = GetATRDistance(ATR_Period, TP_ATR_Multiplier);

   //--- BUY
   bool buyCondition =
       h4BreakConfirmed &&
       h4_price > h4_ma &&
       emaFast_2 < emaSlow_2 &&
       emaFast_1 > emaSlow_1 &&
       priceRetest;

   if(buyCondition)
   {
       double lot = GetLotSize(atrSL/pip);
       double sl = Bid - atrSL;
       double tp = Bid + atrTP;

       DrawSLTPLines(sl,tp);

       if(OrderSend(Symbol(), OP_BUY, lot, Ask, 3, sl, tp,
                    "EMA Buy ATR SL/TP", MagicNumber, 0, clrBlue) > 0)
       {
           RegisterTrade();
       }
   }

   //--- SELL
   if(EnableSell)
   {
       bool sellCondition =
           h4_close < resistance &&
           h4_price < h4_ma &&
           emaFast_2 > emaSlow_2 &&
           emaFast_1 < emaSlow_1 &&
           priceRetest;

       if(sellCondition)
       {
           double lot = GetLotSize(atrSL/pip);
           double sl = Ask + atrSL;
           double tp = Ask - atrTP;

           DrawSLTPLines(sl,tp);

           if(OrderSend(Symbol(), OP_SELL, lot, Bid, 3, sl, tp,
                        "EMA Sell ATR SL/TP", MagicNumber, 0, clrRed) > 0)
           {
               RegisterTrade();
           }
       }
   }
}

//+------------------------------------------------------------------+


Please can you correct this EA to make it work


Répondu

1
Développeur 1
Évaluation
(15)
Projets
34
24%
Arbitrage
4
0% / 50%
En retard
2
6%
Travail
2
Développeur 2
Évaluation
(17)
Projets
21
10%
Arbitrage
4
50% / 50%
En retard
1
5%
Travail
3
Développeur 3
Évaluation
(15)
Projets
21
0%
Arbitrage
3
0% / 67%
En retard
4
19%
Chargé
4
Développeur 4
Évaluation
(18)
Projets
19
74%
Arbitrage
0
En retard
1
5%
Travail
Publié : 2 codes
5
Développeur 5
Évaluation
(4)
Projets
5
20%
Arbitrage
0
En retard
0
Travail
6
Développeur 6
Évaluation
(305)
Projets
546
35%
Arbitrage
79
32% / 42%
En retard
196
36%
Travail
7
Développeur 7
Évaluation
(3)
Projets
6
17%
Arbitrage
0
En retard
3
50%
Gratuit
8
Développeur 8
Évaluation
(27)
Projets
38
24%
Arbitrage
14
0% / 93%
En retard
4
11%
Gratuit
9
Développeur 9
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
10
Développeur 10
Évaluation
(3)
Projets
3
33%
Arbitrage
2
0% / 100%
En retard
0
Gratuit
11
Développeur 11
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
12
Développeur 12
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
13
Développeur 13
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
14
Développeur 14
Évaluation
(71)
Projets
254
53%
Arbitrage
16
50% / 38%
En retard
83
33%
Gratuit
15
Développeur 15
Évaluation
(1)
Projets
0
0%
Arbitrage
5
0% / 80%
En retard
0
Gratuit
16
Développeur 16
Évaluation
(2)
Projets
2
0%
Arbitrage
1
0% / 100%
En retard
0
Travail
17
Développeur 17
Évaluation
(9)
Projets
9
11%
Arbitrage
0
En retard
2
22%
Gratuit
18
Développeur 18
Évaluation
(8)
Projets
8
0%
Arbitrage
0
En retard
0
Gratuit
19
Développeur 19
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
20
Développeur 20
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Travail
21
Développeur 21
Évaluation
Projets
1
0%
Arbitrage
0
En retard
1
100%
Gratuit
22
Développeur 22
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
23
Développeur 23
Évaluation
(152)
Projets
228
80%
Arbitrage
22
27% / 50%
En retard
11
5%
Gratuit
Publié : 24 articles, 1882 codes
24
Développeur 24
Évaluation
(5)
Projets
4
0%
Arbitrage
2
50% / 50%
En retard
2
50%
Gratuit
25
Développeur 25
Évaluation
(3)
Projets
1
100%
Arbitrage
3
0% / 100%
En retard
0
Gratuit
26
Développeur 26
Évaluation
(43)
Projets
56
4%
Arbitrage
7
0% / 57%
En retard
4
7%
Travail
27
Développeur 27
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
28
Développeur 28
Évaluation
(294)
Projets
469
39%
Arbitrage
102
40% / 24%
En retard
77
16%
Chargé
Publié : 2 codes
Commandes similaires
PrimeFlowEA — v1 Specification Objective: PrimeFlowEA v1 is designed to enforce disciplined, rule-based execution within a single daily trading session. The goal of v1 is correct behavior and execution discipline , not optimization or performance tuning. 1. Market & Time Platform: MetaTrader 5 (MQL5) Symbol(s): User-selectable (single symbol per chart) Execution timeframe: Configurable (default: M5 / M15)
Top manager 70 - 120 USD
A multi-symbol, rule-based trade management Expert Advisor designed to recover, neutralize, and scale out of DCA baskets using intelligent closing logic and full manual control through an on-chart dashboard. The EA continuously scans multiple symbols and monitors all open trades with a specific magic number. Based on trader-enabled rules (R1–R4) and Break-Even modes (BE1–BE3), it selectively closes trades when
Specifications – Development of an MQL5 Expert Advisor (Reverse Engineering) Project context: I have access to a real trading history consisting of more than 500 trades executed over a period of approximately 3 years. These trades have been exported into a CSV file containing all available information, including date, time, symbol, order type, entry price, and exit price. Important: I do not have access to the
1.Sinyal Perdagangan : Sinyal beli: garis MACD utama memotong garis sinyal ke atas (macd_current>signal_current && macd_previous<signal_previous). Sinyal jual: garis MACD utama memotong garis sinyal ke bawah (macd_current<signal_current && macd_previous>signal_previous). Gambar di bawah menunjukkan kasus beli dan jual. 2. Posisi ditutup pada sinyal yang berlawanan: Posisi beli ditutup pada sinyal jual, dan posisi
Trading Bot Executes Trades on Specific Days via TradingView Alerts **As a** trader, **I want** to develop a trading bot that integrates with TradeLocker and MTS, **So that** when a TradingView alert (based on a 2,4,5,10,15,30 minute break and retest strategy whichever one) is triggered first. the bot will execute trades on both platforms, but only on specific days of the week. --- ## Acceptance Criteria 1
Project Description I am looking to collaborate with an experienced MQL5 / algorithmic trading developer who also has hands-on experience with Large Language Models (LLMs) and AI-driven systems. This is a long-term partnership opportunity , not a one-off paid freelance job. I bring 9 years of practical Elliott Wave trading experience , applied in live market conditions. The objective is to translate Elliott Wave
Hello, I’m looking for an experienced MT4 (MQL4) developer to convert the Lucky Reversal indicator from indicatorspot.com into a fully functional Expert Advisor (EA). Project Scope Code an MT4 EA that replicates the exact logic and signals of the Lucky Reversal indicator Trades should open and close automatically based on the indicator’s rules Must match indicator behavior 1:1 (no approximations) EA Requirements MT4
Looking for a developer to develop or provide past expert advisor that can cope with high impact news and high trends. needs to be mt5. Any strategy necessary. need to be able to backtest myself or see past results. Minimum profit per month 30% but needs to be very low drawdown. Can be one shot trade a day or a 1 min scalper ea. I will not be going to telegram to discuss further
🔹 COMPLETE DEVELOPMENT ASSIGNMENT Institutional Volume & Structure Indicator Platform: MT5 (preferred) OR TradingView (Pine Script v5) Type: Indicator only (NO EA, NO auto trading) Purpose: Institutional analysis for manual trading & manual backtesting 1. GENERAL REQUIREMENTS Indicator only (no orders, no strategy execution) No repainting Auto update + auto remove logic Clean, modular, performance-safe code User
specification High-Frequency Candle Momentum Scalper 1. Strategy Overview Core Logic: The EA identifies the current color of the active candle (Bullish or Bearish). Entry Trigger: It opens positions only after a specific duration of the candle has passed (e.g., after 30 seconds on a 1-minute candle) to confirm the direction. 2. Entry Logic (The "Half-Candle" Rule) Timeframe: M1 (Default, but adjustable). Time Filter

Informations sur le projet

Budget
30+ USD
Délais
à 10 jour(s)

Client

Commandes passées1
Nombre d'arbitrages0