Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 1631

 

¡¡¡Buenas tardes!!!

Ayúdame. Estoy añadiendo un trailing stop a un EA de rejilla, de momento sólo a la primera orden. El rastro no se ha disparado todavía. ¿Cuál es el problema?

Este es el fragmento de código en el que se abren las órdenes individuales

double JAW = iAlligator(Symbol(),TimeframesIndicators,13,8,5,8,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORJAW,0);
     double TEETH = iAlligator(Symbol(),TimeframesIndicators,13,8,5,8,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORTEETH,0);
     double LIPS = iAlligator(Symbol(),TimeframesIndicators,13,8,5,8,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORLIPS,0);
     double DI_PLUSCurrent=iADX(Symbol(),TimeframesIndicators,14, PRICE_CLOSE,MODE_PLUSDI,0);
     double DI_MINUSCurrent=iADX(Symbol(),TimeframesIndicators,14, PRICE_CLOSE,MODE_MINUSDI,0);
     double MacdCurrent=iMACD(Symbol(),TimeframesIndicators,12,26,9, PRICE_CLOSE,MODE_MAIN,0);
     double MacdPrevious=iMACD(Symbol(),TimeframesIndicators,12,26,9, PRICE_CLOSE,MODE_MAIN,2 ); 
     double ATR = iATR(Symbol(), TimeframesVolatility, BarCount, 0);
     if (CountTrade() == 0)
     { 
        if((UseHour==1&&Hour()>=StartTime&&Hour()<=StopTime)||UseHour==0)
        if(LIPS>TEETH&& TEETH>JAW&&DI_PLUSCurrent>18&&DI_PLUSCurrent>DI_MINUSCurrent&&MacdCurrent>MacdPrevious)                              
         {
           FirstLots = Lots();
           tp = NormalizeDouble(Ask + TakeProfitFirstOrder*Point, Digits);
           ticket = OrderSend(Symbol(), OP_BUY, FirstLots, Ask, slip, 0, tp, "1-ый ордер", Magic, 0, Blue); 
            {
             if(Bid - OrderOpenPrice() > TrailingStop*Point) 
              Trailing();
            }
         }
        if((UseHour==1&&Hour()>=StartTime&&Hour()<=StopTime)||UseHour==0)
        if(LIPS<TEETH&& TEETH<JAW&&DI_MINUSCurrent>18&&DI_MINUSCurrent>DI_PLUSCurrent&&MacdCurrent<MacdPrevious)                            
         {
           FirstLots = Lots();
           tp = NormalizeDouble(Bid - TakeProfitFirstOrder*Point, Digits);
           ticket = OrderSend(Symbol(), OP_SELL, FirstLots, Bid, slip, 0, tp, "1-ый ордер", Magic, 0, Red); 
           {
           if(OrderOpenPrice() - Ask > TrailingStop*Point)
              Trailing();
           }
         }
       }

Esta es la función de modificación de los pedidos individuales

//+----------------------------------------------------------------------------+
//| Трейлинг стоп одиночных ордеров                                            |
//+----------------------------------------------------------------------------+
void Trailing()
{
   for(int i = OrdersTotal()-1; i>=0; i--)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
         {
           if(OrderType() == OP_BUY)
           {
             if(Bid - OrderOpenPrice() > TrailingStop*Point || OrderStopLoss() == 0)
             {
                if(OrderStopLoss() < Bid - (TrailingStep + TrailingStop)*Point || OrderStopLoss() == 0)
                {
                  if(!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - TrailingStop*Point, Digits), tp, 0))
                    Print("Ошибка модификации ордера на покупку!");
                }
             }
           }
           if(OrderType() == OP_SELL)
           {
             if(OrderOpenPrice() - Ask > TrailingStop*Point || OrderStopLoss() == 0)
             {
                if(OrderStopLoss() > Ask + (TrailingStep + TrailingStop)*Point || OrderStopLoss() == 0)
               {
                  if(!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + TrailingStop*Point, Digits), tp, 0))
                    Print("Ошибка модификации ордера на продажу!");
               }
             }
           }
         }
      }
   }
}

¡¡¡¡Gracias!!!!

 
EVGENII SHELIPOV #:

¡¡¡Buenas tardes!!!

Ayúdame. Estoy añadiendo un trailing stop a un EA de rejilla, de momento sólo a la primera orden. El rastro no se ha disparado todavía. ¿Cuál es el problema?

Este es el fragmento de código en el que se abren las órdenes individuales

Esta es la función de modificación de los pedidos individuales

¡¡¡¡Gracias!!!!

