EA with nested Indicators

MQL5 Indicadores Asesores Expertos

Trabajo finalizado

Plazo de ejecución 19 horas
Comentario del Cliente
I was really happy with the result I got from Nguyen Nga. He is highly recommended 10/10 points to him!
Comentario del Ejecutor
Nice customer, Thank you.

Tarea técnica

MetaTrader 5, Version: 5.00 build 1375, 15 Jul 2016

Hello, I have one Expert Advisor (EA) which loads 2 indicators. Indicator 1 is a moving average (IND_MA / top indicator) and Indicator 2 is a custom indicator (IND_CUSTOM / bottom indicator) which reads the information from the moving average indicator on every tick and output the values of IND_MA rounded to the third digit after the floating point, producing what you can see on the following image:

The EA needs the IND_CUSTOM for it's own functionality. So that's a requirement for it. It outputs the following on the Toolbox / Experts window:


My problem is that the EA works OK on the terminal but on the Strategy Tester (ST) the IND_CUSTOM doesn't get any value. as you can see on the following image:

I need the IND_CUSTOM gets the values on the ST, so I can do backtesting.

Below you have the code of the IND_CUSTOM and the EA. Please, try it on the terminal first to see how it works, then try it on the ST.

// File: ProblemIndicator.mq5

#property indicator_separate_window
#property indicator_buffers                             1
#property indicator_plots                               1
#property indicator_type1                               DRAW_LINE
#property indicator_color1                              clrBlue
#property indicator_style1                              STYLE_SOLID
#property indicator_width1                              1

input int handle_base;                                  // Handle of the base indicator
input int handle_base_buffer;                   // Buffer index of the base indicator

double buffer[];
double data_base[];

int OnInit() {

        be_aware_of_indicators_available();     // needed here at the beginning

        if (!is_valid_indicator_handle(handle_base)) {
                printf("The handle of the base indicator: %d, is invalid", handle_base);
                return -1;
        }

        ArraySetAsSeries(buffer, true);
        ArraySetAsSeries(data_base, true);

        IndicatorSetInteger(INDICATOR_DIGITS, _Digits + 1);

        PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 0);
        SetIndexBuffer(0, buffer, INDICATOR_DATA);

        return 0;
}

int OnCalculate(const int rates_total,          // number of bars in history at the current tick
                                const int prev_calculated,      // number of bars calculated at previous call
                                const int begin, const double &price[]
        ) {
        int count = rates_total - prev_calculated;
        CopyBuffer(handle_base, handle_base_buffer, 0, count, data_base);

        for (int i = count - 1; i >= 0; i--)
                buffer[i] = MathRoundDecimals(data_base[i], 3);

        return rates_total;
}

void get_chart_indicators_handle(int &handles[]) {
        ArrayResize(handles, 0);
        int total = (int) ChartGetInteger(0, CHART_WINDOWS_TOTAL);
        for (int w = 0; w < total; w++) {
                for (int i = 0; i < ChartIndicatorsTotal(0, w); i++) {
                        string name = ChartIndicatorName(0, w, i);
                        ArrayResize(handles, ArraySize(handles) + 1);
                        handles[ArraySize(handles) - 1] = ChartIndicatorGet(0, w, name);
                }
        }
}

void be_aware_of_indicators_available() {
        int handles[];
        get_chart_indicators_handle(handles);
}

bool is_valid_indicator_handle(int handle) {
        ENUM_INDICATOR type;
        MqlParam parameters[];
        int result = IndicatorParameters(handle, type, parameters);
        if (MQL_TESTER && GetLastError() == ERR_FUNCTION_NOT_ALLOWED) // on ST "IndicatorParameters" is not allowed
                return true;
        else
                return (result != -1);
}

double MathRoundDecimals(double num, int decimals) {
        return MathRound(num * MathPow(10, decimals)) / MathPow(10, decimals);
}
// File: ProblemEA.mq5

int handle_1, handle_2;

int OnInit() {

        ChartSetInteger(0, CHART_SCALE, 3);
        ChartSetInteger(0, CHART_MODE, CHART_CANDLES);

        int i = 0;

        MqlParam params_1[4];
        params_1[0].type = TYPE_INT;
        params_1[0].integer_value = 20;
        params_1[1].type = TYPE_INT;
        params_1[1].integer_value = 0;
        params_1[2].type = TYPE_INT;
        params_1[2].integer_value = MODE_SMA;
        params_1[3].type = TYPE_INT;
        params_1[3].integer_value = PRICE_CLOSE;
        handle_1 = IndicatorCreate(_Symbol, PERIOD_CURRENT, IND_MA, ArraySize(params_1), params_1);
        ChartIndicatorAdd(0, i, handle_1);

        MqlParam params_2[3];
        params_2[0].type = TYPE_STRING;
        params_2[0].string_value = "ProblemIndicator";
        params_2[1].type = TYPE_INT;
        params_2[1].integer_value = handle_1;
        params_2[2].type = TYPE_INT;
        params_2[2].integer_value = 0; // buffer index to use
        handle_2 = IndicatorCreate(_Symbol, PERIOD_CURRENT, IND_CUSTOM, ArraySize(params_2), params_2);
        ChartIndicatorAdd(0, ++i, handle_2);

        return (INIT_SUCCEEDED);
}

