[¡Archivo!] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen de largo. No puedo ir a ningún sitio sin ti - 4. - página 121

 
mahla:

¿dónde añadir trailing stop y breakeven de salida? y no aumenta el lote cuando se aumenta el depósito

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

En el asesor

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

lote de la función increase...... es probablemente mejor cambiar

ejemplo:

extern double Lots               = 0.1;
extern double MaximumRisk        = 0.02;
extern double DecreaseFactor     = 3;
//////
//+------------------------------------------------------------------+
//| Calculate optimal lot size                                       |
//+------------------------------------------------------------------+
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//---- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }
//---- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }

Mira Moving Average.mq4

 

Me puedes decir por favor como usar las bandas de bollinger para el momentum y no para el precio, lo he intentado así:

BandOPeriodT - variable externa, periodo de las bandas de bollinger.

MomentumPeriodT - período de impulso, respectivamente.

BandOBottom=iBands (NULL,0,BandOPeriodT,1,0,iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0),MODE_LOWER,0);

y también así:

MomO=iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0); - variable interna que devuelve el valor

BandOBottom=iBands(NULL,0,BandOPeriodT,1,0,MomO,MODE_LOWER,0); - la variable debe devolver el valor de la línea Bollinger inferior para el valor de la variable anterior.

Además, ¿estoy en lo cierto al pensar que MODE_LOWER significa que obtengo el valor de la línea BOLLINGER en una variable? Si no es así, ¿cómo lo consigo exactamente?

 
Ovari:

Me puedes decir por favor como usar las bandas de bollinger para el momentum y no para el precio, lo he intentado así:

BandOPeriodT - variable externa, periodo de las bandas de bollinger.

MomentumPeriodT - período de impulso, respectivamente.

BandOBottom=iBands (NULL,0,BandOPeriodT,1,0,iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0),MODE_LOWER,0);

y también así:

MomO=iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0); - variable interna que devuelve el valor

BandOBottom=iBands(NULL,0,BandOPeriodT,1,0, MomO,MODE_LOWER,0); - la variable debe devolver el valor de la línea Bollinger inferior para el valor de la variable anterior.

Además, ¿estoy en lo cierto al pensar que MODE_LOWER significa que obtengo el valor de Bollinger BOW en una variable? Si no es así, ¿cómo lo consigo exactamente?


Ver trailer - allí Bandas para RSI - hacer lo mismo para Momentum.

Descripción - en el registro - ver código al principio.

Archivos adjuntos:
 
Gracias, porque soy muy nuevo, y tampoco soy muy programador:)
 

¡Hola! ¡Por favor, ayuda! Quiero probar el indicador PVT:

double PVT = iCustom(NULL,240,"PVT",PRICE_CLOSE,1,1)

¿Pueden decirme qué es lo que falta?

Dice: 2012.05.14 19:34:46 No se puede abrir el archivo 'C:\NProgram Files\Alpari NZ MT4\experts\indicators\PVT.ex4' en el EURUSD,H4

Gracias.

 
mahla:

¿dónde añadir trailing stop y breakeven de salida? y no aumenta el lote cuando se aumenta el depósito

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int Comprar (int StopLoss = 0, int TakeProfit = 0, double Lote = 0)

{

int Billete = 0;

doble SL = 0;

doble TP = 0;

double VolumenLote = 0;

RefreshRates();

si (StopLoss != 0)

SL = NormalizeDouble(Bid-StopLoss*Point, Digits);

si (TakeProfit != 0)

TP = NormalizeDouble(Ask+TakeProfit*Point, Digits);

si (Lote == 0)

VolumeLot = GetLot ();

si no

VolumenLote = Lote;

Ticket = OrderSend(Symbol(), OP_BUY, VolumeLot, NormalizeDouble(Ask, Digits), 20, SL, TP, NULL, AccountNumber(), 0, Green);

si (Ticket == -1)

{

return (GetLastError ();

}

si no

{

volver (Ticket);

}

}

int Vender (int StopLoss = 0, int TakeProfit = 0, double Lote = 0)

{

int Billete = 0;

doble SL = 0;

doble TP = 0;

double VolumenLote = 0;

RefreshRates();

si (StopLoss != 0)

SL = NormalizeDouble(Ask+StopLoss*Point, Digits);

si (TakeProfit != 0)

TP = NormalizeDouble(Bid-TakeProfit*Point, Digits);

si (Lote == 0)

VolumeLot = GetLot ();

si no

VolumenLote = Lote;

Ticket = OrderSend(Symbol(), OP_SELL, VolumeLot, NormalizeDouble(Bid, Digits), 20, SL, TP, NULL, AccountNumber(), 0, Red);

si (Ticket == -1)

return (GetLastError ();

si no

volver (Ticket);

}

double GetLot ()

{

en el lote;

si (AccountBalance()>=300) lote=0,01;

si (AccountBalance()>=500) lote=0,02;

si (AccountBalance()>=800) lote=0,03;

retorno (lote);

}

Supongamos que la posición abierta ya ha sido seleccionada y sabemos con certeza que esta posición está abierta
para el símbolo al que está vinculado el Asesor Experto. También se supone que el valor del trailing stop
en pips está contenido en la variable TrailingStop.

   int err;
   if (OrderType() == OP_BUY)
     {
       // позиция на покупку
       if ((Bid-OrderOpenPrice())>=(TrailingStop*Point))
         {
           // выставляем Stop Loss
           if (OrderModify(OrderTicket(), OrderOpenPrice(), Bid-TrailingStop*Point,
                                    OrderTakeProfit(), 0))
             Print("#", OrderTicket(),": trailing stop ", Bid-TrailingStop*Point);
           else
             {
              err = GetLastError();
              Print("#", OrderTicket(),": trailing stop error ", err);
             }
         }
     }
   else
     {
       // позиция на продажу
       if ((OrderOpenPrice()-Ask)>=(TrailingStop*Point))
         {
           // выставляем Stop Loss
           if (OrderModify(OrderTicket(), OrderOpenPrice(), Ask+TrailingStop*Point,
                                    OrderTakeProfit(), 0))
             Print("#", OrderTicket(),": trailing stop ", Ask+TrailingStop*Point);
           else
             {
              err = GetLastError();
              Print("#", OrderTicket(),": trailing stop error ", err);
             }
         }
     }
La función OrderProfit() devuelve el beneficio de la orden seleccionada mediante la función OrderSelect().

Supongamos que queremos calcular el beneficio que hemos obtenido de las posiciones cerradas.

   int profit = 0;
   int pos;
   for ( pos = 0; pos<HistoryTotal(); pos++ )
     {
       // выделим позицию
       if (OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) == true)
         {
           // это не отложенный ордер?
           if ( OrderType() <= OP_SELL) profit += OrderProfit();            
         }
       else
           Print("Ошибка ", GetLastError(), " при выделении ордера ", OrderTicket());
     }
   Print("Суммарный профит по закрытым позициям = ", profit);
Y el código completo que calcula el beneficio para todas las posiciones cerradas,
que se abren hoy, será:

   //---- вычислим начало дня - переменная day_start
   int c_time = CurTime();  
   datetime day_start;
   day_start=c_time-TimeHour(c_time)*60*60-TimeMinute(c_time)*60-TimeSeconds(c_time);
   //---- подсчитаем прибыль
   int profit = 0;
   int pos;
   for ( pos = 0; pos<HistoryTotal(); pos++ )
     {
       // выделим позицию
       if (OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) == true)
         {
           // это не отложенный ордер?
           if ( OrderType() <= OP_SELL)
             {
               // ордер был открыт сегодня?
               if (OrderOpenTime()>=day_start) profit += OrderProfit();
             }
         }
       else
           Print("Ошибка ", GetLastError(), " при выделении ордера ", OrderTicket());
     }
   Print("Суммарный профит по закрытым позициям = ", profit);
 
mahla:

Y no aumenta el tamaño del lote cuando se aumenta el depósito

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Quizá falte algo más en el código:

doble OrderLots( )
Devuelve el número de lotes de la orden seleccionada.
El pedido debe ser preseleccionado mediante OrderSelect().
Ejemplo:
 if(OrderSelect(10,SELECT_BY_POS)==true) Print("lotes para el pedido 10 ",OrderLots()); else Print("OrderSelect() ha devuelto un error - ",GetLastError());
 
borilunad:

¡Hola! ¡Por favor, ayuda! Quiero probar el indicador PVT:

¿Pueden decirme qué es lo que falta?

Dice: 2012.05.14 19:34:46 No se puede abrir el archivo 'C:\NProgram Files\Alpari NZ MT4\experts\indicators\PVT.ex4' en el EURUSD,H4

Gracias.

Falta el indicador PVT propiamente dicho (¿está seguro de que tiene uno?).
 
alsu:
Falta el indicador PVT propiamente dicho (¿está seguro de que tiene uno?).

Por supuesto que lo tengo y está compilado y eh4. Y ponlo también en el gráfico. ¿Tal vez escribí algo mal? Gracias.
 

borilunad:

Por supuesto, hay tanto compilado como eh4. Y ponlo en el gráfico. ¿Tal vez escribí algo mal? Gracias.


Sólo tiene UN búfer, ¿qué sentido tiene que un EA llame a un segundo búfer inexistente?

Razón de la queja: