EA for executing trades based on manually drawn trendlines

MQL5 Uzmanlar

İş tamamlandı

Tamamlanma süresi: 2 gün

Şartname

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

            }

        }

    }

}




Yanıtlandı

1
Geliştirici 1
Derecelendirme
(213)
Projeler
286
47%
Arabuluculuk
27
59% / 37%
Süresi dolmuş
36
13%
Serbest
2
Geliştirici 2
Derecelendirme
(435)
Projeler
642
53%
Arabuluculuk
35
63% / 20%
Süresi dolmuş
6
1%
Çalışıyor
3
Geliştirici 3
Derecelendirme
(195)
Projeler
242
34%
Arabuluculuk
11
45% / 45%
Süresi dolmuş
8
3%
Serbest
Yayınlandı: 1 makale, 8 kod
4
Geliştirici 4
Derecelendirme
(50)
Projeler
64
20%
Arabuluculuk
11
27% / 55%
Süresi dolmuş
5
8%
Serbest
5
Geliştirici 5
Derecelendirme
(9)
Projeler
11
18%
Arabuluculuk
4
0% / 100%
Süresi dolmuş
4
36%
Serbest
6
Geliştirici 6
Derecelendirme
(2)
Projeler
3
0%
Arabuluculuk
8
13% / 88%
Süresi dolmuş
1
33%
Serbest
7
Geliştirici 7
Derecelendirme
(3)
Projeler
4
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
8
Geliştirici 8
Derecelendirme
(33)
Projeler
35
20%
Arabuluculuk
5
40% / 40%
Süresi dolmuş
0
Serbest
Yayınlandı: 1 kod
9
Geliştirici 9
Derecelendirme
(3)
Projeler
3
0%
Arabuluculuk
6
17% / 67%
Süresi dolmuş
0
Serbest
10
Geliştirici 10
Derecelendirme
(64)
Projeler
144
46%
Arabuluculuk
20
40% / 20%
Süresi dolmuş
32
22%
Çalışıyor
11
Geliştirici 11
Derecelendirme
(162)
Projeler
289
35%
Arabuluculuk
18
22% / 61%
Süresi dolmuş
43
15%
Serbest
12
Geliştirici 12
Derecelendirme
(210)
Projeler
273
21%
Arabuluculuk
24
54% / 17%
Süresi dolmuş
0
Çalışıyor
Benzer siparişler
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 &
Hello, please make me a simple MT5 Expert Advisor for XAUUSD on M15 timeframe. TRADING LOGIC: - BUY when EMA(10) crosses UP EMA(30) - SELL when EMA(10) crosses DOWN EMA(30) TRADING HOURS: - Only trade between 19:00 - 22:00 WIB / Jakarta time RISK SETTINGS: - Lot size: 0.01 - Stop Loss: 70 points - Take Profit: 150 - 300 points - Max 1 open position Please deliver .ex5 file ready to use. Thank you

Proje bilgisi

Bütçe
50+ USD