Sólo se puede recurrir a una red de arrastre cuando no hay órdenes...
 
MakarFX #:
Tienes razón, funciona... hay un error en los muelles.
El modo multidivisa en la versión 1345 funciona). Lo he comprobado en 10 mayores, obtiene datos de los 10 pares y dibuja lo que quieras)
Y pulsando botones en el probador)
 
MakarFX #:
Sólo tiene una llamada a la red de arrastre cuando no hay pedidos...

No ha cambiado nada

void OnTick()
{
     double JAW = iAlligator(Symbol(),TimeframesIndicators,13,8,5,8,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORJAW,0);
     double TEETH = iAlligator(Symbol(),TimeframesIndicators,13,8,5,8,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORTEETH,0);
     double LIPS = iAlligator(Symbol(),TimeframesIndicators,13,8,5,8,5,3,MODE_SMMA,PRICE_MEDIAN,MODE_GATORLIPS,0);
     double DI_PLUSCurrent=iADX(Symbol(),TimeframesIndicators,14, PRICE_CLOSE,MODE_PLUSDI,0);
     double DI_MINUSCurrent=iADX(Symbol(),TimeframesIndicators,14, PRICE_CLOSE,MODE_MINUSDI,0);
     double MacdCurrent=iMACD(Symbol(),TimeframesIndicators,12,26,9, PRICE_CLOSE,MODE_MAIN,0);
     double MacdPrevious=iMACD(Symbol(),TimeframesIndicators,12,26,9, PRICE_CLOSE,MODE_MAIN,2 ); 
     double ATR = iATR(Symbol(), TimeframesVolatility, BarCount, 0);
     if (CountTrade() == 0)
     { 
        if((UseHour==1&&Hour()>=StartTime&&Hour()<=StopTime)||UseHour==0)
        if(LIPS>TEETH&& TEETH>JAW&&DI_PLUSCurrent>18&&DI_PLUSCurrent>DI_MINUSCurrent&&MacdCurrent>MacdPrevious)                              
         {
           FirstLots = Lots();
           tp = NormalizeDouble(Ask + TakeProfitFirstOrder*Point, Digits);
           ticket = OrderSend(Symbol(), OP_BUY, FirstLots, Ask, slip, 0, 0, "1-ый ордер", Magic, 0, Blue); 
         }
        if((UseHour==1&&Hour()>=StartTime&&Hour()<=StopTime)||UseHour==0)
        if(LIPS<TEETH&& TEETH<JAW&&DI_MINUSCurrent>18&&DI_MINUSCurrent>DI_PLUSCurrent&&MacdCurrent<MacdPrevious)                            
         {
           FirstLots = Lots();
           tp = NormalizeDouble(Bid - TakeProfitFirstOrder*Point, Digits);
           ticket = OrderSend(Symbol(), OP_SELL, FirstLots, Bid, slip, 0, 0, "1-ый ордер", Magic, 0, Red); 
         }
         if (CountTrade() == 1) Trailing();

       }
 
EVGENII SHELIPOV #:

No ha cambiado nada

No has cambiado nada.

su conversión

 if (CountTrade() == 1) Trailing();

está dentro.

if (CountTrade() == 0)
 
Hola, ¿podríais decirme si es posible añadir una operación en un sentido (compra o venta) en moving averages-expert para mt5?
 
amsgif80 moving averages-expert para mt5?

Escríbalo en el código MQL5 del Asesor Experto y tendrá esta opción.

 
Vladimir Karputov #:

Escríbalo en el código MQL5 del Asesor Experto y tendrá esta opción.

Lo intenté, pero no funcionó. Soy un cero total en este negocio :(
 
amsgif80 #:
Lo intenté, pero no funcionó. Soy un completo novato en esto :(
Muéstrame tus intentos...
 
amsgif80 #:
Lo intenté, pero no funcionó. Soy un completo novato en este negocio :(

Este es el código que he intentado insertar:

En la parte superior del código tirar esto:
enum ENUM_DIRECTION{
DIRECTION_BUY = 0, // comprar sólo
DIRECTION_SELL = 1, // vender sólo
DIRECTION_ANY = 2, // comprar & vender
};

input ENUM_DIRECTION inp_direction = DIRECTION_ANY; // dirección de comercio permitida


además encontrar donde en el código abre comprar y donde vender. Mira dentro de la función start() o OnTick()
dondecomprar está enlas condiciones añadir:
if(inp_direction!=DIRECTION_SELL)
donde vender está en las condiciones añadir:
if(inp_direction!=DIRECTION_BUY )

Razón de la queja: