EA Expert basado en EMA lenta barras y EMA rapida

MQL5 전문가

작업 종료됨

실행 시간 2 일
피고용인의 피드백
Gracias por la oportunidad.
고객의 피드백
This encoder performs extremely well in the mql language. He interpreted the strategy extremely well and patiently knew how to add conditions to the code to achieve the objective.

명시

Necesito que se desarrole un EA Expert para MT5 basado en EMA de 200 periodos el cual será el detector de la tendencia principal.

Para indice de futuros S&P500 y otros en marco temporal D1 y H1:

El EA debe detectar que la tendencia es alcista, de lo contrario no hacer nada.

Condiciones: se deben cumplir 3 barras bajistas completadas en contra de la tendencia principal, despues de la tercera vela el EA debe abrir una operacion de compra en favor de la tendencia principal.

El EA cerrará la orden solo cuando el precio esté por encima de la EMA de 5 periodos.

En imputs debe haber gestión de capital lote fijo o dinámico así como ajuste de Stop Loss

Es una estrategia FIFO.

Aquí un borrador en código de la estrategia:

//+------------------------------------------------------------------+

//|                                            EMAS&bars.mq5   |

//|                          Copyright 2024, xxxx xxxxxx xxxxx. |

//|                                   https://www.opentrading.top |

//+------------------------------------------------------------------+

input int emaSlowPeriods = 200;

input int emaFastPeriods = 5;

input double lotSize = 0.1;

input int stopLoss = 135; // en puntos


// Variables globales

bool trendIsUp = false;

int consecutiveBearishCandles = 0;

int ticket = 0;


//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

   return (INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

   //--- 

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

   // Verificar tendencia

   double emaSlow = iMA(NULL, 0, emaSlowPeriods, 0, MODE_EMA, PRICE_CLOSE, 0);

   double emaFast = iMA(NULL, 0, emaFastPeriods, 0, MODE_EMA, PRICE_CLOSE, 0);


   if (emaSlow > emaSlow[1])

       trendIsUp = true;

   else

       trendIsUp = false;


   // Detectar velas bajistas consecutivas

   if (Close[0] < Open[0])

       consecutiveBearishCandles++;

   else

       consecutiveBearishCandles = 0;


   // Condición de entrada

   if (trendIsUp && consecutiveBearishCandles >= 3 && ticket == 0)

   {

       // Realizar acciones de entrada

       double stopLossPrice = NormalizeDouble(Bid - stopLoss * Point, Digits);

       ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, stopLossPrice, 0, "Compra basada en estrategia", 0, 0, Green);

       if (ticket > 0)

       {

           Print("Orden de compra abierta: Ticket #", ticket);

       }

       else

       {

           Print("Error al abrir la orden de compra: ", GetLastError());

       }

   }


   // Condición de salida

   if (ticket > 0)

   {

       if (OrderSelect(ticket, SELECT_BY_TICKET) == true)

       {

           if (OrderType() == OP_BUY && Close[0] > emaFast)

           {

               if (OrderClose(ticket, OrderLots(), Bid, 3, Red))

               {

                   Print("Orden de compra cerrada: Ticket #", ticket);

                   ticket = 0; // Restablecer la variable ticket

               }

               else

               {

                   Print("Error al cerrar la orden de compra: ", GetLastError());

               }

           }

       }

   }

  }

//+------------------------------------------------------------------+



응답함

1
개발자 1
등급
(154)
프로젝트
258
24%
중재
12
25% / 8%
기한 초과
15
6%
작업중

프로젝트 정보

예산
30+ USD
VAT (19%): 5.7 USD
총: 35.7 USD
개발자에게
27 USD