BearNakedPattern1
Download scriptThis technical script is designed to function as a visual trading assistant for MetaTrader users. It identifies specific price action opportunities by analyzing the relationship between three different market indicators: the CCI (Commodity Channel Index), a Moving Average, and Bollinger Bands.
Instead of just following one signal, the logic requires multiple conditions to align simultaneously before it marks a potential entry on your chart. Here is a breakdown of how the logic functions:
Core Mechanics
The script monitors the "momentum" and "volatility" of the market to spot moments where the price might be overextended and ready to reverse. It focuses on two primary scenarios:
1. Identifying Selling Opportunities (Bearish Signals)
For a potential sell signal to appear, the following conditions must be met:
- Overbought Momentum: The CCI indicator must exceed a pre-defined high threshold (indicating the market is moving up very quickly).
- Momentum Cooling: The CCI must cross back below its own Moving Average (suggesting the upward strength is starting to wane).
- Price Proximity: The price must be interacting with the Upper Bollinger Band. The script specifically checks if the price is either just inside or has pushed outside this upper boundary.
- Trend Confirmation: The script looks at recent price highs to ensure the current movement follows a specific structural pattern, ensuring it isn't just "noise."
- Distance Check: It verifies that the price isn't too far away from the band, aiming for a more precise entry point.
2. Identifying Buying Opportunities (Bullish Signals)
Conversely, for a potential buy signal to appear, the market must meet these criteria:
- Oversold Momentum: The CCI indicator must drop below a pre-defined low threshold (indicating the market is moving down aggressively).
- Momentum Recovery: The CCI must cross back above its own Moving Average (suggesting the downward pressure is easing).
- Price Proximity: The price must be interacting with the Lower Bollinger Band, either sitting just above it or having pushed below it.
- Trend Confirmation: Similar to the sell logic, the script validates the recent lows to confirm that the downward move has reached a significant point of exhaustion.
Visual Output
Once all these conditions are satisfied for a single candle, the script places an arrow on your chart:
- Red Arrows: Indicate potential areas to consider a Sell position.
- Dark Turquoise Arrows: Indicate potential areas to consider a Buy position.
Summary of Strategy
Essentially, this tool acts as a "confirmation filter." It ignores minor price fluctuations and only signals an entry when the market is technically overextended (via CCI), showing signs of losing steam (via the Moving Average), and hitting a significant volatility boundary (via Bollinger Bands). This multi-layered approach is designed to help traders find high-probability reversal points.
//+------------------------------------------------------------------+
//| BB_CCI_CrossOver.mq4 |
//| Daniel Vieira Costa |
//| seilatrader.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Daniel Vieira Costa"
#property link "seilatrader.blogspot.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkTurquoise
#property indicator_color2 Red
//--
extern int CCI_Periodo = 21;
extern double NivelCCI_MIN = -80;
extern double NivelCCI_MAX = 80;
extern int MM_Periodo = 14;
extern int BB_Periodo = 21;
extern int BB_Desvio = 2;
extern double PIP_DesvioMAX = 0.0010;
extern double PIP_Oscilacao = 0.0015;
//---
double compra[];
double venda[];
//--
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 228);
SetIndexBuffer(0, compra);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 230);
SetIndexBuffer(1, venda);
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// indicadores
double mm, cci, Range, AvgRange;
double CCI[];
double MM[];
double BB_UP[], BB_LOW[];
int i, barrasContadas, limite, Counter;
barrasContadas = IndicatorCounted();
if (barrasContadas < 0)
return(-1);
if (barrasContadas > 0)
barrasContadas--;
limite = Bars-barrasContadas;
// seto o tamanho das listas
ArraySetAsSeries(CCI, true);
ArrayResize(CCI, limite);
ArrayResize(MM, limite);
ArrayResize(BB_UP, limite);
ArrayResize(BB_LOW, limite);
i = limite;
while (i > 0)
{
Counter =0;
Range =0;
AvgRange =0;
for (Counter=i; Counter>=i+9; Counter--)
AvgRange=AvgRange+MathAbs(High[Counter]-Low[Counter]);
Range=AvgRange/10;
CCI[i] = iCCI(NULL, 0, CCI_Periodo, PRICE_WEIGHTED, i);
MM[i] = iMAOnArray(CCI, limite, MM_Periodo, 0, MODE_EMA, i);
BB_UP[i] = iBands(NULL, 0, BB_Periodo, BB_Desvio, 0, PRICE_WEIGHTED, MODE_UPPER, i);
BB_LOW[i]= iBands(NULL, 0, BB_Periodo, BB_Desvio, 0, PRICE_WEIGHTED, MODE_LOWER, i);
// primeiro verifica se CCI está acima do nivel positivo
if (CCI[i] > NivelCCI_MAX)
{
if (CCI[i] < MM[i])
// verifica se o preço está dentro da banda superior
if (High[i] <= BB_UP[i])
{
// verifica se a máxima é menor que a máxima anterior
// o motivo é para ratificar a confirmação da tendência
if (High[i+1] > High[i])
// verifica a distância entre a o preço máximo e a banda de bollinger
// só se posiciona se a distância for considerável, ou seja, não tão distante
if ((BB_UP[i] - High[i]) <= PIP_DesvioMAX)
venda[i] = High[i] + Range*0.10;
}
else
// quando o preço está fora da banda superior
if (High[i] >= BB_UP[i])
{
// verifica se a máxima é menor que a máxima anterior
// o motivo é para ratificar a confirmação da tendência
if (High[i+1] > High[i])
venda[i] = High[i] + Range*0.10;
}
}
else
// verifica se o nivel de CCI está abaixo da mínima
if (CCI[i] < NivelCCI_MIN)
{
if (CCI[i] > MM[i])
// quando o preço está dentro da banda inferior
if (Low[i] >= BB_LOW[i])
{
// verifica se a mínima é maior que a mínima anterior
// o motivo é para ratificar a confirmação da tendência
if (Low[i+1] < Low[i])
compra[i] = Low[i]- Range*0.10;
}
else
// quando o preço ainda se encontra fora da banda inferior
if (Low[i] <= BB_LOW[i])
{
if (Low[i+1] < Low[i])
compra[i] = Low[i]- Range*0.10;
}
}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments