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
(214)
Projects
266
26%
Arbitration
15
47% / 33%
Overdue
10
4%
Busy
2
Developer 2
Rating
(134)
Projects
164
52%
Arbitration
10
80% / 0%
Overdue
0
Working
Published: 1 code
3
Developer 3
Rating
(432)
Projects
547
38%
Arbitration
93
41% / 29%
Overdue
15
3%
Working
4
Developer 4
Rating
(3)
Projects
2
0%
Arbitration
1
0% / 0%
Overdue
0
Free
5
Developer 5
Rating
(248)
Projects
362
24%
Arbitration
21
62% / 24%
Overdue
1
0%
Working
6
Developer 6
Rating
(535)
Projects
613
34%
Arbitration
32
41% / 47%
Overdue
9
1%
Busy
7
Developer 7
Rating
(230)
Projects
236
30%
Arbitration
0
Overdue
3
1%
Free
Published: 2 codes
8
Developer 8
Rating
(284)
Projects
458
39%
Arbitration
94
44% / 18%
Overdue
72
16%
Loaded
Published: 2 codes
Similar orders
Just have a let down by previous coder. (Andrii) please dont apply for this one. Coder with low Metrix please dont apply : High Arbitrage/Low reviews/High Overdue I will just avoid This is a long-term Project You ll have to continue work on the source file done so far, there might be bug to fix and continue the work as needed. What be involve: Grid system Dashboard Indicaotor Addon Setting/Logic enhancement News
Experts mt5 30 - 50 USD
I need a programmer to create an MT5 robot, putting my strategy inside it, send me a message if you are interested! The robot will be based on averages making purchases and sales together
To develop EA algo on GBPUSD on MT5 Client will provide the necessary indicator which will plot Daily pivots on the chart. PFA screenshot attached for details of job work
Hello, my budget is 30$, I need MT5 EA send alert to telegram: 1. Send alert if any position volume by magic number more than: for example, 0.25 lot, send position symbol name and positions not all positions just the positions are more than 0.25 lot volume and positions trade comment and send Custom comment: I entered it manually in input menu. 2. Send alert if I have open positions by magic number in
Description de la stratégie de trading : Bot de trading ULTIMATE AI Smart Money Concept (SMC) Aperçu: J'ai besoin du robot de trading IA ultime, conçu pour mettre en œuvre une stratégie de trading Smart Money Concept (SMC) axée sur l'identification des configurations de trading à forte probabilité en fonction de la structure du marché, des blocs d'ordres et de l'évolution des prix. Ce robot vise à capitaliser sur le
I’m looking for a skilled MQL5 developer to build an MT5 Expert Advisor that mirrors inverse trades (Buy ↔ Sell) from a prop firm challenge account (demo) to a live hedge account . Core Requirements: Open and close opposite trades in real-time Dynamic lot sizing based on account balances (Objective: recover approx. $500 if the challenge account fails) Support for multiple symbols , including: XAUUSD, NAS100, BTCUSD
Hi, I’m looking for an experienced MQL5 or AI trading systems developer who can build a scalable, beginner-friendly forex trading network . The system should include: Fully automated trading logic (AI-enhanced or rule-based) MT5 (or MT4 if needed) compatibility A beginner dashboard with simplified controls A structure that supports onboarding of multiple traders (eventually multi-asset) Key modules like performance
Trading Strategy Description: ULTIMATE AI Smart Money Concept (SMC) Trading Bot Overview: i need The ULTIMATE AI trading bot that is designed to implement a Smart Money Concept (SMC) trading strategy that focuses on identifying high-probability trading setups based on market structure, order blocks, and price action. The bot aims to capitalize on institutional trading behavior by analyzing price movements and
I need someone who can provide metatrader4/5 restful api. And I want restful and websockets. we need to use metatrader api in our app for statistics and trade copying. Apply only if you have the necessary qualifications and experience for this project
I need a highly disciplined, low-risk EA for MT4/MT5 that trades only when 100% strategy conditions are met. It must include multi-timeframe trend logic, support/resistance rejection, BOS/CHoCH detection from real swing levels, and a breakout strategy with trailing SL. EA should scan all major pairs (from one chart), trade only during 07:00–16:00 GMT, and skip trades 2 hours before major news. Max 1 trade per pair

Project information

Budget
40+ USD
For the developer
36 USD