O que é order_id ? - página 3

 

Por que você está imprimindo o valor de DIPlus1 oito vezes?

Use esta linha ... uma vez.

Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
 

Você precisa tornar seu travessão mais claro para que seja fácil para você e para os outros seguirem ...

for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)  
   {
   if(  OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   
   
   Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
   
   if( OrderMagicNumber() == MagicNumber2      
   && OrderSymbol() == Symbol()          
   && OrderType() == OP_BUY         
   || OrderType() == OP_SELL )  
      {
      if( DIPlus1 > DIMinus1 || Main0 < err || Rsi < xx)
         OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);
      } 

   if( OrderMagicNumber() == MagicNumber1      
   && OrderSymbol() == Symbol()          
   &&  OrderType() == OP_BUY          
   || OrderType() == OP_SELL )  
      { 
      if( DIPlus1 < DIMinus1 || Main0 < err || Rsi > x  )
         OrderClose(OrderTicket(),OrderLots(),Ask,3,Green);   
      }

   if ( ! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 3 ) )                           //  <------  why this extra OrderClose ???
         Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() ); 
              
   }
 

Agradeça ao Raptor. Espero que meu trabalho na EA.

Meu novo código:

int start()
{
   int i ,times;
   string DIPlus1;
   string DIPlus0;
 
   string DIMinus1;
   string DIMinus0;
   
   string Main1;
   string Main0;
   
   string MACD_main;
   string MACD_signal;
   string Rsi;
   
   string err = 26;
   string x = 70;
   string xx = 30;
   
   double sl = 300;
   double tp = 50;
   
   int MagicNumber1=1234,MagicNumber2=4321;
//----
/*DIPlus1=DoubleToStr(  DIPlus1, 4);
DIPlus0=DoubleToStr(    DIPlus0, 4);
DIMinus1=DoubleToStr(   DIMinus1, 4);
DIMinus0=DoubleToStr(   DIMinus0, 4);
Main1=DoubleToStr(      Main1, 4);
Main0=DoubleToStr(      Main0, 4);
Rsi=DoubleToStr(        Rsi, 4);
//err=DoubleToStr(err,4);
//x=DoubleToStr(x,4);
//xx=DoubleToStr(xx,4);*/

//---
 
DIPlus1=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,1);
DIPlus0=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,0);
 
DIMinus1=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,1);
DIMinus0=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,0);

Main1=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,1);
Main0=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,0);

Rsi = iRSI(NULL,0,14,PRICE_CLOSE,0);

times = Minute() % 15 ==0 && Seconds() ==0;

//MACD_main = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); 
//MACD_signal = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
   
//----
if(Minute() % 15 ==0 && Seconds() ==0)
{
  if( Main0 > err && Main1 < err && DIPlus1 > DIMinus1 && Rsi < x )

    
       OrderSend(Symbol(),OP_BUY,0.03,Ask,5,Ask-sl*Point,Ask+tp*Point,"",1234,0,Blue);
          
   

   if (Main0 > err && Main1 < err && DIPlus1 < DIMinus1  && Rsi > xx)
     
       OrderSend(Symbol(),OP_SELL,0.03,Bid,5,Bid+sl*Point ,Bid-tp*Point,"",4321,0,Red);
}
     
  //---
 int PositionIndex;    
 
int TotalNumberOfOrders;  

TotalNumberOfOrders = OrdersTotal();   

for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)  
   
   if(  OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   
      {
         if( OrderMagicNumber() == MagicNumber2      
           && OrderSymbol() == Symbol()          
            && OrderType() == OP_BUY         
             || OrderType() == OP_SELL )  
             
             Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
             
               {if( DIPlus1 > DIMinus1 || Main0 < err || Rsi < xx)
                             OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);
                  else Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() ); 
               
               } 
      
      
         
            if( OrderMagicNumber() == MagicNumber1      
              && OrderSymbol() == Symbol()          
               &&  OrderType() == OP_BUY          
                 || OrderType() == OP_SELL ) 
                  
                Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
                
                  { if( DIPlus1 < DIMinus1 || Main0 < err || Rsi > x  )
                                 OrderClose(OrderTicket(),OrderLots(),Ask,3,Green); 
                    else Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() ); 
                 
                  }
      }
   
    
 return(0);
 }
   

Feche imediatamente! :(

 
RaptorUK:

//  <------  why this extra OrderClose ???


?? você tem uma resposta?
 
RaptorUK:
?? você tem uma resposta ?

eu o consertei!

Por favor, veja meu novo código. Obrigado!

 
toi10005doi:

eu o consertei!

Por favor, veja meu novo código. Obrigado!

Eu lhe dei o código para usar . . . . tudo que você precisa fazer é copiá-lo e colá-lo.

Seu código ainda está errado. . . você precisa voltar e ler o Livro novamente.

            if( OrderMagicNumber() == MagicNumber1      
              && OrderSymbol() == Symbol()          
               &&  OrderType() == OP_BUY          
                 || OrderType() == OP_SELL )    //  if this is true only the Print is called . . .
                  
                Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
                
                  { if( DIPlus1 < DIMinus1 || Main0 < err || Rsi > x  )             //  this happens regardless of the if above . . .
                                 OrderClose(OrderTicket(),OrderLots(),Ask,3,Green); 
                    else Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() );   //  this happens if the if above is false . . .  why ??
                 
                  }
 
RaptorUK:
Eu lhe dei o código para usar . . . . tudo que você precisa fazer é copiá-lo e colá-lo.

Seu código ainda está errado. . . você precisa voltar e ler o livro novamente.



Sim! vou ler mais sobre o livro. Você pode prever este código para mim?

for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)  
   {
   if(  OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   
   
               Print("DIPlus1: ", DoubleToStr(DIPlus1, Digits), " DIMinus1: ", DoubleToStr(DIMinus1, Digits), " Main0: ",DoubleToStr(Main0, Digits), " Rsi: ",DoubleToStr(Rsi, Digits) );
   
               if( OrderMagicNumber() == MagicNumber2      
               && OrderSymbol() == Symbol()          
               && OrderType() == OP_BUY         
               || OrderType() == OP_SELL )  
                  {
                  if( DIPlus1 > DIMinus1 || Main0 < err || Rsi < xx)
                     {
                        if(! OrderClose(OrderTicket(),OrderLots(),Bid,3,Green))
                           Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() );
                     } 
                  }
               if( OrderMagicNumber() == MagicNumber1      
               && OrderSymbol() == Symbol()          
               &&  OrderType() == OP_BUY          
               || OrderType() == OP_SELL )  
                  { 
                     if( DIPlus1 < DIMinus1 || Main0 < err || Rsi > x  )
                        {
                           if(! OrderClose(OrderTicket(),OrderLots(),Ask,3,Green))  
                              Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() );
                        } 
                      
                  }

   
    }
 return(0);
 }
   

porque ele não fecha o pedido?

 
toi10005doi:

Sim! vou ler mais sobre o livro. Você pode prever este código para mim?

porque ele não fecha o pedido?

Você pode copiar e colar as informações impressas no log para as variáveis na declaração de impressão.
 
RaptorUK:
Você pode copiar e colar as informações impressas no log para as variáveis na declaração de impressão.

Acabei de testá-lo novamente. Mas não fechou nenhum pedido?

 
toi10005doi:

Acabei de testá-lo novamente. Mas não fechou nenhum pedido?

Veja no Jornal, descubra quais são os valores impressos. Você pode copiá-los e colá-los aqui também, por favor . . . todo o objetivo de acrescentar a declaração impressa foi por razões de depuração . . . você precisa olhar para esses dados e descobrir o que está errado.
Razão: