pergunta simples - página 2

 
Ais:

Favor verificar o valor "Dist".

cheque? Como? Eu copiei o código (a parte com a variável de distância) do livro da 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. Certifique-se de que o valor inicial de "Dist" esteja correto

2. Inserir alerta para verificar o valor de "Dist" no início do ciclo: "Alerta ( " Dist = ", Dist ) ; "

há alguma maneira de selecionar a ordem correta sem usar a variável "dist"?

 
Ais:

Resposta 1

Os sinais ">" e "<" nas amostras estão em direções diferentes para a mesma expressão

Ver linha 22 de closeorder.mq4 e linha 6 da amostra anterior

Acho que na segunda amostra deve ser um erro...o que você acha?

 
Ais:

Resposta 2

Depende do significado de "a ordem certa".

Eu preciso selecionar (e fechar) a ordem OP_BUY que tem o menor preço aberto e esta seleção deve começar quando houver 2 ordens OP_BUY... a mesma coisa para OP_SELL... isto é tão difícil de implementar? Estou tão confuso...

 
Ais:

trabalho ordinário

então o que estou fazendo de errado? Como você selecionaria o OP_BUY com o preço aberto mais baixo? Eu tentei mesmo sem "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
 

Qual é a intenção da linha " if (Preço < Preço), Dígitos) " ??

Parece-me uma loucura.


CB

 
cloudbreaker:

Qual é a intenção da linha " if (Preço < Preço), Dígitos) " ??

Parece-me uma loucura.

Não é só isso.

como isso poderia compilar sem erros, com um colchete esquerdo ausente.

estou cansado deste código - agarrar-nulo-idiota-folhuda-idiota-folhuda-idiota-e-folhuda-folhuda-e-não-pague-um-agente-agregando-agregando-agregando-agregando-agregando-agregando-agregando-agregando-agregando-agregando-agregando

 
Ais:

todos os humanos cometem erros

se (a_human_made_a_mistake==verdadeiro)

{human_learn_next_lesson();}

senão

{reincarnate_as_plant=true;}

 
meikel:

{human_learn_next_lesson();}

Se tivéssemos apenas o MT5. Então poderíamos fazer humano->learnNextLesson() em vez disso.

 
jjc:

Se ao menos tivéssemos o MT5. Então poderíamos fazer Human->learnNextLesson() em vez disso.

Eu nunca estive familiarizado com o OOP.

Odeio isso. Muito aborrecimento por nada.

em tais casos, recuso-me a aprender... ;-)

isto->repeat->isto->repeat->isto->repeat->isto->repeat->isto->repeat->isto->repeat->isto->repeat->isto->repeat->isto;