CandleStick

Download script
Author: Copyright � 2005, Profi_R
CandleStick

This technical script is designed to function as an automated visual aid for traders, specifically identifying significant candlestick patterns and price action signals on a trading chart. Instead of requiring a trader to manually scan every candle, the logic automatically processes historical and real-time data to highlight specific "turning points" or momentum shifts.

Core Analytical Logic

The script operates by evaluating three primary layers of market data:

1. Dynamic Volatility Assessment The tool first establishes a baseline for "normal" price movement. It calculates a moving average of the price range (the difference between the highest and lowest prices) over a user-defined period. By understanding the average volatility, the script can distinguish between standard market noise and significant price fluctuations.

2. Candle Classification Every candle on the chart is categorized based on its size relative to that established average volatility. The logic determines if a candle is:

  • A "Large" candle (significant momentum).
  • A "Doji" (indecision where the opening and closing prices are nearly identical).
  • An "Ordinary" candle (standard movement).

3. Pattern Recognition & Signal Generation The script then applies specific rules to identify five distinct types of market behaviors:

  • Hammer and Hanging Man: It identifies candles with very small bodies and long lower wicks (Hammers) or upper wicks (Hanging Men). When these appear at the bottom or top of a price range, respectively, they suggest potential reversals.
  • High Waves: The script looks for a sequence of three consecutive large "Doji" candles with long shadows. If these occur at extreme highs or lows of a recent trend, it flags them as a signal for a possible reversal.
  • Falling Star: It specifically looks for a large candle followed by a "Star" (a candle with a small body and a long upper wick) at the peak of a price movement, signaling that buying pressure is exhausting.
  • Thrusting Fine (Momentum): This detects a shift in momentum where two consecutive candles move in opposite directions but the second one fails to break through the midpoint of the previous candle's range, suggesting a continuation of the current trend.

Visual Output

When the script identifies any of these patterns, it performs two actions simultaneously:

  1. Text Labels: It places descriptive text directly on the chart (e.g., "hammer", "falling star", "high wave") to provide immediate context to the trader.
  2. Visual Arrows: It plots colored arrows (Red for downward pressure/reversals and Blue for upward pressure/reversals) to provide a clear, high-speed visual cue for decision-making.
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
CandleStick
//+------------------------------------------------------------------+
//|                                                  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",Lime);
            //ïîâåøåííûé íà âåðøèíå, ñòàâèì ñòðåëêó âíèç
            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",Lime);
            //ìîëîò âíèçó, ñòàâèì ñòðåëêó ââåðõ
            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",Lime);
            //âûñîêèå âîëíû íàâåðõó - ðàçâîðîò âíèç
            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",Lime);
            //âûñîêèå âîëíû âíèçó - ðàçâîðîò ââåðõ
            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",Lime);
         //ïàäàþùàÿ çâåçäà - ðàçâîðîò âíèç
         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",Lime);
            //òîë÷îê - ïðîäîëæåíèå òåíäåíöèè âíèç
            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",Lime);
            //òîë÷îê - ïðîäîëæåíèå òåíäåíöèè ââåðõ
            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