Automate my trading 1.0

MQL5 Experts

Specification

#property copyright "Copyright 2024, Trade Smart Fx Tools"
#property link      "tradesmartfxtools.online"
#property version   "1.00"
#property strict

// Global Varibles
int MAGIC_NUMBER = 0907200406;
string labelName = "tradesmartfxtools.online";
string updatedLabelName = "updated_version_label";
string updatedLabelText = "Updated version available at tradesmartfxtools.online";
string labelText = "EA by tradesmartfxtools.online";
string buyProfitLabelName = "OverallBuyProfitLabel";
string sellProfitLabelName = "OverallSellProfitLabel";
int labelFontSize = 16;
int updatedLabelFontSize = 12;
color labelColor = Yellow;
color profitLabelColor = White;
color lossLabelColor = White;
int spaceFromBottom = 50;
color updatedLabelColor = White; 
int updatedSpaceFromBottom = 20;

input int fastMAPeriod = 10; // Period for fast MA
input int slowMAPeriod = 25; // Period for slow MA


//+------------------------------------------------------------------+
//| Labels                                                           |
//+------------------------------------------------------------------+

void createOrUpdateLabels(double buyProfit, double sellProfit)
  {
   if(ObjectFind(0, labelName) == -1)
     {
      ObjectCreate(0, labelName, OBJ_LABEL, 0, 0, 0);
     }
   ObjectSetInteger(0, labelName, OBJPROP_CORNER, CORNER_LEFT_LOWER);
   ObjectSetInteger(0, labelName, OBJPROP_XDISTANCE, 10);
   ObjectSetInteger(0, labelName, OBJPROP_YDISTANCE, spaceFromBottom);
   ObjectSetInteger(0, labelName, OBJPROP_COLOR, labelColor);
   ObjectSetInteger(0, labelName, OBJPROP_FONTSIZE, labelFontSize);
   ObjectSetInteger(0, labelName, OBJPROP_SELECTABLE, false);
   ObjectSetInteger(0, labelName, OBJPROP_SELECTED, false);
   ObjectSetString(0, labelName, OBJPROP_TEXT, labelText);


   if(ObjectFind(0, updatedLabelName) == -1)
     {
      ObjectCreate(0, updatedLabelName, OBJ_LABEL, 0, 0, 0);
     }
   ObjectSetInteger(0, updatedLabelName, OBJPROP_CORNER, CORNER_LEFT_LOWER);
   ObjectSetInteger(0, updatedLabelName, OBJPROP_XDISTANCE, 10);
   ObjectSetInteger(0, updatedLabelName, OBJPROP_YDISTANCE, updatedSpaceFromBottom);
   ObjectSetInteger(0, updatedLabelName, OBJPROP_COLOR, updatedLabelColor);
   ObjectSetInteger(0, updatedLabelName, OBJPROP_FONTSIZE, updatedLabelFontSize);
   ObjectSetString(0, updatedLabelName, OBJPROP_TEXT, updatedLabelText);

// Create or update the buy profit label
   string buyProfitText = "Overall Buy Profit: " + DoubleToString(buyProfit, 2);
   if(ObjectFind(0, buyProfitLabelName) == -1)
     {
      ObjectCreate(0, buyProfitLabelName, OBJ_LABEL, 0, 0, 0);
     }
   ObjectSetInteger(0, buyProfitLabelName, OBJPROP_CORNER, CORNER_LEFT_UPPER);
   ObjectSetInteger(0, buyProfitLabelName, OBJPROP_XDISTANCE, 20);
   ObjectSetInteger(0, buyProfitLabelName, OBJPROP_YDISTANCE, spaceFromBottom - 6); // Adjusted Y position
   ObjectSetInteger(0, buyProfitLabelName, OBJPROP_COLOR, profitLabelColor);
   ObjectSetInteger(0, buyProfitLabelName, OBJPROP_FONTSIZE, labelFontSize);
   ObjectSetInteger(0, buyProfitLabelName, OBJPROP_SELECTABLE, false);
   ObjectSetInteger(0, buyProfitLabelName, OBJPROP_SELECTED, false);
   ObjectSetString(0, buyProfitLabelName, OBJPROP_TEXT, buyProfitText);

// Create or update the sell profit label
   string sellProfitText = "Overall Sell Profit: " + DoubleToString(sellProfit, 2);
   if(ObjectFind(0, sellProfitLabelName) == -1)
     {
      ObjectCreate(0, sellProfitLabelName, OBJ_LABEL, 0, 0, 0);
     }
   ObjectSetInteger(0, sellProfitLabelName, OBJPROP_CORNER, CORNER_LEFT_UPPER);
   ObjectSetInteger(0, sellProfitLabelName, OBJPROP_XDISTANCE, 20);
   ObjectSetInteger(0, sellProfitLabelName, OBJPROP_YDISTANCE, spaceFromBottom - 36); // Adjusted Y position
   ObjectSetInteger(0, sellProfitLabelName, OBJPROP_COLOR, lossLabelColor);
   ObjectSetInteger(0, sellProfitLabelName, OBJPROP_FONTSIZE, labelFontSize);
   ObjectSetInteger(0, sellProfitLabelName, OBJPROP_SELECTABLE, false);
   ObjectSetInteger(0, sellProfitLabelName, OBJPROP_SELECTED, false);
   ObjectSetString(0, sellProfitLabelName, OBJPROP_TEXT, sellProfitText);



  }

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   createOrUpdateLabels(0.0, 0.0); // Initialize labels with 0 profit and trade counts

   return(INIT_SUCCEEDED);
  }
  
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+

