Padrão de 3 barras:
1ª vela: Verde com corpo grande (pico de alta).
2º candle: Vermelho (recuo).
3º candle: Verde com corpo grande (pico de alta).
Quando esse padrão aparece, uma zona é criada.
Um retângulo azul é desenhado a partir da faixa alta/baixa dos 3 candles.
Uma linha de entrada horizontal verde-limão é desenhada no preço de abertura do candle do meio (2º).
A linha se estende para o futuro até que o preço volte.
mq5 input color BoxColor = clrBlue; // Cor da caixa de padrão de 3 velas input color EntryLineColor = clrLime; // Cor da linha de entrada input ENUM_LINE_STYLE EntryLineStyle = STYLE_SOLID; // Estilo da linha de entrada input int BoxWidth = 2; // Largura da borda da caixa input int EntryLineWidth = 2; // Largura da linha de entrada input int EntryLineLength = 200; // Até onde a linha de atenuação se estende ``` These inputs let you fully control the style of the box and entry line.
IDEIA PRINCIPAL
Procuramos um padrão de alta de 3 candles
1. Primeira vela - forte alta (pico)
2. Segundo candle - retração de baixa
3. Terceiro candle - forte pico de alta novamente
Quando isso aparece, nós desenhamos:
- Uma caixa ao redor do padrão
- Uma linha horizontal na abertura do segundo candle (ponto de entrada)
Quando o preço retorna a essa linha ("atenuação"), cortamos a linha e evitamos redesenhá-la.
struct PatternInfo { datetime time; // Hora do padrão double entry; // Preço de entrada (abertura do segundo candle) double high; // Máxima mais alta das 3 velas double low; // Mínima mais baixa das 3 velas bool mitigated; // O preço retornou ao nível 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.
int OnInit() { IndicatorSetInteger(INDICATOR_DIGITS, _Digits); ArrayInitialize(activePatterns, 0); return INIT_SUCCEEDED; } ``` We set the indicator precision and prepare our array.
```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.
```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.
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];
}Esse indicador é simples, mas poderoso:
Agora você pode testá-lo ao vivo no Boom 500 ou no Boom 1000.
Traduzido do inglês pela MetaQuotes Ltd.
Publicação original: https://www.mql5.com/en/code/61749
Moving Price Line Indicator MT5
Esse indicador simples serve para descobrir facilmente quando o preço atinge um determinado momento em qualquer candle ou período de tempo.
Creat Button Close BuySell On Chart
Script MQL5 para o MetaTrader 5 que adiciona dois botões para fechar todas as posições de compra ou venda do símbolo atual.
CBitBuffer Class - Data Serialization in MQL5
Uma classe para leitura e gravação de bits individuais ou sequências de bits de e para um buffer.
Crash Spike Trade Pattern
Esse indicador detecta uma formação específica de pico de baixa em 3 velas