Mira cómo descargar robots gratis
¡Búscanos en Facebook!
Pon "Me gusta" y sigue las noticias
¿Es interesante este script?
Deje un enlace a él, ¡qué los demás también lo valoren!
¿Le ha gustado el script?
Evalúe su trabajo en el terminal MetaTrader 5
Visualizaciones:
24
Ranking:
(3)
Publicado:
candel 2.mq5 (10.74 KB) ver
MQL5 Freelance ¿Necesita un robot o indicador basado en este código? Solicítelo en la bolsa freelance Pasar a la bolsa

Detección de patrones alcistas

  • Patrón de 3 barras:

    • 1ª vela: Verde con cuerpo grande (pico alcista).

    • 2ª vela: Roja (retroceso).

    • 3ª vela: Verde con gran cuerpo (pico alcista).

  • Cuando aparece este patrón, se crea una zona.

Creación de la zona

  • Se traza un rectángulo azul a partir del rango alto/bajo de las 3 velas.

  • Se traza una línea de entrada horizontal verde lima en el precio de apertura de la vela central (2ª).

  • La línea se extiende hacia el futuro hasta que el precio vuelva.


ENTRADAS EXPLICADAS

mq5
input color BoxColor = clrBlue;              // Color de la caja del patrón de 3 velas
input color EntryLineColor = clrLime;        // Color de la línea de entrada
input ENUM_LINE_STYLE EntryLineStyle = STYLE_SOLID; // Estilo de la línea de entrada
input int BoxWidth = 2;                      // Anchura del borde de la caja
input int EntryLineWidth = 2;                // Anchura de la línea de entrada
input int EntryLineLength = 200;             // Hasta dónde se extiende la línea de mitigación
```
These inputs let you fully control the style of the box and entry line.


IDEA PRINCIPAL

Buscamos un patrón alcista de 3 velas

1. Primera vela - alcista fuerte (pico)

2. Segunda vela - retroceso bajista

3. Tercera vela - fuerte pico alcista de nuevo


Cuando esto aparece, dibujamos

- Una caja alrededor del patrón

- Una línea horizontal en la apertura de la 2ª vela (punto de entrada)

Una vez que el precio vuelve a esa línea ("mitigación"), acortamos la línea y evitamos volver a dibujarla.


ESTRUCTURAS DE DATOS

struct PatternInfo {
  datetime time;   // Hora del patrón
  double entry;    // Precio de entrada (apertura de la 2ª vela)
  double high;     // Máximo de las 3 velas
  double low;      // Mínimo de las 3 velas
  bool mitigated;  // ¿Ha vuelto el precio al nivel de entrada?
};

CArrayObj activePatterns;
```
We use a struct `PatternInfo` to track each valid pattern and store it in an array. This helps avoid repeated processing.

FUNCIÓN ON INIT

int OnInit() {
  IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
  ArrayInitialize(activePatterns, 0);
  return INIT_SUCCEEDED;
}
```
We set the indicator precision and prepare our array.


DETECCIÓN DEL PATRÓN (EN CADA TICK)

```mq5
for (int i = limit - 3; i >= 0; i--) {
```
We loop through candles and look 3 bars back.

```mq5
if (isBullish(i+2) && isBearish(i+1) && isBullish(i))
```
We check if the last 3 candles fit the spike pattern: Green-Red-Green.

```mq5
double high = MathMax(MathMax(High[i], High[i+1]), High[i+2]);
double low = MathMin(MathMin(Low[i], Low[i+1]), Low[i+2]);
double entry = Open[i+1];
```
We extract high/low for box and the entry level from the 2 nd (middle) candle.

```mq5
PatternInfo *pattern = new PatternInfo;
pattern.time = Time[i];
pattern.entry = entry;
pattern.high = high;
pattern.low = low;
pattern.mitigated = false;
```
Create and add this pattern to our list.
DIBUJAR CUADRO Y LÍNEA
```mq5
string boxName = "Box_" + IntegerToString(Time[i]);
ObjectCreate(0, boxName, OBJ_RECTANGLE, 0, Time[i+2], high, Time[i], low);
```
Draw the rectangle (box) from the 3-candle pattern.

```mq5
string lineName = "EntryLine_" + IntegerToString(Time[i]);
ObjectCreate(0, lineName, OBJ_TREND, 0, Time[i], entry, Time[i] + PeriodSeconds() * EntryLineLength, entry);
```
Draw the entry line from the 2 nd candle’s open forward in time.

COMPROBACIÓN DE MITIGACIÓN (EN CADA TICK)

Loop through all patterns:
```mq5
for (int p = 0; p < activePatterns.Total(); p++) {
  PatternInfo *pt = (PatternInfo*)activePatterns.At(p);
```
If not already mitigated, check:
```mq5
if (!pt.mitigated && Low[0] <= pt.entry)
```
If current price hits the entry level:
```mq5
pt.mitigated = true;
ObjectDelete("EntryLine_" + IntegerToString(pt.time));
```
Delete original long line.

```mq5
ObjectCreate(0, "MitigatedLine_" + IntegerToString(pt.time), OBJ_TREND, 0,
pt.time, pt.entry,
Time[0], pt.entry);
```
Create a short line showing where mitigation happened.
HELPER FUNCTIONS

###  Check Bullish/Bearish:
```mq5
bool isBullish(int i) {
  return Close[i] > Open[i];
}

bool isBearish(int i) {
  return Close[i] < Open[i];
}

Este indicador es simple pero potente:

  • Detecta el comportamiento real de picos en Boom
  • Visualiza entradas de dinero inteligente
  • Detecta automáticamente la mitigación

Ya puedes probarlo en vivo en Boom 500 o Boom 1000.


gracias comenta si quieres preguntar o compartir .


Traducción del inglés realizada por MetaQuotes Ltd.
Artículo original: https://www.mql5.com/en/code/61749

Moving Price Line Indicator MT5 Moving Price Line Indicator MT5

Este simple indicador es para averiguar fácilmente cuando el precio alcanza un momento determinado en cualquier vela o marco de tiempo.

Creat Button Close BuySell On Chart Creat Button Close BuySell On Chart

Script MQL5 para MetaTrader 5 que añade dos botones para cerrar todas las posiciones de compra o venta para el símbolo actual.

CBitBuffer Class - Data Serialization in MQL5 CBitBuffer Class - Data Serialization in MQL5

Una clase para leer y escribir bits individuales o secuencias de bits desde y hacia una memoria intermedia.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

El indicador Acceleration/Deceleration (AC, Aceleración/Desaceleración) mide la aceleración y la desaceleración de la fuerza impulsora del mercado.