Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen de largo. En ninguna parte sin ti - 6. - página 200

 
Vinin:

Por qué quitarlo. Si lo hubieran dejado dentro, todo habría funcionado.

Puse este signo misterioso ...... pero el resultado es el mismo ...la función no funciona

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:
Me pregunto ..... qué significa este signo.... No se me ocurre nada en el libro de texto al respecto.


Transferir por referencia, permite modificar (cambiar) el parámetro
 
Vinin:

La transferencia por referencia, permite la modificación (cambio) del parámetro

Gracias. Lo tendré en cuenta para el futuro.

Pero, ¿por qué no funciona la función?

Le agradecería que me indicara la dirección correcta.
 
solnce600:

Gracias. Lo tendré en cuenta para el futuro.

Pero, ¿por qué no funciona la función?

Le agradecería que me indicara la dirección correcta.

Le agradecería que me indicara la dirección correcta.
 
Vinin:

Devolución del lote mínimo también

Devuelto.

Ahora al compilar da error.... que la variable Lot no está definida.

' ' - variable no definida C:\NArchivos de programa\NAlpari NZ MT4\experts\PREDICADO LOT.mq4 (47, 39)
http://clip2net.com/s/61vFZH

Aunque se definió antes de 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:

Devuelto.

Ahora al compilar da error.... que la variable Lot no está definida.

' ' - variable no definida C:\NArchivos de programa\NAlpari NZ MT4\experts\PREDICADO LOT.mq4 (47, 39)
http://clip2net.com/s/61vFZH

Sin embargo, lo he definido antes de empezar.




Necesito todo el código
 
Vinin:

Necesito todo el código
 
 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:

Necesito todo el código

Necesito que después de cerrar la orden en un stop se abra la siguiente orden con el volumen igual al que había en la última cerrada en un stop

orden multiplicada por 2

Y si la ÚLTIMA orden se cerró por cualquier otra razón (no un stop) - el volumen de la posición debe ser 0,1
 
solnce600:

Devuelto.

Ahora al compilar da error.... que la variable Lot no está definida.

' ' - variable no definida C:\NArchivos de programa\NAlpari NZ MT4\\Nexperts\PREDITIONS.mq4 (47, 39)
http://clip2net.com/s/61vFZH

Pero está definida antes de la puesta en marcha.

Compila. Me parece - que su lógica es totalmente cojo allí ... Por supuesto, no he mirado a través de él. Sólo he comprobado si hay errores.

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 es lo mismo que int