$CDL
Download scriptThis indicator is designed to provide a clear, visual representation of price movement direction by analyzing the relationship between the opening and closing prices of each candle on a trading chart. Rather than showing complex mathematical formulas or standard price action, it simplifies market data into three distinct states to help traders quickly identify the immediate "sentiment" of the market.
How the Logic Works
The script examines every individual bar (candle) on your chart and evaluates whether the price finished higher, lower, or unchanged compared to where it started:
- Positive Movement: If a candle closes at a price higher than its opening price, the indicator assigns a positive value of 1. Visually, this represents an upward move.
- Negative Movement: If a candle closes at a price lower than its opening price, the indicator assigns a negative value of -1. Visually, this represents a downward move.
- Neutral Movement: If the closing price is exactly equal to the opening price, the indicator assigns a value of 0, indicating no net change in price for that specific period.
Purpose and Visual Output
By converting these fluctuations into a single line of data (1, -1, or 0), the script creates a streamlined visual history of market momentum. It filters out the "noise" of the actual price levels and focuses entirely on the direction of travel. This allows you to see at a glance whether the market has been trending upward, downward, or remains stagnant over a specific period of time.
//+------------------------------------------------------------------+
//| $CDL |
//| |
//| |
//| Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne |
//| |
//| PO BOX 43575, TUCSON, AZ 85733 |
//| |
//| GIFT AND DONATIONS ACCEPTED |
//| |
//| therumpldone@gmail.com |
//+------------------------------------------------------------------+
//| |
//| go to www.kreslik.com for the latest indicator updates |
//+------------------------------------------------------------------+
//| |
//| Use www.efxgroup.com as your forex broker... |
//| ...tell them therumpledone sent you! |
//+------------------------------------------------------------------+
#property copyright "Avery T. Horton, Jr. aka TheRumpledOne © 2008"
#property link "www.kreslik.com"
#property indicator_separate_window
#property indicator_buffers 1
//---- input parameters
//---- buffers
double _Value[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(1);
SetIndexBuffer(0,_Value);
SetIndexStyle(0,DRAW_LINE);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i--)
{
double _Result = ( Close[i] - Open[i] ) ;
if ( _Result > 0 ) _Value[i] = 1;
else {
if ( _Result < 0 ) _Value[i] = -1;
else _Value[i] = 0; }
}
//----
return( 0 );
}
//+------------------------------------------------------------------+
Comments