void OnTick() {
        double last_1 = get_last_indicator_value(handle_1);
        double last_2 = get_last_indicator_value(handle_2);
        printf("values: %f %f", last_1, last_2);
}

double get_last_indicator_value(int handle) { // just first buffer
        double values[1];
        int result = CopyBuffer(handle, 0, TimeCurrent(), 1, values);
        return values[0];
}

Any question, please let me know.

Regards, Cyberglassed.


Han respondido

1
Desarrollador 1
Evaluación
(253)
Proyectos
358
49%
Arbitraje
24
25% / 50%
Caducado
80
22%
Libre
2
Desarrollador 2
Evaluación
(28)
Proyectos
36
17%
Arbitraje
5
20% / 40%
Caducado
17
47%
Libre
3
Desarrollador 3
Evaluación
(1)
Proyectos
1
0%
Arbitraje
1
0% / 100%
Caducado
0
Libre
Solicitudes similares
I'm looking for a developer who has already working on a HFT tailored to pass prop firm challenges within a short period, maintaining a very low drawdown. Here is a link to a video demonstrating an existing EA executing the same strategy: https://youtu.be/N6NEcIpPzV4 Any developer having already worked on this type of project and able to provide quickly a test version is welcome to contact me
have trade signals i get by telegram messaging, i would like to have a robot designed to read those message for trade inputs and open and close trades base on the signals Ea must be able to scan my telegram Message app Read signals sent Open trades on the mt4 and manage them to close Read signals every one minute (user changeable input) I also need the programmer to teach me how to install and make the robot work
I want a skillful and experience deverloper to apply for this job. The strategy for the EA is Two Exponential Moving Average CROSSOVER strategy. The EA should work on any Timeframe. I want the EA to trade the direction of the CROSSOVER, the EA should open a BUY or SELL trades automatic when the Two Exponential Moving Average crossover. *(10EMA) ABOVE (23EMA) = BUY Trades *(10EMA) BELOW (23EMA) = SELL Trades BUY
MACD EA 50+ USD
Hello Freelancers, I am seeking an experienced developer to create an Expert Advisor (EA) for MetaTrader 5 (MT5). The EA will be based on the MACD indicator and should adhere to the following specifications: EA Requirements: Trading Logic: 1. Long Trades: • Entry: Open a long trade when the MACD line crosses above the signal line below the zero level. • Exit: Close the long trade when the signal line crosses above
EA Configuration. FIBO ------------------------------------------------------------------- Magic: 123456 Stop: Real or Virtual Order: Pending / CLOSE / price== LOT Description: 0.01 ------------------------------------------------------------------- STOP: -0.25 ------------------------------------------------------------------- ENT_1: 1.00 Lot_1: 0.01 ENT_2: 0.50 Lot_2: 0.01 ENT_3: 1.00 Lot_3: 0.01
Hi I'm looking for a professional programmer to modify my EA the EA send signal alert to telegram and screen shot of the chart patterns my EA is dased to the harmonic pattern but I want to see on the screen shot the pattern of the harmonic pattern and on the chat as well
Hello I need create simple trend first candle session EA. Ea wait for first M5/M15/M30/H1 (all possible timeframes to choose) candle at asian, european and NYC session and open buy/sell stop order above (in long situation) or below (in short situation) x points from highest/lowest point of the first candle. + trailing stop loss stop loss take profit breakeven magic key
Hello Guys ! Looking for a developer to create a EA for my Buy and Sell No repaint indicator. I only have the EX4 indicator file and I want the EA to take trades according to the Buy and sells signals generated by the Indicator. Here are some inputs I want for the EA: - Trailing stop - TP and SL ( in pips ) - Entries, TP and SL ( based on opposite signals arrow ) - Daily target ( in Dollars $ or % ) - Trading hours -
I need a robot that copies the orders sent in the telegram group to MT4 or MT5 so that I can configure the parameters. I would like it to have functions so I can enter and exit negotiations according to my configuration parameters
i need to delegate this job. XAUUSD H4 MT4 i have an ea with source code with smc, fvg, orderblocks and fibonacci, i need to fix somethings and add some features for live markets, any new ideas are accepted, i need also a 4 years backtest report (of metatrader 4). if you have good price and feedbacks and you want work for me also for new jobs apply for this job it's not urgent i need only a good price

Información sobre el proyecto

Presupuesto
15 - 100 USD
Para el ejecutor
13.5 - 90 USD
Plazo límite de ejecución
de 1 a 5 día(s)