在MetaTrader 5策略测试器中分析测试结果并进行优化 - 页 8

有谁能帮我建立策略吗?

,因为我做了每件事,但仍然无法修复错误 ,
Error : 'advanctradingapproch.mq5'
advanctradingapproch.mq5 (行)1 (列)1
没有为指标定义指标图 0 0
';' - 预期的开放括号 advanctradingapproch.mq5 119 61
';' - open parenthesis expected advanctradingapproch.mq5 125 63

这里是代码:

//+------------------------------------------------------------------+
//|                                        advancetradingapproch.mq5 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window

input int BuyArrow = 233;
input int SellArrow = 234;

#define  CHART_ARROW_FIRST  0
#define  CHART_ARROW_LAST   1
#define  MODE_MAIN 0
#define  MODE_SIGNAL 1

int BuySignalBar = 0;
int SellSignalBar = 0;
double lastDayClose;
double adxValue, rsiValue, macdMain, macdSignal, stochasticMain, stochasticSignal;
datetime Time[];

double emaBuffer[];
double adxBuffer[];
double rsiBuffer[];
double macdBuffer[];
double stochasticBuffer[];

int OnInit()
{
    emaBuffer[0] = iMA(_Symbol, PERIOD_D1, 8, 0, MODE_EMA, PRICE_CLOSE);
    emaBuffer[1] = iMA(_Symbol, PERIOD_D1, 16, 0, MODE_EMA, PRICE_CLOSE);

    adxBuffer[0] = iADX(_Symbol, PERIOD_D1, 14);
    rsiBuffer[0] = iRSI(_Symbol, PERIOD_D1, 14, PRICE_CLOSE);
    macdBuffer[0] = iMACD(_Symbol, PERIOD_D1, 12, 26, 9, PRICE_CLOSE);
    macdBuffer[1] = iMACD(_Symbol, PERIOD_D1, 12, 26, 9, PRICE_CLOSE);
    stochasticBuffer[0] = iStochastic(_Symbol, PERIOD_D1, 5, 3, 3, MODE_SMA, STO_LOWHIGH);
    stochasticBuffer[1] = iStochastic(_Symbol, PERIOD_D1, 5, 3, 3, MODE_SMA, STO_LOWHIGH);
    
    
    ChartSetInteger(0, CHART_ARROW_FIRST, BuyArrow);
    ChartSetInteger(0, CHART_ARROW_LAST, SellArrow);
    
    ArraySetAsSeries(emaBuffer, true);
    ArraySetAsSeries(adxBuffer, true);
    ArraySetAsSeries(rsiBuffer, true);
    ArraySetAsSeries(macdBuffer, true);
    ArraySetAsSeries(stochasticBuffer, true);

    IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
    SetIndexBuffer(0, emaBuffer);
    SetIndexBuffer(1, adxBuffer);
    SetIndexBuffer(2, rsiBuffer);
    SetIndexBuffer(3, macdBuffer);
    SetIndexBuffer(4, stochasticBuffer);

     return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
    double emaDiff = emaBuffer[0] - emaBuffer[1];
    bool isUptrend = emaDiff > 0;
    bool isDowntrend = emaDiff < 0;

    bool emaCrossoverBuy = (emaBuffer[0] > emaBuffer[1]) && (low[0] < emaBuffer[0]);
    bool emaCrossoverSell = (emaBuffer[0] < emaBuffer[1]) && (high[0] > emaBuffer[0]);

    double currentPrice = close[0];

    bool isHighAdx = adxBuffer[0] > 25;
    bool isOversoldRsi = rsiBuffer[0] < 30;
    bool isBullishMacd = macdBuffer[0] > macdBuffer[1];
    bool isBullishStochastic = (stochasticBuffer[0] > stochasticBuffer[1]) && (stochasticBuffer[0] < 80);

    
    if (isUptrend && emaCrossoverBuy) {
        // Generate Buy signal
    } else if (isDowntrend && emaCrossoverSell) {
        // Generate Sell signal
    }

    return(rates_total);
}

void OnTimer()
{
    // Implement timer-related functionality if needed
}

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
    datetime chartTime[];
    double high[], low[];
    datetime time[];

    if(id == CHARTEVENT_OBJECT_CREATE) {
        if(ObjectFind(0, "BuySignalArrow") != -1)
            ObjectDelete(0, "BuySignalArrow");
        if(ObjectFind(0, "SellSignalArrow") != -1)
            ObjectDelete(0, "SellSignalArrow");

        if(BuySignalBar != -1 && BuySignalBar < ArraySize(high) && BuySignalBar < ArraySize(low)) {
           double buyPrice = high[BuySignalBar] + 10 * Point;
            ObjectCreate(0, "BuySignalArrow", OBJ_ARROW, 0, Time[BuySignalBar], buyPrice);
            ObjectSetInteger(0, "BuySignalArrow", OBJPROP_ARROWCODE, BuyArrow);
        }

        if(SellSignalBar != -1 && SellSignalBar < ArraySize(high) && SellSignalBar < ArraySize(low)) {
            double sellPrice = low[SellSignalBar] - 10 * Point;
            ObjectCreate(0, "SellSignalArrow", OBJ_ARROW, 0, Time[SellSignalBar], sellPrice);
            ObjectSetInteger(0, "SellSignalArrow", OBJPROP_ARROWCODE, SellArrow);
        }
    }
}


[删除]
@Ezio Evan #:  有谁能帮我建立策略吗?我做了所有的事情,但仍然无法修复错误 ,
Error : 'advanctradingapproch.mq5'
advanctradingapproch.mq5 (行)1 (列)1
没有为指标定义指标图 0 0
';' - 预期的开放括号 advanctradingapproch.mq5 119 61
';' - open parenthesis expected advanctradingapproch.mq5 125 63

这里是代码:

请不要为ChatGPT(或其他人工智能) 生成的代码寻求帮助。它生成的代码非常糟糕,混合了 MQL4 和 MQL5。请使用自由职业者 版块来处理此类请求。

  • 通常不会编写代码的人不会在本论坛获得免费帮助。
  • 如果您展示您的尝试并清楚地描述您的问题,您很可能会收到来自社区的答复。插入代码时请使用CODE 按钮 (Alt-S)。
  • 要学习 MQL 编程,您可以研究有关该主题的许多可用文章 或代码库中的 示例,以及参考在线文档。
  • 如果您不想学习编程,也没有问题。如果已经存在免费产品,您可以查看代码库,或者在市场中 查看付费产品(有时也是免费的)。不过, 论坛上不允许 推荐或建议市场 产品,因此您必须自己进行研究。
  • 最后,您还可以选择在自由职业者版块 聘请程序员。
Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2023.11.30
  • www.mql5.com
The largest freelance service with MQL5 application developers

大家好、

我想了解计算机的理想组件是什么,以帮助更快地完成大型策略优化(跨越多年 M1 数据的 100,000+ 组合)。我这样问是为了采纳你们的建议,创建一个具有所需规格(x 个 vCPU、x 个内存等)的 AWS EC2 实例(自定义虚拟计算机),以帮助简化流程,更快地获得优化结果。

如果对社区有帮助,我将在之后分享 EC2 成本和完成时间的结果。

提前感谢您的周到答复。

请帮我解决我的 MT5 EA 中的这个问题



我试图创建一个使用 2个布林线(一个为 1 std,另一个为 1.5 std)的 EA。

我想自动修改 Oder,使其将 sl 和 tp 移至布林带和中线的最新值,即当前蜡烛图的指数为 0,上一个蜡烛图的指数为 1,因此布林带的值为指数 1。我知道我可以获得仓位票据,并用它来修改 sl/tp,但我很难从 bb 中提取 2 个值,即每根蜡烛的初始 tp/sl 和修改后的 sl/tp。我可以从 ibands 函数中获得值,并使用复制缓冲区函数来提取值,但我只成功提取了初始 sl/tp,我该如何提取滚动 sl/tp 的值呢?

看着不错。
I've tested quite a few MT5 EAs over time, and one thing I've noticed is that a profitable backtest doesn't always mean the EA will perform well in a live environment.

At first, I mainly focused on the profit curve and win rate. Later, I started paying more attention to drawdown, execution speed, spread changes and how the EA behaves during volatile market conditions.

One issue I encountered was that some EAs worked well under certain market conditions but struggled when volatility increased. Others had trouble handling different symbol settings or broker execution environments.

This made me realize that EA development is not just about writing an entry and exit strategy. Proper testing, parameter optimization and compatibility are equally important.

I'm now more interested in understanding how developers build and maintain reliable MT5 tools, especially custom indicators and automated trading systems.

For those who develop or use EAs regularly, what do you think is the most overlooked part of EA testing?