Specification

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);

                }

            }

        }

    }

}


Responded

1
Developer 1
Rating
(146)
Projects
173
23%
Arbitration
7
29% / 43%
Overdue
4
2%
Working
2
Developer 2
Rating
(139)
Projects
181
24%
Arbitration
23
22% / 39%
Overdue
13
7%
Free
3
Developer 3
Rating
(198)
Projects
321
16%
Arbitration
21
38% / 33%
Overdue
17
5%
Loaded
4
Developer 4
Rating
(41)
Projects
54
4%
Arbitration
5
0% / 60%
Overdue
4
7%
Free
5
Developer 5
Rating
(166)
Projects
180
32%
Arbitration
6
50% / 50%
Overdue
2
1%
Working
6
Developer 6
Rating
(202)
Projects
206
27%
Arbitration
0
Overdue
3
1%
Free
7
Developer 7
Rating
(158)
Projects
226
22%
Arbitration
15
60% / 20%
Overdue
1
0%
Loaded
8
Developer 8
Rating
(95)
Projects
117
38%
Arbitration
9
89% / 0%
Overdue
0
Free
9
Developer 9
Rating
(63)
Projects
101
31%
Arbitration
1
100% / 0%
Overdue
2
2%
Free
10
Developer 10
Rating
(37)
Projects
59
27%
Arbitration
25
20% / 52%
Overdue
10
17%
Working
11
Developer 11
Rating
(1130)
Projects
1432
62%
Arbitration
21
57% / 10%
Overdue
43
3%
Free
12
Developer 12
Rating
(512)
Projects
773
63%
Arbitration
33
27% / 45%
Overdue
23
3%
Free
13
Developer 13
Rating
(42)
Projects
62
8%
Arbitration
12
58% / 42%
Overdue
1
2%
Free
14
Developer 14
Rating
(463)
Projects
524
33%
Arbitration
28
39% / 43%
Overdue
7
1%
Busy
15
Developer 15
Rating
(9)
Projects
21
5%
Arbitration
1
0% / 0%
Overdue
7
33%
Free
16
Developer 16
Rating
(368)
Projects
398
70%
Arbitration
3
100% / 0%
Overdue
2
1%
Loaded
17
Developer 17
Rating
(140)
Projects
205
80%
Arbitration
18
33% / 44%
Overdue
10
5%
Working
18
Developer 18
Rating
(45)
Projects
76
20%
Arbitration
7
0% / 86%
Overdue
14
18%
Free
19
Developer 19
Rating
(2)
Projects
2
0%
Arbitration
1
0% / 0%
Overdue
2
100%
Free
20
Developer 20
Rating
(38)
Projects
40
25%
Arbitration
23
13% / 70%
Overdue
8
20%
Loaded
21
Developer 21
Rating
(2)
Projects
1
100%
Arbitration
1
0% / 100%
Overdue
0
Free
22
Developer 22
Rating
(15)
Projects
19
37%
Arbitration
2
0% / 100%
Overdue
0
Free
23
Developer 23
Rating
(257)
Projects
341
58%
Arbitration
7
14% / 71%
Overdue
9
3%
Free
24
Developer 24
Rating
(3)
Projects
1
0%
Arbitration
2
0% / 100%
Overdue
0
Working
25
Developer 25
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Similar orders
Hello, I have an EA already created and what I require is a modification to the code so that when a backtest is executed, it generates a CSV file with custom data that I want to extract to perform an analysis of the backtest operations
Smithpiper EA 30+ USD
i want to use 4 defualt indicators to create an EA ,BB BAND ,STOCH,HEIKEN ASHI AND PARABOLIC SAR USING TWO TIMEFRAME ON ATTACHED CHART , EXAMPLE OF SELL SETUP ON LOWER TF ,,IF PRICE HAS CROSS 50 LEVEL DOWN ON STOCHASTIC 50,3,3 AND PARABOLIC SAR HAS FORMED RESISTANCE ABOVE PRICE HEIKEN ASHI HAS TURN RED AND FINALY PRICE HAS CROSS BB BAND 50 MIDDLE LINE A SETUP IS FORMED HIGHER TIME FRAME WILL BE USE FOR FILTER FILTER
Formal Software Request Software Title: High-Performance Automated Trading System Requestor: 80485848 Date: 19 August 2024 1. Introduction We seek a sophisticated automated trading system capable of executing trades across Forex, Gold, and Cryptocurrency markets. The primary objective is to achieve a high win rate while operating autonomously. 2. Core Requirements Win Rate: The system must demonstrate a
1. The Trading View indicator code needs to be converted into and adapted for Ninja Trader 8 2. An indicator and Automated Trading Strategy needs to be developed. 3. Any parts of the Trading View Indicator that can't be replicated needs to be discussed with me and agreed before excluding. (there should not be any) 4. Trailing stop and Trailing Draw Down options need to be implemented 5. Risk needs to be in % of
I WRITE a code i want to conect this for automatic trading through vps .and als advanced features for this code .i attached afile please watch .and give me perfect ea
I need a simple panel to execute both buy and sell operations with very basic things like stopp loss take profit that functions for both market orders such as buy stop sell stop buy limit sell limit I don't care about colors or design I just want how you can do it what interests me most are the functions
I want to create an EA that can take bids according to information of a logic I have developed to give indication of a BUY or SELL opportunity. The EA will then be able to activate the BUY at the lowest possible position once the indicator clears it for a BUY and take bid upwards or identify the highest point and clears it for a SELL and take bids downwards. As you can see from example of JULY 2024 data to see how
Hello, I‘m interested in an indicator to predict the next candles probability (bullish or bearish). But honestly I have no idea how to do this. Would be interested in your opinion how we can create such an indicator. Please let me know if you‘ve done similar work
Hello, I want to make an EA based on SMC and a developer that is familiar with the concept and full understanding of this. Must have done similar jobs before and be able show it. I only want to work with developer that has good track record and is precise. Further information will be handed when contact is made. Developers that has zero rating will not be considered. Listed price is a base point. The project can also
New york session based strategy 9:30 open Price takes out buy side or sell side liquidity Usually using 15min high and lows 5m entry Price takes out that high/low and price must close strongly back into the zone Is price is above price we have a sell bias vis versa for buys Sl is at the high or low with option for “offset” for cushion Tp is usually the opposite High or low. Would like the option for set pips-points &

Project information

Budget
30+ USD
For the developer
27 USD