Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 541

 
Rustam Bikbulatov:

Visto y probado. Ya ha ayudado mucho pero hay un límite a mi comprensión

¿Entonces no quiere el número de pedidos sino el volumen en lotes?

//+------------------------------------------------------------------+
int fMarketOrdersOpenVolume(const ENUM_ORDER_TYPE order_type)
  {
   int total=OrdersTotal();
   double lots=0;
   for(int i=total-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS))
        {
         if(OrderType()!=order_type) continue;
         if(OrderMagicNumber()==123 && OrderSymbol()==Symbol())
            lots+=OrderLots();
        }
     }
   return lots;
  }
//+------------------------------------------------------------------+
 
Artyom Trishkin:

¿Entonces no quiere el número de pedidos, sino el volumen en lotes?

double fMarketOrdersOpenVolume(const ENUM_ORDER_TYPE order_type)
 
Konstantin Nikitin:

¡¡¡¡¡¡Ahrinet!!!!!! ¡¡¡¡¡¡Lo que necesitaba!!!!!! ¡¡¡¡¡Nunca se me habría ocurrido eso!!!!! ¡¡¡¡¡Muchas gracias!!!!!

 
Konstantin Nikitin:

Sí, me lo perdí en mis preocupaciones.

 
¡¡¡Gracias chicos por ayudarnos!!! ¡¡¡Bien hecho, todos!!!
 

Sin embargo, ¡hola!

¡¿Puede usted aconsejar sobre esta situación: basado en TMA_Fair abro en el límite y cierro en el límite opuesto, pero no se cierra en el otro límite! ¿Dónde está el error en el código?

void OnTick()
{
  PriceHigh = iCustom(NULL, 0, "ExtremeTMALine st2050 v1", TimeFrame, TMAPeriod, Price, ATRMultiplier, ATRPeriod, TrendThreshold, ShowCenterLine, alertsOn, alertsMessage, alertsSound, alertsEmail, MaxBars, ShowInfo, ShowInfo_WindowNo, ShowInfo_X, ShowInfo_Y, ShowInfo_ColorLabel, ShowInfo_ColorSwing, ShowInfo_ColorUp, ShowInfo_ColorDown, 1, 0);
  PriceLow  = iCustom(NULL, 0, "ExtremeTMALine st2050 v1", TimeFrame, TMAPeriod, Price, ATRMultiplier, ATRPeriod, TrendThreshold, ShowCenterLine, alertsOn, alertsMessage, alertsSound, alertsEmail, MaxBars, ShowInfo, ShowInfo_WindowNo, ShowInfo_X, ShowInfo_Y, ShowInfo_ColorLabel, ShowInfo_ColorSwing, ShowInfo_ColorUp, ShowInfo_ColorDown, 2, 0);
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+  
  if (CountSell() == 0 && Bid >= PriceHigh)
  {
      ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, "ExtremeTMALine_Robot", Magic, 0, Red);
      if (ticket>0)
      {
       SL = NormalizeDouble(Bid + StopLoss*Point, Digits);
       
       if(OrderSelect(ticket, SELECT_BY_TICKET))
          if(!OrderModify (ticket, OrderOpenPrice(), SL, 0, 0))
          Print ("Ошибка модификации ордера на продажу!!!"); 
      } else Print ("Ошибка открытия ордера на продажу!!!");
        
  }
//+------------------------------------------------------------------+  
  if(Ask <= PriceLow && CountSell() > 0)
  {
    for(int i = OrdersTotal()-1; i >= 0; i--)
    {
      if (OrderSelect (i, SELECT_BY_POS, MODE_TRADES))
      {
        if (OrderMagicNumber() == Magic && OrderType() == OP_SELL)
            if (!OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Black))
            Print ("Ошибка закрытия ордера на продажу!!!");  
      } else Print ("Ошибка открытия ордера на продажу!!!");
    }
  }  
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+  
  
  if (CountBuy() == 0 && Ask <= PriceLow)
  {
      ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, "ExtremeTMALine_Robot", Magic, 0, Blue);
      if (ticket>0)
      {
       SL = NormalizeDouble(Ask - StopLoss*Point, Digits);
       
       if(OrderSelect(ticket, SELECT_BY_TICKET))
          if (!OrderModify (ticket, OrderOpenPrice(), SL, 0, 0))
          Print ("Ошибка модификации ордера на покупку!!!");  
      } else Print ("Ошибка открытия ордера на покупку!!!");
        
  }
//+------------------------------------------------------------------+  
   if(Bid >= PriceHigh && CountBuy() > 0)
  {
    for(int i = OrdersTotal()-1; i >= 0; i--)
    {
      if (OrderSelect (i, SELECT_BY_POS, MODE_TRADES))
      {
        if (OrderMagicNumber() == Magic && OrderType() == OP_BUY)
           if(!OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Green))
           Print ("Ошибка закрытия ордера на покупку!!!"); 
      } else Print ("Ошибка открытия ордера на покупку!!!");
    }
  }
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int CountSell()
{
 int count = 0;
     for (int trade = OrdersTotal()-1; trade>=0; trade--)
     {
          if(OrderSelect(trade, SELECT_BY_POS, MODE_TRADES))
          {
             if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL)
             count++;
          }
     }
     return (count);
}
//+------------------------------------------------------------------+
int CountBuy()
{
 int count = 0;
     for (int trade = OrdersTotal()-1; trade>=0; trade--)
     {
          if(OrderSelect(trade, SELECT_BY_POS, MODE_TRADES))
          {
             if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY)
             count++;
          }
     }
     return (count);
}
//+------------------------------------------------------------------+
 
Domovoi44:

Sin embargo, ¡hola!

¡¿Puede usted aconsejar sobre esta situación: basado en TMA_Fair abro en el límite y cierro en el límite opuesto, pero no se cierra en el otro límite! ¿Dónde está el error en el código?

Si se sigue el indicador de cerca, se puede ver que redibuja 10 o más barras hacia atrás. Esta es la razón.

 
Alexey Viktorov:

Si sigue el indicador de cerca, se dará cuenta de que vuelve a trazar 10 barras o más hacia atrás. Esta es la razón.

Ehhhhhhh hombre!!! seguiré indagando) Gracias por la ayuda!!!
 
¿Puede decirme si existe un indicador de divergencia de volumen de foso para MT-4?
 

Buenas tardes, ¡por favor, ayuda! Estoy tratando de escribir mucho control de cuentas. Si mi cuenta se convierte en +10% de beneficio, el lote se duplica. Si es +20%, entonces lote*4. Si en mi cuenta disminuye, entonces respectivamente disminuye el tamaño del lote. No entiendo cómo hacer que Lots_New tome un nuevo valor en cada nueva operación.

double Bal= AccountBalance();
double GetLots()
{
double Lots_New;
double Lots = 0.1;
   
   if(Bal <=AccountBalance()+0.1*AccountBalance()){
   Lots_New=Lots*2;
   }
   if(Bal >=AccountBalance()+0.1*AccountBalance()){
   Lots_New=Lots/2;
   }
   if(Bal ==AccountBalance()){
   Lots_New=Lots;
   }

Alert("Lot new= ",Lots_New);
return (Lots_New);
}
Razón de la queja: