Sub EliminarDuplicados()
Dim ws As Worksheet
Dim ultimaFila As Long
' Referencia a la hoja "Salida"
Set ws = ThisWorkbook.Sheets("Salida")
' Determinar la última fila con datos en la columna "A"
ultimaFila = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Definir el rango de datos incluyendo encabezados (asume que los datos empiezan en A1)
Dim rangoDatos As Range
Set rangoDatos = ws.Range("A1:F" & ultimaFila) ' Ajustar rango según las columnas
' Eliminar duplicados en el rango especificado
' Asumiendo que los duplicados se basan en todos los campos (columnas)
rangoDatos.RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6), Header:=xlYes
MsgBox "Duplicados eliminados exitosamente", vbInformation
End Sub
//+------------------------------------------------------------------+
ResponderEliminar//| HighLine_3.mq4 |
//| Indicador para encontrar 3 Highs alineados en una recta|
//+------------------------------------------------------------------+
#property indicator_chart_window
// Declarar color de la línea
color line_color = clrBlue;
//+------------------------------------------------------------------+
//| Función de inicialización |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Función principal del indicador |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
// Iterar sobre las velas desde la vela 1 (índice 1)
for(int i = 1; i < rates_total - 3; i++)
{
// Comprobar si hay 3 Highs alineados
if(CheckThreeHighs(i, high))
{
// Si los 3 Highs están alineados, dibujar la línea
DrawHighLine(i, i+1, i+2, high[i], high[i+1], high[i+2]);
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
//| Función para verificar si 3 Highs están alineados |
//+------------------------------------------------------------------+
bool CheckThreeHighs(int index, const double &high[])
{
// Calcular la pendiente de la recta que conecta los 3 Highs
double slope1 = (high[index+1] - high[index]) / (index+1 - index);
double slope2 = (high[index+2] - high[index+1]) / (index+2 - (index+1));
// Comprobar si las pendientes son iguales, permitiendo una tolerancia mínima
if(MathAbs(slope1 - slope2) > Point * 0.1)
return(false);
// Verificar que no haya ningún otro High que toque la recta
for(int j = index+3; j < Bars; j++)
{
double expected_high = high[index] + slope1 * (j - index);
if(MathAbs(high[j] - expected_high) < Point * 0.1)
return(false); // Otro High toca la recta
}
return(true);
}
//+------------------------------------------------------------------+
//| Función para dibujar la línea entre 3 Highs |
//+------------------------------------------------------------------+
void DrawHighLine(int index1, int index2, int index3, double high1, double high2, double high3)
{
string line_name = "HighLine_" + IntegerToString(index1);
if(ObjectFind(0, line_name) == -1)
{
ObjectCreate(0, line_name, OBJ_TREND, 0, Time[index1], high1, Time[index3], high3);
ObjectSetInteger(0, line_name, OBJPROP_COLOR, line_color);
ObjectSetInteger(0, line_name, OBJPROP_WIDTH, 2);
}
else
{
ObjectMove(0, line_name, 0, Time[index1], high1);
ObjectMove(0, line_name, 1, Time[index3], high3);
}
}