FIX ERRORS ON MY CODE

指定

HI

i want some one to make the following MQL5 code work for me. the code has errors.


#include <Trade\Trade.mqh> // Include the trade library


// Define input parameters

input double lotSize = 0.1;    // Lot size for trading

input int stopLoss = 50;       // Stop Loss in pips

input int takeProfit = 100;    // Take Profit in pips


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

//| Expert initialization function                                   |

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

int OnInit()

{

    // Subscribe to OnTrade() event

    EventSetMillisecondTimer(60);  // Set a timer to check conditions every 60 milliseconds

    return(INIT_SUCCEEDED);

}


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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

{

    // Deinitialization function (if needed)

    EventKillTimer();  // Kill the timer when deinitializing

}


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

//| Expert tick function                                             |

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

void OnTick()

{

    // Nothing to do here for conditions check, as we use OnTrade()

}


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

//| Expert trade event handler                                       |

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

void OnTrade()

{

    // Calculate the open and close prices of the previous day

    double prevDayOpen = iOpen(Symbol(), PERIOD_D1, 1);

    double prevDayClose = iClose(Symbol(), PERIOD_D1, 1);


    // Check for Rule 1: Previous day was an uptrend

    if (prevDayClose > prevDayOpen)

    {

        // Check if the current open price is between the previous day's open and close prices

        double currentOpen = iOpen(Symbol(), PERIOD_D1, 0);

        if (currentOpen > prevDayOpen && currentOpen < prevDayClose)

        {

            // Buy if the price breaks above the previous day's close price

            double currentHigh = iHigh(Symbol(), PERIOD_D1, 0);

            if (currentHigh > prevDayClose)

            {

                // Place a Buy order

                double openPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

                double stopLossPrice = openPrice - stopLoss * _Point;

                double takeProfitPrice = openPrice + takeProfit * _Point;


                int ticket = OrderSend(_Symbol, OP_BUY, lotSize, openPrice, 3, 0, 0, "", 0, clrNONE, 0, clrNONE);

                if (ticket > 0)

                {

                    // Order placed successfully - set Stop Loss and Take Profit

                    OrderSend(_Symbol, OP_SELL, lotSize, openPrice, 0, stopLossPrice, takeProfitPrice, "", 0, clrNONE, 0, clrNONE);

                }

            }

        }

    }


    // Check for Rule 2: Opposite of Rule 1

    if (prevDayClose < prevDayOpen)

    {

        // Check if the current open price is between the previous day's open and close prices

        double currentOpen = iOpen(Symbol(), PERIOD_D1, 0);

        if (currentOpen > prevDayOpen && currentOpen < prevDayClose)

        {

            // Sell if the price breaks below the previous day's close price

            double currentLow = iLow(Symbol(), PERIOD_D1, 0);

            if (currentLow < prevDayClose)

            {

                // Place a Sell order

                double openPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);

                double stopLossPrice = openPrice + stopLoss * _Point;

                double takeProfitPrice = openPrice - takeProfit * _Point;


                int ticket = OrderSend(_Symbol, OP_SELL, lotSize, openPrice, 3, 0, 0, "", 0, clrNONE, 0, clrNONE);

                if (ticket > 0)

                {

                    // Order placed successfully - set Stop Loss and Take Profit

                    OrderSend(_Symbol, OP_BUY, lotSize, openPrice, 0, stopLossPrice, takeProfitPrice, "", 0, clrNONE, 0, clrNONE);

                }

            }

        }

    }

}


反馈

1
开发者 1
等级
(277)
项目
349
29%
仲裁
37
27% / 65%
逾期
10
3%
已载入
2
开发者 2
等级
(139)
项目
181
24%
仲裁
23
22% / 39%
逾期
13
7%
空闲
3
开发者 3
等级
(329)
项目
515
19%
仲裁
35
46% / 31%
逾期
34
7%
工作中
4
开发者 4
等级
(44)
项目
60
5%
仲裁
6
0% / 67%
逾期
5
8%
空闲
5
开发者 5
等级
(195)
项目
242
34%
仲裁
11
45% / 45%
逾期
8
3%
空闲
发布者: 1 文章, 8 代码
6
开发者 6
等级
(258)
项目
269
29%
仲裁
1
100% / 0%
逾期
3
1%
工作中
发布者: 2 代码
7
开发者 7
等级
(274)
项目
403
28%
仲裁
40
40% / 50%
逾期
1
0%
空闲
8
开发者 8
等级
(160)
项目
208
61%
仲裁
10
80% / 0%
逾期
0
空闲
发布者: 1 代码
9
开发者 9
等级
(85)
项目
174
44%
仲裁
3
100% / 0%
逾期
5
3%
空闲
发布者: 1 代码
10
开发者 10
等级
(37)
项目
59
27%
仲裁
26
19% / 54%
逾期
10
17%
工作中
发布者: 1 代码
11
开发者 11
等级
(1156)
项目
1462
63%
仲裁
21
57% / 10%
逾期
43
3%
空闲
12
开发者 12
等级
(552)
项目
840
61%
仲裁
33
27% / 45%
逾期
24
3%
空闲
发布者: 1 代码
13
开发者 13
等级
(43)
项目
66
12%
仲裁
12
58% / 42%
逾期
1
2%
空闲
14
开发者 14
等级
(616)
项目
719
33%
仲裁
46
48% / 41%
逾期
14
2%
已载入
15
开发者 15
等级
(12)
项目
25
4%
仲裁
1
0% / 0%
逾期
7
28%
空闲
16
开发者 16
等级
(461)
项目
488
70%
仲裁
6
67% / 0%
逾期
2
0%
空闲
17
开发者 17
等级
(152)
项目
228
80%
仲裁
22
27% / 50%
逾期
11
5%
空闲
发布者: 24 文章, 1882 代码
18
开发者 18
等级
(45)
项目
76
20%
仲裁
7
0% / 86%
逾期
14
18%
空闲
19
开发者 19
等级
(2)
项目
2
0%
仲裁
1
0% / 0%
逾期
2
100%
空闲
20
开发者 20
等级
(45)
项目
46
24%
仲裁
34
9% / 85%
逾期
10
22%
空闲
21
开发者 21
等级
(3)
项目
2
50%
仲裁
2
0% / 100%
逾期
0
空闲
22
开发者 22
等级
(15)
项目
20
35%
仲裁
3
0% / 100%
逾期
0
空闲
发布者: 1 代码
23
开发者 23
等级
(257)
项目
341
58%
仲裁
7
14% / 71%
逾期
9
3%
空闲
24
开发者 24
等级
(3)
项目
1
0%
仲裁
5
0% / 100%
逾期
0
空闲
25
开发者 25
等级
项目
0
0%
仲裁
0
逾期
0
空闲
相似订单
NinjaTrader 8 / NinjaScript Phase 1 build: convert an existing Auction Market Theory (AMT) strategy into objective, alert-only decision-support logic. Not a bot, no auto-execution — trades stay manual. Covers NQ/MNQ, ES, CL, MGC using 30-min TPO/Volume Profile context with 5-min confirmation: one 5-min close outside VAH/VAL = acceptance, close back inside = rejection. Dashboard shows bias, auction state, location
Hi i need help to connect my chat gtp with ninja trader I have all tools. Just need supervision and seeking a professional who can do that for me. This the bridge extension https://crosstrade.io/blog/chatgpt-to-ninjatrader-mcp-walkthrough
Hello, I am looking for an experienced MQL5 developer to convert an open-source TradingView indicator into a fully functional MetaTrader 5 Expert Advisor (automated trading robot). Source Indicator: Heikin Ashi RSI Oscillator (HARSI) by JayRogers TradingView Link: Target Platform: MetaTrader 5 (MT5) Core Requirements: Indicator Replication: The EA must accurately replicate the HARSI candle logic, smoothing
I need a pine script coder to automate my strategy (based on trendline) on tradingview platform. I simply need tradingview to open a position when the price touches the specified trendline with options to buy or sell and SL level. Please let me know if you are interested and I can give you exact details. Thank you
MT5 EA DEVELOPMENT SPECIFICATION CHANNEL + RSI REVERSAL STRATEGY I need a professional MetaTrader 5 Expert Advisor based on the following exact strategy. 1. Core Strategy The EA must automatically identify a valid price channel using confirmed swing highs and swing lows. The strategy trades reversals from the channel extremes: SELL: Upper channel + RSI above 70 + bearish rejection. BUY: Lower channel + RSI below 40 +
Senior MQL5 Developer Required — XAUUSD & BTCUSD Algorithmic EA I am looking for an experienced MQL5 developer to design and build a robust MT5 Expert Advisor for XAUUSD (Gold) and BTCUSD . This is not a request for a basic RSI/EMA EA, martingale, grid, or recovery system . I want a properly engineered algorithmic trading system with a demonstrable trading rationale, robust risk management, reliable execution and
Ai sadick 30+ USD
Fully automated entry and exit of trades. Identify market trends using price action and reliable technical indicators. Trade major Forex pairs and XAU/USD (Gold). Automatic Stop Loss and Take Profit on every trade. Adjustable risk management, with default risk of 1% per trade. Maximum daily loss protection to stop trading after a specified loss. Break-even and trailing-stop functions. Adjustable lot size, risk %
Hello there, I am looking for a automated strategy for ninjatrader 5 Looking for a proven profit factor of 1.5 ( minimum ) on 15 mins time frame . I do MNQ futures I do not have the logic, but I like mean reverssion variable , plus RSI etc . that could make the automated tool robust and long lasting. i need fast response if you have
Date:29.08.2026 **TECHNICAL SPECIFICATIONS** PDF Attached for reference rest all details given below. Required: Creation, Integration and successful execution of trading algo/robot in MT5 using MT5 VPS. Brokers: Trades to be executed in both brokers Swissquote and Pepperstone. Symbols: All available in MT5. ** Common parameters for all executions: · Manual Start/Stop. · Session time (defined / always
ZONDII Scalpers 30+ USD
I need an Expert Advisor called ZONDII Scalpers for MT5 (MQL5). Timeframe: M5 Pairs: XAUUSD / EURUSD BUY when: Price > EMA200 and EMA50 crosses above EMA200 and RSI(14) > 50 SELL when: Price < EMA200 and EMA50 crosses below EMA200 and RSI(14) < 50 Risk: Fixed lot 0.01, SL 300 points, TP 600 points, Trailing start 200 points / step 100 points. Filter: Max spread 30 points. Only 1 trade at a time. Inputs must be

项目信息

预算
30+ USD