void OnDeinit(const int reason)
  {
// Delete the main EA label
   if(ObjectFind(0, labelName) != -1)
      ObjectDelete(0, labelName);

// Delete the updated version label
   if(ObjectFind(0, updatedLabelName) != -1)
      ObjectDelete(0, updatedLabelName);

// Delete the buy profit label
   if(ObjectFind(0, buyProfitLabelName) != -1)
      ObjectDelete(0, buyProfitLabelName);

// Delete the sell profit label
   if(ObjectFind(0, sellProfitLabelName) != -1)
      ObjectDelete(0, sellProfitLabelName);

   Print("All labels have been removed.");
  }


//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   double totalBuyProfit = 0.0;
   double totalSellProfit = 0.0;


// Calculate total buy and sell profits and count trades
   for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == _Symbol)
        {
         if(OrderType() == OP_BUY)
           {
            totalBuyProfit += OrderProfit();

           }
         else
            if(OrderType() == OP_SELL)
              {
               totalSellProfit += OrderProfit();

              }
        }
     }

   createOrUpdateLabels(totalBuyProfit, totalSellProfit);

   CloseProfitableTradesOnMACrossover();



  }


//+------------------------------------------------------------------+
//| Close Profitable Trades On MA Crossover                          |
//+------------------------------------------------------------------+
void CloseProfitableTradesOnMACrossover()
  {
   double fastMA = iMA(NULL, 0, fastMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 0);
   double slowMA = iMA(NULL, 0, slowMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 0);
   double fastMA_prev = iMA(NULL, 0, fastMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 1);
   double slowMA_prev = iMA(NULL, 0, slowMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 1);

// Check for crossover
   bool bullishCrossover = fastMA_prev < slowMA_prev && fastMA > slowMA;
   bool bearishCrossover = fastMA_prev > slowMA_prev && fastMA < slowMA;

   if(bullishCrossover || bearishCrossover)
     {

      // Loop through all open trades

      int totalOrders = OrdersTotal();
      if(totalOrders == 0)
        {
         Print("No open orders found.");
         return;
        }
      for(int i = totalOrders - 1; i >= 0; i--)
        {
         if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
           {
            // Check if the trade is profitable
            double profit = OrderProfit();
            if(profit >= 0)
              {
               // Attempt to close the order
               bool closed = false;
               if(OrderType() == OP_BUY)
                 {
                  closed = OrderClose(OrderTicket(), OrderLots(), Bid, 2, clrRed);
                  if(closed)
                     Print("Closed profitable Buy order ", OrderTicket(), " with profit: ", profit);
                  else
                     Print("Error closing Buy order ", OrderTicket(), ": Error code ", GetLastError());
                 }
               else
                  if(OrderType() == OP_SELL)
                    {
                     closed = OrderClose(OrderTicket(), OrderLots(), Ask, 2, clrRed);
                     if(closed)
                        Print("Closed profitable Sell order ", OrderTicket(), " with profit: ", profit);
                     else
                        Print("Error closing Sell order ", OrderTicket(), ": Error code ", GetLastError());
                    }
              }
            else
              {
               Print("Order ", OrderTicket(), " is not profitable, skipping.");
              }
           }
         else
           {
            Print("Error selecting order ", i, ": Error code ", GetLastError());
           }
        }
     }
  }


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

Responded

1
Developer 1
Rating
(237)
Projects
298
28%
Arbitration
33
24% / 61%
Overdue
9
3%
Working
2
Developer 2
Rating
(151)
Projects
188
57%
Arbitration
10
80% / 0%
Overdue
0
Free
Published: 1 code
3
Developer 3
Rating
(442)
Projects
570
37%
Arbitration
106
39% / 33%
Overdue
17
3%
Free
4
Developer 4
Rating
(3)
Projects
2
0%
Arbitration
1
0% / 0%
Overdue
0
Free
5
Developer 5
Rating
(268)
Projects
396
27%
Arbitration
38
39% / 50%
Overdue
1
0%
Free
6
Developer 6
Rating
(539)
Projects
618
33%
Arbitration
36
36% / 47%
Overdue
10
2%
Busy
7
Developer 7
Rating
(246)
Projects
253
30%
Arbitration
0
Overdue
3
1%
Free
Published: 2 codes
8
Developer 8
Rating
(294)
Projects
469
39%
Arbitration
102
40% / 24%
Overdue
77
16%
Loaded
Published: 2 codes
Similar orders
Hi, I’m searching for a developer who already has a high‑performance Gold EA that can beat the results shown in my screenshot. If you have such an EA, please reply with: - A brief description of how it works (grid, scalping, SMC, etc.) - Backtest results and the set files you used - Whether you’re willing to make minor tweaks so I can use it as my own If the performance looks good, we can discuss adjustments and next
Requirements Specification for the development of the Expert Advisor, in the latest version of MetaTrader 5 including the source code. 1. The idea of the trading system is as follows: market entries are performed when a new renko box is created in the current trend direction using an indicator from Trading view. Indicator Name: Renko Candles Overlay Published By: LonesomeTheBlue Code Available In: Pine Script which
Hello I would like to modify the exit method of the trade for current expert advisor which include martingale trading. basically adjusting the position size and closing the trade. additional details will be provided in the next step
I have 3 pine script of trading view and want to convert it into mql5 code. basically it has 2 script and in that one script I use 2 different ways. so here is 3 stratagy that can work in one code mql5 and I can use in mt5
I need a MetaTrader 5 Expert Advisor with full MQ5 source code. Platform: - MT5 only - Full MQ5 source code mandatory - Must work with Exness broker (symbol suffix like XAUUSDm) Strategy: - Trend-based trading only - NO grid - NO martingale - NO averaging - Fixed Stop Loss & Take Profit - Max 1–2 trades at a time Risk Management: - Daily profit target (stop trading after hit) - Daily loss limit - Maximum drawdown
Multi-Asset AI Trading Bot Details Proposals I want a single, cohesive AI bot that can log in to MetaTrader, Coinbase, Robinhood, and TradingView, scan live market data, and execute trades automatically in stocks, forex, and crypto. The core logic must support day-trading, swing-trading, and scalping modes that I can toggle on a schedule or by simple configuration. The workflow I picture is: • Real-time data
I need someone that is able to develop for me a MT5 EA that perform VERY WELL on XAUUSD. Every strategy is accepted. By applying, please send me screenshot of results since 2018
Hello developers, I'm looking for existing, proven EAs (MQL5) that work flawlessly on MT5. Requirements: Demo version available for testing Backtest results + screenshots Verified trade history from 2018-2025 Budget is negotiable If you've got an EA that fits, hit me up
cần người tạo EA y thay đổi hình ảnh gửi đầy đủ tính năng như hình giá cả có thể tăng thêm khối lượng mong muốn viết giống hình không khác ROBOT HƠI NHIỀU TÍNH NĂNG MỌI NGƯỜI CÓ THỂ ĐƯA GIÁ THAM KHẢO
I need an experienced MQL4 developer to build a robust, conservative MT4 EA designed to trade Forex major pairs on IG . This is for long-term use with controlled drawdown — no martingale/grid/hedging . Platform / Broker Platform: MT4 Broker: IG Must work with: 5-digit pricing, variable spreads, slippage, and IG’s execution constraints Symbols (Majors only) EURUSD, GBPUSD, USDJPY, AUDUSD, USDCHF, USDCAD (configurable

Project information

Budget
40+ USD