Cog_Histo

This tool is designed as a visual momentum and trend indicator that operates in a separate window beneath your main price chart. Its primary purpose is to provide a clear, color-coded representation of market direction by comparing two different data streams derived from the "Center of Gravity" calculation.

Core Logic and Functionality

The script functions by monitoring the relationship between two specific technical values (referred to as ma0 and ma1). These values represent weighted averages of price action over a user-defined period and historical bar count. By comparing these two lines in real-time, the tool determines the prevailing "sentiment" of the market:

  • Bullish Momentum (Green): When the primary value (ma0) rises above the secondary value (ma1), the indicator identifies an upward trend. The visual output highlights this as a green histogram, signaling to the trader that buying pressure is dominant.
  • Bearish Momentum (Red): When the primary value (ma0) falls below the secondary value (ma1), the tool detects downward pressure. This is represented by a red histogram, indicating that selling pressure is currently leading the market.
  • Neutral State (White): In the specific instance where both values are perfectly equal, the indicator shifts to a neutral white state. This serves as a "balanced" signal, suggesting a lack of clear direction or a potential transition point between trends.

User Experience and Visuals

The indicator simplifies complex price data into three distinct visual layers. By using thick histogram bars (with a width of 4), it ensures that the trend is easy to see at a glance without cluttering the screen. Instead of showing you the raw, fluctuating numbers of the calculations, it translates those numbers into a simple "traffic light" system:

  1. Green means the trend is moving up.
  2. Red means the trend is moving down.
  3. White means the market is in equilibrium.

By observing these shifts, a trader can quickly identify when momentum is changing or when the market is consolidating, allowing for more informed decision-making regarding entry and exit points based on the overall flow of the market.

Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
Cog_Histo

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  White
#property  indicator_color2  SpringGreen
#property  indicator_color3  Red
#property  indicator_width1  4
#property  indicator_width2  4
#property  indicator_width3  4

extern int Par                      = 10;      //cog2
extern int CountBars                = 2000;     //cog2

double     nuet[];
double     up[];
double     down[];

//+------------------------------------------------------------------+

int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,nuet);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,up);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexBuffer(2,down);
SetIndexEmptyValue(0,0);
SetIndexEmptyValue(1,0);
SetIndexEmptyValue(2,0);
return(0);
}

//+------------------------------------------------------------------+

int deinit()
{
return(0);
}

//+------------------------------------------------------------------+

int start()
{
int    counted_bars;
int    limit;
int    i;
double ma0;
double ma1;

counted_bars = IndicatorCounted();
if (counted_bars < 0) return(-1);
if (counted_bars > 0) counted_bars--;
limit = Bars - counted_bars;

for (i = 0; i < limit; i++)
   {
   ma0 = iCustom(NULL,0,"Center of Gravity2",Par,CountBars,0,i);
   ma1 = iCustom(NULL,0,"Center of Gravity2",Par,CountBars,1,i);
   nuet[i] = 0;
   up[i]   = ma0;
   down[i] = ma1;
   if (ma0 > ma1)  down[i] = 0 && up[i] == EMPTY_VALUE && nuet[i] == EMPTY_VALUE;
   if (ma0 < ma1)  up[i] = 0 && down[i] == EMPTY_VALUE && nuet[i] == EMPTY_VALUE;
   if (ma0 == ma1) nuet[i] = 0 && down[i] == EMPTY_VALUE && up[i] == EMPTY_VALUE;
   }
return(0);
}

Comments