Termos de Referência

//+------------------------------------------------------------------+
//| XAUUSD Ultimate Institutional EA                                  |
//| Features:                                                         |
//| - True swing-based market structure                                |
//| - BOS sniper entries on M5                                         |
//| - Liquidity sweep filter                                           |
//| - Partial TP + breakeven                                           |
//| - Visual BOS, swings, liquidity                                   |
//| - ATR-based dynamic SL                                             |
//| - Trailing stop                                                    |
//| - Session filter (London + NY)                                     |
//| - Risk management (1% per trade)                                   |
//+------------------------------------------------------------------+
#property strict
#include <Trade/Trade.mqh>
CTrade trade;

//================ INPUTS =================
input double RiskPercent = 1.0;           // % risk per trade
input double RR = 2.0;                    // Target RR
input double PartialClosePercent = 50.0;  // % to close at first TP
input int    SL_Buffer_Points = 400;      // SL buffer (XAU volatility)
input int    MaxSL_Points = 3000;         // Skip trades if SL too wide
input ENUM_TIMEFRAMES HTF = PERIOD_H1;    // Higher timeframe
input ENUM_TIMEFRAMES LTF = PERIOD_M5;    // Lower timeframe
input int LondonStart = 10;               // London session start
input int LondonEnd   = 13;               // London session end
input int NYStart     = 15;               // NY session start
input int NYEnd       = 18;               // NY session end
input bool UseNewsFilter = true;          // Toggle news filter
input int NewsPauseBefore = 30;           // Minutes before news
input int NewsPauseAfter  = 30;           // Minutes after news
input int FractalDepth = 2;               // For true swing detection
input int ATR_Period = 14;                // ATR period
input double ATR_Multiplier = 1.5;        // ATR multiplier for SL
input double TrailingStart = 1.0;         // RR ratio to start trailing
input double TrailingStep = 50;           // Points per trailing move

//================ GLOBALS =================
datetime LastTradeDay;
bool PartialTaken = false;
bool BuyLiquidityTaken = false;
bool SellLiquidityTaken = false;
double LastSwingHigh = 0;
double PrevSwingHigh = 0;
double LastSwingLow  = 0;
double PrevSwingLow  = 0;

//================ SESSION CHECK =================
bool InSession()
{
   int h = TimeHour(TimeCurrent());
   return (h>=LondonStart && h<=LondonEnd) || (h>=NYStart && h<=NYEnd);
}

//================ TRUE SWING DETECTION =================
void DetectSwings()
{
   for (int i = 5; i < 100; i++)
   {
      double fh = iFractals(_Symbol, HTF, MODE_UPPER, i);
      double fl = iFractals(_Symbol, HTF, MODE_LOWER, i);

      if (fh != 0)
      {
         PrevSwingHigh = LastSwingHigh;
         LastSwingHigh = fh;
      }
      if (fl != 0)
      {
         PrevSwingLow = LastSwingLow;
         LastSwingLow = fl;
      }
      if (PrevSwingHigh > 0 && PrevSwingLow > 0) break;
   }
}

//================ MARKET STRUCTURE =================
bool BullishStructure()
{
   DetectSwings();
   return (LastSwingHigh > PrevSwingHigh &&
           LastSwingLow  > PrevSwingLow);
}

bool BearishStructure()
{
   DetectSwings();
   return (LastSwingHigh < PrevSwingHigh &&
           LastSwingLow  < PrevSwingLow);
}

//================ LOT CALCULATION =================
double LotByRisk(double sl_points)
{
   double bal = AccountInfoDouble(ACCOUNT_BALANCE);
   double riskMoney = bal * RiskPercent / 100.0;
   double tickVal = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
   double tickSz  = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
   double lot = riskMoney / (sl_points * tickVal / tickSz);
   return NormalizeDouble(lot, 2);
}

//================ LIQUIDITY SWEEP =================
void DetectLiquiditySweep(double ltf_low, double ltf_high, double close)
{
   BuyLiquidityTaken  = (ltf_low < LastSwingLow && close > LastSwingLow);
   SellLiquidityTaken = (ltf_high > LastSwingHigh && close < LastSwingHigh);

   // Visualize sweeps
   if(BuyLiquidityTaken)
      DrawLabel("LIQ_SWEEP_BUY", TimeCurrent(), LastSwingLow, "Sell-side Liquidity Taken", clrDodgerBlue);
   if(SellLiquidityTaken)
      DrawLabel("LIQ_SWEEP_SELL", TimeCurrent(), LastSwingHigh, "Buy-side Liquidity Taken", clrOrangeRed);
}

