Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 520

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 535

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 542

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 578

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/forex/public_html/wp-settings.php on line 18
forex decode

WeeklyPivot.mq4

//+------------------------------------------------------------------+
//|                                                  WeeklyPivot.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Magenta
#property indicator_color2 RoyalBlue
#property indicator_color3 Crimson
#property indicator_color4 RoyalBlue
#property indicator_color5 Crimson
#property indicator_color6 SeaGreen
#property indicator_color7 SeaGreen
//---- input parameters

//---- buffers
double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];
double S3Buffer[];
double R3Buffer[];
string Pivot="WeeklyPivotPoint",Sup1="W_S 1", Res1="W_R 1";
string Sup2="W_S 2", Res2="W_R 2", Sup3="W_S 3", Res3="W_R 3";
int fontsize=10;
double P,S1,R1,S2,R2,S3,R3;
double last_week_high, last_week_low, this_week_open, last_week_close;

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here

   ObjectDelete("WeeklyPivot");
   ObjectDelete("Sup1");
   ObjectDelete("Res1");
   ObjectDelete("Sup2");
   ObjectDelete("Res2");
   ObjectDelete("Sup3");
   ObjectDelete("Res3");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;

//---- indicator line
   SetIndexStyle(0,DRAW_LINE,0,2,Magenta);
   SetIndexStyle(1,DRAW_LINE,0,2,RoyalBlue);
   SetIndexStyle(2,DRAW_LINE,0,2,Crimson);
   SetIndexStyle(3,DRAW_LINE,0,2,RoyalBlue);
   SetIndexStyle(4,DRAW_LINE,0,2,Crimson);
   SetIndexStyle(5,DRAW_LINE,0,2,SeaGreen);
   SetIndexStyle(6,DRAW_LINE,0,2,SeaGreen);
   SetIndexBuffer(0,PBuffer);
   SetIndexBuffer(1,S1Buffer);
   SetIndexBuffer(2,R1Buffer);
   SetIndexBuffer(3,S2Buffer);
   SetIndexBuffer(4,R2Buffer);
   SetIndexBuffer(5,S3Buffer);
   SetIndexBuffer(6,R3Buffer);

//---- name for DataWindow and indicator subwindow label
   short_name="WeeklyPivotPoint";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

//----
   SetIndexDrawBegin(0,1);
//----

//----
   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()

  {
   int counted_bars=IndicatorCounted();

   int limit, i;
//---- indicator calculation
if (counted_bars==0)
{

   ObjectCreate("WeeklyPivot", OBJ_TEXT, 0, 0,0);
   ObjectSetText("WeeklyPivot", "                            Weekly Pivot Point",fontsize,"Arial",Red);
   ObjectCreate("Sup1", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("Sup1", "        wS 1",fontsize,"Arial",Red);
   ObjectCreate("Res1", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("Res1", "        wR 1",fontsize,"Arial",Red);
   ObjectCreate("Sup2", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("Sup2", "        wS 2",fontsize,"Arial",Red);
   ObjectCreate("Res2", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("Res2", "        wR 2",fontsize,"Arial",Red);
   ObjectCreate("Sup3", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("Sup3", "        wS 3",fontsize,"Arial",Red);
   ObjectCreate("Res3", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("Res3", "        wR 3",fontsize,"Arial",Red);
}
   if(counted_bars<0) return(-1);

   limit=(Bars-counted_bars)-1;

for (i=limit; i>=0;i--)
{

   // Monday
	if ( 1 == TimeDayOfWeek(Time[i]) && 1 != TimeDayOfWeek(Time[i+1]) )
	{
		last_week_close = Close[i+1];
		this_week_open = Open[i];

		// WeeklyPivot
		P = (last_week_high + last_week_low + this_week_open + last_week_close) / 4;

   R1 = (2*P)-last_week_low;
   S1 = (2*P)-last_week_high;
   R2 = P+(last_week_high - last_week_low);
   S2 = P-(last_week_high - last_week_low);
   R3 = (2*P)+(last_week_high-(2*last_week_low));
   S3 = (2*P)-((2* last_week_high)-last_week_low);

   last_week_low=Low[i]; last_week_high=High[i];

	ObjectMove("WeeklyPivot", 0, Time[i],P);
   ObjectMove("Sup1", 0, Time[i],S1);
   ObjectMove("Res1", 0, Time[i],R1);
   ObjectMove("Sup2", 0, Time[i],S2);
   ObjectMove("Res2", 0, Time[i],R2);
   ObjectMove("Sup3", 0, Time[i],S3);
   ObjectMove("Res3", 0, Time[i],R3);

}

    last_week_high = MathMax(last_week_high, High[i]);
 	 last_week_low = MathMin(last_week_low, Low[i]);
    PBuffer[i]=P;
    S1Buffer[i]=S1;
    R1Buffer[i]=R1;
    S2Buffer[i]=S2;
    R2Buffer[i]=R2;
    S3Buffer[i]=S3;
    R3Buffer[i]=R3;

}

//----
   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

WcciPatterns.mq4

#property copyright "(C)2005, Yuri Ershtad"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 MediumSeaGreen
#property indicator_color2 OrangeRed
#property indicator_color3 DeepSkyBlue
#property indicator_color4 IndianRed
#property indicator_color5 Tomato
#property indicator_color6 LimeGreen
#property indicator_color7 Coral
#property indicator_color8 Red

//////////////////////////////////////////////////////////////////////
// ????
//////////////////////////////////////////////////////////////////////

extern int fastPeriod  = 6;
extern int slowPeriod  = 14;

//////////////////////////////////////////////////////////////////////
// ??? ???
//////////////////////////////////////////////////////////////////////

double ZlrBuffer[];     // 1. Zero-line Reject (ZLR)      -- trend
double ShamuBuffer[];   // 2. Shamu Trade                 -- counter
double TlbBuffer[];     // 3. Trend Line Break (TLB/HTLB) -- both
double VegasBuffer[];   // 4. Vegas Trade (VT)			    -- counter
double GhostBuffer[];   // 5. Ghost Trade                 -- counter
double RevdevBuffer[];  // 6. Reverse Divergence          -- trend
double HooksBuffer[];   // 7. Hook from Extremes (HFE)    -- counter
double ExitBuffer[];    // 8. Exit signals

//////////////////////////////////////////////////////////////////////
// ???????
//////////////////////////////////////////////////////////////////////

int init()
{
   string short_name;
   IndicatorBuffers(8);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   ///////////////////////////////////////////////////////////////
   // ??????????? ????? 1 ? 8.
   // ?? ???? ????? ? ??? ?????? ???? ???
   // ??? ??? ????, ??? - ?? TLB ?HTLB
   // ----
   short_name="Woodies CCI Paterns ("+fastPeriod+","+slowPeriod+")";
   IndicatorShortName(short_name);
   // Zero-line Reject (ZLR), trend
   SetIndexStyle(0, DRAW_ARROW, EMPTY, 1, MediumSeaGreen);
   SetIndexBuffer(0, ZlrBuffer);
   SetIndexArrow(0, 140);
   SetIndexLabel(0,"Zero-line Reject (ZLR), trend");
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexDrawBegin(0, slowPeriod);
   // Shamu Trade, counter-trend
   SetIndexStyle(1, DRAW_ARROW, EMPTY, 1, OrangeRed);
   SetIndexBuffer(1, ShamuBuffer);
   SetIndexArrow(1, 141);
   SetIndexLabel(1,"Shamu Trade, counter-trend");
   SetIndexEmptyValue(1, EMPTY_VALUE);
   SetIndexDrawBegin(1, slowPeriod);
   // Trend Line Break (TLB), both
   SetIndexStyle(2, DRAW_ARROW, EMPTY, 1, DeepSkyBlue);
   SetIndexBuffer(2, TlbBuffer);
   SetIndexArrow(2, 142);
   SetIndexLabel(2,"Trend Line Break (TLB), both");
   SetIndexEmptyValue(2, EMPTY_VALUE);
   SetIndexDrawBegin(2, slowPeriod);
   // Vegas Trade (VT), counter-trend
   SetIndexStyle(3, DRAW_ARROW, EMPTY, 1, IndianRed);
   SetIndexBuffer(3, VegasBuffer);
   SetIndexArrow(3, 143);
   SetIndexLabel(3,"Vegas Trade (VT), counter-trend");
   SetIndexEmptyValue(3, EMPTY_VALUE);
   SetIndexDrawBegin(3, slowPeriod);
   // Ghost Trade, counter-trend
   SetIndexStyle(4, DRAW_ARROW, EMPTY, 1, Tomato);
   SetIndexBuffer(4, GhostBuffer);
   SetIndexArrow(4, 144);
   SetIndexLabel(4,"Ghost Trade, counter-trend");
   SetIndexEmptyValue(4, EMPTY_VALUE);
   SetIndexDrawBegin(4, slowPeriod);
   // Reverse Divergence, trend
   SetIndexStyle(5, DRAW_ARROW, EMPTY, 1, LimeGreen);
   SetIndexBuffer(5, RevdevBuffer);
   SetIndexArrow(5, 145);
   SetIndexLabel(5,"Reverse Divergence, trend");
   SetIndexEmptyValue(5, EMPTY_VALUE);
   SetIndexDrawBegin(5, slowPeriod);
   // Hook from Extremes (HFE), counter-trend
   SetIndexStyle(6, DRAW_ARROW, EMPTY, 1, Coral);
   SetIndexBuffer(6, HooksBuffer);
   SetIndexArrow(6, 146);
   SetIndexLabel(6,"Hook from Extremes (HFE), counter-trend");
   SetIndexEmptyValue(6, EMPTY_VALUE);
   SetIndexDrawBegin(6, slowPeriod);
   // Exit signal
   SetIndexStyle(7, DRAW_ARROW, EMPTY, 1, RoyalBlue);
   SetIndexBuffer(7, ExitBuffer);
   SetIndexArrow(7, 251);
   SetIndexLabel(7,"Exit signal");
   SetIndexEmptyValue(7, EMPTY_VALUE);
   SetIndexDrawBegin(7, slowPeriod);
   //----
   return(0);
}

//////////////////////////////////////////////////////////////////////
// Custor indicator deinitialization function
//////////////////////////////////////////////////////////////////////

int deinit()
{
   // TODO: add your code here
   return(0);
}

//////////////////////////////////////////////////////////////////////
// Custom indicator iteration function
//////////////////////////////////////////////////////////////////////

int start()
{
   string symbolName;
   int i, shift, checksum, counted_bars=IndicatorCounted();
   if (Bars<slowPeriod) return(0);
   // 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-slowPeriod-counted_bars;
   if (counted_bars<1 || checksum!=(fastPeriod+slowPeriod+Period()) || symbolName!=Symbol())
   {
      // ?????????, ???? ????????
      for(i=1;i<=slowPeriod;i++) ZlrBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) ShamuBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) TlbBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) VegasBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) GhostBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) RevdevBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) HooksBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) ExitBuffer[Bars-i]=EMPTY_VALUE;
      checksum = fastPeriod+slowPeriod+Period();
      symbolName=Symbol();
      limit=Bars-slowPeriod;
   }
   for (shift=limit; shift>=0; shift--)
   {
      ///////////////////////////////////////////////////////////////
      //	????? ?????????????????
      ///////////////////////////////////////////////////////////////

      int delta=25,level=100;
      double slowCCI[20], fastCCI[20];
      int a, up=0, dn=0, upnt=5,dpnt=5;
      for (a=0;a<20;a++)
      {
         fastCCI[a]=iCCI(NULL,0,fastPeriod,PRICE_TYPICAL,shift+a);
         slowCCI[a]=iCCI(NULL,0,slowPeriod,PRICE_TYPICAL,shift+a);
         if (a<8) {
            if (slowCCI[a]>0) up++;
            if (slowCCI[a]<=0) dn++;
         }
		}

      ///////////////////////////////////////////////////////////////
      // ?????1 - ??? ? ???????(ZLR)
      // -----------------------------------------------------------
      // ????"??? ? ??????? (ZLR)" ?????? ???
      // ??????? CCI ? ???????(ZL) ??? ???,
      // ?????? ??? ??? ???? CCI ??????????
      // ???? ????? ? +100 ? -100  ?? ??  ????
      // ????? ???? ???? ????????? ??????
      // ???? ? +/-50, ???, ??? ???????? ???
      // ???. ???? ?????? ? ??? ??, ??????????
      // ????????? ???????
      // ???? ????? ???????????? ZLR ????
      // Woodies CCI ??????? ???? ????????? ?????
      // ???? ????????????? ???? ? ?? ?
      // ?????? ?????? ??????, ? ??????????
      // ???CCI.
      // ?? ??????????? ?????????? ? ??,
      // ? ??? ????? ??????????? ZLR ??????
      // "??? ?????? (TLB)". ?????????ZLR ?????
      // ?TLB ?? ???? ????? ????????? ??? CCI
      // ???? TLB. ???? ???????? ????
      // ZLR - ???? ? ???. ????? ?? ??? ????
      // ????? ?????? ???? ?????????Woodies CCI,
      // ?????????? ????? ??? ???? ??????
      // ????
      // ----
      delta=20;  // ??? ??? (|?I[1]-?I[2]|>delta)
      level=80; // ??? ????????
      ZlrBuffer[shift]=EMPTY_VALUE;
      // ---- ZLR ??????????
      if ( dn>=6 &&
      slowCCI[0]<slowCCI[1] && slowCCI[2]<slowCCI[1] &&
      MathAbs(slowCCI[0])<level && MathAbs(slowCCI[1])<level &&
      MathAbs(slowCCI[1]-slowCCI[2])>delta )
	   {
         ZlrBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
	   }
	   // ZLR ??????????
      if ( up>=6
      && slowCCI[0]>slowCCI[1] && slowCCI[2]>slowCCI[1] &&
      MathAbs(slowCCI[0])<level && MathAbs(slowCCI[1])<level &&
      MathAbs(slowCCI[1]-slowCCI[2])>delta )
	   {
         ZlrBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
	   }

      ///////////////////////////////////////////////////////////////
      // ?????2 - ?? (shamu trade)
      // -----------------------------------------------------------
      // ????"?? (shamu trade)" ??????, ???CCI ?????
      // ???????(ZL), ??????????? ???????
      // ????? ???????(ZL) ???????????????
      // ??????????????? ?????? ???????
      // ????? ???? ???????? ??????
      // ??- ?????????? ???? ??? ZL.
      // ? ? ?????? ?????????????? ???????
      // ? ??? ???? ?? ?????? ?????????????
      // CCI ????? ???? +/-50.
      // ???? ?????? - ???????? ????ZLR.
      // ???????????????ZLR. ? ZLR ?????? ?
      // ???????????????? ???????, ?????
      // ??? ????. ????? ? ? ?????????????? ?,
      // ?????? ???? ???? ??? ?? ? ?? ?? ????
      // ????? ????? ????? ????? ???? ZLR,
      // ? ????? ?? ??? ? ???? ? ??? ? ??? ????
      // ?????? ???????.
      // ???? ???????? ???? ?? - ? ?? ?????
      // ????????, ??? ????????? ???? ? ????
      // stop-and-reverse (SAR) ??????? ZLR. ???? ???
      // ???? ????????Woodies CCI, ? ??? ??????
      // ?? ??? ????. ??? ???? ? ?? ???? ?
      // ???? ? ?? ?????? ????? ????
      // ----
      delta=15; level=50;
      ShamuBuffer[shift]=EMPTY_VALUE;
      // ?? ??????????
      if (dn>=6 &&
	   slowCCI[0]>slowCCI[1]+delta &&
	   slowCCI[1]<slowCCI[2] && slowCCI[2]>slowCCI[3] &&
	   slowCCI[1]<=level && slowCCI[1]>=-level &&
	   slowCCI[2]<=level && slowCCI[2]>=-level)
	   {
         ShamuBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
	   }
	   // ?? ??????????
	   if (up>=6 &&
	   slowCCI[0]<slowCCI[1]-delta &&
	   slowCCI[1]>slowCCI[2] && slowCCI[2]<slowCCI[3] &&
	   slowCCI[1]>=-level && slowCCI[1]<=level &&
	   slowCCI[2]>=-level && slowCCI[2]<=level)
	   {
         ShamuBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
	   }

      ///////////////////////////////////////////////////////////////
      // ?????3 - ??? ?????? (TLB)
      // -----------------------------------------------------------
      // ????"??? ?????? (TLB)" ????? ???????
      // ????????? ?? ?????? ????? CCI ??TCCI
      // ?? ??, ??????? ???????????. ????????
      // ?????? CCI ?? ?????? (tl), ???????? ??
      // ???? ???? ????, ?????? ?????????,
      // ?? ????????? ??? ??????? ? ??? +/-100
      // CCI ????? ????? ??????? ?????? ??? ???,
      // ????????? ???????. ?????????? ?? ???
      // ???? ????? ????? ???????????????
      // ????TLB. ??????? ????? ???????????
      // CCI ?TCCI ?? ??? ??????. ?? ?????????????
      // ???? ? ???? ??? ????CCI ??? ???????.
      // ????? ??? ???? ?????? ?????Woodies CCI.
      // ???? ???????? ???? TLB ????????? ??
      // ? ???, ?????? ???. ???? ?????? ????
      // Woodies CCI, ??? ?????????????? TLB ??? ?
      // ???. ??? ?????????? ????? ??? ??
      // ?????? ????? ????
      // ? ??? ?????????????????? "????
      // ???????(ZLR)" ????? "???? ?????? (rev diver)"
      // ??????"??? ?????? (TLB)" ?? ???? ?????
      // ?????????? ???. ??? ????? ????????
      // ????? ????????????????, ???????
      // ????? ??????????
      // ??? ??????????? ? TLB ????????????
      // ??????????? ? CCI, - ??????? ??? +/-100.
      // ???? ?????? ????? ???. ? ??? ? ??????
      // ?? ???? ??? ??? ???? ??????????????
      // ? TLB, ?? ? ????????? ??????. ??? ?? ?
      // ? ???? ???????CCI ??? ?????? ? ??? +/-100,
      // ????? ???? ? TLB ??????? ?????? ????
      // ??? ?????????????? ? ???????????
      // ? ????????? ???? ?????? ????????? TLB ?
      // ZLR. ??? ??? ??? ???????????? ????"rev diver".
      // ? ??? ??? ????? ???CCI ???? ?????? ? ???,
      // ?????????? ???, ??????????? ????????
      // ???? ?????????? ?? CCI ???? ???????????
      // ??? ?? ?????????? ? ????? ????, ? ??????
      // ??? ?? ??? ???????.
      // -----------------------------------------------------------
      // ??? ??????? ?????? (HTLB)
      // -----------------------------------------------------------
      // ?????? ? ??? ??????? ?????? (HTLB) -
      // ??? ??? ????? ??????????????????
      // CCI ?TCCI ? ??????????? ??? ???????????
      // ??????????? ? ???? ?????? ?????
      // ?????? CCI.
      // ?????? ??????? ???????? ?????????
      // ??? ? ???????? ??????? ??? ????????
      // ??? ??????? ? ???????? ??????? ???
      // ?????????? ?????????? ???????
      // ??????, ???????????? +/-50.
      // ???? ??????? ??? ??? ???? ?????????
      // ??????, ? ????? ??????????????
      // ??? ???? ?? ???? ??????? ?????????,
      // ????? ??????????? ??? ?? ?? ???????
      // ???????. ???????? ??????????????
      // ???? ? ???????, ???????? ?? ???????
      // ????????? ????????? ???
      // ???? ? ??? ??????? ?????? ???????
      // ??? ???, ?????? ???. ????? ???? ? ???
      // ??????????? ????????.
      // ----

      delta=25; level=100;
      // ----
      TlbBuffer[shift]=EMPTY_VALUE;
      int min1=0,min2=0,min3=0,max1=0,max2=0,max3=0;        // ???? ????
      int tmin1=0,tmin2=0,tmin3=0,tmax1=0,tmax2=0,tmax3=0;  // ??? ????
      double kmin=0,kmax=0; // ???? ??????
      double line;
      //	?????????? ?????? ??????
      for (a=0;a<=17;a++)
      {
         // ???????????
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
            if (max1!=0 && max2==0)
				{
					max2=slowCCI[a+1];
					tmax2=Time[a+1+shift];
					kmax=100*(max2-max1)/(tmax2-tmax1);
				}
				if (max1==0)
				{
					max1=slowCCI[a+1];
					tmax1=Time[a+1+shift];
				}
			}
         // ???????????
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min1!=0 && min2==0)
				{
					min2=slowCCI[a+1];
					tmin2=Time[a+1+shift];
					kmin=100*(min2-min1)/(tmin2-tmin1);
				}
				if (min1==0)
				{
					min1=slowCCI[a+1];
					tmin1=Time[a+1+shift];
				}
			}
      }

      // TLB ctr ??????????
      if (kmax!=0 && dn>=6 && (max1<-level || max2<-level))
      {
		   line=(Time[shift]-tmax1)*kmax/100+max1;
		   if (slowCCI[1]<line && slowCCI[0]>=line)
		   {
		      TlbBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
		   }
      }
      //  TLB ctr ??????????
      if (kmin!=0 && up>=6 && (min1>level || min2>level))
      {
		   line=(Time[shift]-tmin1)*kmin/100+min1;
         if (slowCCI[1]>line && slowCCI[0]<=line)
         {
            TlbBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
         }
      }
      // TLB tr ??????????
	   if (kmin!=0 && dn >=6 && (min1<-level || min2<-level))
      {
         line=(Time[shift]-tmin1)*kmin/100+min1;
         if (slowCCI[1]>line && slowCCI[0]<line)
         {
            TlbBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
         }
		}
      //  TLB tr ??????????
      if (kmax!=0 && up>=6 && (max1>level || max2>level))
      {
		   line=(Time[shift]-tmax1)*kmax/100+max1;
         if (slowCCI[1]<line && slowCCI[0]>line)
         {
            TlbBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
         }
      }

      ///////////////////////////////////////////////////////////////
      // ?????4 - ???(VT)
      // -----------------------------------------------------------
      // ???????(VT) ????? ??????????? ???
      // ?-???, ??? ????? CCI ????"????????? (HFE)",
      // ????????? ????? ???CCI ?????? ????
      // ??????????????????. ??????? ??????
      // ?? ??????3 ?? ? ????????????????? ??
      // ???????? ??????????? ???????????
      // ??????? ??, ? ???????? ???????(ZL) ??????
      // ???????? ??? ????????VT ??? ???????
      // ??? ? ???????? ??????? ??????, ?????
      // ???(? ???CCI) ????? ???? high/low ? ????? ??????
      // ??? ????. ?????????? ????? ????????
      // ???? high/low ????? ?????? ???. ??????????
      // ?????????????high/low. ??????????????
      // ???? ??????????? ???, ???? ??? ???????
      // ????? ????????.
      // ????? ??????? - ??? ???, ?????? ??? ???
      // ?? ??????????????. ??? ??????? ?????? -
      // ???? ?????.
      // ----
      // ??? ??? ????"???(VT)" ?????? ????? ? ???
      // ? 8 ? 12 ??????? ? ?? ? ????? ?????????
      // ????? ????? ??, ????????? ??? ?????, ???
      // ???? ????? ???. ????"???(VT)"  ??????
      // ???????????????????? ????? ???.
      // Woodie ?????? ???????????? 25-lsma ?????
      // ????????? ???? ???? ???? "???(VT)".
      // ???25-lsma ??????????, ???? ????? ? ????
      // ?????? ???? ???? "???(VT)", ????? ????
      // ?????? ??, ?????? ???????. ??????
      // ??????????LSMA ???? Least Squares Moving Average,
      // ???? ?????? ???? ????? ??????????
      // ??????????????? "??? ???? ?????
      // (Linear Regression Curve).
      // ???????? ?? ????"???(VT)" ?????? ??
      // ???? ??? ?????, ????? ?? ?? 25-lsma ?????
      // ? ? ?????? 25-lsma ????????????? ?? ????
      // VT ?????? ?? ???????? ?????, ????? ??
      // ?? 25-lsma ? ?????, ???25-lsma ????????????.
      // ????? ? ????? ??, ????????? ????Woodies CCI,
      // ? ??????? ? ?????? ????? ??? 25-lsma ?????
      // ?????????? 25-lsma ????? ??????? ???????
      // ?CCI, ??????????? ???? ????? ????.
      // ???? ???????? ???? "??? ? ?? - ????
      // ??? ???.
      // ----
      delta=10; limit=200;
      // ----
      max1=0; max2=0; tmax1=0; tmax2=0;
      min1=0; min2=0; tmin1=0; tmin2=0;
      VegasBuffer[shift]=EMPTY_VALUE;
      // ?????????
      if  (dn>=6)
      {
         for (a=13;a>=1;a--)
         {
            if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2] &&
            min1!=0 && max1==0)
            {
               max1=slowCCI[a+1];
					tmax1=a+1;
			   }
            if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2] &&
             min1==0 && slowCCI[a+1]<=-limit && a+1>=5)
            {
					min1=slowCCI[a+1];
					tmin1=a+1;
            }
         }
	   }
      //  ?????????
      if (up>=6)
      {
         for (a=13;a>=1;a--)
         {
			   if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2] &&
			   min2!=0 && max2==0)
            {
					min2=slowCCI[a+1];
					tmin2=a+1;
            }
            if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2] &&
            max2==0 && slowCCI[a+1]>=limit && a+1>=5)
            {
               max2=slowCCI[a+1];
               tmax2=a+1;
            }
         }
      }

      // Vegas ??????????
      if (dn>=6 && max1!=0 && slowCCI[1]<max1 && slowCCI[0]>=max1 &&
      slowCCI[0]-delta>slowCCI[1] /* && slowCCI[0]>slowCCI[1] && !(slowCCI[1]-delta>slowCCI[2]) */)
      {
		   VegasBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }
      //  Vegas ??????????
      if (up >=6 && min2!=0 && slowCCI[1]>min2 && slowCCI[0]<=min2 &&
      slowCCI[0]+delta<slowCCI[1]
		/* && slowCCI[0]<slowCCI[1] && !(slowCCI[1]+delta<slowCCI[2]) */)
      {
			VegasBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ?????5 - ????(Ghost)
      // -----------------------------------------------------------
      // ????"???? ?????? 3 ????? ????????????
      // ????: ?? ??, ??? ??????? ??. (????,
      // ??? ??????? "??? ????). ????? ?????
      // ?????? ??CCI, ???TCCI. ??? ??? ??????
      // ?????????? CCI ?? ?????? ???????.
      // ?????, ?????? ?? ??? ??. ?? ??????
      // ??????? ??? ??? ???? "???? - ???
      // ??- ????? ??? ???.
      // ? ??? ????? ????????? CCI ?? ???? "????,
      // ???? ??????? ??????? ? ????? ??????
      // ?????????? ?????? ??? ?????????
      // ?????? ????? ? ??? ? ???????????
      // ??????????? CCI ? ????? ????? ???
      // ???????? ????? CCI ?? ??? ? ??? ??
      // ??? ??? ??? - ?????? ????????,
      // ??????????? Woodies CCI.
      // ????, ?? ???? ??????????(??? ???)
      // ? ???? "????, ? ??????????"??? ???
      // ??? (TLB)" ??????"????, ?????????? ?
      // ???????????? ???. ??? ??? ???????
      // ? ?????????????? ??- ???????????
      // ???????? "???? ? ???????? ??????
      // ??? ???????? ? ??????? ??????? ??
      // ???? ????? ?????? ?? ????.
      // ???? ???????? ???? "???? ? ?? - ????
      // ??? ???.
      // -----
      delta=15; level=50;
      max1=0; max2=0; max3=0; tmax1=0; tmax2=0; tmax3=0;
      min1=0; min2=0; min3=0; tmin1=0; tmin2=0; tmin3=0;
      // -----
      GhostBuffer[shift]=EMPTY_VALUE;
      // ???????????
      if (up>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
				if (max2!=0 && max3==0) max3=slowCCI[a+1];
				if (max1!=0 && max2==0) max2=slowCCI[a+1];
				if (max1==0) max1=slowCCI[a+1];
			}
      }
      // ???????????
      if (dn>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min2!=0 && min3==0) min3=slowCCI[a+1];
				if (min1!=0 && min2==0) min2=slowCCI[a+1];
				if (min1==0) min1=slowCCI[a+1];
			}
      }
      // Ghost ??????????
	   if (dn>=6 &&
	   min3!=0 && min1>min2 && min3>min2+delta && min1<0 &&
		slowCCI[0]-delta>min1 && slowCCI[0]>slowCCI[1] &&
   /* min3<0 && max1<=0 && max1>=-level && max2<=level && max2>=-level */
      !(slowCCI[1]-delta>min1))
      {
		   GhostBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }
      // Ghost ??????????
      if (up>=6 &&
      max3!=0 && max1<max2 && max3<max2-delta && max1>0 &&
      slowCCI[0]+delta<max1 && slowCCI[0]<slowCCI[1] &&
   /* max3>0 && min1<=level && min1>=0 && min2<=level && min2>=-level */
		!(slowCCI[1]+delta<max1))
      {
         GhostBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ?????6 - ?????? ?????? Woodies CCI (Rev Diver)
      // -----------------------------------------------------------
      // ?????? ?????? Woodies CCI (Rev Diver) - ???????
      // ???????? ? ???, ?????????? ???
      // ?????CCI, ?????? ????????? ???????????
      // ????? ??? ? ????????? ????? ?????
      // ?????CCI ??????. ? ????????? ????
      // ?? ??? ?? ????? ?????????????????????
      // ? ????? ????? ?????, ???????? ????Rev Diver.
      // ----
      // ???????????- ???? ??????? ?? ??????
      // ???? Rev Diver:
      // * Rev Diver ? ????- CCI ?? ?????????????????
      //   6 ??????? ??? ????- ?????? ????????
      // * Rev Diver ? ????- CCI ?? ?????????????????
      //   6 ??????? ??? ????- ?????? ?? ????????
      // ----
      // ????"?????? ??????" - ???????? ? ???.
      // ? ??? ????? ???? ???????? Rev Diver ??????
      // "??? ? ???????(ZLR)" ??"??? ?????? (TLB)"
      // ?? ???????????? ?????????? ???. ? ??????
      // ??? ??? ???? ????????? ZLR ??????Rev Diver.
      // ????? ?????? ????????? ZLR, ???????? Rev Diver,
      // ??????? ?? ??????????? ????? +/-100  ???CCI.
      // ????? ?? ??????????? ?????? ????CCI ZLR.
      // ????? ?????????? ?? ????? ??? ??? ????
      // ----
      delta=20; level=70;
      // ----
      max1=0; max2=0; tmax1=0; tmax2=0;
      min1=0; min2=0; tmin1=0; tmin2=0;
      // -----
      RevdevBuffer[shift]=EMPTY_VALUE;
      // ???????????
      if (dn>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
				if (max1!=0 && tmax1<3 && max2==0)
				{
					max2=slowCCI[a+1];
					tmax2=a+1;
				}
				if (max1==0)
				{
					max1=slowCCI[a+1];
					tmax1=a+1;
				}
			}
      }
      // ???????????
      if (up>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min1!=0 && tmin1<3 && min2==0)
				{
					min2=slowCCI[a+1];
					tmin2=a+1;
				}
				if (min1==0)
				{
					min1=slowCCI[a+1];
					tmin1=a+1;
				}
			}
      }
      // Revdiv ??????????
	   if (dn>=6 &&
	   max1<=0 && max2!=0 && max1>max2 && max1>=-level && tmax2-tmax1>=3 &&
   /* max2<=level && max2>=-level && */
	   slowCCI[0]+delta<max1 && slowCCI[0]<slowCCI[1] && !(slowCCI[1]+delta<max1) )
      {
         RevdevBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }
      // Revdiv ??????????
	   if (up>=6 &&
	   min1>=0 && min2!=0 && min1<min2 && min1<=level && tmin2-tmin1>=3 &&
   /* pmn2<=level && pmn2>=-level && */
      slowCCI[0]-delta>min1 && slowCCI[0]>slowCCI[1] && !(slowCCI[1]-delta>min1) )
      {
         RevdevBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ?????7 - ????????? (HFE)
      // -----------------------------------------------------------
      // ?? ??????????, ???CCI ??? ? ????+/-200,
      // ???????????? ??????????? ??- ???
      // ??????? ????. ????HFE ????? ???????
      // Woodies CCI ???? ???.
      // ----
      // ???? ? ??????? ????? ??????. ?????
      // ?? ???????? ??????????? ???? ?????
      // ??????? ??-?? ???? ????????? ?????
      // ???? ??? ????????? ??????. ?????
      // ????? ??? ???? - ???? ?????.
      // ???? ??????????? ??? ???????????,
      // ?? ?? ??CCI ????? ??? ?????? ????
      // ???? ????? ??????? 50%, ?? ???????
      // ??? ????HFE. ??? ??????? ??????????
      // ???? ?? ? ??? ?????? ??????-?? ???.
      // ???? ???????? ??????? ?? ?????
      // ????????, ???????????????????
      // ???????.
      // ----
      // ?? ???????????? ??? ????? ???? ?
      // HFE-???? ????? ?????? ????????? CCI
      // ??? +/-100, ????????? ????????????.
      // ----
      delta=10; level=200;
      HooksBuffer[shift]=EMPTY_VALUE;
      // HFE ??????????
      if (dn>=6 &&
      slowCCI[1]<=-level && slowCCI[0]>-level && slowCCI[1]<slowCCI[0]-delta)
      {
         HooksBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }
      // HFE ?????????
      if (up>=6 &&
      slowCCI[1]>=level && slowCCI[0]<level && slowCCI[1]>slowCCI[0]-delta)
      {
         HooksBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ??? ? ???
      // -----------------------------------------------------------
      // 1. ???? (CCI(14) ???? ??) ?????????? CCI
      // 2. ??? CCI ?????? (TLB)
      // 3. CCI(6) ????? CCI(14) ????
      // 4. CCI ????? ???????(ZLC).
      // 5. ???CCI 14 ???? ?? ?????? +/-200 ??? ??
      // 6. CCI (?????? ?????)
      // -----------------------------------------------------------

      // 1. ???? (CCI(14) ???? ??) ?????????? CCI
	   if (HooksBuffer[shift]!=EMPTY_VALUE)
      {
         if (up>=6)
	      {
		      ExitBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
		   }
	      if (dn>=6)
	      {
		      ExitBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
		   }
		}
      // 2. ??? CCI ?????? (??? ???)
      if (TlbBuffer[shift]!=EMPTY_VALUE)
      {
         if (up>=6 && TlbBuffer[shift]>High[shift])
	      {
		      ExitBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
		   }
	      if (dn>=6 && TlbBuffer[shift]<Low[shift])
	      {
		      ExitBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
		   }
		}
		/*
      // 3. CCI(6) ????? CCI(14) ????
      if (up>=6 && fastCCI[1]>=slowCCI[1] && fastCCI[0]<=slowCCI[0])
	   {
		   ExitBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
		}
	   if (dn>=6 && TlbBuffer[shift]<Low[shift])
	   {
		   ExitBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
		} */

/*
      delta=10; level=100;
      // ----
      ExitBuffer[shift]=EMPTY_VALUE;
      min1=0; max1=0; // ???? ????
      //	?????????? ?????? ??????
      for (a=0;a<=17;a++)
      {
         // ???????????
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
				if (max1==0) max1=slowCCI[a+1];
			}
         // ???????????
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min1==0) min1=slowCCI[a+1];
			}
      }
      // ?????????????
	   if (min1!=0 && slowCCI[0]-delta>min1 && !(slowCCI[1]-delta>min1) && MathAbs(slowCCI[0])>level)
      {
		   ExitBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
	   }
      // ?????????????
      if (max1!=0 && slowCCI[0]+delta<max1 && !(slowCCI[1]+delta<max1) && MathAbs(slowCCI[0])>level)
      {
		   ExitBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }
*/
   }
   return(0);
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

WcciPaterns Sep.mq4

#property copyright "(C)2005, Yuri Ershtad"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 MediumSeaGreen
#property indicator_color2 OrangeRed
#property indicator_color3 DeepSkyBlue
#property indicator_color4 IndianRed
#property indicator_color5 Tomato
#property indicator_color6 LimeGreen
#property indicator_color7 Coral
#property indicator_color8 Red

//////////////////////////////////////////////////////////////////////
// ????
//////////////////////////////////////////////////////////////////////

extern int fastPeriod  = 6;
extern int slowPeriod  = 14;

//////////////////////////////////////////////////////////////////////
// ??? ???
//////////////////////////////////////////////////////////////////////

double ZlrBuffer[];     // 1. Zero-line Reject (ZLR)      -- trend
double ShamuBuffer[];   // 2. Shamu Trade                 -- counter
double TlbBuffer[];     // 3. Trend Line Break (TLB/HTLB) -- both
double VegasBuffer[];   // 4. Vegas Trade (VT)			    -- counter
double GhostBuffer[];   // 5. Ghost Trade                 -- counter
double RevdevBuffer[];  // 6. Reverse Divergence          -- trend
double HooksBuffer[];   // 7. Hook from Extremes (HFE)    -- counter
double ExitBuffer[];    // 8. Exit signals

//////////////////////////////////////////////////////////////////////
// ???????
//////////////////////////////////////////////////////////////////////

int init()
{
   string short_name;
   IndicatorBuffers(8);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   ///////////////////////////////////////////////////////////////
   // ??????????? ????? 1 ? 8.
   // ?? ???? ????? ? ??? ?????? ???? ???
   // ??? ??? ????, ??? - ?? TLB ?HTLB
   // ----
   short_name="Woodies CCI Paterns ("+fastPeriod+","+slowPeriod+")";
   IndicatorShortName(short_name);
   // Zero-line Reject (ZLR), trend
   SetIndexStyle(0, DRAW_ARROW, EMPTY, 1, MediumSeaGreen);
   SetIndexBuffer(0, ZlrBuffer);
   SetIndexArrow(0, 140);
   SetIndexLabel(0,"Zero-line Reject (ZLR), trend");
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexDrawBegin(0, slowPeriod);
   // Shamu Trade, counter-trend
   SetIndexStyle(1, DRAW_ARROW, EMPTY, 1, OrangeRed);
   SetIndexBuffer(1, ShamuBuffer);
   SetIndexArrow(1, 141);
   SetIndexLabel(1,"Shamu Trade, counter-trend");
   SetIndexEmptyValue(1, EMPTY_VALUE);
   SetIndexDrawBegin(1, slowPeriod);
   // Trend Line Break (TLB), both
   SetIndexStyle(2, DRAW_ARROW, EMPTY, 1, DeepSkyBlue);
   SetIndexBuffer(2, TlbBuffer);
   SetIndexArrow(2, 142);
   SetIndexLabel(2,"Trend Line Break (TLB), both");
   SetIndexEmptyValue(2, EMPTY_VALUE);
   SetIndexDrawBegin(2, slowPeriod);
   // Vegas Trade (VT), counter-trend
   SetIndexStyle(3, DRAW_ARROW, EMPTY, 1, IndianRed);
   SetIndexBuffer(3, VegasBuffer);
   SetIndexArrow(3, 143);
   SetIndexLabel(3,"Vegas Trade (VT), counter-trend");
   SetIndexEmptyValue(3, EMPTY_VALUE);
   SetIndexDrawBegin(3, slowPeriod);
   // Ghost Trade, counter-trend
   SetIndexStyle(4, DRAW_ARROW, EMPTY, 1, Tomato);
   SetIndexBuffer(4, GhostBuffer);
   SetIndexArrow(4, 144);
   SetIndexLabel(4,"Ghost Trade, counter-trend");
   SetIndexEmptyValue(4, EMPTY_VALUE);
   SetIndexDrawBegin(4, slowPeriod);
   // Reverse Divergence, trend
   SetIndexStyle(5, DRAW_ARROW, EMPTY, 1, LimeGreen);
   SetIndexBuffer(5, RevdevBuffer);
   SetIndexArrow(5, 145);
   SetIndexLabel(5,"Reverse Divergence, trend");
   SetIndexEmptyValue(5, EMPTY_VALUE);
   SetIndexDrawBegin(5, slowPeriod);
   // Hook from Extremes (HFE), counter-trend
   SetIndexStyle(6, DRAW_ARROW, EMPTY, 1, Coral);
   SetIndexBuffer(6, HooksBuffer);
   SetIndexArrow(6, 146);
   SetIndexLabel(6,"Hook from Extremes (HFE), counter-trend");
   SetIndexEmptyValue(6, EMPTY_VALUE);
   SetIndexDrawBegin(6, slowPeriod);
   // Exit signal
   SetIndexStyle(7, DRAW_ARROW, EMPTY, 1, RoyalBlue);
   SetIndexBuffer(7, ExitBuffer);
   SetIndexArrow(7, 251);
   SetIndexLabel(7,"Exit signal");
   SetIndexEmptyValue(7, EMPTY_VALUE);
   SetIndexDrawBegin(7, slowPeriod);
   //----
   return(0);
}

//////////////////////////////////////////////////////////////////////
// Custor indicator deinitialization function
//////////////////////////////////////////////////////////////////////

int deinit()
{
   // TODO: add your code here
   return(0);
}

//////////////////////////////////////////////////////////////////////
// Custom indicator iteration function
//////////////////////////////////////////////////////////////////////

int start()
{
   string symbolName;
   int i, shift, checksum, counted_bars=IndicatorCounted();
   if (Bars<slowPeriod) return(0);
   // 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-slowPeriod-counted_bars;
   if (counted_bars<1 || checksum!=(fastPeriod+slowPeriod+Period()) || symbolName!=Symbol())
   {
      // ?????????, ???? ????????
      for(i=1;i<=slowPeriod;i++) ZlrBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) ShamuBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) TlbBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) VegasBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) GhostBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) RevdevBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) HooksBuffer[Bars-i]=EMPTY_VALUE;
      for(i=1;i<=slowPeriod;i++) ExitBuffer[Bars-i]=EMPTY_VALUE;
      checksum = fastPeriod+slowPeriod+Period();
      symbolName=Symbol();
      limit=Bars-slowPeriod;
   }
   for (shift=limit; shift>=0; shift--)
   {
      ///////////////////////////////////////////////////////////////
      //	????? ?????????????????
      ///////////////////////////////////////////////////////////////

      int delta=25,level=100;
      double slowCCI[20], fastCCI[20];
      int a, up=0, dn=0, upnt=5,dpnt=5;
      for (a=0;a<20;a++)
      {
         fastCCI[a]=iCCI(NULL,0,fastPeriod,PRICE_TYPICAL,shift+a);
         slowCCI[a]=iCCI(NULL,0,slowPeriod,PRICE_TYPICAL,shift+a);
         if (a<8) {
            if (slowCCI[a]>0) up++;
            if (slowCCI[a]<=0) dn++;
         }
		}

      ///////////////////////////////////////////////////////////////
      // ?????1 - ??? ? ???????(ZLR)
      // -----------------------------------------------------------
      // ????"??? ? ??????? (ZLR)" ?????? ???
      // ??????? CCI ? ???????(ZL) ??? ???,
      // ?????? ??? ??? ???? CCI ??????????
      // ???? ????? ? +100 ? -100  ?? ??  ????
      // ????? ???? ???? ????????? ??????
      // ???? ? +/-50, ???, ??? ???????? ???
      // ???. ???? ?????? ? ??? ??, ??????????
      // ????????? ???????
      // ???? ????? ???????????? ZLR ????
      // Woodies CCI ??????? ???? ????????? ?????
      // ???? ????????????? ???? ? ?? ?
      // ?????? ?????? ??????, ? ??????????
      // ???CCI.
      // ?? ??????????? ?????????? ? ??,
      // ? ??? ????? ??????????? ZLR ??????
      // "??? ?????? (TLB)". ?????????ZLR ?????
      // ?TLB ?? ???? ????? ????????? ??? CCI
      // ???? TLB. ???? ???????? ????
      // ZLR - ???? ? ???. ????? ?? ??? ????
      // ????? ?????? ???? ?????????Woodies CCI,
      // ?????????? ????? ??? ???? ??????
      // ????
      // ----
      delta=20;  // ??? ??? (|?I[1]-?I[2]|>delta)
      level=80; // ??? ????????
      ZlrBuffer[shift]=EMPTY_VALUE;
      // ---- ZLR ??????????
      if ( dn>=6 &&
      slowCCI[0]<slowCCI[1] && slowCCI[2]<slowCCI[1] &&
      MathAbs(slowCCI[0])<level && MathAbs(slowCCI[1])<level &&
      MathAbs(slowCCI[1]-slowCCI[2])>delta )
	   {
         ZlrBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
	   }
	   // ZLR ??????????
      if ( up>=6
      && slowCCI[0]>slowCCI[1] && slowCCI[2]>slowCCI[1] &&
      MathAbs(slowCCI[0])<level && MathAbs(slowCCI[1])<level &&
      MathAbs(slowCCI[1]-slowCCI[2])>delta )
	   {
         ZlrBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
	   }

      ///////////////////////////////////////////////////////////////
      // ?????2 - ?? (shamu trade)
      // -----------------------------------------------------------
      // ????"?? (shamu trade)" ??????, ???CCI ?????
      // ???????(ZL), ??????????? ???????
      // ????? ???????(ZL) ???????????????
      // ??????????????? ?????? ???????
      // ????? ???? ???????? ??????
      // ??- ?????????? ???? ??? ZL.
      // ? ? ?????? ?????????????? ???????
      // ? ??? ???? ?? ?????? ?????????????
      // CCI ????? ???? +/-50.
      // ???? ?????? - ???????? ????ZLR.
      // ???????????????ZLR. ? ZLR ?????? ?
      // ???????????????? ???????, ?????
      // ??? ????. ????? ? ? ?????????????? ?,
      // ?????? ???? ???? ??? ?? ? ?? ?? ????
      // ????? ????? ????? ????? ???? ZLR,
      // ? ????? ?? ??? ? ???? ? ??? ? ??? ????
      // ?????? ???????.
      // ???? ???????? ???? ?? - ? ?? ?????
      // ????????, ??? ????????? ???? ? ????
      // stop-and-reverse (SAR) ??????? ZLR. ???? ???
      // ???? ????????Woodies CCI, ? ??? ??????
      // ?? ??? ????. ??? ???? ? ?? ???? ?
      // ???? ? ?? ?????? ????? ????
      // ----
      delta=15; level=50;
      ShamuBuffer[shift]=EMPTY_VALUE;
      // ?? ??????????
      if (dn>=6 &&
	   slowCCI[0]>slowCCI[1]+delta &&
	   slowCCI[1]<slowCCI[2] && slowCCI[2]>slowCCI[3] &&
	   slowCCI[1]<=level && slowCCI[1]>=-level &&
	   slowCCI[2]<=level && slowCCI[2]>=-level)
	   {
         ShamuBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
	   }
	   // ?? ??????????
	   if (up>=6 &&
	   slowCCI[0]<slowCCI[1]-delta &&
	   slowCCI[1]>slowCCI[2] && slowCCI[2]<slowCCI[3] &&
	   slowCCI[1]>=-level && slowCCI[1]<=level &&
	   slowCCI[2]>=-level && slowCCI[2]<=level)
	   {
         ShamuBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
	   }

      ///////////////////////////////////////////////////////////////
      // ?????3 - ??? ?????? (TLB)
      // -----------------------------------------------------------
      // ????"??? ?????? (TLB)" ????? ???????
      // ????????? ?? ?????? ????? CCI ??TCCI
      // ?? ??, ??????? ???????????. ????????
      // ?????? CCI ?? ?????? (tl), ???????? ??
      // ???? ???? ????, ?????? ?????????,
      // ?? ????????? ??? ??????? ? ??? +/-100
      // CCI ????? ????? ??????? ?????? ??? ???,
      // ????????? ???????. ?????????? ?? ???
      // ???? ????? ????? ???????????????
      // ????TLB. ??????? ????? ???????????
      // CCI ?TCCI ?? ??? ??????. ?? ?????????????
      // ???? ? ???? ??? ????CCI ??? ???????.
      // ????? ??? ???? ?????? ?????Woodies CCI.
      // ???? ???????? ???? TLB ????????? ??
      // ? ???, ?????? ???. ???? ?????? ????
      // Woodies CCI, ??? ?????????????? TLB ??? ?
      // ???. ??? ?????????? ????? ??? ??
      // ?????? ????? ????
      // ? ??? ?????????????????? "????
      // ???????(ZLR)" ????? "???? ?????? (rev diver)"
      // ??????"??? ?????? (TLB)" ?? ???? ?????
      // ?????????? ???. ??? ????? ????????
      // ????? ????????????????, ???????
      // ????? ??????????
      // ??? ??????????? ? TLB ????????????
      // ??????????? ? CCI, - ??????? ??? +/-100.
      // ???? ?????? ????? ???. ? ??? ? ??????
      // ?? ???? ??? ??? ???? ??????????????
      // ? TLB, ?? ? ????????? ??????. ??? ?? ?
      // ? ???? ???????CCI ??? ?????? ? ??? +/-100,
      // ????? ???? ? TLB ??????? ?????? ????
      // ??? ?????????????? ? ???????????
      // ? ????????? ???? ?????? ????????? TLB ?
      // ZLR. ??? ??? ??? ???????????? ????"rev diver".
      // ? ??? ??? ????? ???CCI ???? ?????? ? ???,
      // ?????????? ???, ??????????? ????????
      // ???? ?????????? ?? CCI ???? ???????????
      // ??? ?? ?????????? ? ????? ????, ? ??????
      // ??? ?? ??? ???????.
      // -----------------------------------------------------------
      // ??? ??????? ?????? (HTLB)
      // -----------------------------------------------------------
      // ?????? ? ??? ??????? ?????? (HTLB) -
      // ??? ??? ????? ??????????????????
      // CCI ?TCCI ? ??????????? ??? ???????????
      // ??????????? ? ???? ?????? ?????
      // ?????? CCI.
      // ?????? ??????? ???????? ?????????
      // ??? ? ???????? ??????? ??? ????????
      // ??? ??????? ? ???????? ??????? ???
      // ?????????? ?????????? ???????
      // ??????, ???????????? +/-50.
      // ???? ??????? ??? ??? ???? ?????????
      // ??????, ? ????? ??????????????
      // ??? ???? ?? ???? ??????? ?????????,
      // ????? ??????????? ??? ?? ?? ???????
      // ???????. ???????? ??????????????
      // ???? ? ???????, ???????? ?? ???????
      // ????????? ????????? ???
      // ???? ? ??? ??????? ?????? ???????
      // ??? ???, ?????? ???. ????? ???? ? ???
      // ??????????? ????????.
      // ----

      delta=25; level=100;
      // ----
      TlbBuffer[shift]=EMPTY_VALUE;
      int min1=0,min2=0,min3=0,max1=0,max2=0,max3=0;        // ???? ????
      int tmin1=0,tmin2=0,tmin3=0,tmax1=0,tmax2=0,tmax3=0;  // ??? ????
      double kmin=0,kmax=0; // ???? ??????
      double line;
      //	?????????? ?????? ??????
      for (a=0;a<=17;a++)
      {
         // ???????????
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
            if (max1!=0 && max2==0)
				{
					max2=slowCCI[a+1];
					tmax2=Time[a+1+shift];
					kmax=100*(max2-max1)/(tmax2-tmax1);
				}
				if (max1==0)
				{
					max1=slowCCI[a+1];
					tmax1=Time[a+1+shift];
				}
			}
         // ???????????
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min1!=0 && min2==0)
				{
					min2=slowCCI[a+1];
					tmin2=Time[a+1+shift];
					kmin=100*(min2-min1)/(tmin2-tmin1);
				}
				if (min1==0)
				{
					min1=slowCCI[a+1];
					tmin1=Time[a+1+shift];
				}
			}
      }

      // TLB ctr ??????????
      if (kmax!=0 && dn>=6 && (max1<-level || max2<-level))
      {
		   line=(Time[shift]-tmax1)*kmax/100+max1;
		   if (slowCCI[1]<line && slowCCI[0]>=line)
		   {
		      TlbBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
		   }
      }
      //  TLB ctr ??????????
      if (kmin!=0 && up>=6 && (min1>level || min2>level))
      {
		   line=(Time[shift]-tmin1)*kmin/100+min1;
         if (slowCCI[1]>line && slowCCI[0]<=line)
         {
            TlbBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
         }
      }
      // TLB tr ??????????
	   if (kmin!=0 && dn >=6 && (min1<-level || min2<-level))
      {
         line=(Time[shift]-tmin1)*kmin/100+min1;
         if (slowCCI[1]>line && slowCCI[0]<line)
         {
            TlbBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
         }
		}
      //  TLB tr ??????????
      if (kmax!=0 && up>=6 && (max1>level || max2>level))
      {
		   line=(Time[shift]-tmax1)*kmax/100+max1;
         if (slowCCI[1]<line && slowCCI[0]>line)
         {
            TlbBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
         }
      }

      ///////////////////////////////////////////////////////////////
      // ?????4 - ???(VT)
      // -----------------------------------------------------------
      // ???????(VT) ????? ??????????? ???
      // ?-???, ??? ????? CCI ????"????????? (HFE)",
      // ????????? ????? ???CCI ?????? ????
      // ??????????????????. ??????? ??????
      // ?? ??????3 ?? ? ????????????????? ??
      // ???????? ??????????? ???????????
      // ??????? ??, ? ???????? ???????(ZL) ??????
      // ???????? ??? ????????VT ??? ???????
      // ??? ? ???????? ??????? ??????, ?????
      // ???(? ???CCI) ????? ???? high/low ? ????? ??????
      // ??? ????. ?????????? ????? ????????
      // ???? high/low ????? ?????? ???. ??????????
      // ?????????????high/low. ??????????????
      // ???? ??????????? ???, ???? ??? ???????
      // ????? ????????.
      // ????? ??????? - ??? ???, ?????? ??? ???
      // ?? ??????????????. ??? ??????? ?????? -
      // ???? ?????.
      // ----
      // ??? ??? ????"???(VT)" ?????? ????? ? ???
      // ? 8 ? 12 ??????? ? ?? ? ????? ?????????
      // ????? ????? ??, ????????? ??? ?????, ???
      // ???? ????? ???. ????"???(VT)"  ??????
      // ???????????????????? ????? ???.
      // Woodie ?????? ???????????? 25-lsma ?????
      // ????????? ???? ???? ???? "???(VT)".
      // ???25-lsma ??????????, ???? ????? ? ????
      // ?????? ???? ???? "???(VT)", ????? ????
      // ?????? ??, ?????? ???????. ??????
      // ??????????LSMA ???? Least Squares Moving Average,
      // ???? ?????? ???? ????? ??????????
      // ??????????????? "??? ???? ?????
      // (Linear Regression Curve).
      // ???????? ?? ????"???(VT)" ?????? ??
      // ???? ??? ?????, ????? ?? ?? 25-lsma ?????
      // ? ? ?????? 25-lsma ????????????? ?? ????
      // VT ?????? ?? ???????? ?????, ????? ??
      // ?? 25-lsma ? ?????, ???25-lsma ????????????.
      // ????? ? ????? ??, ????????? ????Woodies CCI,
      // ? ??????? ? ?????? ????? ??? 25-lsma ?????
      // ?????????? 25-lsma ????? ??????? ???????
      // ?CCI, ??????????? ???? ????? ????.
      // ???? ???????? ???? "??? ? ?? - ????
      // ??? ???.
      // ----
      delta=10; limit=200;
      // ----
      max1=0; max2=0; tmax1=0; tmax2=0;
      min1=0; min2=0; tmin1=0; tmin2=0;
      VegasBuffer[shift]=EMPTY_VALUE;
      // ?????????
      if  (dn>=6)
      {
         for (a=13;a>=1;a--)
         {
            if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2] &&
            min1!=0 && max1==0)
            {
               max1=slowCCI[a+1];
					tmax1=a+1;
			   }
            if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2] &&
             min1==0 && slowCCI[a+1]<=-limit && a+1>=5)
            {
					min1=slowCCI[a+1];
					tmin1=a+1;
            }
         }
	   }
      //  ?????????
      if (up>=6)
      {
         for (a=13;a>=1;a--)
         {
			   if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2] &&
			   min2!=0 && max2==0)
            {
					min2=slowCCI[a+1];
					tmin2=a+1;
            }
            if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2] &&
            max2==0 && slowCCI[a+1]>=limit && a+1>=5)
            {
               max2=slowCCI[a+1];
               tmax2=a+1;
            }
         }
      }

      // Vegas ??????????
      if (dn>=6 && max1!=0 && slowCCI[1]<max1 && slowCCI[0]>=max1 &&
      slowCCI[0]-delta>slowCCI[1] /* && slowCCI[0]>slowCCI[1] && !(slowCCI[1]-delta>slowCCI[2]) */)
      {
		   VegasBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }
      //  Vegas ??????????
      if (up >=6 && min2!=0 && slowCCI[1]>min2 && slowCCI[0]<=min2 &&
      slowCCI[0]+delta<slowCCI[1]
		/* && slowCCI[0]<slowCCI[1] && !(slowCCI[1]+delta<slowCCI[2]) */)
      {
			VegasBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ?????5 - ????(Ghost)
      // -----------------------------------------------------------
      // ????"???? ?????? 3 ????? ????????????
      // ????: ?? ??, ??? ??????? ??. (????,
      // ??? ??????? "??? ????). ????? ?????
      // ?????? ??CCI, ???TCCI. ??? ??? ??????
      // ?????????? CCI ?? ?????? ???????.
      // ?????, ?????? ?? ??? ??. ?? ??????
      // ??????? ??? ??? ???? "???? - ???
      // ??- ????? ??? ???.
      // ? ??? ????? ????????? CCI ?? ???? "????,
      // ???? ??????? ??????? ? ????? ??????
      // ?????????? ?????? ??? ?????????
      // ?????? ????? ? ??? ? ???????????
      // ??????????? CCI ? ????? ????? ???
      // ???????? ????? CCI ?? ??? ? ??? ??
      // ??? ??? ??? - ?????? ????????,
      // ??????????? Woodies CCI.
      // ????, ?? ???? ??????????(??? ???)
      // ? ???? "????, ? ??????????"??? ???
      // ??? (TLB)" ??????"????, ?????????? ?
      // ???????????? ???. ??? ??? ???????
      // ? ?????????????? ??- ???????????
      // ???????? "???? ? ???????? ??????
      // ??? ???????? ? ??????? ??????? ??
      // ???? ????? ?????? ?? ????.
      // ???? ???????? ???? "???? ? ?? - ????
      // ??? ???.
      // -----
      delta=15; level=50;
      max1=0; max2=0; max3=0; tmax1=0; tmax2=0; tmax3=0;
      min1=0; min2=0; min3=0; tmin1=0; tmin2=0; tmin3=0;
      // -----
      GhostBuffer[shift]=EMPTY_VALUE;
      // ???????????
      if (up>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
				if (max2!=0 && max3==0) max3=slowCCI[a+1];
				if (max1!=0 && max2==0) max2=slowCCI[a+1];
				if (max1==0) max1=slowCCI[a+1];
			}
      }
      // ???????????
      if (dn>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min2!=0 && min3==0) min3=slowCCI[a+1];
				if (min1!=0 && min2==0) min2=slowCCI[a+1];
				if (min1==0) min1=slowCCI[a+1];
			}
      }
      // Ghost ??????????
	   if (dn>=6 &&
	   min3!=0 && min1>min2 && min3>min2+delta && min1<0 &&
		slowCCI[0]-delta>min1 && slowCCI[0]>slowCCI[1] &&
   /* min3<0 && max1<=0 && max1>=-level && max2<=level && max2>=-level */
      !(slowCCI[1]-delta>min1))
      {
		   GhostBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }
      // Ghost ??????????
      if (up>=6 &&
      max3!=0 && max1<max2 && max3<max2-delta && max1>0 &&
      slowCCI[0]+delta<max1 && slowCCI[0]<slowCCI[1] &&
   /* max3>0 && min1<=level && min1>=0 && min2<=level && min2>=-level */
		!(slowCCI[1]+delta<max1))
      {
         GhostBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ?????6 - ?????? ?????? Woodies CCI (Rev Diver)
      // -----------------------------------------------------------
      // ?????? ?????? Woodies CCI (Rev Diver) - ???????
      // ???????? ? ???, ?????????? ???
      // ?????CCI, ?????? ????????? ???????????
      // ????? ??? ? ????????? ????? ?????
      // ?????CCI ??????. ? ????????? ????
      // ?? ??? ?? ????? ?????????????????????
      // ? ????? ????? ?????, ???????? ????Rev Diver.
      // ----
      // ???????????- ???? ??????? ?? ??????
      // ???? Rev Diver:
      // * Rev Diver ? ????- CCI ?? ?????????????????
      //   6 ??????? ??? ????- ?????? ????????
      // * Rev Diver ? ????- CCI ?? ?????????????????
      //   6 ??????? ??? ????- ?????? ?? ????????
      // ----
      // ????"?????? ??????" - ???????? ? ???.
      // ? ??? ????? ???? ???????? Rev Diver ??????
      // "??? ? ???????(ZLR)" ??"??? ?????? (TLB)"
      // ?? ???????????? ?????????? ???. ? ??????
      // ??? ??? ???? ????????? ZLR ??????Rev Diver.
      // ????? ?????? ????????? ZLR, ???????? Rev Diver,
      // ??????? ?? ??????????? ????? +/-100  ???CCI.
      // ????? ?? ??????????? ?????? ????CCI ZLR.
      // ????? ?????????? ?? ????? ??? ??? ????
      // ----
      delta=20; level=70;
      // ----
      max1=0; max2=0; tmax1=0; tmax2=0;
      min1=0; min2=0; tmin1=0; tmin2=0;
      // -----
      RevdevBuffer[shift]=EMPTY_VALUE;
      // ???????????
      if (dn>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
				if (max1!=0 && tmax1<3 && max2==0)
				{
					max2=slowCCI[a+1];
					tmax2=a+1;
				}
				if (max1==0)
				{
					max1=slowCCI[a+1];
					tmax1=a+1;
				}
			}
      }
      // ???????????
      if (up>=6) for (a=0;a<=17;a++)
      {
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min1!=0 && tmin1<3 && min2==0)
				{
					min2=slowCCI[a+1];
					tmin2=a+1;
				}
				if (min1==0)
				{
					min1=slowCCI[a+1];
					tmin1=a+1;
				}
			}
      }
      // Revdiv ??????????
	   if (dn>=6 &&
	   max1<=0 && max2!=0 && max1>max2 && max1>=-level && tmax2-tmax1>=3 &&
   /* max2<=level && max2>=-level && */
	   slowCCI[0]+delta<max1 && slowCCI[0]<slowCCI[1] && !(slowCCI[1]+delta<max1) )
      {
         RevdevBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }
      // Revdiv ??????????
	   if (up>=6 &&
	   min1>=0 && min2!=0 && min1<min2 && min1<=level && tmin2-tmin1>=3 &&
   /* pmn2<=level && pmn2>=-level && */
      slowCCI[0]-delta>min1 && slowCCI[0]>slowCCI[1] && !(slowCCI[1]-delta>min1) )
      {
         RevdevBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ?????7 - ????????? (HFE)
      // -----------------------------------------------------------
      // ?? ??????????, ???CCI ??? ? ????+/-200,
      // ???????????? ??????????? ??- ???
      // ??????? ????. ????HFE ????? ???????
      // Woodies CCI ???? ???.
      // ----
      // ???? ? ??????? ????? ??????. ?????
      // ?? ???????? ??????????? ???? ?????
      // ??????? ??-?? ???? ????????? ?????
      // ???? ??? ????????? ??????. ?????
      // ????? ??? ???? - ???? ?????.
      // ???? ??????????? ??? ???????????,
      // ?? ?? ??CCI ????? ??? ?????? ????
      // ???? ????? ??????? 50%, ?? ???????
      // ??? ????HFE. ??? ??????? ??????????
      // ???? ?? ? ??? ?????? ??????-?? ???.
      // ???? ???????? ??????? ?? ?????
      // ????????, ???????????????????
      // ???????.
      // ----
      // ?? ???????????? ??? ????? ???? ?
      // HFE-???? ????? ?????? ????????? CCI
      // ??? +/-100, ????????? ????????????.
      // ----
      delta=10; level=200;
      HooksBuffer[shift]=EMPTY_VALUE;
      // HFE ??????????
      if (dn>=6 &&
      slowCCI[1]<=-level && slowCCI[0]>-level && slowCCI[1]<slowCCI[0]-delta)
      {
         HooksBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
      }
      // HFE ?????????
      if (up>=6 &&
      slowCCI[1]>=level && slowCCI[0]<level && slowCCI[1]>slowCCI[0]-delta)
      {
         HooksBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }

      ///////////////////////////////////////////////////////////////
      // ??? ? ???
      // -----------------------------------------------------------
      // 1. ???? (CCI(14) ???? ??) ?????????? CCI
      // 2. ??? CCI ?????? (TLB)
      // 3. CCI(6) ????? CCI(14) ????
      // 4. CCI ????? ???????(ZLC).
      // 5. ???CCI 14 ???? ?? ?????? +/-200 ??? ??
      // 6. CCI (?????? ?????)
      // -----------------------------------------------------------

      // 1. ???? (CCI(14) ???? ??) ?????????? CCI
	   if (HooksBuffer[shift]!=EMPTY_VALUE)
      {
         if (up>=6)
	      {
		      ExitBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
		   }
	      if (dn>=6)
	      {
		      ExitBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
		   }
		}
      // 2. ??? CCI ?????? (??? ???)
      if (TlbBuffer[shift]!=EMPTY_VALUE)
      {
         if (up>=6 && TlbBuffer[shift]>High[shift])
	      {
		      ExitBuffer[shift]=High[shift]+upnt*Point;
            upnt=upnt+5;
		   }
	      if (dn>=6 && TlbBuffer[shift]<Low[shift])
	      {
		      ExitBuffer[shift]=Low[shift]-dpnt*Point;
            dpnt=dpnt+5;
		   }
		}
		/*
      // 3. CCI(6) ????? CCI(14) ????
      if (up>=6 && fastCCI[1]>=slowCCI[1] && fastCCI[0]<=slowCCI[0])
	   {
		   ExitBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
		}
	   if (dn>=6 && TlbBuffer[shift]<Low[shift])
	   {
		   ExitBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
		} */

/*
      delta=10; level=100;
      // ----
      ExitBuffer[shift]=EMPTY_VALUE;
      min1=0; max1=0; // ???? ????
      //	?????????? ?????? ??????
      for (a=0;a<=17;a++)
      {
         // ???????????
         if (slowCCI[a]<=slowCCI[a+1] && slowCCI[a+1]>=slowCCI[a+2])
			{
				if (max1==0) max1=slowCCI[a+1];
			}
         // ???????????
         if (slowCCI[a]>=slowCCI[a+1] && slowCCI[a+1]<=slowCCI[a+2])
			{
				if (min1==0) min1=slowCCI[a+1];
			}
      }
      // ?????????????
	   if (min1!=0 && slowCCI[0]-delta>min1 && !(slowCCI[1]-delta>min1) && MathAbs(slowCCI[0])>level)
      {
		   ExitBuffer[shift]=Low[shift]-dpnt*Point;
         dpnt=dpnt+5;
	   }
      // ?????????????
      if (max1!=0 && slowCCI[0]+delta<max1 && !(slowCCI[1]+delta<max1) && MathAbs(slowCCI[0])>level)
      {
		   ExitBuffer[shift]=High[shift]+upnt*Point;
         upnt=upnt+5;
      }
*/
   }
   return(0);
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

WcciChart.mq4

#property copyright "Copyright ?2005, Gaba"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Silver
#property indicator_color2 LimeGreen
#property indicator_color3 OrangeRed
#property indicator_color4 Silver
#property indicator_color5 Black

#property indicator_minimum -300
#property indicator_maximum  300

#property indicator_level1  200
#property indicator_level2  100
#property indicator_level3 -100
#property indicator_level4 -200

//////////////////////////////////////////////////////////////////////
// ????
//////////////////////////////////////////////////////////////////////

extern int fastPeriod  = 6;
extern int slowPeriod  = 14;
extern int histLength  = 500;

//////////////////////////////////////////////////////////////////////
// ??? ???
//////////////////////////////////////////////////////////////////////

double FastBuffer[];    // ????CCI
double SlowBuffer[];    // ?????CCI
double HistBuffer[];
double UpTrBuffer[];
double DnTrBuffer[];

//////////////////////////////////////////////////////////////////////
// ???????
//////////////////////////////////////////////////////////////////////

int init()
{
   string short_name;
   IndicatorBuffers(5);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   short_name="WoodiesCCI("+fastPeriod+","+slowPeriod+")";
   IndicatorShortName(short_name);
   // indicator lines ////////////////////////////////
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, HistBuffer);
   SetIndexDrawBegin(0, slowPeriod);
   SetIndexLabel(0,"SlowCCI histogram");
   SetIndexEmptyValue(0, EMPTY_VALUE);
   //////////////////////////////////////////////////
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, UpTrBuffer);
   SetIndexDrawBegin(1, slowPeriod);
   SetIndexLabel(1,"UpTrend histogram");
   SetIndexEmptyValue(1, EMPTY_VALUE);
   //////////////////////////////////////////////////
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexBuffer(2, DnTrBuffer);
   SetIndexDrawBegin(2, slowPeriod);
   SetIndexLabel(2,"DnTrend histogram");
   SetIndexEmptyValue(2, EMPTY_VALUE);
   //////////////////////////////////////////////////
   SetIndexStyle(3, DRAW_LINE,1,3);
   SetIndexBuffer(3, SlowBuffer);
   SetIndexDrawBegin(3, slowPeriod);
   SetIndexLabel(3,"SlowCCI("+slowPeriod+")");
   SetIndexEmptyValue(3, EMPTY_VALUE);
   //////////////////////////////////////////////////
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, FastBuffer);
   SetIndexDrawBegin(4, slowPeriod);
   SetIndexLabel(4,"FastCCI("+fastPeriod+")");
   SetIndexEmptyValue(4, EMPTY_VALUE);
   //////////////////////////////////////////////////
   return(0);
}

//////////////////////////////////////////////////////////////////////
// Custor indicator deinitialization function
//////////////////////////////////////////////////////////////////////

int deinit()
{
   // TODO: add your code here
   return(0);
}

//////////////////////////////////////////////////////////////////////
// Custom indicator iteration function
//////////////////////////////////////////////////////////////////////

int start()
{
   string symbolName;
   int i, shift, checksum, counted_bars=IndicatorCounted();
   double slowCCI=0.0;
   if (Bars<slowPeriod) return(0);
   // 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;
   if (counted_bars<1 || checksum!=(histLength+fastPeriod+slowPeriod+Period()) || symbolName!=Symbol())
   {
      // ?????????, ???? ????????
      for(i=Bars-1; i<=Bars-histLength; i++)
      {
         FastBuffer[i]=EMPTY_VALUE;    // ????CCI
         SlowBuffer[i]=EMPTY_VALUE;    // ?????CCI
         HistBuffer[i]=EMPTY_VALUE;    // ??????????? CCI
         UpTrBuffer[i]=EMPTY_VALUE;    // ?????????
         DnTrBuffer[i]=EMPTY_VALUE;    // ?????????
      }
      checksum = histLength+fastPeriod+slowPeriod+Period();
      symbolName=Symbol();
      limit = histLength;
   }
   for (shift=limit; shift>=0; shift--)
   {
      FastBuffer[shift] = iCCI(NULL,0,fastPeriod,PRICE_TYPICAL,shift);
      SlowBuffer[shift] = iCCI(NULL,0,slowPeriod,PRICE_TYPICAL,shift);
      HistBuffer[shift] = SlowBuffer[shift];
      UpTrBuffer[shift] = EMPTY_VALUE;
      DnTrBuffer[shift] = EMPTY_VALUE;
      //	????? ?????????????????
      int a, up=0, dn=0;
      for (a=0;a<8;a++)
      {
         slowCCI=iCCI(NULL,0,slowPeriod,PRICE_TYPICAL,shift+a);
         if (slowCCI>0) up++;
         if (slowCCI<=0) dn++;
		}
      if (up>=6) UpTrBuffer[shift]=SlowBuffer[shift];
      if (dn>=6) DnTrBuffer[shift]=SlowBuffer[shift];
   }
   return(0);
}

