Automate my trading 1.0

MQL5 Эксперты

Техническое задание

#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());
           }
        }
     }
  }


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

Откликнулись

1
Разработчик 1
Оценка
(237)
Проекты
298
28%
Арбитраж
33
24% / 61%
Просрочено
9
3%
Работает
2
Разработчик 2
Оценка
(151)
Проекты
188
57%
Арбитраж
10
80% / 0%
Просрочено
0
Свободен
Опубликовал: 1 пример
3
Разработчик 3
Оценка
(442)
Проекты
570
37%
Арбитраж
106
39% / 33%
Просрочено
17
3%
Свободен
4
Разработчик 4
Оценка
(3)
Проекты
2
0%
Арбитраж
1
0% / 0%
Просрочено
0
Свободен
5
Разработчик 5
Оценка
(268)
Проекты
396
27%
Арбитраж
38
39% / 50%
Просрочено
1
0%
Свободен
6
Разработчик 6
Оценка
(539)
Проекты
619
33%
Арбитраж
35
37% / 49%
Просрочено
11
2%
Занят
7
Разработчик 7
Оценка
(246)
Проекты
253
30%
Арбитраж
0
Просрочено
3
1%
Свободен
Опубликовал: 2 примера
8
Разработчик 8
Оценка
(294)
Проекты
469
39%
Арбитраж
102
40% / 24%
Просрочено
77
16%
Загружен
Опубликовал: 2 примера
Похожие заказы
Hi all, i would like to seek your help to develop an MT4 indicator and EA. A. Dual Range Detection Indicator Logic Summary The core function of this Indicator is to lock specific consolidation ranges (Range A and Range B) in the market. 1. Detection Mechanism Detect Criteria (pause = true): A Range is formed and detected when the following two conditions are met simultaneously: Size Requirement: The current bar's
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

Информация о проекте

Бюджет
40+ USD