Analysis of test results and optimisation in the MetaTrader 5 strategy tester - page 8

 
can any on help me to build up strategy ?

as i did evry thing but still am not able to fix the error ,
Error : 'advanctradingapproch.mq5'
advanctradingapproch.mq5                                                (line)    1 (Column) 1
no indicator plot defined for indicator                                    0                  0
';' - open parenthesis expected advanctradingapproch.mq5         119              61
';' - open parenthesis expected advanctradingapproch.mq5         125              63

here is the code :

//+------------------------------------------------------------------+
//|                                        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 #can any on help me to build up strategy ? as i did evry thing but still am not able to fix the error ,
Error : 'advanctradingapproch.mq5'
advanctradingapproch.mq5                                                (line)    1 (Column) 1
no indicator plot defined for indicator                                    0                  0
';' - open parenthesis expected advanctradingapproch.mq5         119              61
';' - open parenthesis expected advanctradingapproch.mq5         125              63

here is the code :

Please, don't request help for ChatGPT (or other A.I.) generated code. It generates horrible code, mixing MQL4 and MQL5. Please use the Freelance section for such requests.

  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Documentation.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
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
 

Hey guys,

I'm looking to understand what are the ideal components of a computer that will help large Strategy Optimizations (100,000+ combinations across multiple years of M1 data) to complete quicker. I am asking so that I can then take your recommendations, and create an AWS EC2 Instance (custom virtual computer) with the desired specs (x amount of vCPUs, x amount of memory, etc) to help streamline getting optimization results back quicker.

I will share the results of my EC2 costs & time to completion afterwards if it will help the community.

Thank you in advance for your thoughtful responses.

 

PLEASE HELP ME SOLVE THIS PROBLEM IN MY MT5 EA 



i am trying to create an EA that utilizes 2 Bollinger Bands (one with 1 std and and another with 1.5 std)

and i enter a position with a close below the bb(1 std) and markets price with a sl at the larger bb and a tp at the middle line , i wanna automatically modify the oder such that it moves the sl and tp to the latest value of the bolllinger band and the middle line i.e. the current candle has an index of 0 and the previous candle has an index of 1, so the bb values at index 1 . i want this to happen until either sl/tp is hit. can someone please guide me into the right direction??? i am an amateur and just getting started with this EA stuff. i am aware i can get the position ticket and use that to modify sl/tp but i have a hard time extracting the 2 values from the bb , the initial tp/sl and the modified sl/tp with every candle. i can get the values from ibands function and use the copy buffer function to extract the values , but i am only successful doing so for the initial sl/tp how do i extract the values for the rolling sl/tp , please help me out , thank you for the help,appreciate it.

 
Colleagues, please advise me how in the MT5 strategy tester during fast (genetic) optimisation not to take into account those passes that ended with forced closing of open positions. That is, when the pass came to the end and positions have not yet had time to come to profit. Thank you in advance!
 
exes86 strategy tester during fast (genetic) optimisation not to take into account those passes that ended with forced closing of open positions. That is, when the pass came to the end and positions have not yet had time to come to profit. Thank you in advance!

Add an input to the Expert Advisor, where the time is specified one hour before the end of the testing interval.

In the Expert Advisor, as soon as the time has passed this input and there are open positions, either raise the flag for zeroing OnTester, or zero the balance at the expense of the spread.

 
fxsaber #:

Add an input to the Expert Advisor that specifies the time one hour before the end of the testing interval.

In the Expert Advisor, as soon as the time has passed this input and there are open positions, either raise the flag to zero OnTester,

Thank you! I will try it.
 
I Don't know why It stops trading after trading already from someone time. But if I run the strategy tester from the time that it initially stopped opening positions. It starts to open positions.

I attached the screenshots. 
The deposit load for the first test . Automatically goes to zero and then jumps back up and returns back to zero. 
While for the second time when I only tested for one of the month where it initially should that it did not open , positions . It's working properly.