Help with writing an 1/3 auto take profit ea

MQL5 Indicators Experts

Job finished

Execution time 4 days
Feedback from employee
Very good to work with.

Specification

I need an expert advisor to check for existing positions with a set take profit target and to close 1/3 of the position if the price reaches 1/3 of the take profit target and close another 1/3 of the position if price reaches 2/3 of the take profit target.


This is what google bard wrote but has too many errors.

If it could auto get the symbol from the chart that it is loaded onto that would be better too.


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

//| Expert Advisor code generated by MetaTrader 5 |
//|                                                   |
//| Author: Bard                                       |
//| Date: 2023-05-14                                   |
//|                                                   |
//+------------------------------------------------------------------+

#property copyright "Bard"
#property link "https://bard.ai"
#property version "1.00"

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>

//--- variables
CPositionInfo m_position; // trade position object
CTrade m_trade; // trading object
CSymbolInfo m_symbol; // symbol info object
CAccountInfo m_account; // account info wrapper

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit() {

  // Get the symbol info
  m_symbol = SymbolInfo("US30.a");

  // Get the account info
  m_account = AccountInfo();

  // Set the expert magic number
  m_trade.SetExpertMagicNumber(13324);

  // Set the deviation in points
  m_trade.SetDeviationInPoints(10);

  return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit() {}

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

  // Get the current price
  double price = MarketInfo("US30.a", MODE_BID);

  // Check if there are any open orders
  if (m_trade.GetOrdersTotal() > 0) {

    // Loop through the open orders
    for (int i = 0; i < m_trade.GetOrdersTotal(); i++) {

      // Get the current order
      CTrade order = m_trade.GetOrder(i);

      // Check if the order is a buy or sell order
      if (order.GetType() == ORDER_TYPE_LONG || order.GetType() == ORDER_TYPE_SHORT) {

        // Calculate the 1/3 take profit price
        double takeProfit1 = price + (m_symbol.GetStopLoss() / 3);

        // Calculate the 2/3 take profit price
        double takeProfit2 = price + (m_symbol.GetTakeProfit() / 2);

        // Check if the price has reached the 1/3 take profit price
        if (price >= takeProfit1) {

          // Sell 1/3 of the position
          if (order.GetType() == ORDER_TYPE_LONG) {
            m_trade.Sell(order.GetLots() / 3, order.GetPrice());
          } else {
            m_trade.Buy(order.GetLots() / 3, order.GetPrice());
          }
        }

        // Check if the price has reached the 2/3 take profit price
        if (price >= takeProfit2) {

          // Sell another 1/3 of the position
          if (order.GetType() == ORDER_TYPE_LONG) {
            m_trade.Sell(order.GetLots() / 3, order.GetPrice());
          } else {
            m_trade.Buy(order.GetLots() / 3, order.GetPrice());
          }
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Expert start function |
//+------------------------------------------------------------------+
void OnStart() {

}

//+------------------------------------------------------------------+
//| Expert stop function |
//+------------------------------------------------------------------+
void OnStop() {

}

Responded

1
Developer 1
Rating
(21)
Projects
25
52%
Arbitration
3
0% / 100%
Overdue
2
8%
Free
2
Developer 2
Rating
(101)
Projects
123
31%
Arbitration
7
29% / 29%
Overdue
5
4%
Loaded
3
Developer 3
Rating
(44)
Projects
60
5%
Arbitration
6
0% / 67%
Overdue
5
8%
Free
4
Developer 4
Rating
(7)
Projects
11
36%
Arbitration
3
0% / 100%
Overdue
0
Free
5
Developer 5
Rating
(287)
Projects
359
29%
Arbitration
37
27% / 65%
Overdue
10
3%
Working
6
Developer 6
Rating
(37)
Projects
59
27%
Arbitration
26
19% / 54%
Overdue
10
17%
Working
Published: 1 code
7
Developer 7
Rating
(70)
Projects
91
25%
Arbitration
26
19% / 54%
Overdue
25
27%
Free
8
Developer 8
Rating
(574)
Projects
945
47%
Arbitration
309
58% / 27%
Overdue
125
13%
Free
9
Developer 9
Rating
(624)
Projects
731
34%
Arbitration
48
52% / 40%
Overdue
14
2%
Working
10
Developer 10
Rating
(78)
Projects
246
74%
Arbitration
7
100% / 0%
Overdue
1
0%
Free
Published: 1 article
11
Developer 11
Rating
(35)
Projects
50
42%
Arbitration
3
33% / 33%
Overdue
4
8%
Free
12
Developer 12
Rating
(251)
Projects
400
54%
Arbitration
9
67% / 22%
Overdue
36
9%
Free
Published: 2 codes
Similar orders
Hello, I'm looking for developer or coder to create a custom expert advisor (EA) on mql4 according to my strategy. The developer should be able deliver both indicator and source code for the job. Thanks
Hello I need an EA for MT4 The EA uses only indicator, which shows a buy arrow for buy signal , and a sell arrow for sell signal. Conditions to open a trade: Open BUY trade, when we have a buy arrow show up, CANDLE CLOSES , AND THE ARROW IS STILL THERE .Then open BUY TRADE Open SELL trade, when we have a sell arrow show up, CANDLE CLOSES , AND THE ARROW IS THIS THERE .Then open BUY TRADE Open Close on opposite
​ Indicators: Fast MA (Period 10, Exponential) and Slow MA (Period 50, Exponential). ​ Buy Signal: When Fast MA crosses above Slow MA. ​ Sell Signal: When Fast MA crosses below Slow MA. ​ Risk Management & Parameters: ​Customizable Lot Size (Default: 0.01). ​Stop Loss (SL) and Take Profit (TP) in pips. ​Trailing Stop options. ​Max Spread filter. ​ Platform: MetaTrader 5 (MQL5)
​ Indicators: Fast MA (Period 10, Exponential) and Slow MA (Period 50, Exponential). ​ Buy Signal: When Fast MA crosses above Slow MA. ​ Sell Signal: When Fast MA crosses below Slow MA. ​ Risk Management & Parameters: ​Customizable Lot Size (Default: 0.01). ​Stop Loss (SL) and Take Profit (TP) in pips. ​Trailing Stop options. ​Max Spread filter. ​ Platform: MetaTrader 5 (MQL5)
A robot 30+ USD
Je souhaite trouver un développeur pour réaliser ce travail et effectuer les paiements via cette application. Je m'engage à ne communiquer avec les candidats que par cette application, y compris par messageries tierces, correspondance personnelle ou courriel. Je comprends que toute personne ne respectant pas ces conditions sera interdite de publier des commandes sur la plateforme Freelance
I am looking for an experienced MQL5/MT5 developer to develop a custom Expert Advisor based on a complete technical architecture already prepared by the client. This is not a request to design a trading strategy from scratch . The strategy architecture, entry/exit concepts, filters, risk-management requirements and testing requirements are already documented. The main responsibility will be MQL5 development
EAs 100+ USD
To apply, you must already have your EA running on an active MT5 trading account connected to the market. The account must have genuine trading history that can be independently reviewed and verified. EA Requirements 1. Prop-Firm Compatible Risk Management - The EA must include daily and overall drawdown protection. - Required inputs: "MaxDailyLoss = 5%" "MaxTotalDrawdown = 10%" - Once either limit is
Strategy 40 - 60 USD
yo i have a strategy i would really like to turn into a signal bot basically please this is very technical and serious to me the strategy needs more time 1 time frame and the bot most be 100% accurate
Ready to use bot 100+ USD
seller must provide the following to be considered... i will answer to all who fit this description, and can purchase more than 1 EA... - brief strategy description - overall EA expectancy - 1 week limited trial version, with whatever settings you consider best (can be blocked on demo, i don't really care) - investor password from a reputable broker (if history is available... live / demo, same thing, doesn't really
I want you to develop a professional HFT trading robot for MT5/MQL5 , initially focused on XAUUSD . The robot should be designed for high-speed tick-level trading , analyzing real-time bid/ask movement, spread, tick velocity, momentum, volatility, price acceleration and short-term market microstructure to identify very short-term opportunities. The core strategy should be capable of opening 5–10+ positions in a

Project information

Budget
30 - 100 USD