EA_Gold_MNAKOO

MQL4 Experts

Specification

//+------------------------------------------------------------------+
//| XAUUSD Automated Forex Robot                                     |
//| Enhanced Version with Error Handling and Improvements           |
//+------------------------------------------------------------------+
input int FastMA = 10;                 // Fast moving average period
input int SlowMA = 50;                 // Slow moving average period
input int RSI_Period = 14;             // RSI period
input double Overbought = 70;          // RSI overbought level
input double Oversold = 30;            // RSI oversold level
input double RiskPercent = 1.0;        // Risk per trade as a percentage of account equity
input double ATRMultiplier = 2.0;      // ATR multiplier for stop-loss
input double TrailingStop = 300;       // Trailing stop in points
input double MinLotSize = 0.01;        // Minimum lot size
input double LotStep = 0.01;           // Lot size increment
input int ATR_Period = 14;             // ATR period
input int MaxSlippage = 3;             // Maximum slippage in points
input int MAGIC_NUMBER = 123456;       // Unique identifier for trades
input string TradeComment = "XAUUSD Bot"; // Trade comment

//+------------------------------------------------------------------+
//| OnTick Function - Main Logic                                     |
//+------------------------------------------------------------------+
void OnTick() {
    // Calculate indicators
    static double fastMA, slowMA, rsi, atr;
    fastMA = iMA(NULL, 0, FastMA, 0, MODE_EMA, PRICE_CLOSE, 0);
    slowMA = iMA(NULL, 0, SlowMA, 0, MODE_EMA, PRICE_CLOSE, 0);
    rsi = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, 0);
    atr = iATR(NULL, 0, ATR_Period, 0);

    // Check for existing trades
    bool buyOpen = IsTradeOpen(OP_BUY);
    bool sellOpen = IsTradeOpen(OP_SELL);

    // Entry logic
    if (fastMA > slowMA && rsi > Oversold && rsi < 50 && !buyOpen) {
        // Buy Signal
        double sl = Bid - ATRMultiplier * atr;
        double tp = Bid + ATRMultiplier * atr * 2;
        double lotSize = CalculateLotSize(sl);
        OpenTrade(OP_BUY, lotSize, sl, tp);
    }

    if (fastMA < slowMA && rsi < Overbought && rsi > 50 && !sellOpen) {
        // Sell Signal
        double sl = Ask + ATRMultiplier * atr;
        double tp = Ask - ATRMultiplier * atr * 2;
        double lotSize = CalculateLotSize(sl);
        OpenTrade(OP_SELL, lotSize, sl, tp);
    }

    // Exit logic (Close trades when conditions reverse)
    if (buyOpen && (fastMA < slowMA || rsi >= Overbought)) {
        CloseTrade(OP_BUY);
    }

    if (sellOpen && (fastMA > slowMA || rsi <= Oversold)) {
        CloseTrade(OP_SELL);
    }

    // Manage Trailing Stop
    ManageTrailingStop();
}

//+------------------------------------------------------------------+
//| Calculate Lot Size Based on Risk                                 |
//+------------------------------------------------------------------+
double CalculateLotSize(double stopLossPrice) {
    double accountEquity = AccountEquity();
    double riskAmount = (RiskPercent / 100) * accountEquity;
    double stopLossDistance = MathAbs(Bid - stopLossPrice);
    double lotSize = riskAmount / (stopLossDistance * MarketInfo(Symbol(), MODE_TICKVALUE));

    // Adjust lot size to broker limits
    lotSize = MathMax(lotSize, MinLotSize);
    lotSize = NormalizeDouble(MathFloor(lotSize / LotStep) * LotStep, 2);
    return lotSize;
}

//+------------------------------------------------------------------+
//| Open Trade Function                                              |
//+------------------------------------------------------------------+
void OpenTrade(int tradeType, double lotSize, double stopLoss, double takeProfit) {
    double price = tradeType == OP_BUY ? Ask : Bid;
    int ticket = OrderSend(Symbol(), tradeType, lotSize, price, MaxSlippage, stopLoss, takeProfit, TradeComment, MAGIC_NUMBER, 0, Blue);
    if (ticket < 0) {
        int errorCode = GetLastError();
        Print("Error opening trade: ", errorCode, ". Retrying...");
        Sleep(1000); // Retry after 1 second
        ticket = OrderSend(Symbol(), tradeType, lotSize, price, MaxSlippage, stopLoss, takeProfit, TradeComment, MAGIC_NUMBER, 0, Blue);
        if (ticket < 0) {
            Print("Failed to open trade after retry. Error: ", GetLastError());
        }
    } else {
        Print("Trade opened: ", ticket);
    }
}

//+------------------------------------------------------------------+
//| Close Trade Function                                             |
//+------------------------------------------------------------------+
void CloseTrade(int tradeType) {
    for (int i = OrdersTotal() - 1; i >= 0; i--) {
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
            if (OrderSymbol() == Symbol() && OrderType() == tradeType && OrderMagicNumber() == MAGIC_NUMBER) {
                int ticket = OrderClose(OrderTicket(), OrderLots(), tradeType == OP_BUY ? Bid : Ask, MaxSlippage, Red);
                if (ticket < 0) {
                    Print("Error closing trade: ", GetLastError());
                } else {
                    Print("Trade closed: ", ticket);
                }
            }
        }
    }
}

//+------------------------------------------------------------------+
//| Manage Trailing Stop Function                                    |
//+------------------------------------------------------------------+
void ManageTrailingStop() {
    for (int i = OrdersTotal() - 1; i >= 0; i--) {
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC_NUMBER) {
                double newStopLoss;
                if (OrderType() == OP_BUY) {
                    newStopLoss = Bid - TrailingStop * Point;
                    if (newStopLoss > OrderStopLoss()) {
                        OrderModify(OrderTicket(), OrderOpenPrice(), newStopLoss, OrderTakeProfit(), 0, Blue);
                    }
                } else if (OrderType() == OP_SELL) {
                    newStopLoss = Ask + TrailingStop * Point;
                    if (newStopLoss < OrderStopLoss()) {
                        OrderModify(OrderTicket(), OrderOpenPrice(), newStopLoss, OrderTakeProfit(), 0, Blue);
                    }
                }
            }
        }
    }
}

//+------------------------------------------------------------------+
//| Check if Trade Exists                                            |
//+------------------------------------------------------------------+
bool IsTradeOpen(int tradeType) {
    for (int i = OrdersTotal() - 1; i >= 0; i--) {
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
            if (OrderSymbol() == Symbol() && OrderType() == tradeType && OrderMagicNumber() == MAGIC_NUMBER) {
                return true;
            }
        }
    }
    return false;
}

Files:

Responded

1
Developer 1
Rating
(134)
Projects
162
52%
Arbitration
10
80% / 0%
Overdue
0
Working
Published: 1 code
2
Developer 2
Rating
(211)
Projects
263
26%
Arbitration
16
44% / 31%
Overdue
9
3%
Busy
3
Developer 3
Rating
(28)
Projects
32
9%
Arbitration
3
0% / 33%
Overdue
0
Free
4
Developer 4
Rating
(290)
Projects
451
18%
Arbitration
27
48% / 26%
Overdue
27
6%
Loaded
5
Developer 5
Rating
(9)
Projects
20
10%
Arbitration
3
67% / 33%
Overdue
5
25%
Free
6
Developer 6
Rating
(389)
Projects
564
53%
Arbitration
27
56% / 22%
Overdue
6
1%
Working
7
Developer 7
Rating
(5)
Projects
8
13%
Arbitration
2
0% / 0%
Overdue
2
25%
Free
Published: 1 code
8
Developer 8
Rating
(12)
Projects
13
23%
Arbitration
6
0% / 67%
Overdue
3
23%
Working
9
Developer 9
Rating
(102)
Projects
105
60%
Arbitration
0
Overdue
0
Free
10
Developer 10
Rating
(1)
Projects
4
0%
Arbitration
0
Overdue
3
75%
Free
11
Developer 11
Rating
(4)
Projects
2
0%
Arbitration
1
0% / 0%
Overdue
1
50%
Free
12
Developer 12
Rating
(121)
Projects
134
66%
Arbitration
36
25% / 56%
Overdue
22
16%
Free
Published: 10 codes
13
Developer 13
Rating
(427)
Projects
447
73%
Arbitration
5
80% / 0%
Overdue
0
Loaded
14
Developer 14
Rating
(91)
Projects
131
18%
Arbitration
4
25% / 25%
Overdue
12
9%
Loaded
15
Developer 15
Rating
(535)
Projects
613
34%
Arbitration
33
39% / 45%
Overdue
9
1%
Busy
16
Developer 16
Rating
(2)
Projects
1
0%
Arbitration
1
0% / 100%
Overdue
0
Free
17
Developer 17
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
18
Developer 18
Rating
(59)
Projects
78
44%
Arbitration
22
14% / 64%
Overdue
8
10%
Working
19
Developer 19
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Working
Similar orders
Break 30+ USD
i havee an ea that work in tandem with an indicator i created. 1.i want to add a trend filter, using a trend line on a higher timeframe to decide the direction of the market then trades would be taken on a smaller timeframe using the same mss and bos entry. in the event the on the higher timeframe a bullish trendline was drawn then on the smaller timeframe only buy trades would be taken and sell signals ignored. when
i NEED SOMEONE WHO CAN HELP ME CREATE A BOT THAT EXECUTE AND CLOSE TRADE AUTOMATICALLY ONLY FOR GOLD (XAUUSD) . A BOT THAT DOES NOT TRADE THE NEWS BUT ONLY TAKE TRADE ON ITS OWN AUTOMATICALLYON A NORMAL TRADING DAYS , I DONT MIND IF YOU ALREADY HAVE ONE THAT YOU ALREADY CREATED BUT TRUST AND HAVE A GOOD PERCENTAGE WIN RATE . I WANTS A BOT THAT USES (SL & TP) ON ITS OWN , OPENING AND CLOSES TRADE AUTOMATICALLY WITHOUT
Busco programador para crear un bot de trading automático. El bot operará en opciones binarias en Nadex, basado en la relación entre dos índices. La estrategia completa será entregada por privado al programador que acepte el trabajo. Requisitos: • Operación automática con delay configurable. • Entrada basada en datos de otro activo. • Personalizable en cantidad, expiración y lógica. • Código fuente incluido
Hello, I'm currently seeking a skilled and reliable MQL4 developer to assist in modifying and enhancing my Expert Advisor, Reversal Master V10.1 , to its next version V12.1 FF . This update involves integrating several advanced third-party indicators and implementing new trading logic based on clearly defined conditions to improve performance and strategy precision. If you have experience in EA development and enjoy
Hello, I'm currently seeking a skilled and reliable MQL4 developer to assist in modifying and enhancing my Expert Advisor, Reversal Master V10.1 , to its next version V12.1 FF . This update involves integrating several advanced third-party indicators and implementing new trading logic based on clearly defined conditions to improve performance and strategy precision. If you have experience in EA development and enjoy
Project Description: I am looking for a highly skilled MQL5 developer to create a robust solution for a persistent TLS handshake failure. My Expert Advisor (EA) needs to connect to a secure WebSocket server ( wss:// ) hosted on Railway.app or any other online websocket provider, but the connection consistently fails during the security negotiation phase. Ideal Candidate Skills: Deep expertise in MQL5 programming
I need an experienced developer to convert my MT4 EA based on the Super Trend indicator to MT5. The new EA should also include additional features. Essential modifications: - Incorporate additional indicators: Moving Average and PSAR. - Add custom alerts: Push and sound notifications. - Implement money management rules
I have a custom EA that I need optimized. I need it optimized for many pairs and the set files sent to me. The EA was created a few months ago, it works, but I need it optimized for it to run better
hello freelancers i need some one with a profitable ea for gold and dj30 i need the ea to be a scalping ea which places orders with sl and tp of 200 points for each trade and have a winning rate of more than 70 percent. if you have it already please apply for this
A robot 50+ USD
hy i am looking for someone who can fix robot for me .i need someone who know about order block .my entries are only order block. I have robot already i need only fix it.i just need someone who can fix this as soon as possible

Project information

Budget
100+ USD
For the developer
90 USD