EA_Gold_MNAKOO

MQL4 전문가

명시

//+------------------------------------------------------------------+
//| 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;
}

파일:

응답함

1
개발자 1
등급
(154)
프로젝트
192
58%
중재
10
80% / 0%
기한 초과
0
작업중
게재됨: 1 코드
2
개발자 2
등급
(249)
프로젝트
312
28%
중재
33
27% / 64%
기한 초과
10
3%
작업중
3
개발자 3
등급
(33)
프로젝트
38
21%
중재
5
0% / 60%
기한 초과
0
무료
4
개발자 4
등급
(325)
프로젝트
505
19%
중재
32
44% / 31%
기한 초과
34
7%
로드됨
5
개발자 5
등급
(9)
프로젝트
20
10%
중재
4
50% / 50%
기한 초과
5
25%
무료
6
개발자 6
등급
(429)
프로젝트
628
54%
중재
30
53% / 23%
기한 초과
6
1%
로드됨
7
개발자 7
등급
(5)
프로젝트
8
13%
중재
3
0% / 33%
기한 초과
2
25%
무료
게재됨: 1 코드
8
개발자 8
등급
(12)
프로젝트
13
23%
중재
7
0% / 71%
기한 초과
3
23%
작업중
9
개발자 9
등급
(102)
프로젝트
105
60%
중재
0
기한 초과
0
무료
10
개발자 10
등급
(3)
프로젝트
6
17%
중재
0
기한 초과
3
50%
무료
11
개발자 11
등급
(4)
프로젝트
2
0%
중재
5
0% / 80%
기한 초과
1
50%
무료
12
개발자 12
등급
(121)
프로젝트
134
66%
중재
36
25% / 56%
기한 초과
22
16%
무료
게재됨: 10 코드
13
개발자 13
등급
(467)
프로젝트
486
75%
중재
6
67% / 17%
기한 초과
0
작업중
14
개발자 14
등급
(103)
프로젝트
165
24%
중재
23
9% / 78%
기한 초과
16
10%
작업중
15
개발자 15
등급
(548)
프로젝트
632
33%
중재
39
38% / 49%
기한 초과
11
2%
로드됨
16
개발자 16
등급
(2)
프로젝트
1
0%
중재
1
0% / 100%
기한 초과
0
무료
17
개발자 17
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
게재됨: 1 코드
18
개발자 18
등급
(59)
프로젝트
81
43%
중재
27
11% / 70%
기한 초과
8
10%
무료
19
개발자 19
등급
프로젝트
0
0%
중재
0
기한 초과
0
작업중
비슷한 주문
Olá, Sou um comprador sério interessado em adquirir um Expert Advisor (EA) já existente, estável e rentável, projetado especificamente para: 👉 principalmente (XAUUSD) ou qualquer outro câmbio Trata-se de um pedido de compra integral. ⚠️ Não estou interessado em criar um novo EA do zero. Somente sistemas prontos para uso e comprovados, com histórico real de desempenho. ✅ Requisitos da EA (Rigorosos) 📌 Símbolo e
My EA (Expert Advisor) is a powerhouse! 💪 With rock-solid 100% risk management, it lets you trade stress-free while maximizing gains. Free to manage manually, it's designed to boost profitability. 🚀
Hello, Primary goal: convert the existing MQL5 strategy logic to Python as soon as possible and make it work for API trading (order management, exchange connection, basic bot structure). I want to keep the core logic unchanged . I haven’t chosen the exchange yet (must be usable in the EU ). Binance, OKX, Kraken, and Bybit are not options. Bitmart, pionex, gateio are options. Secondary goal (code reduction): the
This post is subject to developers response . Edit the post as you like . May be with me you can make a come back . So , , , Shift calculations . More to the calculation then you can comprehend is known . What else comes to your mind
This first robot I'm needing to order a robot that will help me with my trading and make it most efficient Help me with my margins my signals or anything I need to do associated to my trading or classroom
1- In the Universal EA that I currently have, in MA mode under the Take Profit options, when using the “Kill positions + clean one buy one” option, the counter resets itself before the accumulated loss is fully recovered while the loss stored in memory is being cleared. If fixing this is not possible, then I would like to modify the method as follows: Instead of clearing the accumulated losses in the Losses Pool one
1. Shift the Time Gate (Critical) Current start time: 08:30 New required start time: 08:35:01 The EA is currently triggering trades too early (between 08:25 – 08:30 ), which is causing incorrect entries. Please ensure the EA cannot enter any trade before 08:35:01 . 2. Change Order Execution Logic The current code is using Pending Orders . Please remove pending order logic completely . Replace it with Direct Market
Here is an example of Requirements Specification for the development of the MACD Sample Expert Advisor, which is available in the MetaTrader 5 standard package. 1. The idea of the trading system is as follows : market entries are performed when MACD's main and signal lines intersect in the current trend direction . 2. Trend is determined based on the Exponential Moving Average with the specified period
Here is an example of Requirements Specification for the development of the MACD Sample Expert Advisor, which is available in the MetaTrader 5 standard package. 1. The idea of the trading system is as follows: market entries are performed when MACD's main and signal lines intersect in the current trend direction. 2. Trend is determined based on the Exponential Moving Average with the specified period
I am looking for a pre-built MetaTrader 5 (MT5) Expert Advisor (EA) that can fully automate trading on major currency pairs such as EURUSD, AUDUSD, EURCAD, and USDCAD. Requirements: Fully automated trading (no manual intervention required) Compatible with MT5 platform Designed for consistent, long-term performance Demonstrated average monthly return of at least 3% Verified backtest and/or live trading results showing

프로젝트 정보

예산
100+ USD