Author: Copyright � 2005, Pavel Kulko
Wiseman 1

This script is a specialized technical analysis tool designed to identify specific price action anomalies, specifically focusing on "divergent bars." In the world of trading, these moments often represent a conflict between the immediate market momentum and the underlying price structure.

How the Logic Works

The tool works by analyzing each individual candle (bar) on your chart and comparing its behavior to the candle immediately preceding it. It focuses on three main components: the High, the Low, and the Median Price (the midpoint between the high and low of a single bar).

Here is the step-by-step logic the script follows for every candle:

1. Identifying "Upward" Divergence The script looks for a specific scenario where the price shows signs of strength but faces resistance. It checks if:

  • The current candle's Low is lower than the previous candle's Low.
  • However, despite that lower low, the price actually closed above its own midpoint (the median). In this case, the tool flags a "divergence," suggesting that while the price dipped, the buying pressure was strong enough to push it back toward the top half of its range.

2. Identifying "Downward" Divergence Conversely, the script looks for signs of weakness hidden within an upward move. It checks if:

  • The current candle's High is higher than the previous candle's High.
  • Despite that higher high, the price actually closed below its own midpoint (the median). This indicates that even though the price reached a new peak, the selling pressure was dominant enough to pull it toward the bottom half of its range.

Visual Representation

Once these specific conditions are met, the script visualizes them on your chart using a histogram:

  • Bullish Signals: When the "Upward Divergence" is detected, it marks the price points to highlight potential buying interest.
  • Bearish Signals: When the "Downward Divergence" is detected, it marks the price points to highlight potential selling pressure.

Summary for Traders

Essentially, this tool helps filter out "noise" by highlighting bars where the price movement (the highs and lows) doesn't quite match the closing sentiment (the median). It allows you to see where the market might be struggling to maintain a trend or where a reversal in momentum is beginning to form before it becomes obvious on the chart.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
Wiseman 1

//+------------------------------------------------------------------+
//|                                                    Wiseman 1.mq4 |
//|                           Bill Williams Wiseman 1 Divergent bars |
//|                                             Author: David Thomas |
//|                                      MQ4 Conversion: Pavel Kulko |
//|                                                  polk@alba.dp.ua |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Pavel Kulko"
#property link      "polk@alba.dp.ua"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red

double UpBuf[],DnBuf[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
   SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
   SetIndexBuffer(0,UpBuf); 
   SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
   SetIndexBuffer(1,DnBuf);
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int result;
   double median;
   int    counted_bars=IndicatorCounted();
   int limit = Bars-counted_bars-1;
   for(int i=limit; i>=0; i--) {
     result = 0;
     median = (High[i]+Low[i])/2;
     if((Low[i] < Low[i+1]) && (Close[i] > median)) result = -1;
     if((High[i] > High[i+1]) && (Close[i] < median)) result = 1;
     if(result > 0) {
       UpBuf[i] = Low[i];
       DnBuf[i] = High[i];
     }
     if(result < 0) {
       UpBuf[i] = High[i];
       DnBuf[i] = Low[i];
     }
   }
   return(0);
}
//+------------------------------------------------------------------+

Comments