Redactaré un asesor de forma gratuita - página 168

 
Aesen #:
Hey Anton puede ayudarme a hacer mi On Balance Volume Divergence EA más consistentemente rentable? Tal vez cambiar algunas cosas en el código o añadir algunas características y hacerlo mejor por favor. el código es totalmente de trabajo, pero no estoy satisfecho con los resultados que estoy recibiendo de ella
#include <trade/trade.mqh>

input double Lots = 0.01;
input int VerificationCandles = 20;
input int TimeGapCandles = 5;

input int TpPoints = 1000;
input int SlPoints = 1000;

int totalBars;
int handleOBV;

datetime timeLow1, timeLow2, timeHigh1, timeHigh2;
double low1, low2, high1, high2;
datetime timeLowOBV1, timeLowOBV2, timeHighOBV1, timeHighOBV2;
double lowObv1, lowObv2, highObv1, highObv2;

int OnInit(){
   totalBars = iBars(_Symbol,PERIOD_CURRENT);
   
   handleOBV = iOBV(_Symbol,PERIOD_CURRENT,VOLUME_TICK);

   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){

}

void OnTick(){
   int bars = iBars(_Symbol,PERIOD_CURRENT);
   if(totalBars != bars){
      totalBars = bars;
      
      datetime newTime = 0;
      double newlow = 0, newhigh = 0;
      findHighLow(newlow,newhigh,newTime);
      
      datetime newTimeObv = 0;
      double newlowOBV = 0, newhighOBV = 0;      
      findHighLowOBV(newlowOBV,newhighOBV,newTimeObv); 
      
      if(newlow != 0 || newlowOBV != 0){
         if(newlow != 0){
            low2 = low1;
            timeLow2 = timeLow1;
            low1 = newlow;
            timeLow1 = newTime;            
         }   
         if(newlowOBV != 0){
            lowObv2 = lowObv1;
            timeLowOBV2 = timeLowOBV1;
            lowObv1 = newlowOBV;
            timeLowOBV1=newTime;
         }
         
         ulong timeGap = TimeGapCandles * PeriodSeconds(PERIOD_CURRENT);
         if(low1 < low2 && lowObv1 > lowObv2 && (ulong)MathAbs(timeLow1-timeLowOBV1) < timeGap && (ulong)MathAbs(timeLow2-timeLowOBV2) < timeGap){
            Print(__FUNCTION__," > New Buy Signal...");
            
            double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
            ask = NormalizeDouble(ask,_Digits);
            
            double tp = ask + TpPoints * _Point;
            tp = NormalizeDouble(tp,_Digits);
            
            double sl = ask - SlPoints * _Point;
            sl = NormalizeDouble(sl,_Digits);
            
            CTrade trade;
            trade.Buy(Lots,_Symbol,ask,sl,tp);                 
         }
      } 
         
         if(newhigh != 0 || newhighOBV != 0){
            if(newhigh != 0){
               high2 = high1;
               timeHigh2 = timeHigh1;
               high1 = newhigh;
               timeHigh1 = newTime;
            }
            if(newhighOBV != 0){
               highObv2 = highObv1;
               timeHighOBV2 = timeHighOBV1;
               highObv1 = newhighOBV;
               timeHighOBV1 = newTimeObv;
            }
            
           ulong timeGap = TimeGapCandles * PeriodSeconds(PERIOD_CURRENT);
           if(high1 > high2 && highObv1 < highObv2 && (ulong)MathAbs(timeHigh1-timeHighOBV1) < timeGap && (ulong)MathAbs(timeHigh2-timeHighOBV2) < timeGap){
            Print(__FUNCTION__," > New Sell Signal...");
            
            double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
            bid = NormalizeDouble(bid,_Digits);
            
            double tp = bid - TpPoints * _Point;
            tp = NormalizeDouble(tp,_Digits);
            
            double sl = bid + SlPoints * _Point;
            sl = NormalizeDouble(sl,_Digits);
            
            CTrade trade;
            trade.Sell(Lots,_Symbol,bid,sl,tp);                  
         }   
      }
   }             
} 
     
void findHighLow(double &newlow, double &newhigh, datetime &newTime){
   int indexBar = VerificationCandles+1;
   double high = iHigh(_Symbol,PERIOD_CURRENT,indexBar);
   double low = iLow(_Symbol,PERIOD_CURRENT,indexBar);
   datetime time = iTime(_Symbol,PERIOD_CURRENT,indexBar);
      
   bool isHigh = true, isLow = true;
   for(int i = 1; i <= VerificationCandles; i++){
       double highLeft = iHigh(_Symbol,PERIOD_CURRENT,indexBar+i);
       double highRight = iHigh(_Symbol,PERIOD_CURRENT,indexBar-i);
       if(highLeft > high || highRight > high) isHigh = false;
         
       double lowLeft = iLow(_Symbol,PERIOD_CURRENT,indexBar+i);
       double lowRight = iLow(_Symbol,PERIOD_CURRENT,indexBar-i);
       if(lowLeft < low || highRight < low) isLow = false;
          
       if(!isHigh && !isLow) break;
       if(i == VerificationCandles){
         if(isHigh){
            Print(__FUNCTION__," > Found a new high (",DoubleToString(high,_Digits),") at ",time,"...");
            ObjectCreate(0,"High@"+TimeToString(time),OBJ_ARROW_SELL,0,time,high);
            newhigh = high;
            newTime = time;  
         }            
         if(isLow){
            Print(__FUNCTION__," > Found a new low (",DoubleToString(low,_Digits),") at ",time,"...");
            ObjectCreate(0,"Low@"+TimeToString(time),OBJ_ARROW_BUY,0,time,low); 
            newlow = low;
            newTime = time;               
         }
      }   
   }
}
   
void findHighLowOBV(double &newlow, double &newhigh, datetime &newTime){
   int indexBar = VerificationCandles;
   double OBV[];
   if(CopyBuffer(handleOBV,0,1,VerificationCandles*2+1,OBV) < VerificationCandles *2+1) return;
   
   double value = OBV[indexBar];
   datetime time = iTime(_Symbol,PERIOD_CURRENT,indexBar+1);
      
   bool isHigh = true, isLow = true;
   for(int i = 1; i <= VerificationCandles; i++){
       double valLeft = OBV[indexBar+i];
       double valRight = OBV[indexBar-i];
       if(valLeft > value || valRight > value) isHigh = false;      
       if(valLeft < value || valRight < value) isLow = false;
          
       if(!isHigh && !isLow) break;
       if(i == VerificationCandles){
         if(isHigh){
            Print(__FUNCTION__," > Found a new high (",DoubleToString(value,_Digits),") at ",time,"...");
            ObjectCreate(0,"High@"+TimeToString(time),OBJ_ARROW_SELL,1,time,value);
            newhigh = value;
            newTime = time;    
         }
         if(isLow){
            Print(__FUNCTION__," > Found a new low (",DoubleToString(value,_Digits),") at ",time,"...");
            ObjectCreate(0,"Low@"+TimeToString(time),OBJ_ARROW_BUY,1,time,value);
            newlow = value;
            newTime = time;    
         }
      }   
   }
} 
Archivos adjuntos:
 
Aesen #:

Algunas características que tenía en mente que sería bueno tener en el EA es líneas de tendencia para cuando se forma la divergencia oculta y regular en los gráficos de precios y el indicador obv, tal vez un buen trailing stop, también entradas que se ven algo como esto:


Variable Valor

Divergencia Regular Verdadero/Falso

Divergencia oculta Verdadero/Falso

Indicador Trendlines Verdadero/Falso

Líneas de tendencia del precio Verdadero/Falso


Estoy tratando de hacer que este EA de Divergencia OBV siga esta hoja de trucos de Divergencia que obtuve de babypips.com:


Divergenciaalcista(reversión hacia arriba):

Precio en velas - Bajo inferior

Volumen en equilibrio - Baja más alta


Divergencia bajista (reversión a la baja):

Precio de las velas - Alto más alto

Volumen en balance - Alto más bajo


Divergenciaalcista oculta(continuación de la tendencia al alza):

Precio de las velas - Bajo más alto

Volumen en equilibrio - Bajo inferior


Divergencia ocultabajista(continuación de la tendencia a labaja):

Precio de las velas - Alto inferior

Volumen de balance - Alto más alto

A New Approach to Interpreting Classic and Hidden Divergence. Part II
A New Approach to Interpreting Classic and Hidden Divergence. Part II
  • www.mql5.com
The article provides a critical examination of regular divergence and efficiency of various indicators. In addition, it contains filtering options for an increased analysis accuracy and features description of non-standard solutions. As a result, we will create a new tool for solving the technical task.
 
Aesen #:

Algunas características que tenía en mente que sería bueno tener en el EA es líneas de tendencia para cuando se forma la divergencia oculta y regular en los gráficos de precios y el indicador obv, tal vez un buen trailing stop, también las entradas que se ven algo como esto:


Variable Valor

Divergencia Regular Verdadero/Falso

Divergencia oculta Verdadero/Falso

Indicador Trendlines Verdadero/Falso

Líneas de tendencia del precio Verdadero/Falso


Estoy tratando de hacer que este EA de Divergencia OBV siga esta hoja de trucos de Divergencia que obtuve de babypips.com:


Divergenciaalcista(reversión hacia arriba):

Precio en velas - Bajo inferior

Volumen en equilibrio - Baja más alta


Divergencia bajista (reversión a la baja):

Precio de las velas - Alto más alto

Volumen en balance - Alto más bajo


Divergenciaalcista oculta(continuación de la tendencia al alza):

Precio de las velas - Bajo más alto

Volumen en equilibrio - Bajo inferior


Divergencia ocultabajista(continuación de la tendencia a labaja):

Precio de las velas - Alto inferior

Volumen en balance - Alto más alto

Otra característica que tenía en mente era que el EA apilará más operaciones si va a favor de la primera operación que coloca, si eso tiene sentido....


Por ejemplo, cuando el EA detecta una divergencia alcista y hay una señal de compra y se coloca la primera operación de compra, si la operación va a favor de la primera operación de compra que el EA colocó entonces el EA apilará más operaciones en la dirección de compra y viceversa si fuera una operación de venta.
 
Aesen #:

Otra característica que tenía en mente era que el EA apilará más operaciones si va a favor de la primera operación que coloca, si eso tiene sentido....


por ejemplo, cuando el EA detecta una divergencia alcista y hay una señal de compra y se coloca la primera operación de compra, si la operación va a favor de la primera operación de compra que el EA colocó entonces el EA apilará más operaciones en la dirección de compra y viceversa si fuera una operación de venta.
También puede incluir una estrategia de cobertura de recuperación de zona donde se inicia una primera operación digamos de compra con tamaño de lote 0.01, y cuando va en la dirección negativa con algunos pips, digamos por debajo de 30 pips, se activa una contra venta con un tamaño de lote más alto, digamos 0.02, donde si sigue bajando, las operaciones se cierran en un punto de equilibrio o un beneficio y el bucle se inicia de nuevo. Sin embargo, si la venta no funciona bien y el precio sube, se activa otra operación de compra con un tamaño de lote mayor, digamos 0,03, al mismo precio al que se inició la primera compra. si sigue subiendo y los resultados netos son de beneficio, el bucle cierra las operaciones con beneficio y vuelve a empezar. por lo tanto, el gap de 30 pips se fija y se denomina zona de recuperación, lo que lo hace rentable para las cuentas más altas al eliminar las pérdidas. Si esto es posible de programar
 
el script de código es para Mt5 no mt4
 

Hola. Por favor, escriba un EA para MT4:

Cierra todas las operaciones abiertas previamente de forma manual cuando la MA (con todos los ajustes disponibles de muwings) toca el precio actual. Nada más (¿es un EA semiautomático?).

 
torrr #:

Hola. Por favor, escriba un EA para MT4:

Cierra todas las operaciones abiertas cuando la MA (con todos los ajustes de muvinig disponibles) toca el precio actual. Nada más.

Hola, 

Lo acabo de hacer y no llegué a probarlo. Espero le funcione. 

Saludos. 

//+------------------------------------------------------------------+
//|                                                     Practica.mq4 |
//|                        Copyright 2022, Antonio Simón Del Vecchio |
//|                    https://www.mql5.com/es/users/simondelvecchio |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Antonio Simón Del Vecchio"
#property link      "https://www.mql5.com/es/users/simondelvecchio"
#property version   "1.00"
#property strict


input int Periodo = 50;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(OrdersTotal() > 0 && CruceMediaPrecio())
     {
      Cerrar();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Cerrar()
  {
   double Precio = 0;
   for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS))
        {
         if(OrderType() == OP_BUY)
            Precio = Bid;
         else
            Precio = Ask;
         if(!OrderClose(OrderTicket(), OrderLots(), Precio, 3, clrNONE))
            Print("Error al cerrar la órden: ", GetLastError());
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CruceMediaPrecio()
  {
   double Media = iMA(Symbol(), PERIOD_CURRENT, Periodo, 0, MODE_SMA, PRICE_CLOSE, 0);
   double Max = iHigh(Symbol(), PERIOD_CURRENT, 0);
   double Min = iLow(Symbol(), PERIOD_CURRENT, 0);
   if(Max > Media && Min < Media)
     {
      return(true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
 

Para: Antonio Simon Del Vecchio

Gracias. Soy un tonto... ¿Tengo quecrear un EA en el MetaEditor, insertar este código, compilarlo y ya está?

 
torrr #:

Para: Antonio Simon Del Vecchio

Gracias. Soy un tonto... ¿Tengo quecrear un EA en el MetaEditor, insertar este código, compilarlo y ya está?

Correcto. Al compilarlo, se va a generar el EA con el nombre que le hayas colocado a este archivo en el MetaEditor. 

Ahora pregunto yo de forma general para los que me puedan leer: así como compartí el código, es prohibido compartir el EA? me refiero al archivo .exe
 
"Acabo de cocinarlo y no he tenido tiempo de probarlo". ¿Y cómo se puede ejecutar un EA en el probador que sólo cierra posiciones?
Razón de la queja: