Automate my trading 1.0

MQL5 Asesores Expertos

Tarea técnica

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


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

Han respondido

1
Desarrollador 1
Evaluación
(157)
Proyectos
187
26%
Arbitraje
8
25% / 38%
Caducado
5
3%
Trabaja
2
Desarrollador 2
Evaluación
(98)
Proyectos
120
39%
Arbitraje
9
89% / 0%
Caducado
0
Trabaja
3
Desarrollador 3
Evaluación
(397)
Proyectos
502
38%
Arbitraje
83
37% / 33%
Caducado
13
3%
Ocupado
4
Desarrollador 4
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Trabaja
5
Desarrollador 5
Evaluación
(177)
Proyectos
243
21%
Arbitraje
17
65% / 18%
Caducado
1
0%
Trabaja
6
Desarrollador 6
Evaluación
(486)
Proyectos
552
32%
Arbitraje
28
43% / 43%
Caducado
8
1%
Ocupado
7
Desarrollador 7
Evaluación
(204)
Proyectos
209
28%
Arbitraje
0
Caducado
3
1%
Libre
8
Desarrollador 8
Evaluación
(261)
Proyectos
425
38%
Arbitraje
86
44% / 19%
Caducado
71
17%
Trabajando
Solicitudes similares
I need a modification on my existing Ea if you can Can fixed risk management to lot size instead of percentage. don’t want strategic risk management input to be based on percentage Instead lot size. The strategic risk management function I need turned from percentage to lot based And I need sells and buys to have separate tps and sl options Budget:$100 Day: 1 day
I have developed a very strong TradingView strategy in Pine Script but unfortunately, a third-party connector is requiired and in my opinion, I want a more direct connection. I am not brilliant at coding, but I have coded the majority of the MT5 code and I would like you to make sure that the MT5 code matches my TradingView script and executes the same way as the TradingView script that I will provide if you are
I need to get a trading forex robot based on support and accurate resistance and moving avarage more details will be provided on the video links I want a situation where by once I put the robot on the chart and choose buy or sell and the number to open then it will only buy or sell in that particular direction only
NADGIO 30+ USD
I need a developer that can convert two Buy and Sell indicators into a trading robot. the indicators has an input parameter, this should be made available for adjustment. Features 1. Break Even 2. Trailing Stop 3. Global TP and SL 5. Time Filter 6. News Filter (If possible)
I need a developer who can convert trading view indicator in to mt5 expert advisor with some modifications. The other details will shared once chosen the developer. Looking for someone who has good knowledge of forex, mql5,and pine script
Hello, i hope you all well. I am looking or a good developer who can understand SCM/ICT concepts so that can modify an existing EA to trade against that. The EA is already there with code and it was trading based on Breakouts zones. Now i want the EA to be modified so that it trades based on inducements and liquidity. The EA should use Pending orders on those zones instead. I do not want new developers to apply
EA for index trading using ATR % of 5day 1 Give Average true range for the past 5 day so 5day ATR also for ref use the indicator "atr value indicator " my entries will be based on a % of this NO. NO. TO BE SHOWN IN TOP CORNER The Expert im looking for is 1.AT X TIME (ie 8:am ) 2.IF price moves X % of the 5 day atr( either up or down ) within Y TIME (IE 5MINUTES ) (if PRICE moves say 30% of the 5 day atr down i buy or
I want to create an Expert Advisor (EA) that can be set to open either buy or sell trades, depending on user preference (buy-only or sell-only mode). The EA will initiate trades when the market reaches (or is equal to or less than) a specified DeMarker value (e.g., DeMarker value = 0.3). The user will set both the DeMarker value for starting trades and another DeMarker value to stop opening new trades. - **DeMarker
Create a mql5 expert advisor for forex/commodities trading based on modified candlestick formation. If modified bullish engulfing appears, EA will open buy position at closing of last candle area with martingale until opening of last candle area and set stop loss at open last candle area. Trailing stop appears when half of all buy positions running profit then when all buy positions running profit, and so on. If
I want to grid based robot such like CM Manual Grid for mt 5 Snap of that attached. like The expert Advisor helps set a network of pending orders and collect profit from any price movement. I can use it to trade many grid strategies. I can also use it to track open positions. "Buy Stop — - open a network of pending stop orders for sale "Sell Stop" - open a network of pending stop orders for purchase "Buy Limit" -

Información sobre el proyecto

Presupuesto
40+ USD

Cliente

Encargos realizados1
Número de arbitrajes0