EA for executing trades based on manually drawn trendlines

MQL5 EA

작업 종료됨

실행 시간 2 일

명시

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

            }

        }

    }

}




응답함

1
개발자 1
등급
(213)
프로젝트
286
47%
중재
27
59% / 37%
기한 초과
36
13%
무료
2
개발자 2
등급
(435)
프로젝트
642
53%
중재
35
63% / 20%
기한 초과
6
1%
작업중
3
개발자 3
등급
(195)
프로젝트
242
34%
중재
11
45% / 45%
기한 초과
8
3%
무료
게재됨: 1 기고글, 8 코드
4
개발자 4
등급
(50)
프로젝트
64
20%
중재
11
27% / 55%
기한 초과
5
8%
무료
5
개발자 5
등급
(9)
프로젝트
11
18%
중재
4
0% / 100%
기한 초과
4
36%
무료
6
개발자 6
등급
(2)
프로젝트
3
0%
중재
8
13% / 88%
기한 초과
1
33%
무료
7
개발자 7
등급
(3)
프로젝트
4
0%
중재
0
기한 초과
0
무료
8
개발자 8
등급
(33)
프로젝트
35
20%
중재
5
40% / 40%
기한 초과
0
무료
게재됨: 1 코드
9
개발자 9
등급
(3)
프로젝트
3
0%
중재
6
17% / 67%
기한 초과
0
무료
10
개발자 10
등급
(64)
프로젝트
144
46%
중재
20
40% / 20%
기한 초과
32
22%
작업중
11
개발자 11
등급
(162)
프로젝트
289
35%
중재
18
22% / 61%
기한 초과
43
15%
무료
12
개발자 12
등급
(210)
프로젝트
273
21%
중재
24
54% / 17%
기한 초과
0
작업중
비슷한 주문
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

프로젝트 정보

예산
50+ USD