//////////////////////////////////////////////////////////////////////

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

WCCI.mq4

//+------------------------------------------------------------------+
//|                                                   WoodiesCCI.mq4 |
//|                                                             Rosh |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "created by Luis Damiani; converted by Rosh"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 DeepSkyBlue
#property indicator_color3 DimGray
//---- input parameters
extern int       A_period=14;
extern int       B_period=6;
extern int       num_bars=550;
// parameters
int shift=0;
bool initDone=true; // ?? init
int bar=0;
int prevbars=0;
int startpar=0;  // ?? start
int cs=0;
int prevcs=0;
string commodt="nonono";
int frame=0;
int bars=0;

//---- buffers
double FastWoodieCCI[];
double SlowWoodieCCI[];
double HistoWoodieCCI[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,FastWoodieCCI);
   SetIndexStyle(1,DRAW_LINE,1,3);
   SetIndexBuffer(1,SlowWoodieCCI);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,HistoWoodieCCI);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- TODO: add your code here
cs= A_period+B_period+num_bars; //checksum used to see if parameters have been changed
if ((cs==prevcs)&&(commodt==Symbol())&&(frame==(Time[4]-Time[5]))&&((Bars-prevbars)<2)) startpar=Bars-prevbars; else startpar=-1;  //params haven't changed only need to calculate new bar
commodt=Symbol();
frame=Time[4]-Time[5];
prevbars = Bars;
prevcs = cs;
if (startpar==1 | startpar==0)  bar=startpar; else initDone = true;

if (initDone)
   {
   FastWoodieCCI[num_bars-1]=0;
   SlowWoodieCCI[num_bars-1]=0;
   HistoWoodieCCI[num_bars-1]=0;
   //SetIndexValue(num_bars-1, 0);
   //SetIndexValue2(num_bars-1, 0);
   bar=num_bars-2;
   initDone=false;
   }

//SetLoopCount(0);
for (shift = bar;shift>=0;shift--)
   {
   FastWoodieCCI[shift]=iCCI(NULL,0,B_period,PRICE_TYPICAL,shift);
   SlowWoodieCCI[shift]=iCCI(NULL,0,A_period,PRICE_TYPICAL,shift);
   HistoWoodieCCI[shift]=iCCI(NULL,0,A_period,PRICE_TYPICAL,shift);
   //SetIndexValue(shift,iCCIEx(A_period,PRICE_TYPICAL,shift));
   //SetIndexValue2(shift,iCCIEx(B_period,PRICE_TYPICAL,shift));
   }

//----
   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Waterfall [i].mq4

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

double BufferBuy[];

int init()
{
   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexBuffer(0,BufferBuy);
   SetIndexArrow(0,181);
   SetIndexEmptyValue(0,0.0);
   ArraySetAsSeries(BufferBuy,true);

   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   int i,TotalBars, CountedBars;
   double LastBarsRange,Bottom20;

   CountedBars=IndicatorCounted();

   TotalBars=Bars-CountedBars;

   for(i=TotalBars-1;i>=0;i--)
   {
      LastBarsRange=(High[i+1]-Low[i+1]);
      Bottom20=Low[i+1]+(LastBarsRange*0.20);

         if(Highest(Symbol(),0,MODE_HIGH,50,1)==1)
            BufferBuy[i]=High[i];

}
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

VTS_VG_TS_setka.mq4

//+------------------------------------------------------------------+
//|                                                          VTS.mq4 |
//|                                                             IZZY |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "IZZY"
#property link      ""

#define MAXBARSCOUNT 150000

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Aqua
#property indicator_color2 Magenta
#property indicator_color3 Aqua
#property indicator_color4 Magenta
#property indicator_color5 Aqua
#property indicator_color6 Magenta
#property indicator_color7 Blue
#property indicator_color8 Red
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
//extern int Sb = 300;
extern int    PeriodAtr = 10;
extern double kATR      = 2.0;
extern int    GrupNum   = 4;

double VTS[MAXBARSCOUNT];
double VTS1[MAXBARSCOUNT];
double VTS2[MAXBARSCOUNT];
double VTS3[MAXBARSCOUNT];
double VTS4[MAXBARSCOUNT];
double VTS5[MAXBARSCOUNT];
double VTS6[MAXBARSCOUNT];
double VTS7[MAXBARSCOUNT];

double VTS8[MAXBARSCOUNT];
double VTS9[MAXBARSCOUNT];
double VTS10[MAXBARSCOUNT];
double VTS11[MAXBARSCOUNT];
double VTS12[MAXBARSCOUNT];
double VTS13[MAXBARSCOUNT];
double VTS14[MAXBARSCOUNT];
double VTS15[MAXBARSCOUNT];

double VTS16[MAXBARSCOUNT];
double VTS17[MAXBARSCOUNT];
double VTS18[MAXBARSCOUNT];
double VTS19[MAXBARSCOUNT];
double VTS20[MAXBARSCOUNT];
double VTS21[MAXBARSCOUNT];
double VTS22[MAXBARSCOUNT];
double VTS23[MAXBARSCOUNT];

double VTS24[MAXBARSCOUNT];
double VTS25[MAXBARSCOUNT];
double VTS26[MAXBARSCOUNT];
double VTS27[MAXBARSCOUNT];
double VTS28[MAXBARSCOUNT];
double VTS29[MAXBARSCOUNT];
double VTS_TS[MAXBARSCOUNT];
double VTS_TS1[MAXBARSCOUNT];

int init()
  {
//---- indicators
   IndicatorBuffers(8);
   if(GrupNum==1){
   SetIndexBuffer(0, VTS);
   SetIndexBuffer(1, VTS1);
   SetIndexBuffer(2, VTS2);
   SetIndexBuffer(3, VTS3);
   SetIndexBuffer(4, VTS4);
   SetIndexBuffer(5, VTS5);
   SetIndexBuffer(6, VTS6);
   SetIndexBuffer(7, VTS7);
   }
   if(GrupNum==2){
   SetIndexBuffer(0, VTS8);
   SetIndexBuffer(1, VTS9);
   SetIndexBuffer(2, VTS10);
   SetIndexBuffer(3, VTS11);
   SetIndexBuffer(4, VTS12);
   SetIndexBuffer(5, VTS13);
   SetIndexBuffer(6, VTS14);
   SetIndexBuffer(7, VTS15);
   }
   if(GrupNum==3){
   SetIndexBuffer(0, VTS16);
   SetIndexBuffer(1, VTS17);
   SetIndexBuffer(2, VTS18);
   SetIndexBuffer(3, VTS19);
   SetIndexBuffer(4, VTS20);
   SetIndexBuffer(5, VTS21);
   SetIndexBuffer(4, VTS22);
   SetIndexBuffer(5, VTS23);
   }
   if(GrupNum==4){
   SetIndexBuffer(0, VTS24);
   SetIndexBuffer(1, VTS25);
   SetIndexBuffer(2, VTS26);
   SetIndexBuffer(3, VTS27);
   SetIndexBuffer(4, VTS28);
   SetIndexBuffer(5, VTS29);
   SetIndexBuffer(6, VTS_TS);
   SetIndexStyle(6,DRAW_ARROW);
   SetIndexArrow(6,159);
   SetIndexBuffer(7, VTS_TS1);
   SetIndexStyle(7,DRAW_ARROW);
   SetIndexArrow(7,159);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
   int    counted_bars=IndicatorCounted();
//----

int    StartBars = Bars - counted_bars+2;
   //if (StartBars<Sb) StartBars = Sb;
   for(int i = StartBars; i>=0; i--){
       VTS[i] = (Close[i]-kATR*iATR(NULL,0,PeriodAtr,i));
       VTS1[i]= (Close[i]+kATR*iATR(NULL,0,PeriodAtr,i));
       }
   for(i = StartBars-1; i>0; i--){
       VTS2[i]= MathMax(VTS[i],VTS[i+1]);
       VTS3[i]= MathMin(VTS1[i],VTS1[i+1]);
       VTS4[i]= MathMax(VTS2[i],VTS2[i+1]);//VTS2[i+1];
       VTS5[i]= MathMin(VTS3[i],VTS3[i+1]);//VTS3[i+1];
       VTS6[i]= MathMax(VTS4[i],VTS4[i+1]);//VTS4[i+1];
       VTS7[i]= MathMin(VTS5[i],VTS5[i+1]);//VTS5[i+1];
       if (GrupNum >= 2){
          VTS8[i]= MathMax(VTS6[i],VTS6[i+1]);//VTS6[i+1];
          VTS9[i]= MathMin(VTS7[i],VTS7[i+1]);//VTS7[i+1];
          VTS10[i]= MathMax(VTS8[i],VTS8[i+1]);//VTS8[i+1];
          VTS11[i]= MathMin(VTS9[i],VTS9[i+1]);//VTS9[i+1];
          VTS12[i]= MathMax(VTS10[i],VTS10[i+1]);//VTS10[i+1];
          VTS13[i]= MathMin(VTS11[i],VTS11[i+1]);//VTS11[i+1];
          VTS14[i]= MathMax(VTS12[i],VTS12[i+1]);//VTS10[i+1];
          VTS15[i]= MathMin(VTS13[i],VTS13[i+1]);//VTS11[i+1];
          }
       if (GrupNum >= 3){
          VTS16[i]= MathMax(VTS14[i],VTS14[i+1]);//VTS6[i+1];
          VTS17[i]= MathMin(VTS15[i],VTS15[i+1]);//VTS7[i+1];
          VTS18[i]= MathMax(VTS16[i],VTS16[i+1]);//VTS6[i+1];
          VTS19[i]= MathMin(VTS17[i],VTS17[i+1]);//VTS7[i+1];
          VTS20[i]= MathMax(VTS18[i],VTS18[i+1]);//VTS6[i+1];
          VTS21[i]= MathMin(VTS19[i],VTS19[i+1]);//VTS7[i+1];
          VTS22[i]= MathMax(VTS20[i],VTS20[i+1]);//VTS6[i+1];
          VTS23[i]= MathMin(VTS21[i],VTS21[i+1]);//VTS7[i+1];
          }
       if (GrupNum >= 4){
          VTS24[i]= MathMax(VTS22[i],VTS22[i+1]);//VTS6[i+1];
          VTS25[i]= MathMin(VTS23[i],VTS23[i+1]);//VTS7[i+1];
          VTS26[i]= MathMax(VTS24[i],VTS24[i+1]);//VTS6[i+1];
          VTS27[i]= MathMin(VTS25[i],VTS25[i+1]);//VTS7[i+1];
          VTS28[i]= MathMax(VTS26[i],VTS26[i+1]);//VTS6[i+1];
          VTS29[i]= MathMin(VTS27[i],VTS27[i+1]);//VTS7[i+1];
          VTS_TS[i]  = VTS_TS[i+1];
          VTS_TS1[i] = VTS_TS1[i+1];
          if (Close[i]>VTS29[i]) {
              VTS_TS[i] = VTS28[i];
              VTS_TS1[i] = 0;//VTS_TS[i+1];
              }
          if (Close[i]<VTS28[i]) {
              VTS_TS1[i]= VTS29[i];
              VTS_TS[i] = 0;//VTS_TS1[i+1];
              }
          }
       }

//----
   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

VTS_VG_TS.mq4

//+------------------------------------------------------------------+
//|                                                          VTS.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+
#define MAXBARSCOUNT 15000

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
//extern int Sb = 300;
extern int    PeriodAtr = 10;
extern double kATR      = 2.0;

double VTS[MAXBARSCOUNT];
double VTS1[MAXBARSCOUNT];
double VTS2[MAXBARSCOUNT];
double VTS3[MAXBARSCOUNT];
double VTS4[MAXBARSCOUNT];
double VTS5[MAXBARSCOUNT];
double VTS6[MAXBARSCOUNT];
double VTS7[MAXBARSCOUNT];

double VTS8[MAXBARSCOUNT];
double VTS9[MAXBARSCOUNT];
double VTS10[MAXBARSCOUNT];
double VTS11[MAXBARSCOUNT];
double VTS12[MAXBARSCOUNT];
double VTS13[MAXBARSCOUNT];
double VTS14[MAXBARSCOUNT];
double VTS15[MAXBARSCOUNT];

double VTS16[MAXBARSCOUNT];
double VTS17[MAXBARSCOUNT];
double VTS18[MAXBARSCOUNT];
double VTS19[MAXBARSCOUNT];
double VTS20[MAXBARSCOUNT];
double VTS21[MAXBARSCOUNT];
double VTS22[MAXBARSCOUNT];
double VTS23[MAXBARSCOUNT];

double VTS24[MAXBARSCOUNT];
double VTS25[MAXBARSCOUNT];
double VTS26[MAXBARSCOUNT];
double VTS27[MAXBARSCOUNT];
double VTS28[MAXBARSCOUNT];
double VTS29[MAXBARSCOUNT];
double VTS_TS[MAXBARSCOUNT];
double VTS_TS1[MAXBARSCOUNT];

int init()
  {
//---- indicators
   IndicatorBuffers(2);
   SetIndexBuffer(0, VTS_TS);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexBuffer(1, VTS_TS1);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()  {
   int    counted_bars=IndicatorCounted();
//----

int    StartBars = Bars - counted_bars+2;
   //if (StartBars<Sb) StartBars = Sb;
   for(int i = StartBars; i>=0; i--){
       VTS[i] = (Close[i]-kATR*iATR(NULL,0,PeriodAtr,i));
       VTS1[i]= (Close[i]+kATR*iATR(NULL,0,PeriodAtr,i));
       }
   for(i = StartBars-1; i>0; i--){
       VTS2[i]= MathMax(VTS[i],VTS[i+1]);
       VTS3[i]= MathMin(VTS1[i],VTS1[i+1]);
       VTS4[i]= MathMax(VTS2[i],VTS2[i+1]);//VTS2[i+1];
       VTS5[i]= MathMin(VTS3[i],VTS3[i+1]);//VTS3[i+1];
       VTS6[i]= MathMax(VTS4[i],VTS4[i+1]);//VTS4[i+1];
       VTS7[i]= MathMin(VTS5[i],VTS5[i+1]);//VTS5[i+1];
       VTS8[i]= MathMax(VTS6[i],VTS6[i+1]);//VTS6[i+1];
       VTS9[i]= MathMin(VTS7[i],VTS7[i+1]);//VTS7[i+1];
       VTS10[i]= MathMax(VTS8[i],VTS8[i+1]);//VTS8[i+1];
       VTS11[i]= MathMin(VTS9[i],VTS9[i+1]);//VTS9[i+1];
       VTS12[i]= MathMax(VTS10[i],VTS10[i+1]);//VTS10[i+1];
       VTS13[i]= MathMin(VTS11[i],VTS11[i+1]);//VTS11[i+1];
       VTS14[i]= MathMax(VTS12[i],VTS12[i+1]);//VTS10[i+1];
       VTS15[i]= MathMin(VTS13[i],VTS13[i+1]);//VTS11[i+1];
       VTS16[i]= MathMax(VTS14[i],VTS14[i+1]);//VTS6[i+1];
       VTS17[i]= MathMin(VTS15[i],VTS15[i+1]);//VTS7[i+1];
       VTS18[i]= MathMax(VTS16[i],VTS16[i+1]);//VTS6[i+1];
       VTS19[i]= MathMin(VTS17[i],VTS17[i+1]);//VTS7[i+1];
       VTS20[i]= MathMax(VTS18[i],VTS18[i+1]);//VTS6[i+1];
       VTS21[i]= MathMin(VTS19[i],VTS19[i+1]);//VTS7[i+1];
       VTS22[i]= MathMax(VTS20[i],VTS20[i+1]);//VTS6[i+1];
       VTS23[i]= MathMin(VTS21[i],VTS21[i+1]);//VTS7[i+1];
       VTS24[i]= MathMax(VTS22[i],VTS22[i+1]);//VTS6[i+1];
       VTS25[i]= MathMin(VTS23[i],VTS23[i+1]);//VTS7[i+1];
       VTS26[i]= MathMax(VTS24[i],VTS24[i+1]);//VTS6[i+1];
       VTS27[i]= MathMin(VTS25[i],VTS25[i+1]);//VTS7[i+1];
       VTS28[i]= MathMax(VTS26[i],VTS26[i+1]);//VTS6[i+1];
       VTS29[i]= MathMin(VTS27[i],VTS27[i+1]);//VTS7[i+1];
       VTS_TS[i]  = VTS_TS[i+1];
       VTS_TS1[i] = VTS_TS1[i+1];
       if (Close[i]>VTS29[i]) {
           VTS_TS[i] = VTS28[i];
           VTS_TS1[i] = 0;//VTS_TS[i+1];
           }
       if (Close[i]<VTS28[i]) {
           VTS_TS1[i]= VTS29[i];
           VTS_TS[i] = 0;//VTS_TS1[i+1];
           }
       }//for(i = StartBars; i>0; i--){

//----
   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

VSI.mq4

/*
 * Filename:    VSI.mq4
 * Author:      DriverDan
 * Date:        Oct 20, 2005
 *
 * Description: Indicator that calculates volume per second (or period) and the corresponding MA.
 *              Uses volume per second since it will be uniform for all chart periods.
 *              Indicator seems to work best on 15m to 4h charts. IMHO, 1m and 5m periods are
 *              too short for valid results and 1d+ will show low periods for partial days on MT4.
 *
 * Version:     1.0
 *              Initial release
 */

#property copyright         "Copyright ?2005, DriverDan"
#property link              "superfunman2000@yahoo.com"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 2
#property indicator_color1  DodgerBlue
#property indicator_color2  Red

#define    SECINMIN         60  //Number of seconds in a minute

extern int vsiMAPeriod    = 7;  //Period for the moving average.
extern int vsiMAType      = 1;  //Moving average type. 0 = SMA, 1 = EMA, 2 = SMMA, 3 = LWMA
extern int showPerPeriod  = 0;  //0 = volume per second, 1 = volume per chart period
                                /* Volume per second allows you to compare values for different
                                   chart periods. Otherwise the values it will show will only be
                                   valid for the chart period you are viewing. The graph will
                                   look exactly the same but the values will be different. */

double vsiBuffer[];
double vsiMABuffer[];

/**
 * Initialization function
 */
int init() {
   string vsiTitle = "VSI(" + vsiMAPeriod + ")";
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0, vsiBuffer);
   SetIndexBuffer(1, vsiMABuffer);
   IndicatorShortName(vsiTitle);
   SetIndexLabel(0, vsiTitle);
   SetIndexLabel(1, "vsiMA(" + vsiMAPeriod + ")");
   SetIndexDrawBegin(1, vsiMAPeriod);
   return(0);
}

/**
 * Main program
 */
int start() {
   int i, limit, timeDiff;
   int counted_bars = IndicatorCounted();

   if(counted_bars >= 0) {

      //If counted bars is greater than zero we must subtract 1 so we get in the right position
      if(counted_bars > 0) {
         counted_bars--;
      }

      //Only count bars we haven't already drawn
      limit = Bars - counted_bars;

      for(i = 0; i < limit; i++) {
         //Difference between the current time and the bar start
         timeDiff = CurTime() - Time[i];

         //If we are in the current bar and the tick doesn't fall exactly on the '00:00' min & sec
         if(i == 0 && timeDiff > 0) {
            vsiBuffer[i] = Volume[i] / timeDiff;
         } else {
            //Otherwise calculate the total bar volume divided by the total bar seconds
            vsiBuffer[i] = Volume[i] / (Time[i - 1] - Time[i]);
         }

         if(showPerPeriod == 1) {
            vsiBuffer[i] = vsiBuffer[i] * Period() * SECINMIN;
         }
      }

      //Fill the moving average buffer
      for(i = 0; i < limit; i++) {
         vsiMABuffer[i] = iMAOnArray(vsiBuffer, Bars, vsiMAPeriod, 0, vsiMAType, i);
      }
   }

   return(0);
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

volumeMA.mq4

//+------------------------------------------------------------------+
//|                            Volume with Custom Moving Average.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp. Modified RonT"
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 White

// User input
extern int MA_Period=13;
extern int MA_Shift=0;
extern int MA_Method=0;

// Buffers
double VolBuffer1[];  // value down
double VolBuffer2[];  // value up
double VolBuffer3[];  // moving average

//----
int ExtCountedBars=0;
int lastcolor=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int    draw_begin;
   string short_name;

   // indicator buffers mapping, drawing settings and Shift

   // Histogram downArrow Red
   SetIndexBuffer(0,VolBuffer1);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexShift(0,MA_Shift);

   // Histogram upArrow Green
   SetIndexBuffer(1,VolBuffer2);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexShift(1,MA_Shift);

   // Moving average line white
   SetIndexBuffer(2,VolBuffer3);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexShift(2,MA_Shift);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));

   if(MA_Period<2) MA_Period=2;
   draw_begin=MA_Period-1;

   switch(MA_Method)
     {
      case 1  : short_name="EMA(" ;  draw_begin=0; break;
      case 2  : short_name="SMMA(";                break;
      case 3  : short_name="LWMA(";                break;
      default : short_name="SMA(" ;  MA_Method=0;
     }
   IndicatorShortName(short_name+MA_Period+")");

   SetIndexDrawBegin(0,draw_begin);

   return(0);
  }

//+------------------------------------------------------------------+
//| Main                                                             |
//+------------------------------------------------------------------+
int start()
  {

   if(Bars<=MA_Period) return(0);
   ExtCountedBars=IndicatorCounted();

// check for possible errors
   if (ExtCountedBars<0) return(-1);

// last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;

   switch(MA_Method)
     {
      case 0 : sma();  break;
      case 1 : ema();  break;
      case 2 : smma(); break;
      case 3 : lwma();
     }
   return(0);
  }

//+------------------------------------------------------------------+
//| Simple Moving Average                                            |
//+------------------------------------------------------------------+
void sma()
  {
   double sum=0;
   int    i,pos=Bars-ExtCountedBars-1;

   // initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<MA_Period;i++,pos--)
      sum+=Volume[pos];

   while(pos>=0)
     {
      sum+=Volume[pos];
      VolBuffer3[pos]=sum/MA_Period;
	   sum-=Volume[pos+MA_Period-1];
	   Vcolor(pos);
 	   pos--;
     }

   // zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++) VolBuffer1[Bars-i]=0;
  }

//+------------------------------------------------------------------+
//| Exponential Moving Average                                       |
//+------------------------------------------------------------------+
void ema()
  {
   double pr=2.0/(MA_Period+1);
   int    pos=Bars-2;

   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;

   while(pos>=0)
     {
      if(pos==Bars-2) VolBuffer3[pos+1]=Volume[pos+1];
      VolBuffer3[pos]=Volume[pos]*pr+VolBuffer3[pos+1]*(1-pr);
      Vcolor(pos);
 	   pos--;
     }
  }

//+------------------------------------------------------------------+
//| Smoothed Moving Average                                          |
//+------------------------------------------------------------------+
void smma()
  {
   double sum=0;
   int    i,k,pos=Bars-ExtCountedBars+1;

   pos=Bars-MA_Period;
   if(pos>Bars-ExtCountedBars) pos=Bars-ExtCountedBars;
   while(pos>=0)
     {
      if(pos==Bars-MA_Period)
        {
         // initial accumulation
         for(i=0,k=pos;i<MA_Period;i++,k++)
           {
            sum+=Volume[k];
            // zero initial bars
            VolBuffer3[k]=0;
           }
        }
      else sum=VolBuffer3[pos+1]*(MA_Period-1)+Volume[pos];
      VolBuffer3[pos]=sum/MA_Period;
 	   pos--;
     }
  }

//+------------------------------------------------------------------+
//| Linear Weighted Moving Average                                   |
//+------------------------------------------------------------------+
void lwma()
  {
   double sum=0.0,lsum=0.0;
   double price;
   int    i,weight=0,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<=MA_Period;i++,pos--)
     {
      price=Volume[pos];
      sum+=price*i;
      lsum+=price;
      weight+=i;
     }
//---- main calculation loop
   pos++;
   i=pos+MA_Period;
   while(pos>=0)
     {
      VolBuffer3[pos]=sum/weight;
      if(pos==0) break;
      pos--;
      i--;
      price=Volume[pos];
      sum=sum-lsum+price*MA_Period;
      lsum-=Volume[i];
      lsum+=price;
     }
//---- zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++) VolBuffer3[Bars-i]=0;
  }

//+------------------------------------------------------------------+
//| Color depends on gain or loss and previous volume                |
//+------------------------------------------------------------------+
// 1 - histo down red
// 2 - histo up green
// 3 - line white

void Vcolor(int p)
  {

   if (Volume[p+1]>Volume[p])
     {
      VolBuffer1[p]=Volume[p];
      VolBuffer2[p]=0;
      lastcolor=Red;
     }

   if (Volume[p+1]<Volume[p])
     {
      VolBuffer1[p]=0;
      VolBuffer2[p]=Volume[p];
      lastcolor=Green;
     }

   if (Volume[p+1]==Volume[p])
     {
      if ( lastcolor==Red )
        {
         VolBuffer1[p]=Volume[p];
         VolBuffer2[p]=0;
        }
      if ( lastcolor==Green )
        {
         VolBuffer1[p]=0;
         VolBuffer2[p]=Volume[p];
        }
     }
  }

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

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

 Page 5 of 100  « First  ... « 3  4  5  6  7 » ...  Last » 

Tweet This Post links powered by Tweet This v1.3.9, a WordPress plugin for Twitter.