wlxBWACsig
Download scriptThis script is designed as a visual trading tool for the MetaTrader platform, specifically created to identify potential trend reversals or momentum shifts by analyzing price action patterns. Instead of following standard price movements directly, it uses a secondary calculation—the Accumulation/Distribution (AC) indicator—to determine the underlying strength behind those movements.
How the Logic Works
The script scans historical price data and identifies specific "turning points" based on three distinct mathematical conditions. When these conditions are met, the script places a visual arrow on your chart to signal a potential shift in market direction.
1. The Foundation: Accumulation/Distribution (AC) The tool looks at the values of the AC indicator over a 5-bar sequence. It evaluates how much "volume" or "momentum" is being accumulated relative to the price. By looking at five consecutive bars, it can see if the strength of the trend is accelerating, decelerating, or changing polarity (switching from positive to negative).
2. Identifying Upward Signals (Bullish Potential) The script looks for specific scenarios where the price might be preparing for an upward move. It flags these when:
- The momentum values are consistently rising across multiple bars.
- There is a significant "crossover" where the indicator flips from negative to positive while simultaneously showing an increase in strength.
- It detects a specific sequence where the momentum has been dropping but suddenly begins a sharp, structured recovery.
3. Identifying Downward Signals (Bearish Potential) Conversely, the tool looks for signs that a downward move is forming. It flags these when:
- The momentum values are consistently falling across multiple bars.
- The indicator flips from positive to negative while losing strength.
- It identifies a sequence where momentum has been rising but suddenly hits a peak and begins a structured decline.
Visual Representation
When the script detects one of these patterns, it plots an arrow on the chart:
- Upward Signals: An arrow appears slightly above the high price of the candle.
- Downward Signals: An arrow appears slightly below the low price of the candle.
User Customization
The logic includes a "buffer" setting (the updown parameter). This allows you to control exactly how far away from the candle's high or low the arrows are placed, ensuring they remain clearly visible and do not overlap with the price bars themselves.
In summary, this tool acts as a momentum filter. It ignores simple price movements and only highlights moments where the underlying "accumulation" of the market shows a clear, mathematically significant change in direction.
//+------------------------------------------------------------------+
//| wlxBWACsig.mq4 |
//| Copyright © 2005 B.Williams, coding wellx |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005 B.Williams, coding wellx"
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 MediumBlue
#property indicator_color2 HotPink
//---- input parameters
extern int updown=8;
//---- buffers
double BWACup[];
double BWACdown[];
int pos=0;
double AC1,AC2,AC3,AC4,AC5;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,119);
SetIndexBuffer(0,BWACup);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,119);
SetIndexBuffer(1,BWACdown);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int cbars=IndicatorCounted();
if (cbars<0) return(-1);
if (cbars>0) cbars--;
//---- TODO: add your code here
if (cbars > (Bars-40)) pos=(Bars-40);
else pos=cbars;
// pos=10;
while (pos > 0)
{
BWACup[pos]=NULL;
BWACdown[pos]=NULL;
AC1=iAC(NULL,0,pos);
AC2=iAC(NULL,0,pos+1);
AC3=iAC(NULL,0,pos+2);
AC4=iAC(NULL,0,pos+3);
AC5=iAC(NULL,0,pos+4);
if (((AC4>0 && AC3>0 && AC2>0 && AC1>0) && (AC4>AC3 && AC2>AC3 && AC1>AC2)) ||
((AC4<0 && AC3<0 && AC2<0 && AC1>0) && (AC4>AC3 && AC2>AC3 && AC1>AC2)) ||
((AC5<0 && AC4<0 && AC3<0 && AC2<0 && AC1<0) &&
(AC5>AC4 && AC4<AC3 && AC3<AC2 && AC2<AC1)))
BWACup[pos]=(High[pos]+updown*Point) ;
if (((AC4<0 && AC3<0 && AC2<0 && AC1<0) && (AC4<AC3 && AC2<AC3 && AC1<AC2)) ||
((AC4>0 && AC3>0 && AC2>0 && AC1<0) && (AC4<AC3 && AC2<AC3 && AC1<AC2)) ||
((AC5>0 && AC4>0 && AC3>0 && AC2>0 && AC1>0) &&
(AC5<AC4 && AC4>AC3 && AC3>AC2 && AC2>AC1)))
BWACdown[pos]=(Low[pos]-updown*Point) ;
pos--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments