Author: Copyright � 2005, Profi_R
-Dodji

This script is a specialized technical analysis tool designed to identify specific price action patterns and candlestick formations on a trading chart. Instead of relying on standard lagging indicators, it analyzes the physical geometry of price candles—specifically their bodies, wicks (shadows), and relative size—to provide visual signals for potential trend reversals or continuations.

Core Logic Overview

The tool operates by constantly scanning historical and current price bars to classify them into different categories based on three main criteria:

1. Volatility and Body Analysis The script first establishes a baseline for "normal" market movement by calculating the average amplitude (the total range from high to low) over a set period of time. It then compares each individual candle against this average to determine if it is a significant move or a minor fluctuation. Based on this, it categorizes candles as:

  • Stars: Candles with large bodies relative to their total range.
  • Doji's: Candles where the opening and closing prices are very close, resulting in a small body.
  • Unstudied Candles: Candles that do not meet specific size or body ratio thresholds.

2. Pattern Recognition Once the candles are categorized, the script looks for specific geometric configurations that often indicate market psychology:

  • Hammer and Hanging Highs: It identifies "Hanging" patterns (small bodies with long lower wicks) at local lows to suggest upward momentum, or "Hammers" to signal potential buying opportunities.
  • High Waves: The logic detects sequences of three or more consecutive Doji candles with long shadows. If these occur at the top of a price peak or the bottom of a trough, the script flags them as potential reversal points.
  • Falling Stars: It looks for specific "Shooting Star" formations—candles with small bodies and long upper wicks appearing at local highs—to signal a potential downward turn.
  • Thrusting Fins (Impulse): The script identifies sharp, sudden moves where price pushes through a previous candle's range, highlighting areas of strong momentum in either direction.

Visual Feedback

To make this data actionable for the user, the script performs two main visual actions:

  • On-Screen Labeling: It places yellow text directly on the chart to name the specific pattern detected (e.g., "Hanging," "Hammer," "High Wave," or "Falling Star").
  • Directional Arrows: It plots visual arrows above or below the candles to provide a quick reference for whether the detected logic suggests an upward or downward price movement.

Summary for the User

Essentially, this script acts as an automated "price action reader." It filters out market noise by calculating average volatility and then highlights specific candle shapes that traders use to predict when a trend is exhausting or when a new trend is beginning.

Miscellaneous
Implements a curve of type %1
3 Views
0 Downloads
0 Favorites
-Dodji
//+------------------------------------------------------------------+
//|                                                  CandleStick.mq4 |
//|                                        Copyright © 2005, Profi_R |
//|                                               rvm_fam fromru  com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Profi_R"
#property link      "rvm_fam fromru  com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int Range=50;
extern int zv_amp=50;
extern int dj_body=20;
//---- buffers
double Up[]; //çäåñü áóäåì ïèñàòü ñòðåëêè äëÿ ñèãíàëîâ âíèç
double Dn[]; //çäåñü áóäåì ïèñàòü ñòðåëêè äëÿ ñèãíàëîâ ââåðõ
double MAmp[]; //çäåñü áóäåì äåðæàòü ñðåäíåå çíà÷åíèå àìïëèòóäû
double Character[]; //çäåñü áóäåì äåðæàòü õàðàêòåð ñâå÷è
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);
   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Dn);
   SetIndexBuffer(2,MAmp);
   SetIndexBuffer(3,Character);
   SetIndexArrow(0,242);
   SetIndexArrow(1,241);
   SetIndexDrawBegin(0,Range+1);
   SetIndexDrawBegin(1,Range+1);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   ObjectsDeleteAll(0,OBJ_TEXT);
   ObjectsDeleteAll(0,OBJ_ARROW);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted(),cb;
   double amp_lim,body_lim;
//---- 
   for(cb=Bars-1-counted_bars;cb>=0;cb--)
   {
      Amplitude_calc(cb); //ïîëó÷àåì çíà÷åíèå ñðåäíåé àìïëèòóäû äëÿ òåêóùåé ñâå÷è
      //âû÷èñëÿåì çíà÷åíèå äëÿ îïðåäåëåíèÿ çâåçä è äîæè
      amp_lim=NormalizeDouble(MAmp[cb]*zv_amp/100,4);
      body_lim=NormalizeDouble((High[cb]-Low[cb])*dj_body/100,4);
      //åñëè àìïëèòóäà ìåíåå èëè ðàâíà zv_amp% ñðåäíåé àìïëèòóäû
      if(High[cb]-Low[cb]<=amp_lim)
      {
         if(MathAbs(Open[cb]-Close[cb])<=body_lim)
         {
            Character[cb]=2; //äîæè
         }
         else
         {
            Character[cb]=1; //çâåçäà
         }
      }
      else
      {
         if(MathAbs(Open[cb]-Close[cb])<=body_lim)
         {
            Character[cb]=2; //äîæè
         }
         else
         {
            Character[cb]=0; //îáû÷íàÿ ñâå÷à
         }
      }
//-------- äàëåå èäåò îïðåäåëåíèå ñâå÷íûõ êîíôèãóðàöèé
//ìîëîò è ïîâåøåííûé âåðõíÿÿ òåíü íå áîëåå dj_body% àìïëèòóäû, íèæíÿÿ òåíü â äâà ðàçà áîëüøå òåëà
      if(High[cb+2]-MathMax(Open[cb+2],Close[cb+2])<NormalizeDouble((High[cb+2]-Low[cb+2])*dj_body/100,4)&&
         MathAbs(Open[cb+2]-Close[cb+2])*2<MathMin(Open[cb+2],Close[cb+2])-Low[cb+2])
      {
         if(High[cb+2]==High[Highest(NULL,0,MODE_HIGH,6,cb+1)])
         {
            //âûâîäèì òåêñò íà ÷àðò
            ObjectCreate("hanging "+(cb+2),OBJ_TEXT,0,Time[cb+2],High[cb+1]+10*Point);
            ObjectSetText("hanging "+(cb+2),"ïîâåøåííûé",9,"Times New Roman",Yellow);
            //ïîâåøåííûé íà âåðøèíå, ñòàâèì ñòðåëêó âíèç
            Up[cb]=High[cb]+10*Point;
         }
         if(Low[cb+2]==Low[Lowest(NULL,0,MODE_LOW,6,cb+1)])
         {
            //âûâîäèì òåêñò íà ÷àðò
            ObjectCreate("hammer "+(cb+2),OBJ_TEXT,0,Time[cb+2],Low[cb+1]-10*Point);
            ObjectSetText("hammer "+(cb+2),"ìîëîò",9,"Times New Roman",Yellow);
            //ìîëîò âíèçó, ñòàâèì ñòðåëêó ââåðõ
            Dn[cb]=Low[cb]-10*Point;
         }
      }
//âûñîêàÿ âîëíà - òðè è áîëüøåå êîëè÷åñòâî äîæè ñ äëèííûìè òåíÿìè
      if(Character[cb]==2&&High[cb]-Low[cb]>amp_lim&&
         Character[cb+1]==2&&High[cb+1]-Low[cb+1]>NormalizeDouble(MAmp[cb+1]*zv_amp/100,4)&&
         Character[cb+2]==2&&High[cb+2]-Low[cb+2]>NormalizeDouble(MAmp[cb+2]*zv_amp/100,4))
      {
         if(High[cb]==High[Highest(NULL,0,MODE_HIGH,7,cb)]||
            High[cb+1]==High[Highest(NULL,0,MODE_HIGH,7,cb)]||
            High[cb+2]==High[Highest(NULL,0,MODE_HIGH,7,cb)])
         {
            //âûâîäèì òåêñò íà ÷àðò
            ObjectCreate("high wave "+cb,OBJ_TEXT,0,Time[cb],High[cb]+10*Point);
            ObjectSetText("high wave "+cb,"âûñîêèå âîëíû",9,"Times New Roman",Yellow);
            //âûñîêèå âîëíû íàâåðõó - ðàçâîðîò âíèç
            Up[cb]=High[cb]+10*Point;
         }
         if(Low[cb]==Low[Lowest(NULL,0,MODE_LOW,7,cb)]||
            Low[cb+1]==Low[Lowest(NULL,0,MODE_LOW,7,cb)]||
            Low[cb+2]==Low[Lowest(NULL,0,MODE_LOW,7,cb)])
         {
            //âûâîäèì òåêñò íà ÷àðò
            ObjectCreate("high wave "+cb,OBJ_TEXT,0,Time[cb],Low[cb]-10*Point);
            ObjectSetText("high wave "+cb,"âûñîêèå âîëíû",9,"Times New Roman",Yellow);
            //âûñîêèå âîëíû âíèçó - ðàçâîðîò ââåðõ
            Dn[cb]=Low[cb]-10*Point;
         }
      }
//ïàäàþùàÿ çâåçäà
      if(Character[cb]==2 && MathMin(Open[cb],Close[cb])-Low[cb]<body_lim &&
         High[cb]-MathMax(Open[cb],Close[cb])>MathAbs(Open[cb]-Close[cb])*2 &&
         High[cb]==High[Highest(NULL,0,MODE_HIGH,4,cb)])
      {
         //âûâîäèì òåêñò íà ÷àðò
         ObjectCreate("shooting star "+cb,OBJ_TEXT,0,Time[cb],High[cb]+10*Point);
         ObjectSetText("shooting star "+cb,"ïàäàþùàÿ çâåçäà",9,"Times New Roman",Yellow);
         //ïàäàþùàÿ çâåçäà - ðàçâîðîò âíèç
         Up[cb]=High[cb]+10*Point;
      }
//Òîë÷îê
      if(Character[cb]==0 && Character[cb+1]==0)
      {
         if(Close[cb]>Open[cb] && Close[cb+1]<Open[cb+1] && Close[cb]<High[cb+1]-(High[cb+1]-Low[cb+1])/2)
         {
            //âûâîäèì òåêñò íà ÷àðò
            ObjectCreate("thrusting fine "+cb,OBJ_TEXT,0,Time[cb],High[cb]+10*Point);
            ObjectSetText("thrusting fine "+cb,"òîë÷îê",9,"Times New Roman",Yellow);
            //òîë÷îê - ïðîäîëæåíèå òåíäåíöèè âíèç
            Up[cb]=High[cb]+10*Point;
         }
         if(Close[cb]<Open[cb] && Close[cb+1]>Open[cb+1] && Close[cb]>Low[cb+1]+(High[cb+1]-Low[cb+1])/2)
         {
            //âûâîäèì òåêñò íà ÷àðò
            ObjectCreate("thrusting fine "+cb,OBJ_TEXT,0,Time[cb],Low[cb]-10*Point);
            ObjectSetText("thrusting fine "+cb,"òîë÷îê",9,"Times New Roman",Yellow);
            //òîë÷îê - ïðîäîëæåíèå òåíäåíöèè ââåðõ
            Dn[cb]=Low[cb]-10*Point;
         }
      }
//Áðîøåííûé ìëàäåíåö
      
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
void Amplitude_calc(int cb)
  {
//----
   int i,S_Ampl=0;
   for(i=cb+1;i<cb+Range;i++)
   {
      //íàêàïëèâàåì ñóììó âñåõ àìïëèòóä
      S_Ampl=S_Ampl+(High[i]-Low[i]);
      //çàïèñûâàåì çíà÷åíèÿ â áóôåðû èíäèêàòîðà
      MAmp[cb]=NormalizeDouble(S_Ampl/Range,4);
   }
//----
   return(0);
  }

  
 
 

 

Comments