//================ DRAWING FUNCTIONS =================
void DrawLine(string name, datetime t1, double p1, datetime t2, double p2, color clr)
{
   ObjectDelete(0, name);
   ObjectCreate(0, name, OBJ_TREND, 0, t1, p1, t2, p2);
   ObjectSetInteger(0, name, OBJPROP_COLOR, clr);
   ObjectSetInteger(0, name, OBJPROP_WIDTH, 2);
}
void DrawLabel(string name, datetime t, double p, string text, color clr)
{
   ObjectDelete(0, name);
   ObjectCreate(0, name, OBJ_TEXT, 0, t, p);
   ObjectSetText(name, text, 10, "Arial", clr);
}

//================ ATR =================
double ATR(int period, ENUM_TIMEFRAMES tf)
{
   return iATR(_Symbol, tf, period, 0);
}

//================ PARTIAL TP + BREAKEVEN =================
void ManagePosition()
{
   if (!PositionSelect(_Symbol)) return;

   double entry = PositionGetDouble(POSITION_PRICE_OPEN);
   double sl    = PositionGetDouble(POSITION_SL);
   double tp    = PositionGetDouble(POSITION_TP);
   double vol   = PositionGetDouble(POSITION_VOLUME);
   int type     = PositionGetInteger(POSITION_TYPE);
   double price = (type==POSITION_TYPE_BUY) ? SymbolInfoDouble(_Symbol, SYMBOL_BID)
                                            : SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double risk = MathAbs(entry - sl);
   double oneR = (type==POSITION_TYPE_BUY) ? entry + risk : entry - risk;

   // Partial TP
   if (!PartialTaken &&
       ((type==POSITION_TYPE_BUY && price >= oneR) ||
        (type==POSITION_TYPE_SELL && price <= oneR)))
   {
      trade.PositionClosePartial(_Symbol, vol * PartialClosePercent / 100.0);
      trade.PositionModify(_Symbol, entry, tp); // move SL to breakeven
      PartialTaken = true;
   }

   // Trailing Stop
   double rrAchieved = (type==POSITION_TYPE_BUY) ? (price - entry)/risk : (entry - price)/risk;
   if(rrAchieved >= TrailingStart)
   {
      double new_sl;
      if(type==POSITION_TYPE_BUY)
         new_sl = price - TrailingStep*_Point;
      else
         new_sl = price + TrailingStep*_Point;

      if((type==POSITION_TYPE_BUY && new_sl > sl) ||
         (type==POSITION_TYPE_SELL && new_sl < sl))
      {
         trade.PositionModify(_Symbol, new_sl, tp);
      }
   }
}

//================ NEWS FILTER PLACEHOLDER =================
bool NewsSafe()
{
   if(!UseNewsFilter) return true;
   // Placeholder: safe, can integrate news API
   return true;
}

//================ MAIN LOGIC =================
void OnTick()
{
   if(_Symbol != "XAUUSD") return;
   if(!InSession()) return;
   if(!NewsSafe()) return;

   ManagePosition();
   if(PositionsTotal() > 0) return;

   double close = iClose(_Symbol, LTF, 1);
   double prevHigh = iHigh(_Symbol, LTF, 2);
   double prevLow  = iLow(_Symbol, LTF, 2);

   DetectLiquiditySweep(prevLow, prevHigh, close);

   double atr = ATR(ATR_Period, LTF);

   //================ BUY =================
   if(BullishStructure() && BuyLiquidityTaken && close > prevHigh)
   {
      double entry = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
      double sl = entry - atr * ATR_Multiplier;
      double sl_points = (entry - sl)/_Point;
      if(sl_points > MaxSL_Points) return;
      double tp = entry + (entry - sl) * RR;
      double lot = LotByRisk(sl_points);

      trade.Buy(lot, _Symbol, entry, sl, tp);
      PartialTaken = false;

      DrawLine("BOS_BUY", iTime(_Symbol,LTF,2), prevHigh, iTime(_Symbol,LTF,1), close, clrLime);
      DrawLabel("BOS_BUY_LABEL", iTime(_Symbol,LTF,1), close, "BOS BUY", clrLime);
   }

   //================ SELL =================
   if(BearishStructure() && SellLiquidityTaken && close < prevLow)
   {
      double entry = SymbolInfoDouble(_Symbol, SYMBOL_BID);
      double sl = entry + atr * ATR_Multiplier;
      double sl_points = (sl - entry)/_Point;
      if(sl_points > MaxSL_Points) return;
      double tp = entry - (sl - entry) * RR;
      double lot = LotByRisk(sl_points);

      trade.Sell(lot, _Symbol, entry, sl, tp);
      PartialTaken = false;

      DrawLine("BOS_SELL", iTime(_Symbol,LTF,2), prevLow, iTime(_Symbol,LTF,1), close, clrRed);
      DrawLabel("BOS_SELL_LABEL", iTime(_Symbol,LTF,1), close, "BOS SELL", clrRed);
   }
}

Respondido

1
Desenvolvedor 1
Classificação
(21)
Projetos
30
57%
Arbitragem
0
Expirado
1
3%
Trabalhando
2
Desenvolvedor 2
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
3
Desenvolvedor 3
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
4
Desenvolvedor 4
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
5
Desenvolvedor 5
Classificação
(4)
Projetos
3
33%
Arbitragem
2
0% / 100%
Expirado
0
Livre
6
Desenvolvedor 6
Classificação
(10)
Projetos
15
13%
Arbitragem
6
0% / 67%
Expirado
2
13%
Livre
7
Desenvolvedor 7
Classificação
(6)
Projetos
8
0%
Arbitragem
8
13% / 88%
Expirado
0
Livre
8
Desenvolvedor 8
Classificação
(12)
Projetos
19
42%
Arbitragem
3
0% / 67%
Expirado
3
16%
Livre
9
Desenvolvedor 9
Classificação
Projetos
0
0%
Arbitragem
1
0% / 100%
Expirado
0
Livre
10
Desenvolvedor 10
Classificação
(5)
Projetos
5
60%
Arbitragem
2
0% / 0%
Expirado
2
40%
Trabalhando
Publicou: 1 código
Pedidos semelhantes
-I am looking for an experienced MQL5 developer to build a custom MT5 Expert Advisor based on a clear, rule-based trading logic. This project is focused on structure, discipline, and long-term robustness rather than aggressive or experimental approaches. The EA will be based on a single coherent logic and must follow strict execution rules, with clean and professional MQL5 code suitable for controlled testing and
EA Development mentor 30 - 40 USD
am looking for a Mentor that has verifiable experience trading forex and commodities. Somebody who has a couple years experience in failures and successes. I am not a beginner. I have modest success already with discretionary trading. I have had an EA created that is very promising. It has extensive testing with very good results. The idea would be to work together advancing the existing EA and build additional EA's
Hello, I’m reaching out because I’m interested in hiring you to develop a custom trading bot for me. The bot should trade only XAUUSD (Gold) and be designed for long-term account growth using my own trading account size. Here are the core requirements: - Account size: $300 - Asset: XAUUSD only - Risk management: Strict and properly controlled - Risk-to-reward ratio: Clearly defined and consistently applied -
Profitable Gold bot Requirement Able to achieve at least 5% profit per week with any type of strategy Proper risk management with SL Able to back test for at least 6 month proven result No martingale/ No grid Avoid high impact news Reward Willing to pay more if able to achieve higher profits with acceptable drawdown. (Not small reward) very welcome long term cooperation with good rewards Testing is compulsory before
I am looking for an experienced MQL5 developer to convert a complex TradingView Pine Script (will provide the script from tradingview) into a fully automated MT5 Expert Advisor -bot. The TradingView script includes: Market Structure (BOS, CHoCH, Swing BOS) Strong / Weak High & Low Equilibrium (Premium / Discount zones) Volumetric Order Blocks Fair Value Gaps (FVG / VI / OG) Accumulation & Distribution zones Equal
// Add this to your EA after ExportState() function void SendToBase44(const string state, const string dir, double entry, double sl, double tp) { string url = " https://preview-sandbox--ee0a32a725b788974de435e8cef40b7a.base44.app/api/functions/receiveEAState "; string headers = "Content-Type: application/json\r\n"; string json = "{" "\"symbol\":\""+_Symbol+"\","
Hello! I am looking for an experienced, top-rated developer to build highly profitable strategy software that provides accurate signals for both long-term and short-term trades. The software must analyse the market correctly, indicating when to enter and where to set Take Profit (TP) and Stop Loss (SL) levels. It must deliver accurate results across all markets, including Forex, cryptocurrencies, metals, indices, and
For only developer who understand Chaos/ Profiunity trading system by Bill WIlliams, Create The Profitunity System Trading based on Bill Williams Chaos theory, Trade based on Trend Affirmation in Daily, entry in H4, using Williams Fractal, Williams Alligator, Awesome Oscillator, Accelerator Oscillator, Market Facilitation Index. Balance Line, entry on Reversal, add on while market show continuation sign. Please quote
Hi, I am looking for someone who has already developed a high-performance Gold EA that can outperform the one shown in my screenshot. If you have such an EA, please apply for this job. Please describe how the EA works (for example, whether it uses a grid system) and provide backtest results along with the set files. If the EA meets my expectations, you can make the necessary adjustments and I will use it as my own
Description I need an very low latency MT5 Expert Advisor (EA) developed in MQL5 to automate TradingView alerts into MT5 trades for alerts set up done on trading view. The EA must work on both DEMO and LIVE accounts whichever will be attached to MT5 (XM, IC Markets and similar MT5 brokers) and be suitable for fast 1-minute timeframe scalping.End to End solution. Functional Requirements 1. TradingView Integration

Informações sobre o projeto

Orçamento
300+ USD
Prazo
de 1 para 10 dias

Cliente

Pedidos postados1
Número de arbitragens0