CandlesticksBW

Author: Vladimir
CandlesticksBW

This tool is designed to provide visual clarity on price charts by identifying and highlighting specific candlestick patterns based on the Bill Williams methodology. Instead of cluttering the screen with constant data, the script filters through market history to pinpoint high-probability price movements, making it easier for traders to spot potential trends at a glance.

How the Logic Works

The script operates by analyzing two primary momentum components—specifically the Alligator Oscillator (AO) and the Alligator Channel (AC). It compares the current values of these components against their previous states to determine the "strength" or "direction" of the market movement.

1. Identification of Trend Momentum The tool looks for specific conditions where momentum is actively moving in a consistent direction:

  • Bullish Momentum: When both the Alligator Oscillator and the Alligator Channel show an increase compared to the previous period, the script recognizes a potential upward move.
  • Bearish Momentum: Conversely, when both components show a decrease compared to the previous period, the script identifies a potential downward move.

2. Visual Filtering (Signal Mapping) The indicator does not display information for every single candle. It acts as a filter:

  • If the momentum conditions are met, the script captures the price data (the High, Low, Open, and Close prices) of that specific candle.
  • If the market is moving sideways or lacks clear momentum in either direction, the script ignores those candles entirely, leaving them blank on your chart.

3. Visual Representation Once a valid signal is identified, the tool maps these price points onto the chart using four distinct visual "buffers" (histograms):

  • Color Coding: It uses Lime Green to represent bullish (upward) signals and Orange Red to represent bearish (downward) signals.
  • Dynamic Mapping: Depending on whether a candle is "bullish" or "bearish" in its actual price action (comparing the Open to the Close), the tool intelligently assigns the High, Low, Open, and Close values to the corresponding visual colors. This ensures that the graphic representation accurately reflects the structure of the price bar.

Summary for the User

In simple terms, this script acts as a momentum filter. It scans the market history and highlights only those candles where "Alligator" momentum confirms a trend. By doing this, it helps you filter out the "noise" of a choppy market, allowing you to focus on clear, high-momentum price actions highlighted in green and red.

Indicators Used
Bill Williams Accelerator/Decelerator oscillatorBill Williams Awesome oscillator
Miscellaneous
Implements a curve of type %1
17 Views
1 Downloads
0 Favorites
CandlesticksBW
//+------------------------------------------------------------------+
//|                                                 CandlesticksBW.mq4 |
//|                                                         Vladimir |
//|                                         finance@allmotion.com.ua |
//+------------------------------------------------------------------+
// Ðàñêðàñêà ñâå÷åé ïî Âèëüÿìñó
#property copyright "Vladimir"
#property link      "finance@allmotion.com.ua"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 LimeGreen
#property indicator_color2 OrangeRed
#property indicator_color3 LimeGreen
#property indicator_color4 OrangeRed
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,0,1,LimeGreen);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,1,OrangeRed);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM,0,2,LimeGreen);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM,0,2,OrangeRed);
   SetIndexBuffer(3,ExtMapBuffer4);
//----
   //   SetIndexDrawBegin(0,10);
   //   SetIndexDrawBegin(1,10);
   //   SetIndexDrawBegin(2,10);
   //   SetIndexDrawBegin(3,10);
//---- indicator buffers mapping
   //   SetIndexBuffer(0,ExtMapBuffer1);
   //   SetIndexBuffer(1,ExtMapBuffer2);
   //   SetIndexBuffer(2,ExtMapBuffer3);
   //   SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
//----   
   while(pos>=0)
     {
      if (iAO(NULL,0,pos)>=iAO(NULL,0,pos+1) && iAC(NULL,0,pos)>=iAC(NULL,0,pos+1))
        {
         ExtMapBuffer1[pos]=High[pos];
         ExtMapBuffer2[pos]=Low[pos];
         if (Open[pos]>=Close[pos])
         { ExtMapBuffer3[pos]=Open[pos]; ExtMapBuffer4[pos]=Close[pos]; }
         else // if (Open[pos]<=Close[pos]) 
         { ExtMapBuffer3[pos]=Close[pos]; ExtMapBuffer4[pos]=Open[pos]; }
        }
      else
        {
         if (iAO(NULL,0,pos)<=iAO(NULL,0,pos+1) && iAC(NULL,0,pos)<=iAC(NULL,0,pos+1))
           {
            ExtMapBuffer1[pos]=Low[pos];
            ExtMapBuffer2[pos]=High[pos];
            if (Open[pos]<=Close[pos])
            { ExtMapBuffer3[pos]=Open[pos]; ExtMapBuffer4[pos]=Close[pos]; }
            else // if (Open[pos]>=Close[pos]) 
            { ExtMapBuffer3[pos]=Close[pos]; ExtMapBuffer4[pos]=Open[pos]; }
           }
         else
           {
            ExtMapBuffer1[pos]=EMPTY_VALUE;
            ExtMapBuffer2[pos]=EMPTY_VALUE;
            ExtMapBuffer3[pos]=EMPTY_VALUE;
            ExtMapBuffer4[pos]=EMPTY_VALUE;
           }
        }
      //         if (Open[pos]>=Close[pos]) 
      //            { ExtMapBuffer3[pos]=Open[pos]; ExtMapBuffer4[pos]=Close[pos]; }
      //         else // if (Open[pos]<=Close[pos]) 
      //            { ExtMapBuffer3[pos]=Close[pos]; ExtMapBuffer4[pos]=Open[pos]; };         
      pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments