Mt5

MQL5 Experts Forex

Specification

//+------------------------------------------------------------------+
//| HedgingBasket_EA.mq5 |
//| Copyright 2026, Trading Bot |
//+------------------------------------------------------------------+
#property copyright "Trading Assistant"
#property version "1.00"
#include <Trade\Trade.mqh>

CTrade trade;

//--- Input parameters
input group "=== Hedging Settings ==="
input double InpLotSize = 0.01; // Lot Size for both Buy & Sell
input double InpTargetProfit = 0.0; // Target Net Profit to Close (0.0 = Breakeven / No Loss)
input ulong InpMagicNum = 777777; // Magic Number

bool openedInitialTrades = false;

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
  {
   trade.SetExpertMagicNumber(InpMagicNum);
   openedInitialTrades = false;
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }

//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
  {
   // 1. Open both Buy and Sell simultaneously on start if not already opened
   if(!openedInitialTrades)
     {
      double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
      double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
      
      bool buySuccess = trade.Buy(InpLotSize, _Symbol, ask, 0, 0, "Hedge Buy");
      bool sellSuccess = trade.Sell(InpLotSize, _Symbol, bid, 0, 0, "Hedge Sell");
      
      if(buySuccess && sellSuccess)
        {
         Print("Initial Buy and Sell hedging orders opened successfully.");
         openedInitialTrades = true;
        }
     }
     
   // 2. Monitor open positions for total basket profit/loss
   double totalProfit = 0.0;
   int openPositionsCount = 0;
   
   for(int i = PositionsTotal() - 1; i >= 0; i--)
     {
      ulong ticket = PositionGetTicket(i);
      if(ticket > 0)
        {
         if(PositionGetInteger(POSITION_MAGIC) == InpMagicNum && PositionGetString(POSITION_SYMBOL) == _Symbol)
           {
            totalProfit += PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP) + PositionGetDouble(POSITION_COMMISSION);
            openPositionsCount++;
           }
        }
     }
     
   // 3. If positions exist and total profit meets or exceeds target (No Loss / >= 0), close all
   if(openPositionsCount > 0 && totalProfit >= InpTargetProfit)
     {
      Print("Target profit reached (Total: ", totalProfit, "). Closing all hedging positions with no loss.");
      CloseAllManagedPositions();
      // Reset flag if you want it to restart a new cycle, or leave it to stop.
     }
  }

//+------------------------------------------------------------------+
//| Function to close all bot positions |
//+------------------------------------------------------------------+
void CloseAllManagedPositions()
  {
   for(int i = PositionsTotal() - 1; i >= 0; i--)
     {
      ulong ticket = PositionGetTicket(i);
      if(ticket > 0)
        {
         if(PositionGetInteger(POSITION_MAGIC) == InpMagicNum && PositionGetString(POSITION_SYMBOL) == _Symbol)
           {
            trade.PositionClose(ticket);
           }
        }
     }
  }

Responded

1
Developer 1
Rating
(319)
Projects
574
35%
Arbitration
83
31% / 45%
Overdue
207
36%
Free
2
Developer 2
Rating
(2)
Projects
2
0%
Arbitration
1
0% / 100%
Overdue
0
Free
3
Developer 3
Rating
(23)
Projects
34
53%
Arbitration
1
100% / 0%
Overdue
1
3%
Free
4
Developer 4
Rating
(206)
Projects
333
35%
Arbitration
66
12% / 58%
Overdue
87
26%
Free
5
Developer 5
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 7 codes
6
Developer 6
Rating
(3)
Projects
5
60%
Arbitration
0
Overdue
1
20%
Free
Published: 2 codes
7
Developer 7
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 10 codes
8
Developer 8
Rating
(64)
Projects
145
46%
Arbitration
21
38% / 24%
Overdue
32
22%
Free
9
Developer 9
Rating
(559)
Projects
853
61%
Arbitration
33
27% / 45%
Overdue
24
3%
Free
Published: 1 code
10
Developer 10
Rating
(263)
Projects
309
76%
Arbitration
15
67% / 0%
Overdue
6
2%
Loaded
11
Developer 11
Rating
(10)
Projects
17
18%
Arbitration
2
0% / 50%
Overdue
3
18%
Loaded
12
Developer 12
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
13
Developer 13
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
14
Developer 14
Rating
(1)
Projects
1
0%
Arbitration
0
Overdue
0
Free
Published: 3 codes
Similar orders
To create a unique description that meets the freelance site's requirements, you can type the following: "I am looking for an experienced MQL5 developer to create a custom Forex Expert Advisor. The trading strategy should be based on a moving average crossover system, filtered by the Relative Strength Index indicator. The expert advisor needs to feature distinct strategy modules with adjustable settings for the
Custom MT5 Expert Advisor (EA) Development | MQL5 Automation Turn Your Trading Strategy into a Powerful Automated Trading System! Are you looking for a professional MT5 Expert Advisor developer to automate your trading strategy? I specialize in developing custom MetaTrader 5 (MT5) Expert Advisors and indicators using MQL5 , tailored to your trading rules, risk management preferences, and trading goals. Whether you
Hello, I’d like to develop an AI-powered analysis dashboard for , with a clear, easy-to-use design that works on mobile and web, or on the platform we agree on. I’d like it to include: Main dashboard: Show the market status, the latest data update, and the current signal, if available, including direction, entry price, stop loss, targets, and risk-to-reward ratio. AI signal explanations: Explain in clear language why
Scalping bort 30+ USD
GOLD SCALPING BOT STRATEGY Symbol: XAUUSD (Gold vs USD) Broker: Exness Account: Standard Starting Balance: $20 1. TIMEFRAME - Trend analysis: M15. - Entry timeframe: M5. - Trade only when the market has a clear direction. 2. INDICATORS - EMA 50 - EMA 200 - RSI 14 - Support and Resistance 3. BUY RULES The bot must open a BUY trade only when all these conditions are met: 1. EMA 50 is above EMA 200 on M15. 2. Price is
Hello, I am looking for an experienced MQL5 developer to create a professional, reliable, fully customizable Expert Advisor (EA) and trading signal system for MetaTrader 5. 1. Supported Markets The EA must support: Gold (XAUUSD) Silver (XAGUSD) Nasdaq 100 (NAS100/US100) Forex currency pairs Bitcoin (BTCUSD) It must work with MT5 brokers, including Tickmill, where these instruments are available. 2. Two Trading Modes
Entry Strategy: Explain exact conditions for opening a trade specific indicators like Moving Averages or RSI, time of day, or price action rules. Exit Strategy: Define when a trade should closeTake Profit, Stop Loss, Trailing Stop, or indicator signals. Daily Trading Rules: Specify daily limits if applicable maximum trades per day, specific trading hours, or maximum daily loss limit. Risk & Position Sizing: Indicate
Request for an Existing Automated Trading System (Expert Advisor) I am looking to acquire an existing, fully functional Expert Advisor (EA) that trades Forex CFDs, with the option of trading other CFDs if the strategy supports them safely. Performance objectives Target average net monthly return: 1.5%. A consistent 1.0% monthly return may be considered if the system demonstrates strong risk control and credible
Hi All, I am looking for a bot EA which makes good profit. If any having please share it for TEST. After proper TESTING only I will make the payment, no cheating no fraud. Please do not waste the time also
Allow me to set the daily trading bias manually to BUY or SELL. Check my defined 4H and 1H trend-alignment conditions. Execute entries based on my 15-minute pullback and continuation rules. Trade only between 06:00 and 16:00 Nigeria time, Monday to Friday. Calculate lot size based on my chosen risk percentage and stop-loss distance. Automatically place stop-loss and take-profit orders. Enforce my daily trade limits
Hi, I’m looking for a **ready-made MT5 scalping EA specifically for Gold (XAUUSD)**. My main requirement is an **HTF scalping strategy**, so I’m looking for an existing robot that is already developed and can be tested before I make the purchase. I’m not looking to build one from scratch at this stage. I would like to first test the EA on a **demo account** to see how it performs under live market conditions and

Project information

Budget
35+ USD
Deadline
from 3 to 235 day(s)

Customer

Placed orders2
Arbitrage count0