Need an EA

 

Hi!

I would Like to request an EA, that is basically an Breakout EA and First you Tell the EA an time of the Candle that it should Mark the highs and lows of, and then after that time, depending on which tf it IS, it buys If Candle closes above the Zone, but also has a Wick or the Body still in the Zone, and Same for selling, Just that the Candle should be under the Zone (and Body or Wick in it). Also IT would be cool, If there is a setting with min. ATR Level and which period. And maybe SMA Settings too (to Just buy above 200 SMA and sell under)

TP settings are also good, and SL should be dynamic (If sell, then sl = high of that Candle which Is used as Zone and If buy then sel = Low of canlce that is used as Zone)

It would be perfect If there is a setting to add Off Pips

Where you enter your Pips Size and TP gets reduced by These Pips and SL gets  wider, so You dont get Wicked Out, or dont Take Profit.

I have tried this, maybe it can Help you :)

input double UpZone = 1.3000; // Define your UpZone value



input double DownZone = 1.2900; // Define your DownZone value

input int ATR_Period = 14; // ATR period

input double MinATRLevel = 0.001; // Minimum ATR level to trigger a trade

input double TakeProfitPips = 20; // Take Profit in pips

input double SpreadPips = 2; // Desired spread in pips


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

//| Expert initialization function |

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

int OnInit()

{

    // Add initialization code here

    if (!CheckSettings()) {

        Print("EA initialization failed. Check settings.");

        return(INIT_FAILED);

    }


    return(INIT_SUCCEEDED);

}


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

//| Expert tick function |

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

void OnTick()

{

    double closePrice = iClose(Symbol(), 0, 0);

    double openPrice = iOpen(Symbol(), 0, 0);

    double highPrice = iHigh(Symbol(), 0, 0);

    double lowPrice = iLow(Symbol(), 0, 0);


    double atrValue = iATR(Symbol(), 0, ATR_Period, 0);


    double stopLoss, takeProfit; // Declare variables outside of if statements


    // Check if ATR is greater than the specified minimum level

    if (atrValue >= MinATRLevel)

    {

        // Check if candle closes below DownZone but also has its body in the Zone

        if (closePrice < DownZone && openPrice > DownZone)

        {

            stopLoss = DownZone + SpreadPips * Point;

            takeProfit = openPrice + TakeProfitPips * Point - SpreadPips * Point;


            // Execute sell logic

            if (ExecuteSell(stopLoss, takeProfit) < 0) {

                Print("Sell order execution failed. Check logs.");

            }

        }


        // Check if candle closes above UpZone but also has a wick or body in the Zone

        if (closePrice > UpZone && (highPrice > UpZone || lowPrice > UpZone))

        {

            stopLoss = UpZone - SpreadPips * Point;

            takeProfit = openPrice - TakeProfitPips * Point + SpreadPips * Point;


            // Execute buy logic

            if (ExecuteBuy(stopLoss, takeProfit) < 0) {

                Print("Buy order execution failed. Check logs.");

            }

        }

    }

}


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

//| Check EA settings |

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

bool CheckSettings()

{

    // Add additional checks if needed

    return (TakeProfitPips > 0 && SpreadPips >= 0);

}


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

//| Execute Sell Order |

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

int ExecuteSell(double stopLoss, double takeProfit)

{

    int attempts = 0;

    int result;


    do

    {

        result = OrderSend(Symbol(), OP_SELL, 0.1, iClose(Symbol(), 0, 0), 3, stopLoss, takeProfit, "Sell order", 0, 0, Red, 0, 0, 0);

        attempts++;


        // Add a delay to allow the market to settle

        Sleep(1000);

    }

    while (result < 0 && attempts < 3); // Maximum 3 attempts


    return result;

}


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

//| Execute Buy Order |

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

int ExecuteBuy(double stopLoss, double takeProfit)

{

    int attempts = 0;

    int result;


    do

    {

        result = OrderSend(Symbol(), OP_BUY, 0.1, iClose(Symbol(), 0, 0), 3, stopLoss, takeProfit, "Buy order", 0, 0, Blue, 0, 0, 0);

        attempts++;


        // Add a delay to allow the market to settle

        Sleep(1000);

    }

    while (result < 0 && attempts < 3); // Maximum 3 attempts


    return result;

}but UpZone and down Zone should be detected automatically by that one Candle which you should be able to declare in settings, for example

17:05

This will See the high and Low of that Candle and trade based of that (buy above and sell under, but Body or Wick should be includes in the Zone, and Just buy or sell at Close of Candle. Also adjust SL and TP by spread.

Thanks!

 
  1. Wir können hier deutsch sprechen :)
  2. Bitte editiere Dein Post einmal (wichtig), dass Code als Code dargestellt wird mit oder Alt +S
    und dann auch gleich Deinen Beitrag in deutsch - warum nicht.
  3. Erwarte aber nicht, dass hier im Forum jemand für Dich Deine Idee programmiert, weil Du das nicht kannst, 
  4. dafür gibt es die Freelancer, aber beschreibe genau das, was Du willst - lies vorhwer das, es macht die Sache klar und sicherer:
    Regeln:     https://www.mql5.com/de/job/rules
    EA Pflichtenheft HowT:     https://www.mql5.com/de/articles/4368
    Indi Pflichtenheft HowTo:   https://www.mql5.com/de/articles/4304
  5. Hier noch Links zu Tipp und Hinweise für Programmier-Anfänger:
        https://www.mql5.com/de/articles/496
        https://www.mql5.com/de/articles/100
        https://www.mql5.com/de/articles/599
        https://www.mql5.com/de/articles/232
        Ord.,Pos.,Deals: https://www.mql5.com/de/articles/211
        Fertige Vorlagen für die Verwendung von Indikatoren in Expert Advisors: https://www.mql5.com/de/articles/13244
        und zur Fehlersuche, wenn das Programm  nicht tut, was es soll: https://www.metatrader5.com/de/metaeditor/help/development/debug
        Es gibt fast nichts, das nicht schon für MT4/5 programmiert wurde!
        => Suchen in den Artikeln: https://www.mql5.com/de/articles
        => Suchen in der Codebase: https://www.mql5.com/de/code
        => Suchen allgemein: https://www.mql5.com/de/search oder über Google mit: "site:mql5.com .." (verzeiht Schreibfehler)
Überfliege es halt und verweile bei dem, was Du brauchst.
Handelsanwendungen für MetaTrader 5 auf Bestellung
Handelsanwendungen für MetaTrader 5 auf Bestellung
  • 2024.02.29
  • www.mql5.com
Der größte Freelance Service für Entwickler von Programmen in MQL5
 

Oke.

Also ich habe Versucht einen bot zu erstellen bei dem eine bestimmte Kerze als Zone benutzt wird 

Z.B 17:05

Wenn eine Kerze über dieser Zone schließt, dann soll der bot Long gehen mit eigenem TP (Einstellungen)

Und sl sollte die untere Zone der Candle sein. Bei der 17:05 Candle soll auch der Wick gezählt werden.

Wenn eine Kerze unter der Zone schließt soll der bot short gehen mit dem voreingestellten TP und der SL. Soll das oberige der Candle sein (oberige der 17:05 Candle in diesem Fall) und bevor Long oder short gegangen wird, muss auch die Candle entweder mit dem Body oder mit dem Wick in der Zone sein (gleichzeitig)

Außerdem gibt es die Einstellung das nur bei einem bestimmten ATR Wert getradet wird und nur Long bei z.B über 200 SMA und nur short unter 200 SMA


Außerdem soll es eine Einstellung geben das SL vergrößert werden soll und TP verkleinert je nach was man für einen spread hat (sollte man in Einstellungen entscheiden können). Also 2 Pips kürzerer TP und 2 Pips weiterer SL, wenn spread z.b 2 Pips ist.

Breakeven und trailing wären auch super


Das ist was ich versucht have:

 
input double UpZone = 1.3000; // Define your UpZone value
input double DownZone = 1.2900; // Define your DownZone value
input int ATR_Period = 14;     // ATR period
input double MinATRLevel = 0.001; // Minimum ATR level to trigger a trade
input double TakeProfitPips = 20; // Take Profit in pips
input double SpreadPips = 2; // Desired spread in pips

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    // Add initialization code here
    if (!CheckSettings()) {
        Print("EA initialization failed. Check settings.");
        return(INIT_FAILED);
    }

    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    double closePrice = iClose(Symbol(), 0, 0);
    double openPrice = iOpen(Symbol(), 0, 0);
    double highPrice = iHigh(Symbol(), 0, 0);
    double lowPrice = iLow(Symbol(), 0, 0);
    double spread = MarketInfo(Symbol(), MODE_SPREAD);

    double atrValue = iATR(Symbol(), 0, ATR_Period, 0);
    
    double stopLoss, takeProfit; // Declare variables outside of if statements

    // Check if ATR is greater than the specified minimum level
    if (atrValue >= MinATRLevel)
    {
        // Check if candle closes below DownZone but also has its body in the Zone
        if (closePrice < DownZone && openPrice > DownZone)
        {
            stopLoss = DownZone + SpreadPips * Point;
            takeProfit = openPrice + TakeProfitPips * Point - SpreadPips * Point;

            // Execute sell logic
            if (ExecuteSell(stopLoss, takeProfit) < 0) {
                Print("Sell order execution failed. Check logs.");
            }
        }

        // Check if candle closes above UpZone but also has a wick or body in the Zone
        if (closePrice > UpZone && (highPrice > UpZone || lowPrice > UpZone))
        {
            stopLoss = UpZone - SpreadPips * Point;
            takeProfit = openPrice - TakeProfitPips * Point + SpreadPips * Point;

            // Execute buy logic
            if (ExecuteBuy(stopLoss, takeProfit) < 0) {
                Print("Buy order execution failed. Check logs.");
            }
        }
    }
}

//+------------------------------------------------------------------+
//| Check EA settings                                                |
//+------------------------------------------------------------------+
bool CheckSettings()
{
    // Add additional checks if needed
    return (TakeProfitPips > 0 && SpreadPips >= 0);
}

//+------------------------------------------------------------------+
//| Execute Sell Order                                               |
//+------------------------------------------------------------------+
int ExecuteSell(double stopLoss, double takeProfit)
{
    return (OrderSend(Symbol(), OP_SELL, 0.1, iClose(Symbol(), 0, 0), 3, stopLoss, takeProfit, "Sell order", 0, 0, Red));
}

//+------------------------------------------------------------------+
//| Execute Buy Order                                                |
//+------------------------------------------------------------------+
int ExecuteBuy(double stopLoss, double takeProfit)
{
    return (OrderSend(Symbol(), OP_BUY, 0.1, iClose(Symbol(), 0, 0), 3, stopLoss, takeProfit, "Buy order", 0, 0, Blue));
}
 
Kommt das von Chat gpt. Soll das mql4 oder 5 sein?
 
Das ist mql4 und ja chatgpt hat mit aufjedenfall geholfen, aber könnte nicht den ganzen Code fixen
 

Frage, würdest Du, nachdem Du mit einem schrecklichen Ergebnis versucht hast, zu Hause selbst das Haar zu schneiden zum Friseur gehen: "Können Sie mir meine Frisur umsonst schön schneiden, ich hab ja schon mal angefangen...?"

Entweder Du lernst programmieren oder zu zahlst einen Freelancer (die sind nicht sooo teuer!) oder Du suchst, denn es gibt fast nichts, was nicht schon für MT4/MT5 programmiert wurde.

Außerdem der MT4 hat ein 'weiches Ablaufdatum': https://www.mql5.com/en/forum/454319

MT4 End Of Life - End of active support for MT4 with no active support and updates; "What the future holds formt4 and the vast array of
MT4 End Of Life - End of active support for MT4 with no active support and updates; "What the future holds formt4 and the vast array of
  • 2023.09.19
  • narco
  • www.mql5.com
I have heard reports that mt4 is soon to become 'end of life' with no active support or updates. Can anyone explain what the future holds for mt4 and the vast array of millions of ex4 indicators, scripts and ea's. Com/ru/forum/447913/page6#comment_47273082
 
Schau, was gerade neu veröffentlicht wurde: https://www.mql5.com/en/code/48403
Breakout H1 Trading
Breakout H1 Trading
  • www.mql5.com
Short description.
Grund der Beschwerde: