Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate oltre. Da nessuna parte senza di te - 6. - pagina 200

 
Vinin:

Perché rimuoverlo. Se l'avessero lasciato dentro, tutto avrebbe funzionato.

Metti questo segno misterioso ...... ma il risultato è lo stesso...la funzione non funziona

bool isCloseLastPosByStop(string sy, int op, int mn, double &  ll) 
{
   double   pt;
   datetime t;
   int       dg, i, j=-1, k=OrdersHistoryTotal()-1;

   for (i=k; i>=0; i--) 
   {
     if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) 
     {
         if (OrderMagicNumber()!=mn)   continue;   // если магик не тот, переходим к следующему
         if (OrderSymbol()!=sy)        continue;   // если символ не тот, переходим к следующему
         if (OrderType()!=op)           continue;   // если тип не тот, переходим к следующему
         if (t<OrderCloseTime()) 
         {
            t=OrderCloseTime();
            j=i;
            }
         }
      }
      
   if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) 
   {
      dg=MarketInfo(OrderSymbol(), MODE_DIGITS);      // количество знаков в цене символа ордера
      pt=MarketInfo(OrderSymbol(), MODE_POINT);       // размер пункта инструмента в валюте котировки ордера
      if (MathAbs(OrderClosePrice()-OrderStopLoss())< 0.5*pt) // Если закрыт по стопу
      { 
         ll=OrderLots();                              // записываем количество лотов в ордере, закрытом по стопу
         return(true);                                // возвращаем истину
         }
      }
      
   return(False);                                     // возвращаем ложь (позиции нету, либо не по стопу)
}
 
solnce600:
Mi chiedo ..... cosa significhi questo segno.... Non mi viene in mente nulla nel libro di testo al riguardo.


Il trasferimento per riferimento permette di modificare (cambiare) il parametro
 
Vinin:

Il trasferimento per riferimento, permette la modifica (cambiamento) del parametro

Grazie, lo terrò presente per il futuro.

Ma perché la funzione non funziona?

Vi sarei grato se poteste indicarmi la giusta direzione.
 
solnce600:

Grazie, lo terrò presente per il futuro.

Ma perché la funzione non funziona?

Vi sarei grato se poteste indicarmi la direzione giusta.

Vi sarei grato se mi indicaste la direzione giusta.
 
Vinin:

Ritorno lotto minimo anche

Restituito.

Ora quando si compila dà errore .... che la variabile Lot non è definita.

' ' - variabile non definita C:\Program Files\Alpari NZ MT4\experts\PREDICATED LOT.mq4 (47, 39)
http://clip2net.com/s/61vFZH

Anche se è stato definito prima di Start.


 double  Magic, Lot;

int start()
  {
        

  
 double Price=iOpen (Symbol (),0,0);
 

          
 int last_order_bar = 0;                                                                                                                        
 int ot = OrdersTotal();                                                                                                                        
                                                                                                                        
 if (ot>0) //если есть ордера в рынке                                                                                                                   
 {                                                                                                                      
   if (OrderSelect (ot-1,SELECT_BY_POS))                                                                                                                        
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL )                                                                                                                       
         last_order_bar = iBarShift (Symbol (),0,OrderOpenTime ());                                                                                                             
 }                                                                                                                      
                                                                                                                        
 int last_hist_order_bar = 0;                                                                                                                   
 int oht = OrdersHistoryTotal();                                                                                                                        
                                                                                                                
 if (oht>0)                                                                                                                     
 {                                                                                                                      
   if (OrderSelect (oht-1,SELECT_BY_POS, MODE_HISTORY))                                                                                                                         
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL)                                                                                                                        
         last_hist_order_bar = iBarShift (Symbol (),0,OrderOpenTime ());
                                                                                                        
        }

                                                                                                        
if (ot==0)
        
                                                                                                                        
 //if (ot==0 || last_order_bar>0) //если ордеров нет либо последний открыт не на текущем баре                                                                                                                   
 //   if (oht==0 || last_hist_order_bar>0) 
 if (Bid ==Price)
//=============================================================== 
  
if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))

//============================================================
Lot= MarketInfo(Symbol(), MODE_MINLOT);   
if (isCloseLastPosByStop(Symbol(), OP_BUY, Magic, Lot))
{
Lot=Lot*2;
OrderSend(Symbol(),OP_SELL,Lot,Bid,1,Ask+1500*Point,Ask-300*Point,"jfh",123 );
}
else
{

Lot=0.1;        
OrderSend(Symbol(),OP_SELL,1,Bid,Lot,Ask+1500*Point,Ask-300*Point,"jfh",123 );
}
   return(0);
  }
//============================================================  
bool isCloseLastPosByStop(string sy, int op, int mn, double &ll) 
{
   double   pt;
   datetime t;
   int       dg, i, j=-1, k=OrdersHistoryTotal()-1;

   for (i=k; i>=0; i--) 
   {
     if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) 
     {
         if (OrderMagicNumber()!=mn)   continue;   // если магик не тот, переходим к следующему
         if (OrderSymbol()!=sy)        continue;   // если символ не тот, переходим к следующему
         if (OrderType()!=op)           continue;   // если тип не тот, переходим к следующему
         if (t<OrderCloseTime()) 
         {
            t=OrderCloseTime();
            j=i;
            }
         }
      }
      
   if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) 
   {
      dg=MarketInfo(OrderSymbol(), MODE_DIGITS);      // количество знаков в цене символа ордера
      pt=MarketInfo(OrderSymbol(), MODE_POINT);       // размер пункта инструмента в валюте котировки ордера
      if (MathAbs(OrderClosePrice()-OrderStopLoss())< 0.5*pt) // Если закрыт по стопу
      { 
         ll=OrderLots();                              // записываем количество лотов в ордере, закрытом по стопу
         return(true);                                // возвращаем истину
         }
      }
      
   return(False);                                     // возвращаем ложь (позиции нету, либо не по стопу)
}
 
solnce600:

Restituito.

Ora quando si compila dà errore .... che la variabile Lot non è definita.

' ' - variabile non definita C:\Program Files\Alpari NZ MT4\experts\PREDICATED LOT.mq4 (47, 39)
http://clip2net.com/s/61vFZH

L'ho definito prima di Start però.




Ho bisogno di tutto il codice
 
Vinin:

Ho bisogno di tutto il codice
 
 double  Magic, Lot;

int start()
  {
        

  
 double Price=iOpen (Symbol (),0,0);
 

          
 int last_order_bar = 0;                                                                                                                        
 int ot = OrdersTotal();                                                                                                                        
                                                                                                                        
 if (ot>0) //если есть ордера в рынке                                                                                                                   
 {                                                                                                                      
   if (OrderSelect (ot-1,SELECT_BY_POS))                                                                                                                        
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL )                                                                                                                       
         last_order_bar = iBarShift (Symbol (),0,OrderOpenTime ());                                                                                                             
 }                                                                                                                      
                                                                                                                        
 int last_hist_order_bar = 0;                                                                                                                   
 int oht = OrdersHistoryTotal();                                                                                                                        
                                                                                                                
 if (oht>0)                                                                                                                     
 {                                                                                                                      
   if (OrderSelect (oht-1,SELECT_BY_POS, MODE_HISTORY))                                                                                                                         
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL)                                                                                                                        
         last_hist_order_bar = iBarShift (Symbol (),0,OrderOpenTime ());
                                                                                                        
        }

                                                                                                        
if (ot==0)
        
                                                                                                                        
 //if (ot==0 || last_order_bar>0) //если ордеров нет либо последний открыт не на текущем баре                                                                                                                   
 //   if (oht==0 || last_hist_order_bar>0) 
 if (Bid ==Price)
//=============================================================== 
  
if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))

//============================================================
Lot= MarketInfo(Symbol(), MODE_MINLOT);   
if (isCloseLastPosByStop(Symbol(), OP_BUY, Magic, Lot))
{
Lot=Lot*2;
OrderSend(Symbol(),OP_SELL,Lot,Bid,1,Ask+1500*Point,Ask-300*Point,"jfh",123 );
}
else
{

Lot=0.1;        
OrderSend(Symbol(),OP_SELL,1,Bid,Lot,Ask+1500*Point,Ask-300*Point,"jfh",123 );
}
   return(0);
  }
//============================================================  
bool isCloseLastPosByStop(string sy, int op, int mn, double &ll) 
{
   double   pt;
   datetime t;
   int       dg, i, j=-1, k=OrdersHistoryTotal()-1;

   for (i=k; i>=0; i--) 
   {
     if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) 
     {
         if (OrderMagicNumber()!=mn)   continue;   // если магик не тот, переходим к следующему
         if (OrderSymbol()!=sy)        continue;   // если символ не тот, переходим к следующему
         if (OrderType()!=op)           continue;   // если тип не тот, переходим к следующему
         if (t<OrderCloseTime()) 
         {
            t=OrderCloseTime();
            j=i;
            }
         }
      }
      
   if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) 
   {
      dg=MarketInfo(OrderSymbol(), MODE_DIGITS);      // количество знаков в цене символа ордера
      pt=MarketInfo(OrderSymbol(), MODE_POINT);       // размер пункта инструмента в валюте котировки ордера
      if (MathAbs(OrderClosePrice()-OrderStopLoss())< 0.5*pt) // Если закрыт по стопу
      { 
         ll=OrderLots();                              // записываем количество лотов в ордере, закрытом по стопу
         return(true);                                // возвращаем истину
         }
      }
      
   return(False);                                     // возвращаем ложь (позиции нету, либо не по стопу)
}
 
Vinin:

Ho bisogno di tutto il codice

Ho bisogno che dopo la chiusura dell'ordine su uno stop si apra l'ordine seguente con il volume uguale al volume che era nell'ULTIMO chiuso su uno stop

ordine moltiplicato per 2

E se l'ULTIMO ordine è stato chiuso per qualsiasi altra ragione (non uno stop) - il volume della posizione dovrebbe essere 0,1
 
solnce600:

Restituito.

Ora quando si compila dà errore .... che la variabile Lot non è definita.

' ' - variabile non definita C:\Program Files\Alpari NZ MT4\experts\PREDITIONS.mq4 (47, 39)
http://clip2net.com/s/61vFZH

Ma è definito prima di Start.

Compila. Mi sembra che la tua logica sia totalmente zoppa... Naturalmente, non ho guardato attraverso di essa. Ho controllato solo gli errori.

double  Magic, Lot;

int start() {

   double Price=iOpen(Symbol(),0,0);
          
   int last_order_bar=0; 
   int ot=OrdersTotal();
   if (ot>0)  {
      if (OrderSelect(ot-1,SELECT_BY_POS))
         if (OrderType()==OP_BUY || OrderType()==OP_SELL) last_order_bar=iBarShift(Symbol(),0,OrderOpenTime());
      }

   int last_hist_order_bar=0;
   int oht=OrdersHistoryTotal(); 

   if (oht>0) {
      if (OrderSelect(oht-1,SELECT_BY_POS, MODE_HISTORY))
         if (OrderType ()==OP_BUY || OrderType ()==OP_SELL) last_hist_order_bar=iBarShift(Symbol(),0,OrderOpenTime())
      }

   if (ot==0)
      if (Bid==Price)
  //=============================================================== 
         if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
            if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
               if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))
  //============================================================
                  Lot=MarketInfo(Symbol(), MODE_MINLOT);   
                  if (isCloseLastPosByStop(Symbol(), OP_BUY, Magic, Lot)) {
                     Lot=Lot*2;
                     OrderSend(Symbol(),OP_SELL,Lot,Bid,1,Ask+1500*Point,Ask-300*Point,"jfh",123 );
                     }
                  else {
                     Lot=0.1;        
                     OrderSend(Symbol(),OP_SELL,1,Bid,Lot,Ask+1500*Point,Ask-300*Point,"jfh",123 );
                     }
   return(0);
}
//+----------------------------------------------------------------------------+
bool isCloseLastPosByStop(string sy, int op, int mn, double &ll) {
   double   pt;
   int      t, dg, i, j=-1, k=OrdersHistoryTotal()-1;

   for (i=k; i>=0; i--) {
     if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
         if (OrderMagicNumber()!=mn)   continue;   // если магик не тот, переходим к следующему
         if (OrderSymbol()!=sy)        continue;   // если символ не тот, переходим к следующему
         if (OrderType()!=op)          continue;   // если тип не тот, переходим к следующему
         if (t<OrderCloseTime()) {
            t=OrderCloseTime();
            j=i;
            }
         }
      }
   if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
      dg=MarketInfo(OrderSymbol(), MODE_DIGITS);      // количество знаков в цене символа ордера
      pt=MarketInfo(OrderSymbol(), MODE_POINT);       // размер пункта инструмента в валюте котировки ордера
      if (MathAbs(OrderClosePrice()-OrderStopLoss())<0.5*pt) { // Если закрыт по стопу
         ll=OrderLots();                              // записываем количество лотов в ордере, закрытом по стопу
         return(true);                                // возвращаем истину
         }
      }
   return(False);                                     // возвращаем ложь (позиции нету, либо не по стопу)
}
//+----------------------------------------------------------------------------+

datetime è uguale a int