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
(251)
Projects
314
28%
Arbitration
34
26% / 65%
Overdue
10
3%
Working
2
Developer 2
Rating
(155)
Projects
193
58%
Arbitration
10
80% / 0%
Overdue
0
Working
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
(273)
Projects
401
27%
Arbitration
40
40% / 50%
Overdue
1
0%
Free
6
Developer 6
Rating
(556)
Projects
643
33%
Arbitration
41
41% / 46%
Overdue
11
2%
Busy
7
Developer 7
Rating
(255)
Projects
262
30%
Arbitration
0
Overdue
3
1%
Free
Published: 2 codes
8
Developer 8
Rating
(296)
Projects
475
40%
Arbitration
105
40% / 24%
Overdue
80
17%
Busy
Published: 2 codes
Similar orders
I need a professional MQL4/MQL5 developer to build a custom hybrid scalping Expert Advisor for EURUSD M5, with aggressive but controlled risk, using fixed TP/SL, no martingale, no grid, and a hybrid entry engine (price action + indicators). The EA must be delivered in both MT4 (MQL4) and MT5 (MQL5) versions, with identical logic. 1. Platform & symbol - MT4 (MQL4) and MT5 (MQL5) - Symbol: EURUSD - Timeframe: M5 - EA
Hello i need an EA automated using Supply & Demand + Shooting Star/Hammer Bot: Timeframes: H1 main, M5/M15 for entry Indicators: ATR(14 ≥0.80), Supply/Demand zones, Candlestick patterns Short Entry: 1. Price enters supply zone 2. Shooting star forms (small body, long upper wick ≥2× body) 3. ATR ≥0.80 4. Sell below shooting star low Stop Loss: above upper wick Take Profit: next support zone or 1:2 R:R Trailing Stop
HFT Directional Grid Scalper (Simple, Training Project) Overview We are looking for a developer to create a high-frequency grid scalper with a simple, deterministic logic. This is not a complex bot — the goal is to have a clean implementation for training, testing, and educational purposes. The bot should: Continually open trades in one direction only (BUY or SELL) Use ATR-based grid spacing Maintain a fixed lot size
Looking to buy an EA which is good, profitable and takes many trades, good for IB broker comissions, Any strategy or martingale is fine, send me a demo license file, I will backtest and purchase immediately if my team like it
Hi, Before ordering, I want to verify the quality of your ICT/SMC logic. Do you have an existing indicator or strategy (your own work) that I can test on TradingView? If yes, please provide: 1. A demo (invite-only script or video) 2. Proof it is NON-repainting (explained clearly) 3. Live or replay demonstration (not static screenshots) Specifically I want to see: * Clean swing structure (no consecutive highs/lows) *
Indicator 125+ USD
Hi guys looking for a buy sell indicator not necessarily for trading solely based on it but more for getting an indication of market dynamic and direction. If you believe you have or have a good strategy or idea for such an indicator drop a message. I will want to test it before making deposit as this is such an open order woth so many options. Waiting to hear from you. Flexible with price
Looking to work woth manualtraders who have a proved existing strategy. To be clear, this is not a request to develop or design a new strategy. If you already trading and have strategy that is proven, consistent, and production-ready, with at least 6 months of history performance I’m open to reviewing it immediately. Please apply only if you meet all the requirements below. Submissions without a proper introduction
Scalping EA 30+ USD
Hello, I am looking for an Expert Advisor (EA) that focuses on account preservation and consistent growth , rather than aggressive or risky strategies. My requirements are: Target: at least ~1% weekly return Strategy: low-risk, controlled drawdown Must NOT use martingale or grid systems that can blow the account Prefer quality trades over quantity like 100–200 trades per day Consistency is more important than high
Looking for a good EA 2000 - 5000 USD
Hello coders ,I am looking for a good already established MT5 EA ,that doesnt blow account, with maximum 10 percent drowdown,I need to backtest by myself,after that i select the developer
Hello i need bot 30 - 100 USD
I need a trading bot (Expert Advisor) that can send alerts to mobile, Telegram, and the MT5 desktop platform. The bot should work as a market scanner for all symbols available in my MetaTrader 5 Market Watch. It must analyze multiple indicators and convert their signals into a point-based scoring system, then send alerts based on those scores. Requirements: Send notifications to: Mobile (push notifications) Telegram

Project information

Budget
40+ USD