EA for executing trades based on manually drawn trendlines

MQL5 Asesores Expertos

Trabajo finalizado

Plazo de ejecución 2 días

Tarea técnica

I want to create an EA for M15 time frame as follows
1. Use iCustom Zigzag
2. Draw all trendlines
- connect the zigzag peaks
- connect the zigzag bottoms
Condition is that the trendline does not cross the price line
3. Add RSI
4. The EA will be executed as follows

If the price touches the trendline, RSI >70 then Sell, otherwise RSI <30 then Buy. 

--

Sample code


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

//| Expert Advisor using ZigZag and drawing Trendlines              |

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

#property strict

#include <Trade\Trade.mqh>


input int ZigZagDepth=12;

input int ZigZagDeviation=5;

input int ZigZagBackstep=3;

input double LotSize=0.1;

input double StopLoss=50;

input double TakeProfit=100;


CTrade trade;


// ZigZag indicator

int zigzagHandle;

double zigzagBuffer[];

MqlRates PriceData[];


// Initialization function

int OnInit()

{

    // Load ZigZag indicator

    zigzagHandle = iCustom(Symbol(), PERIOD_CURRENT, "Examples\ZigZag", ZigZagDepth, ZigZagDeviation, ZigZagBackstep);

    if(zigzagHandle == INVALID_HANDLE)

    {

        Print("Error loading ZigZag indicator");

        return INIT_FAILED;

    }

    

    return INIT_SUCCEEDED;

}


// Function to check if the trendline crosses the price

bool IsTrendlineCrossPrice(datetime time1, double price1, datetime time2, double price2)

{

    if(CopyRates(Symbol(), PERIOD_CURRENT, 0, 100, PriceData) <= 0)

        return false;

    

    int startIndex = iBarShift(Symbol(), PERIOD_CURRENT, time1, false);

    int endIndex = iBarShift(Symbol(), PERIOD_CURRENT, time2, false);

    

    for(int i = startIndex; i >= endIndex; i--)

    {

        double high = PriceData[i].high;

        double low = PriceData[i].low;

        

        double trendPrice = price1 + (price2 - price1) * ((PriceData[i].time - time1) / (double)(time2 - time1));

        

        if(high >= trendPrice && low <= trendPrice)

        {

            return true; // Trendline crosses the price

        }

    }

    return false;

}


// Main function

void OnTick()

{

    if(CopyBuffer(zigzagHandle, 0, 0, 100, zigzagBuffer) <= 0)

    {

        Print("Failed to copy data from ZigZag");

        return;

    }

    if(CopyRates(Symbol(), PERIOD_CURRENT, 0, 100, PriceData) <= 0)

    {

        Print("Failed to retrieve price data");

        return;

    }

    

    int lastHighIndex = -1;

    int lastLowIndex = -1;

    double lastHigh = 0;

    double lastLow = 0;

    

    for(int i = 99; i >= 0; i--)

    {

        if(zigzagBuffer[i] > 0)

        {

            if(lastHighIndex == -1 && zigzagBuffer[i] > lastLow)

            {

                lastHigh = zigzagBuffer[i];

                lastHighIndex = i;

            }

            else if(lastLowIndex == -1 && zigzagBuffer[i] < lastHigh)

            {

                lastLow = zigzagBuffer[i];

                lastLowIndex = i;

            }

        }

    }

    

    if(lastHighIndex != -1 && lastLowIndex != -1)

    {

        datetime time1 = PriceData[lastHighIndex].time;

        datetime time2 = PriceData[lastLowIndex].time;

        

        if(!IsTrendlineCrossPrice(time1, lastHigh, time2, lastLow))

        {

            // Delete old trendlines

            ObjectDelete(0, "Trendline");

            

            // Draw trendline

            ObjectCreate(0, "Trendline", OBJ_TREND, 0, time1, lastHigh, time2, lastLow);

            ObjectSetInteger(0, "Trendline", OBJPROP_RAY_RIGHT, true);

            ObjectSetInteger(0, "Trendline", OBJPROP_COLOR, clrRed);

            

            // Get Bid/Ask prices

            double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK);

            double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);

            

            // Check trading conditions

            if(Ask > lastHigh) // Buy when price breaks ZigZag high

            {

                trade.PositionOpen(Symbol(), ORDER_TYPE_BUY, LotSize, Ask, StopLoss * _Point, TakeProfit * _Point, "Buy Order");

                Print("Buy at price: ", Ask);

            }

            else if(Bid < lastLow) // Sell when price breaks ZigZag low

            {

                trade.PositionOpen(Symbol(), ORDER_TYPE_SELL, LotSize, Bid, StopLoss * _Point, TakeProfit * _Point, "Sell Order");

                Print("Sell at price: ", Bid);

            }

        }

    }

}




Han respondido

1
Desarrollador 1
Evaluación
(213)
Proyectos
286
47%
Arbitraje
27
59% / 37%
Caducado
36
13%
Libre
2
Desarrollador 2
Evaluación
(435)
Proyectos
642
53%
Arbitraje
35
63% / 20%
Caducado
6
1%
Trabaja
3
Desarrollador 3
Evaluación
(195)
Proyectos
242
34%
Arbitraje
11
45% / 45%
Caducado
8
3%
Libre
Ha publicado: 1 artículo, 8 ejemplos
4
Desarrollador 4
Evaluación
(50)
Proyectos
64
20%
Arbitraje
11
27% / 55%
Caducado
5
8%
Libre
5
Desarrollador 5
Evaluación
(9)
Proyectos
11
18%
Arbitraje
4
0% / 100%
Caducado
4
36%
Libre
6
Desarrollador 6
Evaluación
(2)
Proyectos
3
0%
Arbitraje
8
13% / 88%
Caducado
1
33%
Libre
7
Desarrollador 7
Evaluación
(3)
Proyectos
4
0%
Arbitraje
0
Caducado
0
Libre
8
Desarrollador 8
Evaluación
(33)
Proyectos
35
20%
Arbitraje
5
40% / 40%
Caducado
0
Libre
Ha publicado: 1 ejemplo
9
Desarrollador 9
Evaluación
(3)
Proyectos
3
0%
Arbitraje
6
17% / 67%
Caducado
0
Libre
10
Desarrollador 10
Evaluación
(64)
Proyectos
144
46%
Arbitraje
20
40% / 20%
Caducado
32
22%
Trabaja
11
Desarrollador 11
Evaluación
(162)
Proyectos
289
35%
Arbitraje
18
22% / 61%
Caducado
43
15%
Libre
12
Desarrollador 12
Evaluación
(210)
Proyectos
273
21%
Arbitraje
24
54% / 17%
Caducado
0
Trabaja
Solicitudes similares
I’m looking for an experienced MQL5 / MT5 developer to build an EA that acts as a connector between a user’s MT5 trading account and our own web-based performance tracking platform. The concept is similar to platforms like Myfxbook or ShowMyTrades , where users can connect their trading account and automatically track their trading performance, including trade history, profit/loss, win rate, drawdown, account
Account size 50$ to 100$ or 5000USC to 10000USC ( Account $ Size may not matter ) Max Leverage 1000-2000 Min Lot 0.01 [ if averaging possible ] Averaging + Shift TP Faster Required if Trend Direction is Clear Account Protection Maxx Profit Max Loss Key Based Activation News Filter Need Expert to handle this to avoid false entry [ Developer can suggest extra additional filters inputs here ] as i mentioned I have no
Build a Forex Multi-Basket Trading Bot for OANDA (Python v20 REST API Only) MANDATORY DEVELOPER REQUIREMENTS (PLEASE READ BEFORE APPLYING): Do not apply for this project unless you meet the following strict professional criteria: 1. Deep Mathematical & Quantitative Background: You must thoroughly understand statistical distributions, rolling standard deviations (σ), calculating matrix medians, and dynamic Z-score
I need a complete MetaTrader 5 Expert Advisor built for XAUUSD. The EA will trade a multi-timeframe trend-pullback strategy using the Daily, H4, and M15 timeframes. It must generate signals, manage trades, send alerts, and come with a full backtest on gold. This is a technical build. I am not asking for guaranteed profits or financial advice. Platform and Market Platform: MetaTrader 5 Language: MQL5 Symbol: XAUUSD
I need an AI based mt5 EA which self learns and improves on its previous mistakes. The EA must be able to utilize numerous trade set ups like; 1. CRT, 2. liquidity sweep reversal at selected higher timeframe where a candle sweeps previous candle high and closes lower or sweeps previous candle low and closes higher, 3. SMC where it trades on OB, CHoCH, BOS. 4. Support and resistance. It should trade any currency pair
i need some tradingview strategy that i want to use as a tester, i have something that i am working on currently and i need someone that can provide me with tradingview strategies that doesn't have a win rate, the one with 1:1 RR it need to have low win rate like 10% or 5% profitability, i am not paying $30 for,i dont have up to that for this cause i only want to use it as a test, if anyone have any to send me please
hello i need help building a ea bot for mt5 and i have started on claude but i will need someone if a incredible experience to make my ideas come to live. please contact so we can schedule a quick call and i can share anything that concerns you for the task
I am looking for someone with real experience developing strategies, indicators, or trading tools for Quantower . The strategy itself is relatively simple. The main issue is that I need to use some of Quantower's functions and API capabilities to program the strategy, but there is limited documentation available for some of the functionality, and I do not have enough time to fully understand the API and implement
I am looking for an experienced MQL5 developer who can BOTH research trading strategies and develop a commercial-quality MetaTrader 5 Expert Advisor. This is NOT simply a coding job. The developer is free to choose the trading logic, indicators, entry method, exit method, timeframe architecture and strategy type. I do not require the EA to copy or resemble any existing commercial EA. My priority is: ROBUST LONG-TERM
A developer will create an AI assisted EA forex watch-list scanner (not an auto-trader) designed to surface PDL/PDH bounces on M15, with coding in Python/MQL5. This will strictly be a market intelligence and scanning tool (no automatic order placement) and EA primary function will be a delivery of visual dashboard UI, 2-phased alerts (warning vs. execution), and multi-channel notification. 1. Project Overview &

Información sobre el proyecto

Presupuesto
50+ USD