Overview of the VR-Engulfing Pattern Indicator
This script is designed to act as an automated surveillance tool for traders who want to identify specific price action movements across multiple timeframes simultaneously. Its primary purpose is to detect "Engulfing Patterns"—a classic technical analysis signal where one candle completely overlaps or "engulfs" the body of the previous candle, suggesting a significant shift in market momentum.
How the Logic Works
Multi-Timeframe Monitoring
Instead of just looking at the chart you currently have open, this script monitors nine different timeframes at once. It ranges from very short-term fluctuations (1-minute charts) to long-term trends (monthly charts). This allows a trader to see how the market is behaving on various scales without having to manually switch between different tabs or windows.
The Detection Process
The script constantly scans the most recent completed candles on each of these nine timeframes. It specifically looks at the relationship between the current finished candle and the one immediately preceding it.
To identify a pattern, the logic checks for two specific scenarios:
- Bearish Engulfing (Selling Pressure): The script looks for a situation where a previous candle closed higher than it opened (an upward move), but the very next candle opened lower and closed even further down, effectively "swallowing" the previous price action.
- Bullish Engulfing (Buying Pressure): Conversely, it looks for a situation where a previous candle closed lower than it opened (a downward move), but the next candle opened higher and finished even higher, showing that buyers have taken control of the price.
Real-Time Notifications
The logic is designed to be proactive. The moment the script identifies one of these patterns on any of the monitored timeframes, it triggers an instant alert. These alerts notify the user of:
- The specific timeframe where the pattern occurred (e.g., 15-minute, Hourly, Daily).
- The type of movement detected (Bullish or Bearish).
- The exact time the signal was confirmed.
Summary for the User
Essentially, this tool acts as an automated "lookout." It watches nine different markets at once, scanning for specific visual cues that indicate a potential reversal or continuation in price. When it finds these significant movements, it alerts you immediately so you can make informed trading decisions without having to manually monitor every single timeframe yourself.
//+------------------------------------------------------------------+
//| VR-Engulfing Pattern.mq4 |
//| Copyright 2015, Trading-go Project. |
//| http://trading-go.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Trading-go Project."
#property link "http://trading-go.ru"
#property version "1.00"
#property strict
#property indicator_chart_window
//---
datetime masstime[9]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
for(int i=0; i<=8; i++)
{
datetime tim=iTime(Symbol(),TimeFrame(i),0);
if(masstime[i]==NULL)
{
masstime[i]=tim;
continue;
}
if(masstime[i]!=tim)
{
masstime[i]=tim;
double op1=iOpen(Symbol(),TimeFrame(i),1);
double cl1 = iClose(Symbol(),TimeFrame(i),1);
double op2 = iOpen (Symbol(),TimeFrame(i),2);
double cl2 = iClose(Symbol(),TimeFrame(i),2);
if(op2<cl2 && op1>cl1 && op2>cl1)
Alert(EnumToString(TimeFrame(i))," Engulfing pattern Bears ",TimeToString(tim));
if(op2>cl2 && op1<cl1 && op2<cl1)
Alert(EnumToString(TimeFrame(i))," Engulfing pattern Bulls ",TimeToString(tim));
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
ENUM_TIMEFRAMES TimeFrame(int z)
{
ENUM_TIMEFRAMES time=NULL;
switch(z)
{
case 0:time =PERIOD_M1; break;
case 1:time =PERIOD_M5; break;
case 2:time =PERIOD_M15; break;
case 3:time =PERIOD_M30; break;
case 4:time =PERIOD_H1; break;
case 5:time =PERIOD_H4; break;
case 6:time =PERIOD_D1; break;
case 7:time =PERIOD_W1; break;
case 8:time =PERIOD_MN1; break;
default : time=PERIOD_CURRENT;
}
return time;
}
//+------------------------------------------------------------------+
Comments