Spécifications

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

                }

            }

        }

    }

}


Répondu

1
Développeur 1
Évaluation
(249)
Projets
312
28%
Arbitrage
33
27% / 64%
En retard
10
3%
Travail
2
Développeur 2
Évaluation
(139)
Projets
181
24%
Arbitrage
23
22% / 39%
En retard
13
7%
Gratuit
3
Développeur 3
Évaluation
(325)
Projets
505
19%
Arbitrage
32
44% / 31%
En retard
34
7%
Chargé
4
Développeur 4
Évaluation
(44)
Projets
58
3%
Arbitrage
7
0% / 57%
En retard
5
9%
Travail
5
Développeur 5
Évaluation
(194)
Projets
241
34%
Arbitrage
10
50% / 50%
En retard
8
3%
Travail
Publié : 1 article, 8 codes
6
Développeur 6
Évaluation
(252)
Projets
258
30%
Arbitrage
0
En retard
3
1%
Gratuit
Publié : 2 codes
7
Développeur 7
Évaluation
(271)
Projets
400
27%
Arbitrage
39
41% / 49%
En retard
1
0%
Gratuit
8
Développeur 8
Évaluation
(154)
Projets
192
58%
Arbitrage
10
80% / 0%
En retard
0
Travail
Publié : 1 code
9
Développeur 9
Évaluation
(85)
Projets
168
44%
Arbitrage
3
67% / 0%
En retard
5
3%
Travail
Publié : 1 code
10
Développeur 10
Évaluation
(37)
Projets
59
27%
Arbitrage
26
19% / 54%
En retard
10
17%
Travail
Publié : 1 code
11
Développeur 11
Évaluation
(1156)
Projets
1462
63%
Arbitrage
21
57% / 10%
En retard
43
3%
Gratuit
12
Développeur 12
Évaluation
(527)
Projets
799
63%
Arbitrage
33
27% / 45%
En retard
23
3%
Gratuit
Publié : 1 code
13
Développeur 13
Évaluation
(43)
Projets
66
12%
Arbitrage
12
58% / 42%
En retard
1
2%
Gratuit
14
Développeur 14
Évaluation
(548)
Projets
632
33%
Arbitrage
39
38% / 49%
En retard
11
2%
Chargé
15
Développeur 15
Évaluation
(12)
Projets
25
4%
Arbitrage
1
0% / 0%
En retard
7
28%
Gratuit
16
Développeur 16
Évaluation
(449)
Projets
477
69%
Arbitrage
6
67% / 0%
En retard
2
0%
Gratuit
17
Développeur 17
Évaluation
(152)
Projets
228
80%
Arbitrage
22
27% / 50%
En retard
11
5%
Gratuit
Publié : 24 articles, 1882 codes
18
Développeur 18
Évaluation
(45)
Projets
76
20%
Arbitrage
7
0% / 86%
En retard
14
18%
Gratuit
19
Développeur 19
Évaluation
(2)
Projets
2
0%
Arbitrage
1
0% / 0%
En retard
2
100%
Gratuit
20
Développeur 20
Évaluation
(45)
Projets
46
24%
Arbitrage
34
9% / 85%
En retard
10
22%
Gratuit
21
Développeur 21
Évaluation
(3)
Projets
2
50%
Arbitrage
2
0% / 100%
En retard
0
Gratuit
22
Développeur 22
Évaluation
(15)
Projets
20
35%
Arbitrage
3
0% / 100%
En retard
0
Gratuit
Publié : 1 code
23
Développeur 23
Évaluation
(257)
Projets
341
58%
Arbitrage
7
14% / 71%
En retard
9
3%
Gratuit
24
Développeur 24
Évaluation
(3)
Projets
1
0%
Arbitrage
5
0% / 100%
En retard
0
Gratuit
25
Développeur 25
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
Commandes similaires
The indicator a bit inverted. But it doesn’t matter to me as long as the winrate make sense for investment. For brief details regarding the indicator. What should have been a sell, i inverted it into buy with sl and tp swapped(only change the name of sl and tp for visualisation , but the code still on right tp and sl) . And in script ive inverted the signal command code. But the trouble is the tp and sl cant be
Hello, I want a grid trading bot for the Gate.io crypto exchange. I currently have a working grid bot written in MQL5, and I want a similar bot implemented in Python. The MQL5 bot can be translated, but the codebase is large and it was not designed to be easily ported to Python. Therefore, I prefer that the final Python bot preserves the same core grid logic, but is implemented cleanly in Python rather than doing a
Please explain all the details, including the entry and exit conditions . Refine signal trigger execution . Optimize live chart performance . Ensure stable and clean code structure : Stable and clean code is important . Otherwise its a mess . Apply with as much accurate structure you foresee . requests for details of the project will be ignored
The EA should only set TP and SL( Both Optional, We can set one at the time or no one at the same time or both active at the same time) 1. We active trade ourself , But in The EA this should ask if what the the TP and SL in form of USD we need. We'll put the Exact Required profit and or loss. This EA should calculate and set the tps and Sls itself to all the trades, and when we change the USD profit from info meter
Phahla fx boto 30+ USD
99.99% signal accuracy 10-15 trades distribution all currency trade and meta AI assistance on loss[advice] stop and start robot cyber security firewall protection activation code: 20060605TLP20 Please create a trading bot with any logo with the name elevation
Refine signal trigger execution . Optimize live chart performance . Ensure stable and clean code structure : Stable and clean code is important . Otherwise its a mess . Apply with as much accurate structure you foresee
I am looking to purchase a fully developed and proven Expert Advisor (EA) for XAUUSD. This must be an existing EA with a minimum of 12 months verified live trading history on a real account. I am not interested in new development or demo-only systems. Requirements: • Verified live track record (Myfxbook, MQL5 signal, or broker statement) • Consistent profitability with controlled drawdown • Designed for XAUUSD •
RED DEVIL AI 30+ USD
50 EMA > 200 EMA → Uptrend confirmed Price pulls back to touch or cross below 50 EMA RSI > 50 ATR(14) > 20-period ATR average (volatility expanding) Current candle closes bullish ➡ Enter BUY at candle close50 EMA < 200 EMA → Downtrend Price pulls back to touch or cross above 50 EMA RSI < 50 ATR filter confirms volatility Current candle closes bearish ➡ Enter SELL at candle closeATR(14) Take Profit: 2.5 × ATR(14) This
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

Informations sur le projet

Budget
30+ USD