EA for executing trades based on manually drawn trendlines

MQL5 专家

工作已完成

执行时间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%
仲裁
21
38% / 19%
逾期
32
22%
工作中
11
开发者 11
等级
(162)
项目
289
35%
仲裁
18
22% / 61%
逾期
43
15%
空闲
12
开发者 12
等级
(210)
项目
273
21%
仲裁
24
54% / 17%
逾期
0
工作中
相似订单
I need an Expert Advisor (EA) developed for MetaTrader 5 (MT5) tailored for trading on Exness accounts. Account & Server Details: Trading Platform: MetaTrader 5 (MT5) Broker: Exness Execution Type: Market / Pending Orders Account Type: [Specify: Standard / Pro / Raw Spread / Zero] Target Instruments: [Specify pairs, e.g., XAUUSD, EURUSD, BTCUSD] Strategy Requirements: Entry Rules: [Insert your buy/sell entry
Monthly Report: August 2026 World PEACE Multi FX Algo generated a total realized profit of approximately 31,966 JPY during August. The provider account is normally operated with approximately 200,000 JPY of capital. Compared with this standard operating amount, the realized profit for August was approximately 15.98%. Please note that this is not a compounded monthly return. Realized profits are withdrawn regularly
I am looking for an experienced MQL5/MT5 Expert Advisor developer to build a custom XAUUSD (Gold) HFT/ultra-fast scalping EA for MetaTrader 5. I have attached a reference video showing exactly how I want the EA to behave. Please watch the video carefully before applying. The video should give you a clear understanding of the desired entry behavior, trade frequency, execution style, and overall system behavior. The EA
I’m looking for an experienced developer who can build a Martingale trading bot. I’m willing to pay a fair price for the right developer. I have an example trading account that demonstrates exactly how I want the bot to operate. The strategy is straightforward: the bot trades continuously using a Martingale system. The only exception is that it should automatically pause trading during high-impact news events or
This is a Tradingview project. Would you be able to make this? With a win rate and profit factor and percentage made and profit made and max dd reached. How many modifications would I be able to do? Could there be a table that shows win percentage profit factor and trading window where trades shouldn’t be placed and follows the rules of the pdf How long would it take and would it work on ninjatrader also
I need a professional MQL5 developer to build a high-frequency trading (HFT) Expert Advisor for MT5. Key Requirements & Risk Management Rules: 1. Max Trade Limit: The bot must execute a strict maximum of 1,000 trades. 2. Lot Size Cap: Every trade must be capped at a maximum of 0.50 lots. 3. Execution Speed: Optimized for low-latency, rapid execution. 4. Clean code with proper error handling and clear parameter
I need fully automatic scalping robots for XAUUSD Gold the robot should work on M1 and M5 timeframe and open trades based on the scalping logic using EMA and RSI confirmation it should analyze the market on its own and only take high probability trades
I am looking for an experienced MQL5 / MetaTrader 5 developer to help me add alert notifications to an existing MT5 indicator. What I Have I have an indicator that I am currently using on MetaTrader 5 , but I do not have the source code (.mq5) . I only have the compiled indicator file, or I can provide the indicator file that I currently have. What I Need I want to add alerts when the indicator generates its specific
I need best scalping bot 150 - 300 USD
I have attached the video of the EA I want to reproduce in MQL5. Please study the video carefully and build an EA that follows the same trading behavior shown in it. The EA is for XAUUSD (Gold) and appears to use an automated scalping/grid-style strategy with multiple positions opened around the market price. I want the entry sequence, spacing between positions, lot progression, direction of trades, and
New EA for Moj1367 50 - 100 USD
//@version=6 strategy("Ultimate + 11 Filters Bot [M1 - 0.5 pip TP]", overlay=true, max_boxes_count=500, max_labels_count=500, max_lines_count=500, max_bars_back=5000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=1000, commission_type=strategy.commission.percent, commission_value=0.04) // ═══════════════════════════════════════════════════════════ // 1. تنظیمات ورودی (Inputs)

项目信息

预算
50+ USD