simple pregunta - página 2

 
Ais:

Por favor, compruebe el valor de "Dist".

¿Comprobar? ¿Cómo? He copiado el código (la parte con la variable de distancia) del libro de MQL4:

int start()                                     // Special function 'start'
  {
   string Symb=Symbol();                        // Symbol
   double Dist=1000000.0;                       // Presetting
   int Real_Order=-1;                           // No market orders yet
   double Win_Price=WindowPriceOnDropped();     // The script is dropped here
//-------------------------------------------------------------------------------- 2 --
   for(int i=1; i<=OrdersTotal(); i++)          // Order searching cycle
     {
      if (OrderSelect( i-1, SELECT_BY_POS)==true) // If the next is available
        {                                       // Order analysis:
         //----------------------------------------------------------------------- 3 --
         if (OrderSymbol()!= Symb) continue;    // Symbol is not ours
         int Tip=OrderType();                   // Order type
         if ( Tip>1) continue;                   // Pending order  
         //----------------------------------------------------------------------- 4 --
         double Price=OrderOpenPrice();         // Order price
         if (NormalizeDouble(MathAbs( Price- Win_Price),Digits)< //Selection
            NormalizeDouble( Dist,Digits))       // of the closest order       
           {
            Dist=MathAbs( Price- Win_Price);      // New value
            Real_Order= Tip;                     // Market order available
            int Ticket=OrderTicket();           // Order ticket
            double Lot=OrderLots();             // Amount of lots
           }
         //----------------------------------------------------------------------- 5 --
        }                                       //End of order analysis
     }                                          //End of order searching
//-------------------------------------------------------------------------------- 6 --
   while(true)                                  // Order closing cycle
     {
      if ( Real_Order==-1)                       // If no market orders available
        {
         Alert("For ", Symb," no market orders available");
         break;                                 // Exit closing cycle        
        }
      //-------------------------------------------------------------------------- 7 --
      switch( Real_Order)                        // By order type
        {
         case 0: double Price_Cls=Bid;          // Order Buy
            string Text="Buy ";                 // Text for Buy
            break;                              // Из switch
         case 1: Price_Cls=Ask;                 // Order Sell
            Text="Sell ";                       // Text for Sell
        }
      Alert("Attempt to close ", Text," ", Ticket,". Awaiting response..");
      bool Ans=OrderClose( Ticket, Lot, Price_Cls,2);// Order closing
see also: https://book.mql4.com/trading/orderclose
 
Ais:

1. Asegúrese de que el valor inicial de "Dist" es correcto

2. Insertar una alerta para comprobar el valor de "Dist" al principio del ciclo: "Alerta ( " Dist = ", Dist ) ; "

¿hay alguna forma de seleccionar el orden correcto sin utilizar la variable "dist"?

 
Ais:

Respuesta 1

Los signos ">" y "<" en las muestras están en diferentes direcciones para la misma expresión

Ver línea 22 de closeorder.mq4 y línea 6 de la muestra anterior

Creo que en la segunda muestra debe ser un error... ¿qué opinas?

 
Ais:

Respuesta 2

Depende del significado de "la orden correcta"

Necesito seleccionar (y cerrar) la orden OP_BUY que tiene el precio abierto más bajo y esta selección debe comenzar cuando hay 2 órdenes OP_BUY...lo mismo para OP_SELL...¿es esto tan difícil de implementar? Estoy tan confundido...

 
Ais:

trabajo ordinario

¿qué estoy haciendo mal? ¿Cómo seleccionaría el OP_BUY con el openprice más bajo? Lo he intentado incluso sin "Dist"...


if ( CheckFirstOP(OP_BUY) > 1) {      
      for(int i = OrdersTotal() - 1; i >= 0; i--) {
          OrderSelect( i, SELECT_BY_POS, MODE_TRADES);
          if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber || OrderType() != OP_BUY) continue;     
          double Price = OrderOpenPrice();
          if ( Price < Price), Digits) {                                            
             int Ticket = OrderTicket();           
             double Lot = OrderLots();                          
             OrderClose( Ticket, Lot, OrderClosePrice(), 3); 
         }    
      }   
   }
without any results
 

¿Cuál es la intención de la línea " if (Price < Price), Digits) "?

Me parece una locura.


CB

 
cloudbreaker:

¿Cuál es la intención de la línea " if (Price < Price), Digits) "?

Me parece una locura.

No sólo eso.

como podría esto compilar sin errores, con un corchete izquierdo que falta.

estoy cansado de este código-grabando-nada-de-insight-idiotas-y-no-quieren-pagar-un-centro-pidiendo-ayuda

 
Ais:

todos los humanos cometen errores

if (a_human_made_a_mistake==true)

{humano_aprende_siguiente_lección();}

si no

{reincarnate_as_plant=true;}

 
meikel:

{human_learn_next_lesson();}

Si sólo tuviéramos MT5. Entonces podríamos hacer human->learnNextLesson() en su lugar.

 
jjc:

Si sólo tuviéramos MT5. Entonces podríamos hacer human->learnNextLesson() en su lugar.

Nunca he estado familiarizado con OOP.

Odio eso. Demasiada molestia por nada.

en estos casos, me niego a aprender... ;-)

this->repeat->this->repeat->this->repeat->this->repeat->this->repeat->this;