Chiusura di mezzi lotti. - pagina 4

 
DomGilberto:
Non posso credere che sto facendo questi errori da principiante... Mi infastidisce! Sì, l'ho fatto stampare ora e ho selezionato l'ordine. Questo è il codice che funziona in termini di stampa - i lotti non vengono ancora chiusi però? Ho anche incollato i messaggi del diario qui sotto.

2013.07.31 11:13:52 2013.02.01 16:00 trendfishing_play_ground EURUSD,H1: Order Select returned the error of 0 // Not sure what is going on here?

if(OrderSelect(c,SELECT_BY_TICKET,MODE_TRADES)==true)

c è una POSIZIONE non un numero di biglietto . . .

 

(facepalm - ovviamente ho bisogno di una pausa da esso!) ok risolto questo e ora sta selezionando l'ordine. Questa è la stampa del diario ora - errore "Close_Half_Order" = 0? Questa è la funzione OrderClose che fallisce. Non ha niente a che fare con il numero di "000" dopo la seconda posizione decimale nella parte "i lotti da chiudere sono", vero?

2013.07.31 11:28:49     2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: Close_Half_Order Last Error = 0
2013.07.31 11:28:49     2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: Order Lots Open = 0.18
2013.07.31 11:28:49     2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: Order Ticker Number = 9
2013.07.31 11:28:49     2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: The Lots to close is: 0.09000
2013.07.31 11:28:49     2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: The Lotstep is: 0.01000
2013.07.31 11:28:49     2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: The minimum lots are: 0.01000
2013.07.31 11:28:49     2013.02.01 15:00  trendfishing_play_ground EURUSD,H1: FirstTarget_Buy: 1.37931
 
DomGilberto:

(facepalm - ovviamente ho bisogno di una pausa da esso!) ok risolto questo e ora sta selezionando l'ordine. Questa è la stampa del diario ora - errore "Close_Half_Order" = 0? Questa è la funzione OrderClose che fallisce. Non ha niente a che fare con il numero di "000" dopo la seconda cifra decimale nella parte "i lotti da chiudere sono", vero?

Parentesi graffe, parentesi graffe, parentesi graffe . . . a volte è necessario usarle, a volte no.

La funzione OrderClose() non è fallita . . .

            if(OrderMagicNumber()==MagicNumber)
              if(OrderSymbol()==Symbol())
                if(OrderType()==OP_BUY)
                  if(OpenOrdersThisPair(Symbol())==1)   //  if this is true . . . 

                bool Close_Half_Order = OrderClose(OrderTicket(),half,FirstTarget_Buy,3,CLR_NONE); // . . .  do this.

            if(Close_Half_Order!=TRUE)Print("Close_Half_Order Last Error = ", GetLastError());  //  do this whatever happens . . .

quindi se l'OrderType() non è un OP_BUY l'ultima linea verrà comunque eseguita, da qui l'errore 0 . . . aggiungi le parentesi graffe come questa:

            if(OrderMagicNumber() == MagicNumber)
              if(OrderSymbol() == Symbol())
                if(OrderType() == OP_BUY)
                  if(OpenOrdersThisPair(Symbol()) == 1) 
                     {
                     bool Close_Half_Order = OrderClose(OrderTicket(), half, FirstTarget_Buy, 3, CLR_NONE);
                     if(Close_Half_Order != TRUE) Print("Close_Half_Order Last Error = ", GetLastError() );  // only executed if the OrderClose() was also executed
                     } 
 
Un rientro coerente aiuta anche a vedere chiaramente cosa sta succedendo
 
Hmmm, ancora non vuole chiudere @ "Close_Half_Order" ? Non ottenendo alcun messaggio di errore anche?
 
DomGilberto:
Hmmm, ancora non vuole chiudere @ "Close_Half_Order" ? Non ricevendo nemmeno un messaggio di errore?
Qual è il tuo tipo di ordine?
 
OP_BUY?

  if(OrderSelect(OrdersTotal(),SELECT_BY_TICKET,MODE_TRADES)==true && OpenOrdersThisPair(Symbol())==1){
         
         double FirstTarget_Buy = OrderOpenPrice() + ( ( OrderTakeProfit()-OrderOpenPrice() ) / 2 );{
           Print("FirstTarget_Buy: ", DoubleToStr( FirstTarget_Buy, Digits ));
         }
         
         double minLot  = MarketInfo(Symbol(), MODE_MINLOT);{
                Print("The minimum lots are: ", DoubleToStr( minLot, Digits ));
                }
                        
         double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);{
                Print("The Lotstep is: ", DoubleToStr( lotStep, Digits ));
                }
                
         double half    = MathCeil(OrderLots()/2/lotStep)*lotStep;{
                Print("The Lots to close is: ", DoubleToStr( half, Digits ));
                }
      for( int c=OrdersTotal()-1; c >=0; c-- )
      {
         if(OrderSelect(c,SELECT_BY_POS,MODE_TRADES)==true){
            Print("Order Ticker Number = ",OrderTicket());
            Print("Order Lots Open = ", OrderLots());
            } 
         else{
           Print("Order Select returned the error of ", GetLastError()); // Order Select does not seem to want to work?
            continue;
            }
            if(OrderMagicNumber()==MagicNumber)
              if(OrderSymbol()==Symbol())
                if(OrderType()==OP_BUY)
                  if(OpenOrdersThisPair(Symbol())==1){ 
                bool Close_Half_Order = OrderClose(OrderTicket(),half,FirstTarget_Buy,3,CLR_NONE);
                if(Close_Half_Order!=TRUE)Print("Close_Half_Order Last Error = ", GetLastError());
                }
      } 
   }
 
DomGilberto:
OP_BUY?


Hai parlato prima di ordini pendenti, hai effettivamente un OP_BUY aperto durante il test o hai un ordine pendente aperto?
 

A proposito, queste parentesi non fanno altro che confondere la situazione . . .

         double FirstTarget_Buy = OrderOpenPrice() + ( ( OrderTakeProfit()-OrderOpenPrice() ) / 2 );  {  
           Print("FirstTarget_Buy: ", DoubleToStr( FirstTarget_Buy, Digits ));
         }  
         
         double minLot  = MarketInfo(Symbol(), MODE_MINLOT);  {  
                Print("The minimum lots are: ", DoubleToStr( minLot, Digits ));
                }  
                        
         double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);  {  
                Print("The Lotstep is: ", DoubleToStr( lotStep, Digits ));
                }  
                
         double half    = MathCeil(OrderLots()/2/lotStep)*lotStep;  {  
                Print("The Lots to close is: ", DoubleToStr( half, Digits ));
                }  
 

Ho inserito un ordine pendente "OP_BUYSTOP", ma avevo l'impressione che questo sarebbe cambiato una volta attivato in un "OP_BUY"?

Pensavo che il tipo di ordine sarebbe stato "OP_BUY" se fosse stato attivato?

Dopo tutto, sono interessato solo UNA VOLTA che l'ordine è stato attivato?

Perché queste parentesi sono confuse? Intendi in termini di dove si trova la parentesi sinistra? Se è così, sembra che sia una cosa individuale, dato che sono stato corretto più volte su questo?