Mira cómo descargar robots gratis
¡Búscanos en Telegram!
Pon "Me gusta" y sigue las noticias
¿Es interesante este script?
Deje un enlace a él, ¡qué los demás también lo valoren!
¿Le ha gustado el script?
Evalúe su trabajo en el terminal MetaTrader 5
Asesores Expertos

More Trade After Break Even - Asesor Experto para MetaTrader 4

Visualizaciones:
7714
Ranking:
(25)
Publicado:
2021.07.13 09:50
¿Necesita un robot o indicador basado en este código? Solicítelo en la bolsa freelance Pasar a la bolsa

The Masterpiece of this little EA is the Orders count function ,

int OrdersCounter()
  {
   int counter=0;
//---
   for(int i=OrdersTotal()-1; i>=0; i--)
      if(OrderSelect(i,SELECT_BY_POS))
         if(OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) // if order has been opened by this EA
           {
//--- if break even has taken place 
   /* For buys Only when the StopLoss is equal or above the Open Price NOTE This is implementetion is not
   good if you are going to have Pending Orders Its only suitable for buy and sells only*/
            double XBreakeven = OrderType()==OP_BUY ? OrderStopLoss() >= OrderOpenPrice() : OrderStopLoss() <= OrderOpenPrice();
            if(!XBreakeven) //If only Break Even and trailing stop hasn't taken place'
              {
               counter++; //count the Position
              }
           }
   return counter;
  }

Where as we count Only the Orders that have NOT stoploss above or equal to its open price for buy and below its open price sell . I short we count all orders that have not been breakeven or trailing stop has not protected its opening price.

 double XBreakeven = OrderType()==OP_BUY ? OrderStopLoss() >= OrderOpenPrice() : OrderStopLoss() <= OrderOpenPrice();
            if(!XBreakeven) //If only Break Even and trailing stop hasn't taken place'

Through that we make a counter that returns the value that we are going to use to limit our maximum position which in our case we have just set to 1 order at a time

   if(OrdersCounter()<MaximumOrders)

So whenever the breakeven takes place this function will ignore counting it , which by then since we had only one position in this Example .. it will return zero and boom we open  another sale and the process continues

Also this wouldn't be possible if I did not create a break even function ,

void BreakEvenFunction()
  {
//---
   for(int i=OrdersTotal()-1; i>=0; i--)
      if(OrderSelect(i,SELECT_BY_POS))
         if(OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
           {
// for buy if Bid above Open Price + Breakeven pips Vice Versa for sells
            double xHybrid = OrderType()==OP_BUY ? (Bid>OrderOpenPrice()+BreakevenPips*_Point && OrderStopLoss()<OrderOpenPrice()) : (Ask<OrderOpenPrice()-BreakevenPips*_Point && OrderStopLoss()>OrderOpenPrice());
            /* For buys Only when the StopLoss is equal or above the Open Price Vice versa for sell */
            if(xHybrid)
              {
               bool modfy = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,clrNONE);
              }
           }
  }

Try it ??

    Cercós Chaos vs Movement Cercós Chaos vs Movement

    Volatility indicator

    Moving average breakout Moving average breakout

    trending breakout

    Alligator trend cross Alligator trend cross

    Candle cross either of three lines.

    Indicador Media móvil Hull para MT4 Indicador Media móvil Hull para MT4

    Indicador de medias móviles Hull (HMA) para Metatrader 4 que cambia de color dependiendo de la tendencia. La HMA es una media móvil diseñada para seguir de cerca la acción del precio más reciente pero sin perder el efecto de suavizado. Puede resultar muy útil para el análisis de tendencias.