Index of Chart Sentiment

Index of Chart Sentiment

This script is a specialized technical analysis tool designed to convert the visual characteristics of price candles (the "geometry" of the market) into a numerical data stream. Instead of looking at just the price, it analyzes the shape, size, and proportion of each candle to create a symmetrical index.

Core Logic Overview

The indicator works by breaking down every single candle into three distinct components: the Body, the Upper Shadow (Wick), and the Lower Shadow (Wick). It then assigns a specific numerical value to each of these parts based on their relative size compared to historical averages.

How the Data is Calculated

The script follows a structured process to turn "shapes" into "numbers":

1. Measuring Geometry For every candle on the chart, the script calculates:

  • Body Size: The difference between the opening and closing price.
  • Upper Shadow: The distance from the highest point of the candle to the top of the body.
  • Lower Shadow: The distance from the lowest point of the candle to the bottom of the body.

2. Dynamic Thresholds (Bollinger Band Logic) Rather than using fixed numbers, the script uses a method similar to Bollinger Bands. It looks at the history of these measurements to determine what is considered "Small," "Medium," or "Large" for the current market conditions. It calculates a standard deviation to create dynamic boundaries for:

  • The size of the candle bodies.
  • The length of the upper shadows.
  • The length of the lower shadows.

3. Scoring System Once the thresholds are established, the script assigns "points" to each candle:

  • Body Scoring: If a candle is not a "Doji" (a flat candle), it is assigned a value based on its size category. For example, a large bullish (up) candle gets a positive score, while a large bearish (down) candle gets an equal but negative score.
  • Shadow Scoring: The upper shadows are given positive points, and lower shadows are given negative points. The number of points depends on whether the shadow is small, medium, or large relative to recent history.

Smoothing and Visualization

After every candle is converted into a numerical "score," the script does not plot these raw jumps immediately. Instead, it performs Double Smoothing:

  • It applies a Moving Average to the raw scores.
  • It then applies a second Moving Average to that result.

This creates two smooth lines on a separate window (the Main Line and the Signal Line). Because the scoring system treats upward movements as positive and downward movements as negative in an identical way, the resulting indicator is perfectly symmetrical around a zero line.

Practical Interpretation

  • The Main Line: Represents the primary smoothed trend of the candle geometry.
  • The Signal Line: A secondary, slower moving average used to identify changes in the momentum of that geometry.
  • The Goal: By tracking these lines, the user can see when the "shape" of the market is shifting—identifying trends where price action is becoming more aggressive or where shadows are beginning to dominate the price movement.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
Index of Chart Sentiment
//+--------------------------------------------------------+
//| Candle_Code      Ñâå÷íîé èíäèêàòîð ñèììåòðè÷íûé êîä.mq4|
//|Copight © 2005,àëãîðèòì Ëèõîâèäîâ, äîðàáîòàë Tiger Woods|
//|                                e-mail:tagir1970@mail.ru|
//+--------------------------------------------------------+
//Îñíîâíîå îòëè÷èå îò èíäèêàòîðà Ëèõîâèäîâà â òîì, ÷òî áåëûå è ÷åðíûå ñâå÷è êîäèðóþòñÿ îäèíàêîâûì îáðàçîì,
//ò.å. åñëè ó áåëîé ñâå÷è êîä ðàâåí 50, òî ó òàêîé æå ÷åðíîé ñâå÷è êîä ðàâåí -50. Òàêèì îáðàçîì, èíäèêàòîð ñèììåòðè÷åí 
//îòíîñèòåëüíî íóëåâîé ëèíèè. 
#property  copyright "Copyright © 2005-2007,Tiger Woods"
#property  link      "e-mail:tagir1970@mail.ru"
//---- indicator settings
#property  indicator_separate_window
#property indicator_minimum -50
#property indicator_maximum  50

#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Blue

#property indicator_level1 -25
#property indicator_level2 -50
#property indicator_level3  50
#property indicator_level4  25
#property indicator_level5   0

//---- ïàðàìåòðû èíäèêàòîðà
//extern int    îñíîâíàÿ_ëèíèÿ   =3;  //ïåðèîä ñðåäíåé ïðè ñãëàæèâàíèè îñíîâíîé ëèíèè
//extern int    ñèãíàëüíàÿ_ëèíèÿ =2;  //ïåðèîä ñðåäíåé ïðè ñãëàæèâàíèè ñèãíàëüíîé ëèíèè
extern int    îñíîâíàÿ_ëèíèÿ   =3;  //ïåðèîä ñðåäíåé ïðè ñãëàæèâàíèè îñíîâíîé ëèíèè
extern int    ñèãíàëüíàÿ_ëèíèÿ =2;  //ïåðèîä ñðåäíåé ïðè ñãëàæèâàíèè ñèãíàëüíîé ëèíèè
extern int    òåëî_äîæè        =5;  //ðàçìåð òåëà ñâå÷è â ïóíêòàõ, ïðè êîòîðîì îíà ñ÷èòàåòñÿ äîæè
extern int    áîëëèíäæåð       =55; //ïåðèîä Áîëëèíäæåðà
extern double îòêëîíåíèå       =0.5;//ñòàíäàðòíîå îòêëîíåíèå 
//---- èíäèêàòîðíûå ìàññèâû
double code[],code_av1[],code_av2[],code_av3[],code_av4[],h_shadow[],l_shadow[],body[];
#define	MODE_UPPER	1
#define	MODE_LOWER	2
     int init()
  {
//---- Äëÿ ðàñ÷åòîâ èñïîëüçóþ 8 ìàññèâîâ
   IndicatorBuffers(8);
//----óñòàíîâêè äëÿ ðèñîâàíèÿ 
   SetIndexStyle(0,DRAW_LINE);
   SetIndexDrawBegin(0,2*îñíîâíàÿ_ëèíèÿ);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,2*(îñíîâíàÿ_ëèíèÿ+ñèãíàëüíàÿ_ëèíèÿ));
   IndicatorDigits(2);
   //---- 2 èíäèêàòîðíûõ ìàññèâà è 6 äëÿ âû÷èñëåíèé
   if(!SetIndexBuffer(0,code_av2)&&!SetIndexBuffer(1,code_av4)&&
      !SetIndexBuffer(2,code_av1)&&!SetIndexBuffer(3,code_av3)&&
      !SetIndexBuffer(4,    code)&&!SetIndexBuffer(5,    body)&&
      !SetIndexBuffer(6,l_shadow)&&!SetIndexBuffer(7,h_shadow))
      Print("cannot set indicator buffers!");
//---- Èìÿ äëÿ îêíà è ïåðèîäîâ
  IndicatorShortName("Èíäåêñ ÍÐ("+îñíîâíàÿ_ëèíèÿ+","+ñèãíàëüíàÿ_ëèíèÿ+","+òåëî_äîæè+","+áîëëèíäæåð+","+DoubleToStr(îòêëîíåíèå,1)+")");
//---- Èíèöèàëèçàöèÿ ñäåëàíà
   return(0);
  }

int start()
{  
   double h_limit_body,h_limit_h_shadow,h_limit_l_shadow,l_limit_body,l_limit_h_shadow,l_limit_l_shadow;
   int    i,counted_bars=IndicatorCounted(),limit=Bars-counted_bars;
  
   if(counted_bars<0) return(-1);
//---- ïîñëåäíèé áàð âû÷èñëþ åùå ðàç
   if(counted_bars>0) limit--;
//âû÷èñëÿþ âåëè÷èíû òåëà è òåíåé äëÿ áàðîâ, íà÷èíàÿ ñ limit äî 0 
for(i=limit;i>=0;i--)
   {
      body    [i]=MathAbs(Open[i]-Close[i]);        //òåëî
      h_shadow[i]=High[i]-MathMax(Open[i],Close[i]);//âåðõíÿÿ òåíü
      l_shadow[i]=MathMin(Open[i],Close[i])-Low[i]; //íèæíÿÿ òåíü
   }
//âû÷èñëÿþ code äëÿ ýëåìåíòîâ ìàññèâà
for(i=limit;i>=0;i--)
   {
      code[i]=0;//îáíóëÿþ ñòàðîå çíà÷åíèå
//âû÷èñëÿþ ïîðîãè äëÿ òåëà è òåíåé áàðà
      h_limit_body    =BandsOnArray(body,    Bars,áîëëèíäæåð,îòêëîíåíèå,MODE_UPPER,i);//âåðõíèé ïîðîã äëÿ òåëà
      l_limit_body    =BandsOnArray(body,    Bars,áîëëèíäæåð,îòêëîíåíèå,MODE_LOWER,i);//íèæíèé ïîðîã äëÿ òåëà 
         
      h_limit_h_shadow=BandsOnArray(h_shadow,Bars,áîëëèíäæåð,îòêëîíåíèå,MODE_UPPER,i);//âåðõíèé ïîðîã äëÿ âåðõíåé òåíè 
      l_limit_h_shadow=BandsOnArray(h_shadow,Bars,áîëëèíäæåð,îòêëîíåíèå,MODE_LOWER,i);//íèæíèé ïîðîã äëÿ âåðõíåé òåíè 
         
      h_limit_l_shadow=BandsOnArray(l_shadow,Bars,áîëëèíäæåð,îòêëîíåíèå,MODE_UPPER,i);//âåðõíèé ïîðîã äëÿ íèæíåé òåíè
      l_limit_l_shadow=BandsOnArray(l_shadow,Bars,áîëëèíäæåð,îòêëîíåíèå,MODE_LOWER,i);//íèæíèé ïîðîã äëÿ íèæíåé òåíè 

//âû÷èñëÿþ êîä äëÿ öâåòà è äëÿ òåëà ñâå÷è
      if(body[i]>òåëî_äîæè*Point)//íå äîæè 
        {
          if(Close[i]>Open[i])//áåëàÿ ñâå÷à
            {                                      
              if     (body[i]<l_limit_body) code[i]+=16;//ìàëåíüêîå òåëî
              else if(body[i]<h_limit_body) code[i]+=32;//ñðåäíåå òåëî
              else                          code[i]+=48;//áîëüøîå òåëî
            }                      
          else                //÷åðíàÿ ñâå÷à 
            {                                     
              if     (body[i]<l_limit_body) code[i]-=16;//ìàëåíüêîå òåëî
              else if(body[i]<h_limit_body) code[i]-=32;//ñðåäíåå òåëî
              else                          code[i]-=48;//áîëüøîå òåëî
            }
        } 
      else                                  code[i]+= 0;//äîæè 
//âû÷èñëÿþ êîä äëÿ âåðõíåé òåíè 
      if     (h_shadow[i]==0)               code[i]+= 0;//âåðõíÿÿ òåíü îòñóòñòâóåò
      else if(h_shadow[i]<l_limit_h_shadow) code[i]+= 4;//ìàëåíüêàÿ âåðõíÿÿ òåíü
      else if(h_shadow[i]<h_limit_h_shadow) code[i]+= 8;//ñðåäíÿÿ âåðõíÿÿ òåíü
      else                                  code[i]+=12;//áîëüøàÿ âåðõíÿÿ òåíü             
//âû÷èñëÿþ êîä äëÿ íèæíåé òåíè 
      if     (l_shadow[i]==0)               code[i]-= 0;//íèæíÿÿ òåíü îòñóòñòâóåò
      else if(l_shadow[i]<l_limit_l_shadow) code[i]-= 4;//ìàëåíüêàÿ íèæíÿÿ òåíü 
      else if(l_shadow[i]<h_limit_l_shadow) code[i]-= 8;//ñðåäíÿÿ íèæíÿÿ òåíü
      else                                  code[i]-=12;//áîëüøàÿ íèæíÿÿ òåíü  
   }
//îñíîâíàÿ ëèíèÿ, ñãëàæèâàíèå 2 ðàçà    
for(i=limit;i>=0;i--) code_av1[i]=iMAOnArray(code,    Bars,îñíîâíàÿ_ëèíèÿ,  0,3,i);
for(i=limit;i>=0;i--) code_av2[i]=iMAOnArray(code_av1,Bars,îñíîâíàÿ_ëèíèÿ,  0,3,i);
//ñèãíàëüíàÿ ëèíèÿ, ñãëàæèâàíèå 2 ðàçà  
for(i=limit;i>=0;i--) code_av3[i]=iMAOnArray(code_av2,Bars,ñèãíàëüíàÿ_ëèíèÿ,0,3,i);
for(i=limit;i>=0;i--) code_av4[i]=iMAOnArray(code_av3,Bars,ñèãíàëüíàÿ_ëèíèÿ,0,3,i); 
 
return(0);
 }
//---------------------------------------------------------------------------
//Ðàñ÷åò èíäèêàòîðà Bollinger Bands ñ äðîáíûì îòêëîíåíèåì íà äàííûõ, õðàíÿùèõñÿ â ìàññèâå (îäíà òî÷êà):
//---------------------------------------------------------------------------
double BandsOnArray(double array[],int total,int period,double b_deviation,int mode,int shift)
{
	double deviation,sum,newres,ma_centr;

	if((shift+period)>=total||shift<0) return(0);
//Âû÷èñëèì öåíòðàëüíóþ ëèíèþ (ñðåäíþþ):
   ma_centr=0.0;
   int k=shift+period-1;
	while(k>=shift)
     {
       ma_centr+=array[k];
	    k--;
	  }
   ma_centr=ma_centr/period;
//Âåðõíÿÿ/íèæíÿÿ ëèíèè êàíàëà:   
	sum=0.0;
   k=shift+period-1;
	while(k>=shift)
     {
       newres=array[k]-ma_centr;
	    sum  +=newres*newres;
	    k--;
	  }
	deviation=b_deviation*MathSqrt(sum/period);
	if(mode==MODE_UPPER) return(ma_centr+deviation);
	if(mode==MODE_LOWER) return(ma_centr-deviation);
	return(0);
}

Comments