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
I :forex decode

I Archives

iTrend1.mq4

//+------------------------------------------------------------------+
//|                                                  iTrend_hist.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "tonyc2a@yahoo.com"
#property link      ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_minimum -1
#property indicator_maximum 1

//---- input parameters
extern double iBandsDeviation=2;
extern int iBandsMode0_2=0;     // 0-2: MODE_MAIN, MODE_LOW, MODE_HIGH
extern int iBandsPrice0_6=0;    // 0-6: PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
extern int iBandsPeriod=20;     // 20
extern int iPowerPrice0_6=0;    // 0-6: PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
extern int iPowerPeriod=13;     // 13
extern int iPriceType0_3=0;     // 0-3: PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"Blue");
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"Red");
//----
   IndicatorShortName("iTrend");
//----
   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

   //+----Processes user parameters-------------------------------------+
   double BandsMode,BandsPrice,PowerPrice;

   switch(iBandsMode0_2){
      case 1: BandsMode=MODE_LOWER;
      case 2: BandsMode=MODE_UPPER;
      default: BandsMode=MODE_MAIN;
      } //end switch

   switch(iBandsPrice0_6){
      case 1: BandsPrice=PRICE_OPEN;
      case 2: BandsPrice=PRICE_HIGH;
      case 3: BandsPrice=PRICE_LOW;
      case 4: BandsPrice=PRICE_MEDIAN;
      case 5: BandsPrice=PRICE_TYPICAL;
      case 6: BandsPrice=PRICE_WEIGHTED;
      default: BandsPrice=PRICE_CLOSE;
      } //end switch

   switch(iPowerPrice0_6){
      case 1: PowerPrice=PRICE_OPEN;
      case 2: PowerPrice=PRICE_HIGH;
      case 3: PowerPrice=PRICE_LOW;
      case 4: PowerPrice=PRICE_MEDIAN;
      case 5: PowerPrice=PRICE_TYPICAL;
      case 6: PowerPrice=PRICE_WEIGHTED;
      default: PowerPrice=PRICE_CLOSE;
      } //end switch
   //+------------------------------------------------------------------+

   //+----Main Section--------------------------------------------------+
   double CurrentPrice, value1, value2, x, y;

   for(int i=0;i<=Bars;i++){
      switch(iPriceType0_3){
         case 1: CurrentPrice=Open[i];
         case 2: CurrentPrice=High[i];
         case 3: CurrentPrice=Low[i];
         default: CurrentPrice=Close[i];
         } //end switch

      x=CurrentPrice-iBands(Symbol(),Period(),iBandsPeriod,iBandsDeviation,0,BandsPrice,BandsMode,i);
      y=-(iBullsPower(Symbol(),Period(),iPowerPeriod,PowerPrice,i) + iBearsPower(Symbol(),Period(),iPowerPeriod,PowerPrice,i));

      if(x<0) value1=0;
      if(x>0) value1=1;
      if(y<0) value2=0;
      if(y>0) value2=-1;

      ExtMapBuffer1[i]=value1;
      ExtMapBuffer2[i]=value2;
      } //end for
   //+------------------------------------------------------------------+

   //ObjectCreate("vl",OBJ_VLINE,WindowFind("iTrend"),Time[-1],Close[0]);

//----
   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 

iTrend.mq4

//+------------------------------------------------------------------+
//|                                                       iTrend.mq4 |
//|                                                tonyc2a@yahoo.com |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "tonyc2a@yahoo.com"
#property link      ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_minimum -1
#property indicator_maximum 1

//---- input parameters
extern double iBandsDeviation=2;
extern int iBandsMode0_2=0;     // 0-2: MODE_MAIN, MODE_LOW, MODE_HIGH
extern int iBandsPrice0_6=0;    // 0-6: PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
extern int iBandsPeriod=20;     // 20
extern int iPowerPrice0_6=0;    // 0-6: PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
extern int iPowerPeriod=13;     // 13
extern int iPriceType0_3=0;     // 0-3: PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"Blue");
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"Red");
//----
   IndicatorShortName("iTrend");
//----
   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

   //+----Processes user parameters-------------------------------------+
   double BandsMode,BandsPrice,PowerPrice;

   switch(iBandsMode0_2){
      case 1: BandsMode=MODE_LOWER;
      case 2: BandsMode=MODE_UPPER;
      default: BandsMode=MODE_MAIN;
      } //end switch

   switch(iBandsPrice0_6){
      case 1: BandsPrice=PRICE_OPEN;
      case 2: BandsPrice=PRICE_HIGH;
      case 3: BandsPrice=PRICE_LOW;
      case 4: BandsPrice=PRICE_MEDIAN;
      case 5: BandsPrice=PRICE_TYPICAL;
      case 6: BandsPrice=PRICE_WEIGHTED;
      default: BandsPrice=PRICE_CLOSE;
      } //end switch

   switch(iPowerPrice0_6){
      case 1: PowerPrice=PRICE_OPEN;
      case 2: PowerPrice=PRICE_HIGH;
      case 3: PowerPrice=PRICE_LOW;
      case 4: PowerPrice=PRICE_MEDIAN;
      case 5: PowerPrice=PRICE_TYPICAL;
      case 6: PowerPrice=PRICE_WEIGHTED;
      default: PowerPrice=PRICE_CLOSE;
      } //end switch
   //+------------------------------------------------------------------+

   //+----Main Section--------------------------------------------------+
   double CurrentPrice, value1, value2, x, y;

   for(int i=0;i<=Bars;i++){
      switch(iPriceType0_3){
         case 1: CurrentPrice=Open[i];
         case 2: CurrentPrice=High[i];
         case 3: CurrentPrice=Low[i];
         default: CurrentPrice=Close[i];
         } //end switch

      x=CurrentPrice-iBands(Symbol(),Period(),iBandsPeriod,iBandsDeviation,0,BandsPrice,BandsMode,i);
      y=-(iBullsPower(Symbol(),Period(),iPowerPeriod,PowerPrice,i) + iBearsPower(Symbol(),Period(),iPowerPeriod,PowerPrice,i));

      if(x<0) value1=0;
      if(x>0) value1=1;
      if(y<0) value2=0;
      if(y>0) value2=-1;

      ExtMapBuffer1[i]=value1;
      ExtMapBuffer2[i]=value2;
      } //end for
   //+------------------------------------------------------------------+

   //ObjectCreate("vl",OBJ_VLINE,WindowFind("iTrend"),Time[-1],Close[0]);

//----
   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 

Itrend Old.mq4

//+------------------------------------------------------------------+
//|                                           Traditional Itrend.mq4 |
//| TREND INDICATOR                                                  |
//|                                                                  |
//|                                           Conversion: Dr. Gaines |
//|                                  dr_richard_gaines@yahoo.com
//|                                     |
//+------------------------------------------------------------------+

#property copyright " Andrew "
#property link      " http://anri.aney.ru/forex/ "

#property indicator_separate_window
#property indicator_color1 Blue
#property indicator_buffers 2
#property indicator_color2 Red
#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double iBands_Mode_0_2 = 0;
extern double iPower_Price_0_6 = 0;
extern double iPrice_Type_0_3 = 0;
extern double iBands_Period = 20;
extern double iBands_Deviation = 2;
extern double iPower_Period = 14;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];

void SetLoopCount(int loops)
{
}

void SetIndexValue(int shift, double value)
{
  ExtHistoBuffer[shift] = value;
}

void SetIndexValue2(int shift, double value)
{
  ExtHistoBuffer2[shift] = value;
}

//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(0, ExtHistoBuffer);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);
   return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
double value = 0;
double value2 = 0;
int CurrentBar = 0;
double Bands_Mode = 0;
double Power_Price = 0;
double CurrentPrice = 0;

/*[[
Name := iTrend 1.01
Author := Andrew
Link := http://anri.aney.ru/forex/
Notes := TREND INDICATOR
Separate Window := YES
First Color := blue
First Draw Type := histogram
First Symbol := 217
Use Second Data := Yes
Second Color := red
Second Draw Type := histogram
Second Symbol := 218
]]*/
 // =0-2 MODE_MAIN, MODE_LOW, MODE_HIGH
 // =0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
 // =0-3 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW
//20

//13

SetLoopCount(0);
if( iBands_Mode_0_2 == 1 ) Bands_Mode=MODE_LOW
; else if( iBands_Mode_0_2 == 2 ) Bands_Mode=MODE_HIGH
; else Bands_Mode=MODE_MAIN;

if( iPower_Price_0_6 == 1 ) Power_Price=PRICE_OPEN
; else if( iPower_Price_0_6 == 2 ) Power_Price=PRICE_HIGH
; else if( iPower_Price_0_6 == 3 ) Power_Price=PRICE_LOW
; else if( iPower_Price_0_6 == 4 ) Power_Price=PRICE_MEDIAN
; else if( iPower_Price_0_6 == 5 ) Power_Price=PRICE_TYPICAL
; else if( iPower_Price_0_6 == 6 ) Power_Price=PRICE_WEIGHTED
; else Power_Price=PRICE_CLOSE;

for(CurrentBar=Bars+1;CurrentBar>=0 ;CurrentBar--){
if( iPrice_Type_0_3 == 1 ) CurrentPrice=Open[CurrentBar]
; else if( iPrice_Type_0_3 == 2 ) CurrentPrice=High[CurrentBar]
; else if( iPrice_Type_0_3 == 3 ) CurrentPrice=Low[CurrentBar]
; else CurrentPrice=Close[CurrentBar];
value=CurrentPrice-iBands(NULL, 0, iBands_Period, iBands_Deviation, 0, PRICE_CLOSE, Bands_Mode, CurrentBar);
if( value < 0 ) value = 0;
if( value > 0 ) value = 1;
SetIndexValue(CurrentBar, value);
value2=-(iBearsPower(NULL, 0, iPower_Period,Power_Price,CurrentBar)+iBullsPower(NULL, 0, iPower_Period,Power_Price,CurrentBar));
if( value2 < 0 ) value2 = 0;
if( value2 > 0 ) value2 = -1;
SetIndexValue2(CurrentBar, value2);
if( value == 1 ) GlobalVariableSet("MEDV",value);
if( value2 == -1 ) GlobalVariableSet("MEDV",value);
if( value2 == -1 && value == 1 ) GlobalVariableSet("MEDV",0);
//SetGlobalVariable("BUK",value);
}

  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 

Itend old.mq4

#include <stdlib.mqh>
//+------------------------------------------------------------------+
//|                                                       Itrend.mq4 |
//| TREND INDICATOR                                                  |
//|                                                                  |
//|                                        Converted by Mql2Mq4 v0.6 |
//|                                            http://yousky.free.fr |
//|                                    Copyright ? 2006, Yousky Soft |
//+------------------------------------------------------------------+

#property copyright " Andrew "
#property link      " http://anri.aney.ru/forex/ "

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

//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double iBands_Mode_0_2 = 0;
extern double iPower_Price_0_6 = 0;
extern double iPrice_Type_0_3 = 0;
extern double iBands_Period = 20;
extern double iBands_Deviation = 2;
extern double iPower_Period = 14;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];

void SetLoopCount(int loops)
{
}

void SetIndexValue(int shift, double value)
{
  ExtHistoBuffer[shift] = value;
}

void SetIndexValue2(int shift, double value)
{
  ExtHistoBuffer2[shift] = value;
}

//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(0, ExtHistoBuffer);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);
   return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
double value = 0;
double value2 = 0;
int CurrentBar = 0;
double Bands_Mode = 0;
double Power_Price = 0;
double CurrentPrice = 0;

/*[[
Name := iTrend 1.01
Author := Andrew
Link := http://anri.aney.ru/forex/
Notes := TREND INDICATOR
Separate Window := YES
First Color := blue
First Draw Type := histogram
First Symbol := 217
Use Second Data := Yes
Second Color := red
Second Draw Type := histogram
Second Symbol := 218
]]*/
 // =0-2 MODE_MAIN, MODE_LOW, MODE_HIGH
 // =0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED
 // =0-3 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW
//20

//13

SetLoopCount(0);
if( iBands_Mode_0_2 == 1 ) Bands_Mode=MODE_LOW
; else if( iBands_Mode_0_2 == 2 ) Bands_Mode=MODE_HIGH
; else Bands_Mode=MODE_MAIN;

if( iPower_Price_0_6 == 1 ) Power_Price=PRICE_OPEN
; else if( iPower_Price_0_6 == 2 ) Power_Price=PRICE_HIGH
; else if( iPower_Price_0_6 == 3 ) Power_Price=PRICE_LOW
; else if( iPower_Price_0_6 == 4 ) Power_Price=PRICE_MEDIAN
; else if( iPower_Price_0_6 == 5 ) Power_Price=PRICE_TYPICAL
; else if( iPower_Price_0_6 == 6 ) Power_Price=PRICE_WEIGHTED
; else Power_Price=PRICE_CLOSE;

for(CurrentBar=Bars+1;CurrentBar>=0 ;CurrentBar--){
if( iPrice_Type_0_3 == 1 ) CurrentPrice=Open[CurrentBar]
; else if( iPrice_Type_0_3 == 2 ) CurrentPrice=High[CurrentBar]
; else if( iPrice_Type_0_3 == 3 ) CurrentPrice=Low[CurrentBar]
; else CurrentPrice=Close[CurrentBar];
value=CurrentPrice-iBands(NULL, 0, iBands_Period, iBands_Deviation, 0, PRICE_CLOSE, Bands_Mode, CurrentBar);
if( value < 0 ) value = 0;
if( value > 0 ) value = 1;
SetIndexValue(CurrentBar, value);
value2=-(iBearsPower(NULL, 0, iPower_Period,Power_Price,CurrentBar)+iBullsPower(NULL, 0, iPower_Period,Power_Price,CurrentBar));
if( value2 < 0 ) value2 = 0;
if( value2 > 0 ) value2 = -1;
SetIndexValue2(CurrentBar, value2);
if( value == 1 ) GlobalVariableSet("MEDV",value);
if( value2 == -1 ) GlobalVariableSet("MEDV",value);
if( value2 == -1 && value == 1 ) GlobalVariableSet("MEDV",0);
//SetGlobalVariable("BUK",value);
}

  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 

InstantTrendLine.mq4

//+------------------------------------------------------------------+
//|                          Instantaneous Trend Line by John Ehlers |
//|                               Copyright ? 2004, Poul_Trade_Forum |
//|                                                         Aborigen |
//|                                          http://forex.kbpauk.ru/ |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link      "http://forex.kbpauk.ru/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

//---- buffers
double TRBuffer[];
double ZLBuffer[];
double Value1[],Value2,Value3,Value4,Value5[2],Value11[2];
double Price[],InPhase[2],Quadrature[2],Phase[2],DeltaPhase[],InstPeriod[2],Period_,Trendline;
double test[];

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

   IndicatorBuffers(5);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,EMPTY,1,Red);
   SetIndexStyle(1,DRAW_LINE,EMPTY,1,Blue);

   SetIndexBuffer(0,TRBuffer);
   SetIndexBuffer(1,ZLBuffer);
   SetIndexBuffer(2,Value1);
   SetIndexBuffer(3,Price);
   SetIndexBuffer(4,DeltaPhase);

   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);

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

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

   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(),i,shift,count;

//---- TODO: add your code here
if (counted_bars==0) counted_bars=100;

i=(Bars-counted_bars)-2;

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

InPhase[1] =InPhase[0]; Quadrature[1] =Quadrature[0];
Phase[1]=Phase[0]; InstPeriod[1] = InstPeriod[0];
Value5[1] =Value5[0];Value11[1] =Value11[0];

Price[shift]=(High[shift+1]+Low[shift+1])/2;

//  {Compute InPhase and Quadrature components}
   Value1[shift] = Price[shift] - Price[shift+6];
   Value2 =Value1[shift+3];
   Value3 =0.75*(Value1[shift] - Value1[shift+6]) + 0.25*(Value1[shift+2] - Value1[shift+4]);
   InPhase[0] = 0.33*Value2 + 0.67*InPhase[1];
   Quadrature[0] = 0.2*Value3 + 0.8*Quadrature[1];

//   {Use ArcTangent to compute the current phase}
if (MathAbs(InPhase[0]+InPhase[1])>0) Phase[0]=MathArctan(MathAbs((Quadrature[0]+Quadrature[1])/(InPhase[0]+InPhase[1])));

//   {Resolve the ArcTangent ambiguity}
   if (InPhase[0] < 0 && Quadrature[0] > 0)  Phase[0] = 180 - Phase[0];
   if (InPhase[0] < 0 && Quadrature[0] < 0)  Phase[0] = 180 + Phase[0];
   if (InPhase[0] > 0 && Quadrature[0] < 0)  Phase[0] = 360 - Phase[0];

//   {Compute a differential    phase, resolve phase wraparound, and limit delta phase errors}
   DeltaPhase[shift] = Phase[1] - Phase[0];

   if (Phase[1] < 90 &&  Phase[0] > 270) DeltaPhase[shift] = 360 + Phase[1] - Phase[0];
   if (DeltaPhase[shift] < 1)  DeltaPhase[shift] = 1;
   if (DeltaPhase[shift] > 60) DeltaPhase[shift] = 60;

//   {Sum DeltaPhases  to reach 360  degrees. The sum is the instantaneous period.}
   InstPeriod[0] = 0;
   Value4 = 0;
   for (count = 0;count<=40;count++)
      {
       Value4 = Value4 + DeltaPhase[shift+count];
       if  (Value4 > 360 && InstPeriod[0]  == 0) InstPeriod[0] = count;
     }

//   {Resolve Instantaneous  Period    errors and  smooth}
   if (InstPeriod[0] == 0) InstPeriod[0] = InstPeriod[1];
   Value5[0] = 0.25*(InstPeriod[0]) + 0.75*Value5[1];

//   {Compute Trendline as simple average over the measured dominant cycle period}
   Period_ = MathCeil(Value5[0]); Trendline = 0;///Period_ = IntPortion(Value5)

   for    (count = 0;count<=Period_ + 1;count++)
       { Trendline = Trendline + Price[shift+count]; }

   if (Period_ > 0) Trendline = Trendline    / (Period_  + 2);
   Value11[0] = 0.33*(Price[shift] + 0.5*(Price[shift] - Price[shift+3])) + 0.67*Value11[1];

   TRBuffer[shift]=Trendline;
   ZLBuffer[shift]=Value11[0];

//----

}

   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 

Instantaneous Trend.mq4

//+------------------------------------------------------------------+
//|                          Instantaneous Trend Line by John Ehlers |
//|                               Copyright ? 2004, Poul_Trade_Forum |
//|                                                         Aborigen |
//|                                          http://forex.kbpauk.ru/ |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link      "http://forex.kbpauk.ru/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

//---- buffers
double TRBuffer[];
double ZLBuffer[];
double Value1[],Value2,Value3,Value4,Value5[2],Value11[2];
double Price[],InPhase[2],Quadrature[2],Phase[2],DeltaPhase[],InstPeriod[2],Period_,Trendline;
double test[];

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

   IndicatorBuffers(5);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,EMPTY,1,Red);
   SetIndexStyle(1,DRAW_LINE,EMPTY,1,Blue);

   SetIndexBuffer(0,TRBuffer);
   SetIndexBuffer(1,ZLBuffer);
   SetIndexBuffer(2,Value1);
   SetIndexBuffer(3,Price);
   SetIndexBuffer(4,DeltaPhase);

   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);

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

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

   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(),i,shift,count;

//---- TODO: add your code here
if (counted_bars==0) counted_bars=100;

i=(Bars-counted_bars)-2;

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

InPhase[1] =InPhase[0]; Quadrature[1] =Quadrature[0];
Phase[1]=Phase[0]; InstPeriod[1] = InstPeriod[0];
Value5[1] =Value5[0];Value11[1] =Value11[0];

Price[shift]=(High[shift+1]+Low[shift+1])/2;

//  {Compute InPhase and Quadrature components}
   Value1[shift] = Price[shift] - Price[shift+6];
   Value2 =Value1[shift+3];
   Value3 =0.75*(Value1[shift] - Value1[shift+6]) + 0.25*(Value1[shift+2] - Value1[shift+4]);
   InPhase[0] = 0.33*Value2 + 0.67*InPhase[1];
   Quadrature[0] = 0.2*Value3 + 0.8*Quadrature[1];

//   {Use ArcTangent to compute the current phase}
if (MathAbs(InPhase[0]+InPhase[1])>0) Phase[0]=MathArctan(MathAbs((Quadrature[0]+Quadrature[1])/(InPhase[0]+InPhase[1])));

//   {Resolve the ArcTangent ambiguity}
   if (InPhase[0] < 0 && Quadrature[0] > 0)  Phase[0] = 180 - Phase[0];
   if (InPhase[0] < 0 && Quadrature[0] < 0)  Phase[0] = 180 + Phase[0];
   if (InPhase[0] > 0 && Quadrature[0] < 0)  Phase[0] = 360 - Phase[0];

//   {Compute a differential    phase, resolve phase wraparound, and limit delta phase errors}
   DeltaPhase[shift] = Phase[1] - Phase[0];

   if (Phase[1] < 90 &&  Phase[0] > 270) DeltaPhase[shift] = 360 + Phase[1] - Phase[0];
   if (DeltaPhase[shift] < 1)  DeltaPhase[shift] = 1;
   if (DeltaPhase[shift] > 60) DeltaPhase[shift] = 60;

//   {Sum DeltaPhases  to reach 360  degrees. The sum is the instantaneous period.}
   InstPeriod[0] = 0;
   Value4 = 0;
   for (count = 0;count<=40;count++)
      {
       Value4 = Value4 + DeltaPhase[shift+count];
       if  (Value4 > 360 && InstPeriod[0]  == 0) InstPeriod[0] = count;
     }

//   {Resolve Instantaneous  Period    errors and  smooth}
   if (InstPeriod[0] == 0) InstPeriod[0] = InstPeriod[1];
   Value5[0] = 0.25*(InstPeriod[0]) + 0.75*Value5[1];

//   {Compute Trendline as simple average over the measured dominant cycle period}
   Period_ = MathCeil(Value5[0]); Trendline = 0;///Period_ = IntPortion(Value5)

   for    (count = 0;count<=Period_ + 1;count++)
       { Trendline = Trendline + Price[shift+count]; }

   if (Period_ > 0) Trendline = Trendline    / (Period_  + 2);
   Value11[0] = 0.33*(Price[shift] + 0.5*(Price[shift] - Price[shift+3])) + 0.67*Value11[1];

   TRBuffer[shift]=Trendline;
   ZLBuffer[shift]=Value11[0];

//----

}

   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 

Instant TrendLine.mq4

//+------------------------------------------------------------------+
//|                          Instantaneous Trend Line by John Ehlers |
//|                               Copyright ? 2004, Poul_Trade_Forum |
//|                                                         Aborigen |
//|                                          http://forex.kbpauk.ru/ |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link      "http://forex.kbpauk.ru/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- buffers
double TRBuffer[];
double ZLBuffer[];
double Value1[],Value2,Value3,Value4,Value5[2],Value11[2];
double Price[],InPhase[2],Quadrature[2],Phase[2],DeltaPhase[],InstPeriod[2],Period_,Trendline;
double test[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   IndicatorBuffers(5);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,EMPTY,2,Red);
   SetIndexStyle(1,DRAW_LINE,EMPTY,2,Blue);
   SetIndexBuffer(0,TRBuffer);
   SetIndexBuffer(1,ZLBuffer);
   SetIndexBuffer(2,Value1);
   SetIndexBuffer(3,Price);
   SetIndexBuffer(4,DeltaPhase);

   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);
//---- name for DataWindow and indicator subwindow label
   short_name="Instantaneous Trend";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,30);
   SetIndexDrawBegin(1,30);
//----

   return(0);
  }

int deinit(){return(0);}
int start()
  {
   int    counted_bars=IndicatorCounted(),i,shift,count;

if (counted_bars==0) counted_bars=100;
i=(Bars-counted_bars)-2;
for (shift=i; shift>=0;shift--)
{
InPhase[1] =InPhase[0]; Quadrature[1] =Quadrature[0];
Phase[1]=Phase[0]; InstPeriod[1] = InstPeriod[0];
Value5[1] =Value5[0];Value11[1] =Value11[0];
Price[shift]=(High[shift+1]+Low[shift+1])/2;
//  {Compute InPhase and Quadrature components}
   Value1[shift] = Price[shift] - Price[shift+6];
   Value2 =Value1[shift+3];
   Value3 =0.75*(Value1[shift] - Value1[shift+6]) + 0.25*(Value1[shift+2] - Value1[shift+4]);
   InPhase[0] = 0.33*Value2 + 0.67*InPhase[1];
   Quadrature[0] = 0.2*Value3 + 0.8*Quadrature[1];

//   {Use ArcTangent to compute the current phase}
if (MathAbs(InPhase[0]+InPhase[1])>0) Phase[0]=MathArctan(MathAbs((Quadrature[0]+Quadrature[1])/(InPhase[0]+InPhase[1])));
//   {Resolve the ArcTangent ambiguity}
   if (InPhase[0] < 0 && Quadrature[0] > 0)  Phase[0] = 180 - Phase[0];
   if (InPhase[0] < 0 && Quadrature[0] < 0)  Phase[0] = 180 + Phase[0];
   if (InPhase[0] > 0 && Quadrature[0] < 0)  Phase[0] = 360 - Phase[0];

//   {Compute a differential    phase, resolve phase wraparound, and limit delta phase errors}
   DeltaPhase[shift] = Phase[1] - Phase[0];
   if (Phase[1] < 90 &&  Phase[0] > 270) DeltaPhase[shift] = 360 + Phase[1] - Phase[0];
   if (DeltaPhase[shift] < 1)  DeltaPhase[shift] = 1;
   if (DeltaPhase[shift] > 60) DeltaPhase[shift] = 60;

//   {Sum DeltaPhases  to reach 360  degrees. The sum is the instantaneous period.}
   InstPeriod[0] = 0;
   Value4 = 0;
   for (count = 0;count<=40;count++)
      {
       Value4 = Value4 + DeltaPhase[shift+count];
       if  (Value4 > 360 && InstPeriod[0]  == 0) InstPeriod[0] = count;
     }
//   {Resolve Instantaneous  Period    errors and  smooth}
   if (InstPeriod[0] == 0) InstPeriod[0] = InstPeriod[1];
   Value5[0] = 0.25*(InstPeriod[0]) + 0.75*Value5[1];

//   {Compute Trendline as simple average over the measured dominant cycle period}
   Period_ = MathCeil(Value5[0]); Trendline = 0;///Period_ = IntPortion(Value5)
   for    (count = 0;count<=Period_ + 1;count++)
       { Trendline = Trendline + Price[shift+count]; }

   if (Period_ > 0) Trendline = Trendline    / (Period_  + 2);
   Value11[0] = 0.33*(Price[shift] + 0.5*(Price[shift] - Price[shift+3])) + 0.67*Value11[1];

   TRBuffer[shift]=Trendline;
   ZLBuffer[shift]=Value11[0];

//----
}
/*
Comment("Last Tick:",TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS),"\n",
        "Instant Trendline","\n",
        "Red Trend: ",TRBuffer[0],"\n",
        "Blue Trend: ",ZLBuffer[0]);*/
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 

Ind_TD_DeMark_3_1_LA_Mod_03B_AIME.mq4

//+------------------------------------------------------------------+
//|                            Ind-TD-DeMark-3-1-LA-Mod-03B-AIME.mq4 |
//|                            Copyright ? 2005,Kara Software Corp.  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2005, Kara Software Corp."
#property link      ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue /*Original #property indicator_color1 Red. Color of Upper TD Points*/
#property indicator_color2 Blue /*Original #property indicator_color2 Blue. Color of Lower TD Points*/
//---- input parameters
/* Mod 02: only one step, no back steps, only one target, no fractal trendlines,
no large arrow option for TD points, and added user changable colours and styles*/
/* Mod 03: Alerts Added.  Horizontal Lines indicating where projections start from and
where alerts should be determined from re-enabled with Default of False.*/
/* Mod 03B: Bug where TD Points and TD Lines drawn in wrong place for
double, triple and quadruple tops or bottoms is fixed*/

extern bool AlertsOn = true; // Line added.  Default is true.
extern bool      Comments=True;/*Optional Comments.  Default is false. Orginal variable called "Commen"*/
extern bool      TrendLine=True;/*Default is true to draw current TD Lines*/
extern int       TrendLineStyle=STYLE_DOT;/*STYLE>_SOLID=0,DASH=1,_DOT=2,_DASHDOT=3,_DASHDDOTDOT=4. Line of code added from original.*/
extern int       TrendLineWidth=1;/*Thinnest or allow dots and dashes = 0 or 1, Thinner=2, Medium=3,Thicker=4,Thickest=5.  Line of code added from original.*/
extern color     UpperTrendLineColour=LimeGreen;/*Line of code added from original.*/
extern color     LowerTrendLineColour=Red;/*Line of code added from original.*/
extern bool      ProjectionLines=True;/*Default is True.  These are the TD Price Projections. Original variable called "Take Prof"*/
extern int       ProjectionLinesStyle=STYLE_SOLID;/*STYLE>_SOLID=0,DASH=1,_DOT=2,_DASHDOT=3,_DASHDDOTDOT=4. Line of code added from original.*/
extern int       ProjectionLinesWidth=2;/*Thinnest or allow dots and dashes = 0 or 1, Thinner=2, Medium=3,Thicker=4,Thickest=5.  Line of code added from original.*/
extern color     UpperProjectionLineColour=LimeGreen;/*Line of code added from original.*/
extern color     LowerProjectionLineColour=Red;/*Line of code added from original.*/
extern bool      HorizontLine=False;/*Default is false.  It seems the Horizontal Lines are were the code predicts price may cross TD line.*/

bool             TD=False;/*Default is false. True setting draws up and down arrows instead of dots on TD Points creating more clutter.*/
int              BackSteps=0;/*Used to be extern int now just int. Leave at 0*/
int              ShowingSteps=1;/*Used to be extern int now just int.  Leave at 1*/
bool             FractalAsTD=false;/*Used to be extern bool now just bool.  Leave at false, otherwise Trend Lines based on Fractal Points not TD Points*/

double TrendLineBreakUp=-1;//Line added.
bool TrendLineBreakUpFlag=False;//Line added.
double TrendLineBreakDown=-1;//Line added.
bool TrendLineBreakDownFlag=False;//Line added.

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//====================================================================
int init()
  {
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   for (int i=1;i<=10;i++)
     {
      ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
      ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
      ObjectDelete("HC1_"+i);
      ObjectDelete("HC2_"+i);
      ObjectDelete("HC3_"+i);
      ObjectDelete("LC1_"+i);
      ObjectDelete("LC2_"+i);
      ObjectDelete("LC3_"+i);
     }
   Comment("");
   return(0);
  }
int deinit()
  {
   for (int i=1;i<=10;i++)
     {
      ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
      ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
      ObjectDelete("HC1_"+i);
      ObjectDelete("HC2_"+i);
      ObjectDelete("HC3_"+i);
      ObjectDelete("LC1_"+i);
      ObjectDelete("LC2_"+i);
      ObjectDelete("LC3_"+i);
     }
   Comment("");
   return(0);
  }
//--------------------------------------------------------------------
int SetTDPoint(int B)//It seems B is the same as IndicatorCounted() function
{
 int shift;
 if (FractalAsTD==false)
   {
    //Print("B = ",B);
    //Print("Bars = ",Bars);
    //Print("IndicatorCounted() = ",IndicatorCounted());
    for (shift=B;shift>1;shift--)
       {
        if (High[shift+1]<High[shift] && High[shift-1]<High[shift])// determine single top TD Point
           ExtMapBuffer1[shift]=High[shift];// determine single top TD Point

        if (High[shift+2]<High[shift] && High[shift+1]==High[shift]&& High[shift-1]<High[shift])//I added for double top
           ExtMapBuffer1[shift]=High[shift];//I added for double top

        if (High[shift+3]<High[shift] && High[shift+2]==High[shift]&& High[shift+1]==High[shift]//I added for triple top
           && High[shift-1]<High[shift])//I added for triple top
           ExtMapBuffer1[shift]=High[shift];//I added for triple top

        if (High[shift+4]<High[shift] && High[shift+3]==High[shift]&& High[shift+2]==High[shift]//I added for quadruple top
           && High[shift+1]==High[shift]//I added for quadruple top
           && High[shift-1]<High[shift])//I added for quadruple top
           ExtMapBuffer1[shift]=High[shift];//I added for quadruple top

        if (High[shift-1]>=High[shift])//I added for new way to determine Non-TD High Point
           ExtMapBuffer1[shift]=0;//I added for new way to determine Non-TD High Point

        //else ExtMapBuffer1[shift]=0;

        if (Low[shift+1]>Low[shift] && Low[shift-1]>Low[shift])// determine single bottom TD Point
           ExtMapBuffer2[shift]=Low[shift];// determine single bottom TD Point

        if (Low[shift+2]>Low[shift] && Low[shift+1]==Low[shift] && Low[shift-1]>Low[shift])//I added for double bottom
           ExtMapBuffer2[shift]=Low[shift];//I added for double bottom

        if (Low[shift+3]>Low[shift] && Low[shift+2]==Low[shift] && Low[shift+1]==Low[shift]//I added for triple bottom
           && Low[shift-1]>Low[shift])//I added for triple bottom
           ExtMapBuffer2[shift]=Low[shift];//I added for triple bottom

        if (Low[shift+4]>Low[shift] && Low[shift+3]==Low[shift]&& Low[shift+2]==Low[shift] && Low[shift+1]==Low[shift]//I added for quadruple bottom
           && Low[shift-1]>Low[shift])//I added for quadruple bottom
           ExtMapBuffer2[shift]=Low[shift];//I added for quadruple bottom

        if (Low[shift-1]<=Low[shift])//I added
           ExtMapBuffer2[shift]=0;//I added

        //else ExtMapBuffer2[shift]=0;
       }
    ExtMapBuffer1[0]=0;
    ExtMapBuffer2[0]=0;
    ExtMapBuffer1[1]=0;
    ExtMapBuffer2[1]=0;
   }
 else
   {
    for (shift=B;shift>3;shift--)
       {
        if (High[shift+1]<=High[shift] && High[shift-1]<High[shift] && High[shift+2]<=High[shift] && High[shift-2]<High[shift])
             ExtMapBuffer1[shift]=High[shift];
        else ExtMapBuffer1[shift]=0;
        if (Low[shift+1]>=Low[shift] && Low[shift-1]>Low[shift] && Low[shift+2]>=Low[shift] && Low[shift-2]>Low[shift])
            ExtMapBuffer2[shift]=Low[shift];
        else ExtMapBuffer2[shift]=0;
       }
    ExtMapBuffer1[0]=0;
    ExtMapBuffer2[0]=0;
    ExtMapBuffer1[1]=0;
    ExtMapBuffer2[1]=0;
    ExtMapBuffer1[2]=0;
    ExtMapBuffer2[2]=0;
   }
 return(0);
}
//--------------------------------------------------------------------
int GetHighTD(int P)
{
 int i=0,j=0;
 while (j<P)
   {
    i++;
    while(ExtMapBuffer1[i]==0)
      {i++;if(i>Bars-2)return(-1);}
    j++;
   }
 return (i);
}
//--------------------------------------------------------------------
int GetNextHighTD(int P)
{
 int i=P+1;
 while(ExtMapBuffer1[i]<=High[P]){i++;if(i>Bars-2)return(-1);}
 return (i);
}
//--------------------------------------------------------------------
int GetLowTD(int P)
{
 int i=0,j=0;
 while (j<P)
   {
    i++;
    while(ExtMapBuffer2[i]==0)
      {i++;if(i>Bars-2)return(-1);}
    j++;
   }
 return (i);
}
//--------------------------------------------------------------------
int GetNextLowTD(int P)
{
 int i=P+1;
 while(ExtMapBuffer2[i]>=Low[P] || ExtMapBuffer2[i]==0){i++;if(i>Bars-2)return(-1);}
 return (i);
}
//--------------------------------------------------------------------
int TrendLineHighTD(int H1,int H2,int Step,int Col)/*Draw Upper Trend Line*/
{
 ObjectSet("HL_"+Step,OBJPROP_TIME1,Time[H2]);ObjectSet("HL_"+Step,OBJPROP_TIME2,Time[H1]);
 ObjectSet("HL_"+Step,OBJPROP_PRICE1,High[H2]);ObjectSet("HL_"+Step,OBJPROP_PRICE2,High[H1]);
 ObjectSet("HL_"+Step,OBJPROP_COLOR,UpperTrendLineColour);/*TEMP Original OBJPROP_COLOR,Col*/
 if (Step==1)ObjectSet("HL_"+Step,OBJPROP_WIDTH,TrendLineWidth);/*Original OBJPROP_WIDTH,2*/
 else ObjectSet("HL_"+Step,OBJPROP_WIDTH,1);
 return(0);
}
//--------------------------------------------------------------------
int TrendLineLowTD(int L1,int L2,int Step,int Col)/*Draw Lower Trend Line*/
{
 ObjectSet("LL_"+Step,OBJPROP_TIME1,Time[L2]);ObjectSet("LL_"+Step,OBJPROP_TIME2,Time[L1]);
 ObjectSet("LL_"+Step,OBJPROP_PRICE1,Low[L2]);ObjectSet("LL_"+Step,OBJPROP_PRICE2,Low[L1]);
 ObjectSet("LL_"+Step,OBJPROP_COLOR,LowerTrendLineColour);/*TEMP Original OBJPROP_COLOR,Col*/
 if (Step==1)ObjectSet("LL_"+Step,OBJPROP_WIDTH,TrendLineWidth);/*Original OBJPROP_WIDTH,2*/
 else ObjectSet("LL_"+Step,OBJPROP_WIDTH,1);
 return(0);
}
//--------------------------------------------------------------------
int HorizontLineHighTD(int H1,int H2,int Step,double St,int Col)
{
 ObjectSet("HHL_"+Step,OBJPROP_PRICE1,High[H2]-(High[H2]-High[H1])/(H2-H1)*H2);//HORIZONTAL HIGH LINE HEIGHT CALCULATION
 ObjectSet("HHL_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HHL_"+Step,OBJPROP_COLOR,Col);
 ObjectSet("HHL_"+Step,OBJPROP_BACK,True);//Line added
 return(0);
}
//--------------------------------------------------------------------
int HorizontLineLowTD(int L1,int L2,int Step,double St,int Col)
{

 ObjectSet("HLL_"+Step,OBJPROP_PRICE1,Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2);//HORIZONTAL LOW LINE HEIGHT CALCULATION
 ObjectSet("HLL_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HLL_"+Step,OBJPROP_COLOR,Col);
 ObjectSet("HLL_"+Step,OBJPROP_BACK,True);//Line added
 return(0);
}
//--------------------------------------------------------------------
string TakeProfitHighTD(int H1,int H2,int Step,int Col)/*Draw Buy TD Price Projection(s)*/
{
 int i,ii,j=0;
 string Comm="";
 double kH,HC1,HC2,HC3,k,St;
 kH=(High[H2]-High[H1])/(H2-H1);
 while (NormalizeDouble(Point,j)==0)j++;
 k=0;
 for(i=H1;i>0;i--)if(Close[i]>High[H2]-kH*(H2-i)){k=High[H2]-kH*(H2-i);break;}
 if (k>0)
   {
    Comm=Comm+"UTD_Line ("+DoubleToStr(High[H2]-kH*H2,j)+") broken at "+DoubleToStr(k,j)+", uptargets:\n";
    ii=Lowest(NULL,0,MODE_LOW,H2-i,i);
    HC1=High[H2]-kH*(H2-ii)-Low[ii];
    HC2=High[H2]-kH*(H2-ii)-Close[ii];
    ii=Lowest(NULL,0,MODE_CLOSE,H2-i,i);
    HC3=High[H2]-kH*(H2-ii)-Close[ii];
    St=TrendLineStyle;/*Original STYLE_SOLID*/
   }
 else
   {
    k=High[H2]-kH*H2;
    Comm=Comm+"UTD_Line ("+DoubleToStr(k,j)+"), probable break-up targets:\n";
    ii=Lowest(NULL,0,MODE_LOW,H2,0);
    HC1=High[H2]-kH*(H2-ii)-Low[ii];
    HC2=High[H2]-kH*(H2-ii)-Close[ii];
    ii=Lowest(NULL,0,MODE_CLOSE,H2,0);
    HC3=High[H2]-kH*(H2-ii)-Close[ii];
    St=TrendLineStyle;/*Original STYLE_DASHDOT*/
   }
 ObjectSet("HL_"+Step,OBJPROP_STYLE,St);
 Comm=Comm+"T1="+DoubleToStr(HC1+k,j)+" ("+DoubleToStr(HC1/Point,0)+"pts.)\n";//changed "pts.)" to "pts.)\n"
 //Comm=Comm+" T2="+DoubleToStr(HC2+k,j)+" ("+DoubleToStr(HC2/Point,0)+"pts.)";
 //Comm=Comm+" T3="+DoubleToStr(HC3+k,j)+" ("+DoubleToStr(HC3/Point,0)+"pts.)\n";
 ObjectSet("HC1_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC1_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("HC1_"+Step,OBJPROP_PRICE1,HC1+k);ObjectSet("HC1_"+Step,OBJPROP_PRICE2,HC1+k);
 ObjectSet("HC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC1_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("HC2_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC2_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("HC2_"+Step,OBJPROP_PRICE1,HC2+k);ObjectSet("HC2_"+Step,OBJPROP_PRICE2,HC2+k);
 //ObjectSet("HC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC2_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("HC3_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC3_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("HC3_"+Step,OBJPROP_PRICE1,HC3+k);ObjectSet("HC3_"+Step,OBJPROP_PRICE2,HC3+k);
 //ObjectSet("HC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC3_"+Step,OBJPROP_STYLE,St);
 if (Step==1)
   {
    ObjectSet("HC1_"+Step,OBJPROP_WIDTH,ProjectionLinesWidth);/*Original OBJPROP_WIDTH,2*/
    ObjectSet("HC1_"+Step,OBJPROP_STYLE,ProjectionLinesStyle);/*This Line of code added from original. TD Upper Projection Line Style*/
//    ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
//    ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
   }
 else
   {
    ObjectSet("HC1_"+Step,OBJPROP_WIDTH,2);
//    ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
//    ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
   }
 return(Comm);
}
//--------------------------------------------------------------------
string TakeProfitLowTD(int L1,int L2,int Step,int Col)/*Draw Sell TD Price Projection(s)*/
{
 int i,ii,j=0;
 string Comm="";
 double kL,LC1,LC2,LC3,k,St;
 kL=(Low[L1]-Low[L2])/(L2-L1);
 while (NormalizeDouble(Point,j)==0)j++;
 k=0;
 for(i=L1;i>0;i--)if(Close[i]<Low[L2]+kL*(L2-i)){k=Low[L2]+kL*(L2-i);break;}
 if (k>0)
   {
    Comm=Comm+"LTD_Line ("+DoubleToStr(Low[L2]+kL*L2,j)+") broken at "+DoubleToStr(k,j)+", downtargets:\n";
    ii=Highest(NULL,0,MODE_HIGH,L2-i,i);
    LC1=High[ii]-(Low[L2]+kL*(L2-ii));
    LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
    i=Highest(NULL,0,MODE_CLOSE,L2-i,i);
    LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
    St=TrendLineStyle;/*Original STYLE_SOLID*/
   }
 else
   {
    k=Low[L2]+kL*L2;
    Comm=Comm+"LTD_Line ("+DoubleToStr(k,j)+"), probable downbreak targets:\n";
    ii=Highest(NULL,0,MODE_HIGH,L2,0);
    LC1=High[ii]-(Low[L2]+kL*(L2-ii));
    LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
    ii=Highest(NULL,0,MODE_CLOSE,L2,0);
    LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
    St=TrendLineStyle;/*Original STYLE_DASHDOT*/
   }
 ObjectSet("LL_"+Step,OBJPROP_STYLE,St);
 Comm=Comm+"T1="+DoubleToStr(k-LC1,j)+" ("+DoubleToStr(LC1/Point,0)+"pts.)\n";//changed "pts.)" to "pts.)\n"
 //Comm=Comm+" T2="+DoubleToStr(k-LC2,j)+" ("+DoubleToStr(LC2/Point,0)+"pts.)";
 //Comm=Comm+" T3="+DoubleToStr(k-LC3,j)+" ("+DoubleToStr(LC3/Point,0)+"pts.)\n";
 ObjectSet("LC1_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC1_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("LC1_"+Step,OBJPROP_PRICE1,k-LC1);ObjectSet("LC1_"+Step,OBJPROP_PRICE2,k-LC1);
 ObjectSet("LC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC1_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("LC2_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC2_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("LC2_"+Step,OBJPROP_PRICE1,k-LC2);ObjectSet("LC2_"+Step,OBJPROP_PRICE2,k-LC2);
 //ObjectSet("LC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC2_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("LC3_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC3_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("LC3_"+Step,OBJPROP_PRICE1,k-LC3);ObjectSet("LC3_"+Step,OBJPROP_PRICE2,k-LC3);
 //ObjectSet("LC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC3_"+Step,OBJPROP_STYLE,St);
 if (Step==1)
   {
    ObjectSet("LC1_"+Step,OBJPROP_WIDTH,ProjectionLinesWidth);/*Original OBJPROP_WIDTH,2*/
    ObjectSet("LC1_"+Step,OBJPROP_STYLE,ProjectionLinesStyle);/*This Line of code added from original. TD Lower Projection Line Style*/
    //ObjectSet("LC2_"+Step,OBJPROP_WIDTH,2);
    //ObjectSet("LC3_"+Step,OBJPROP_WIDTH,2);
   }
 else
   {
    ObjectSet("LC1_"+Step,OBJPROP_WIDTH,2);
    //ObjectSet("LC2_"+Step,OBJPROP_WIDTH,2);
    //ObjectSet("LC3_"+Step,OBJPROP_WIDTH,2);
   }
 return(Comm);
}
//--------------------------------------------------------------------
string TDMain(int Step)
{
 int H1,H2,L1,L2;
 string Comm="---   step "+Step+"   --------------------\n";
 int i,j; while (NormalizeDouble(Point,j)==0)j++;
 double Style;
 double Col[20];Col[0]=UpperProjectionLineColour/*Original Col[0]=Red, Colour for Current Upper TD Projection*/;Col[2]=Magenta;Col[4]=Chocolate;Col[6]=Goldenrod;Col[8]=SlateBlue;
                Col[1]=LowerProjectionLineColour/*Original Col[1]=Blue, Colour for Current Lower TD Projection*/;Col[3]=FireBrick;Col[5]=Green;Col[7]=MediumOrchid;Col[9]=CornflowerBlue;
                Col[10]=Red;Col[12]=Magenta;Col[14]=Chocolate;Col[16]=Goldenrod;Col[18]=SlateBlue;
                Col[11]=Blue;Col[13]=FireBrick;Col[15]=Green;Col[17]=MediumOrchid;Col[19]=CornflowerBlue;
   Step=Step+BackSteps;
   H1=GetHighTD(Step);
   H2=GetNextHighTD(H1);
   L1=GetLowTD(Step);
   L2=GetNextLowTD(L1);
   TrendLineBreakUp=High[H2]-(High[H2]-High[H1])/(H2-H1)*H2;//added line
   TrendLineBreakDown=Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2;//added line
   if (H1<0)Comm=Comm+"UTD no TD up-point \n";
   else
     if (H2<0)Comm=Comm+"UTD no TD point-upper then last one ("+DoubleToStr(High[H1],j)+")\n";
     else Comm=Comm+"UTD "+DoubleToStr(High[H2],j)+"  "+DoubleToStr(High[H1],j)+"\n";
   if (L1<0)Comm=Comm+"LTD no TD down-point \n";
   else
     if (L2<0)Comm=Comm+"LTD no TD point-lower then last one ("+DoubleToStr(Low[L1],j)+")\n";
     else Comm=Comm+"LTD  "+DoubleToStr(Low[L2],j)+"  "+DoubleToStr(Low[L1],j)+"\n";
   //-----------------------------------------------------------------------------------
   if (Step==1)Style=STYLE_SOLID;
   else Style=STYLE_DOT;
   if (H1>0 && H2>0)
     {
      if (TrendLine==1)
        {
         ObjectCreate("HL_"+Step,OBJ_TREND,0,0,0,0,0);
         TrendLineHighTD(H1,H2,Step,Col[Step*2-2]);
        }
      else ObjectDelete("HL_"+Step);
      if (HorizontLine==1 && Step==1)
        {
         ObjectCreate("HHL_"+Step,OBJ_HLINE,0,0,0,0,0);
         ObjectSet("HHL_"+Step,OBJPROP_BACK,True);//Line added
         HorizontLineHighTD(H1,H2,Step,Style,Col[Step*2-2]);
        }
      else ObjectDelete("HHL_"+Step);
      if (ProjectionLines==1)
        {
         ObjectCreate("HC1_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("HC2_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("HC3_"+Step,OBJ_TREND,0,0,0,0,0);
         Comm=Comm+TakeProfitHighTD(H1,H2,Step,Col[Step*2-2]);
        }
      else
        {
         ObjectDelete("HC1_"+Step);
         ObjectDelete("HC2_"+Step);
         ObjectDelete("HC3_"+Step);
        }
     }

   //-----------------------------------------------------------------------------------
   if (L1>0 && L2>0)
     {
      if (TrendLine==1)
        {
         ObjectCreate("LL_"+Step,OBJ_TREND,0,0,0,0,0);
         TrendLineLowTD(L1,L2,Step,Col[Step*2-1]);
        }
      else ObjectDelete("LL_"+Step);
      if (HorizontLine==1 && Step==1)
        {
         ObjectCreate("HLL_"+Step,OBJ_HLINE,0,0,0,0,0);
         ObjectSet("HLL_"+Step,OBJPROP_BACK,True);//Line added
         HorizontLineLowTD(L1,L2,Step,Style,Col[Step*2-1]);
        }
      else ObjectDelete("HLL_"+Step);
      if (ProjectionLines==1)
        {
         ObjectCreate("LC1_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("LC2_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("LC3_"+Step,OBJ_TREND,0,0,0,0,0);
         Comm=Comm+TakeProfitLowTD(L1,L2,Step,Col[Step*2-1]);
        }
      else
        {
         ObjectDelete("LC1_"+Step);
         ObjectDelete("LC2_"+Step);
         ObjectDelete("LC3_"+Step);
        }
     }
//--------------------------------------------------------------------
   if(AlertsOn)//added this Alerts section
   {
     //Print("Alerts On");

     if(Close[0]>TrendLineBreakUp && TrendLineBreakUpFlag==False)
     {
     //Print("Upper TrendLine Break ",Symbol()," ",Period()," ",Bid);
     Alert("UTL Break>",TrendLineBreakUp," on ",Symbol()," ",Period()," @ ",Bid);
     TrendLineBreakUpFlag=True;
     }
   if(Close[0]<TrendLineBreakDown && TrendLineBreakDownFlag==False)
     {

     //Print("Lower Trendline Break ",Symbol()," ",Period()," ",Bid);
     Alert("LTL Break<",TrendLineBreakDown," on ",Symbol()," ",Period()," @ ",Bid);
     TrendLineBreakDownFlag=True;
     }
 //--------------------------------------------------------------------
   }
 return(Comm);
}
//--------------------------------------------------------------------
int start()
{
 string Comm="";
   SetTDPoint(Bars-1);
   if (TD==1)
     {
      SetIndexArrow(0,217);
      SetIndexArrow(1,218);
     }
   else
     {
      SetIndexArrow(0,160);
      SetIndexArrow(1,160);
     }
   if (ShowingSteps>10)
    {
     Comment("ShowingSteps readings 0 - 10");
     return(0);
    }
   for (int i=1;i<=ShowingSteps;i++)Comm=Comm+TDMain(i);
   Comm=Comm+"------------------------------------\nShowingSteps="+ShowingSteps+"\nBackSteps="+BackSteps;
   if (FractalAsTD==true)Comm=Comm+"\nFractals";
   else Comm=Comm+"\nTD point";
   if (Comments==1)Comment(Comm);
   else Comment("");
   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 

Ind_TD_DeMark_3_1_LA_Mod_01_AIME.mq4

//+------------------------------------------------------------------+
//|                                            Ind-TD-DeMark-3-1.mq4 |
//|                            Copyright ? 2005, Kara Software Corp. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2005, Kara Software Corp."
#property link      ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int       BackSteps=0;
extern int       ShowingSteps=1;
extern bool      FractalAsTD=false;
extern bool      Commen=False;
extern bool      TD=False;
extern bool      TrendLine=true;
extern bool      HorizontLine=False;
extern bool      TakeProf=True;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//====================================================================
int init()
  {
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   for (int i=1;i<=10;i++)
     {
      ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
      ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
      ObjectDelete("HC1_"+i);
      ObjectDelete("HC2_"+i);
      ObjectDelete("HC3_"+i);
      ObjectDelete("LC1_"+i);
      ObjectDelete("LC2_"+i);
      ObjectDelete("LC3_"+i);
     }
   Comment("");
   return(0);
  }
int deinit()
  {
   for (int i=1;i<=10;i++)
     {
      ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
      ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
      ObjectDelete("HC1_"+i);
      ObjectDelete("HC2_"+i);
      ObjectDelete("HC3_"+i);
      ObjectDelete("LC1_"+i);
      ObjectDelete("LC2_"+i);
      ObjectDelete("LC3_"+i);
     }
   Comment("");
   return(0);
  }
//--------------------------------------------------------------------
int SetTDPoint(int B)
{
 int shift;
 if (FractalAsTD==false)
   {
    for (shift=B;shift>1;shift--)
       {
        if (High[shift+1]<High[shift] && High[shift-1]<High[shift] && Close[shift+2]<High[shift])
             ExtMapBuffer1[shift]=High[shift];
        else ExtMapBuffer1[shift]=0;
        if (Low[shift+1]>Low[shift] && Low[shift-1]>Low[shift] && Close[shift+2]>Low[shift])
            ExtMapBuffer2[shift]=Low[shift];
        else ExtMapBuffer2[shift]=0;
       }
    ExtMapBuffer1[0]=0;
    ExtMapBuffer2[0]=0;
    ExtMapBuffer1[1]=0;
    ExtMapBuffer2[1]=0;
   }
 else
   {
    for (shift=B;shift>3;shift--)
       {
        if (High[shift+1]<=High[shift] && High[shift-1]<High[shift] && High[shift+2]<=High[shift] && High[shift-2]<High[shift])
             ExtMapBuffer1[shift]=High[shift];
        else ExtMapBuffer1[shift]=0;
        if (Low[shift+1]>=Low[shift] && Low[shift-1]>Low[shift] && Low[shift+2]>=Low[shift] && Low[shift-2]>Low[shift])
            ExtMapBuffer2[shift]=Low[shift];
        else ExtMapBuffer2[shift]=0;
       }
    ExtMapBuffer1[0]=0;
    ExtMapBuffer2[0]=0;
    ExtMapBuffer1[1]=0;
    ExtMapBuffer2[1]=0;
    ExtMapBuffer1[2]=0;
    ExtMapBuffer2[2]=0;
   }
 return(0);
}
//--------------------------------------------------------------------
int GetHighTD(int P)
{
 int i=0,j=0;
 while (j<P)
   {
    i++;
    while(ExtMapBuffer1[i]==0)
      {i++;if(i>Bars-2)return(-1);}
    j++;
   }
 return (i);
}
//--------------------------------------------------------------------
int GetNextHighTD(int P)
{
 int i=P+1;
 while(ExtMapBuffer1[i]<=High[P]){i++;if(i>Bars-2)return(-1);}
 return (i);
}
//--------------------------------------------------------------------
int GetLowTD(int P)
{
 int i=0,j=0;
 while (j<P)
   {
    i++;
    while(ExtMapBuffer2[i]==0)
      {i++;if(i>Bars-2)return(-1);}
    j++;
   }
 return (i);
}
//--------------------------------------------------------------------
int GetNextLowTD(int P)
{
 int i=P+1;
 while(ExtMapBuffer2[i]>=Low[P] || ExtMapBuffer2[i]==0){i++;if(i>Bars-2)return(-1);}
 return (i);
}
//--------------------------------------------------------------------
int TrendLineHighTD(int H1,int H2,int Step,int Col)
{
 ObjectSet("HL_"+Step,OBJPROP_TIME1,Time[H2]);ObjectSet("HL_"+Step,OBJPROP_TIME2,Time[H1]);
 ObjectSet("HL_"+Step,OBJPROP_PRICE1,High[H2]);ObjectSet("HL_"+Step,OBJPROP_PRICE2,High[H1]);
 ObjectSet("HL_"+Step,OBJPROP_COLOR,Col);
 if (Step==1)ObjectSet("HL_"+Step,OBJPROP_WIDTH,2);
 else ObjectSet("HL_"+Step,OBJPROP_WIDTH,1);
 return(0);
}
//--------------------------------------------------------------------
int TrendLineLowTD(int L1,int L2,int Step,int Col)
{
 ObjectSet("LL_"+Step,OBJPROP_TIME1,Time[L2]);ObjectSet("LL_"+Step,OBJPROP_TIME2,Time[L1]);
 ObjectSet("LL_"+Step,OBJPROP_PRICE1,Low[L2]);ObjectSet("LL_"+Step,OBJPROP_PRICE2,Low[L1]);
 ObjectSet("LL_"+Step,OBJPROP_COLOR,Col);
 if (Step==1)ObjectSet("LL_"+Step,OBJPROP_WIDTH,2);
 else ObjectSet("LL_"+Step,OBJPROP_WIDTH,1);
 return(0);
}
//--------------------------------------------------------------------
int HorizontLineHighTD(int H1,int H2,int Step,double St,int Col)
{
 ObjectSet("HHL_"+Step,OBJPROP_PRICE1,High[H2]-(High[H2]-High[H1])/(H2-H1)*H2);
 ObjectSet("HHL_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HHL_"+Step,OBJPROP_COLOR,Col);
 return(0);
}
//--------------------------------------------------------------------
int HorizontLineLowTD(int L1,int L2,int Step,double St,int Col)
{
 ObjectSet("HLL_"+Step,OBJPROP_PRICE1,Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2);
 ObjectSet("HLL_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HLL_"+Step,OBJPROP_COLOR,Col);
 return(0);
}
//--------------------------------------------------------------------
string TakeProfitHighTD(int H1,int H2,int Step,int Col)
{
 int i,ii,j=0;
 string Comm="";
 double kH,HC1,HC2,HC3,k,St;
 kH=(High[H2]-High[H1])/(H2-H1);
 while (NormalizeDouble(Point,j)==0)j++;
 k=0;
 for(i=H1;i>0;i--)if(Close[i]>High[H2]-kH*(H2-i)){k=High[H2]-kH*(H2-i);break;}
 if (k>0)
   {
    Comm=Comm+"UTD_Line ("+DoubleToStr(High[H2]-kH*H2,j)+") broken at "+DoubleToStr(k,j)+", uptargets:\n";
    ii=Lowest(NULL,0,MODE_LOW,H2-i,i);
    HC1=High[H2]-kH*(H2-ii)-Low[ii];
    HC2=High[H2]-kH*(H2-ii)-Close[ii];
    ii=Lowest(NULL,0,MODE_CLOSE,H2-i,i);
    HC3=High[H2]-kH*(H2-ii)-Close[ii];
    St=STYLE_SOLID;
   }
 else
   {
    k=High[H2]-kH*H2;
    Comm=Comm+"UTD_Line ("+DoubleToStr(k,j)+"), probable break-up targets:\n";
    ii=Lowest(NULL,0,MODE_LOW,H2,0);
    HC1=High[H2]-kH*(H2-ii)-Low[ii];
    HC2=High[H2]-kH*(H2-ii)-Close[ii];
    ii=Lowest(NULL,0,MODE_CLOSE,H2,0);
    HC3=High[H2]-kH*(H2-ii)-Close[ii];
    St=STYLE_DASHDOT;
   }
 ObjectSet("HL_"+Step,OBJPROP_STYLE,St);
 Comm=Comm+"T1="+DoubleToStr(HC1+k,j)+" ("+DoubleToStr(HC1/Point,0)+"pts.)";
 //Comm=Comm+" T2="+DoubleToStr(HC2+k,j)+" ("+DoubleToStr(HC2/Point,0)+"pts.)";
 //Comm=Comm+" T3="+DoubleToStr(HC3+k,j)+" ("+DoubleToStr(HC3/Point,0)+"pts.)\n";
 ObjectSet("HC1_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC1_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("HC1_"+Step,OBJPROP_PRICE1,HC1+k);ObjectSet("HC1_"+Step,OBJPROP_PRICE2,HC1+k);
 ObjectSet("HC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC1_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("HC2_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC2_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("HC2_"+Step,OBJPROP_PRICE1,HC2+k);ObjectSet("HC2_"+Step,OBJPROP_PRICE2,HC2+k);
 //ObjectSet("HC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC2_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("HC3_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC3_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("HC3_"+Step,OBJPROP_PRICE1,HC3+k);ObjectSet("HC3_"+Step,OBJPROP_PRICE2,HC3+k);
 //ObjectSet("HC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC3_"+Step,OBJPROP_STYLE,St);
 if (Step==1)
   {
    ObjectSet("HC1_"+Step,OBJPROP_WIDTH,2);
//    ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
//    ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
   }
 else
   {
    ObjectSet("HC1_"+Step,OBJPROP_WIDTH,2);
//    ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
//    ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
   }
 return(Comm);
}
//--------------------------------------------------------------------
string TakeProfitLowTD(int L1,int L2,int Step,int Col)
{
 int i,ii,j=0;
 string Comm="";
 double kL,LC1,LC2,LC3,k,St;
 kL=(Low[L1]-Low[L2])/(L2-L1);
 while (NormalizeDouble(Point,j)==0)j++;
 k=0;
 for(i=L1;i>0;i--)if(Close[i]<Low[L2]+kL*(L2-i)){k=Low[L2]+kL*(L2-i);break;}
 if (k>0)
   {
    Comm=Comm+"LTD_Line ("+DoubleToStr(Low[L2]+kL*L2,j)+") broken at "+DoubleToStr(k,j)+", downtargets:\n";
    ii=Highest(NULL,0,MODE_HIGH,L2-i,i);
    LC1=High[ii]-(Low[L2]+kL*(L2-ii));
    LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
    i=Highest(NULL,0,MODE_CLOSE,L2-i,i);
    LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
    St=STYLE_SOLID;
   }
 else
   {
    k=Low[L2]+kL*L2;
    Comm=Comm+"LTD_Line ("+DoubleToStr(k,j)+"), probable downbreak targets:\n";
    ii=Highest(NULL,0,MODE_HIGH,L2,0);
    LC1=High[ii]-(Low[L2]+kL*(L2-ii));
    LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
    ii=Highest(NULL,0,MODE_CLOSE,L2,0);
    LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
    St=STYLE_DASHDOT;
   }
 ObjectSet("LL_"+Step,OBJPROP_STYLE,St);
 Comm=Comm+"T1="+DoubleToStr(k-LC1,j)+" ("+DoubleToStr(LC1/Point,0)+"pts.)";
 //Comm=Comm+" T2="+DoubleToStr(k-LC2,j)+" ("+DoubleToStr(LC2/Point,0)+"pts.)";
 //Comm=Comm+" T3="+DoubleToStr(k-LC3,j)+" ("+DoubleToStr(LC3/Point,0)+"pts.)\n";
 ObjectSet("LC1_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC1_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("LC1_"+Step,OBJPROP_PRICE1,k-LC1);ObjectSet("LC1_"+Step,OBJPROP_PRICE2,k-LC1);
 ObjectSet("LC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC1_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("LC2_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC2_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("LC2_"+Step,OBJPROP_PRICE1,k-LC2);ObjectSet("LC2_"+Step,OBJPROP_PRICE2,k-LC2);
 //ObjectSet("LC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC2_"+Step,OBJPROP_STYLE,St);
 //ObjectSet("LC3_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC3_"+Step,OBJPROP_TIME2,Time[0]);
 //ObjectSet("LC3_"+Step,OBJPROP_PRICE1,k-LC3);ObjectSet("LC3_"+Step,OBJPROP_PRICE2,k-LC3);
 //ObjectSet("LC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC3_"+Step,OBJPROP_STYLE,St);
 if (Step==1)
   {
    ObjectSet("LC1_"+Step,OBJPROP_WIDTH,2);
    //ObjectSet("LC2_"+Step,OBJPROP_WIDTH,2);
    //ObjectSet("LC3_"+Step,OBJPROP_WIDTH,2);
   }
 else
   {
    ObjectSet("LC1_"+Step,OBJPROP_WIDTH,2);
    //ObjectSet("LC2_"+Step,OBJPROP_WIDTH,2);
    //ObjectSet("LC3_"+Step,OBJPROP_WIDTH,2);
   }
 return(Comm);
}
//--------------------------------------------------------------------
string TDMain(int Step)
{
 int H1,H2,L1,L2;
 string Comm="---   step "+Step+"   --------------------\n";
 int i,j; while (NormalizeDouble(Point,j)==0)j++;
 double Style;
 double Col[20];Col[0]=Red;Col[2]=Magenta;Col[4]=Chocolate;Col[6]=Goldenrod;Col[8]=SlateBlue;
                Col[1]=Blue;Col[3]=FireBrick;Col[5]=Green;Col[7]=MediumOrchid;Col[9]=CornflowerBlue;
                Col[10]=Red;Col[12]=Magenta;Col[14]=Chocolate;Col[16]=Goldenrod;Col[18]=SlateBlue;
                Col[11]=Blue;Col[13]=FireBrick;Col[15]=Green;Col[17]=MediumOrchid;Col[19]=CornflowerBlue;
   Step=Step+BackSteps;
   H1=GetHighTD(Step);
   H2=GetNextHighTD(H1);
   L1=GetLowTD(Step);
   L2=GetNextLowTD(L1);
   if (H1<0)Comm=Comm+"UTD no TD up-point \n";
   else
     if (H2<0)Comm=Comm+"UTD no TD point-upper then last one ("+DoubleToStr(High[H1],j)+")\n";
     else Comm=Comm+"UTD "+DoubleToStr(High[H2],j)+"  "+DoubleToStr(High[H1],j)+"\n";
   if (L1<0)Comm=Comm+"LTD no TD down-point \n";
   else
     if (L2<0)Comm=Comm+"LTD no TD point-lower then last one ("+DoubleToStr(Low[L1],j)+")\n";
     else Comm=Comm+"LTD  "+DoubleToStr(Low[L2],j)+"  "+DoubleToStr(Low[L1],j)+"\n";
   //-----------------------------------------------------------------------------------
   if (Step==1)Style=STYLE_SOLID;
   else Style=STYLE_DOT;
   if (H1>0 && H2>0)
     {
      if (TrendLine==1)
        {
         ObjectCreate("HL_"+Step,OBJ_TREND,0,0,0,0,0);
         TrendLineHighTD(H1,H2,Step,Col[Step*2-2]);
        }
      else ObjectDelete("HL_"+Step);
      if (HorizontLine==1 && Step==1)
        {
         ObjectCreate("HHL_"+Step,OBJ_HLINE,0,0,0,0,0);
         HorizontLineHighTD(H1,H2,Step,Style,Col[Step*2-2]);
        }
      else ObjectDelete("HHL_"+Step);
      if (TakeProf==1)
        {
         ObjectCreate("HC1_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("HC2_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("HC3_"+Step,OBJ_TREND,0,0,0,0,0);
         Comm=Comm+TakeProfitHighTD(H1,H2,Step,Col[Step*2-2]);
        }
      else
        {
         ObjectDelete("HC1_"+Step);
         ObjectDelete("HC2_"+Step);
         ObjectDelete("HC3_"+Step);
        }
     }

   //-----------------------------------------------------------------------------------
   if (L1>0 && L2>0)
     {
      if (TrendLine==1)
        {
         ObjectCreate("LL_"+Step,OBJ_TREND,0,0,0,0,0);
         TrendLineLowTD(L1,L2,Step,Col[Step*2-1]);
        }
      else ObjectDelete("LL_"+Step);
      if (HorizontLine==1 && Step==1)
        {
         ObjectCreate("HLL_"+Step,OBJ_HLINE,0,0,0,0,0);
         HorizontLineLowTD(L1,L2,Step,Style,Col[Step*2-1]);
        }
      else ObjectDelete("HLL_"+Step);
      if (TakeProf==1)
        {
         ObjectCreate("LC1_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("LC2_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("LC3_"+Step,OBJ_TREND,0,0,0,0,0);
         Comm=Comm+TakeProfitLowTD(L1,L2,Step,Col[Step*2-1]);
        }
      else
        {
         ObjectDelete("LC1_"+Step);
         ObjectDelete("LC2_"+Step);
         ObjectDelete("LC3_"+Step);
        }
     }
 return(Comm);
}
//--------------------------------------------------------------------
int start()
{
 string Comm="";
   SetTDPoint(Bars-1);
   if (TD==1)
     {
      SetIndexArrow(0,217);
      SetIndexArrow(1,218);
     }
   else
     {
      SetIndexArrow(0,160);
      SetIndexArrow(1,160);
     }
   if (ShowingSteps>10)
    {
     Comment("ShowingSteps readings 0 - 10");
     return(0);
    }
   for (int i=1;i<=ShowingSteps;i++)Comm=Comm+TDMain(i);
   Comm=Comm+"------------------------------------\nShowingSteps="+ShowingSteps+"\nBackSteps="+BackSteps;
   if (FractalAsTD==true)Comm=Comm+"\nFractals";
   else Comm=Comm+"\nTD point";
   if (Commen==1)Comment(Comm);
   else Comment("");
   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 

Ind-TD-DeMark-3-1_eng.mq4

//+------------------------------------------------------------------+
//|                                            Ind-TD-DeMark-3-1.mq4 |
//|                            Copyright ? 2005, Kara Software Corp. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2005, Kara Software Corp."
#property link      ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int       BackSteps=0;
extern int       ShowingSteps=1;
extern bool      FractalAsTD=false;
extern bool      Commen=true;
extern bool      TD=true;
extern bool      TrendLine=true;
extern bool      HorizontLine=true;
extern bool      TakeProf=true;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//====================================================================
int init()
  {
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   for (int i=1;i<=10;i++)
     {
      ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
      ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
      ObjectDelete("HC1_"+i);
      ObjectDelete("HC2_"+i);
      ObjectDelete("HC3_"+i);
      ObjectDelete("LC1_"+i);
      ObjectDelete("LC2_"+i);
      ObjectDelete("LC3_"+i);
     }
   Comment("");
   return(0);
  }
int deinit()
  {
   for (int i=1;i<=10;i++)
     {
      ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
      ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
      ObjectDelete("HC1_"+i);
      ObjectDelete("HC2_"+i);
      ObjectDelete("HC3_"+i);
      ObjectDelete("LC1_"+i);
      ObjectDelete("LC2_"+i);
      ObjectDelete("LC3_"+i);
     }
   Comment("");
   return(0);
  }
//--------------------------------------------------------------------
int SetTDPoint(int B)
{
 int shift;
 if (FractalAsTD==false)
   {
    for (shift=B;shift>1;shift--)
       {
        if (High[shift+1]<High[shift] && High[shift-1]<High[shift] && Close[shift+2]<High[shift])
             ExtMapBuffer1[shift]=High[shift];
        else ExtMapBuffer1[shift]=0;
        if (Low[shift+1]>Low[shift] && Low[shift-1]>Low[shift] && Close[shift+2]>Low[shift])
            ExtMapBuffer2[shift]=Low[shift];
        else ExtMapBuffer2[shift]=0;
       }
    ExtMapBuffer1[0]=0;
    ExtMapBuffer2[0]=0;
    ExtMapBuffer1[1]=0;
    ExtMapBuffer2[1]=0;
   }
 else
   {
    for (shift=B;shift>3;shift--)
       {
        if (High[shift+1]<=High[shift] && High[shift-1]<High[shift] && High[shift+2]<=High[shift] && High[shift-2]<High[shift])
             ExtMapBuffer1[shift]=High[shift];
        else ExtMapBuffer1[shift]=0;
        if (Low[shift+1]>=Low[shift] && Low[shift-1]>Low[shift] && Low[shift+2]>=Low[shift] && Low[shift-2]>Low[shift])
            ExtMapBuffer2[shift]=Low[shift];
        else ExtMapBuffer2[shift]=0;
       }
    ExtMapBuffer1[0]=0;
    ExtMapBuffer2[0]=0;
    ExtMapBuffer1[1]=0;
    ExtMapBuffer2[1]=0;
    ExtMapBuffer1[2]=0;
    ExtMapBuffer2[2]=0;
   }
 return(0);
}
//--------------------------------------------------------------------
int GetHighTD(int P)
{
 int i=0,j=0;
 while (j<P)
   {
    i++;
    while(ExtMapBuffer1[i]==0)
      {i++;if(i>Bars-2)return(-1);}
    j++;
   }
 return (i);
}
//--------------------------------------------------------------------
int GetNextHighTD(int P)
{
 int i=P+1;
 while(ExtMapBuffer1[i]<=High[P]){i++;if(i>Bars-2)return(-1);}
 return (i);
}
//--------------------------------------------------------------------
int GetLowTD(int P)
{
 int i=0,j=0;
 while (j<P)
   {
    i++;
    while(ExtMapBuffer2[i]==0)
      {i++;if(i>Bars-2)return(-1);}
    j++;
   }
 return (i);
}
//--------------------------------------------------------------------
int GetNextLowTD(int P)
{
 int i=P+1;
 while(ExtMapBuffer2[i]>=Low[P] || ExtMapBuffer2[i]==0){i++;if(i>Bars-2)return(-1);}
 return (i);
}
//--------------------------------------------------------------------
int TrendLineHighTD(int H1,int H2,int Step,int Col)
{
 ObjectSet("HL_"+Step,OBJPROP_TIME1,Time[H2]);ObjectSet("HL_"+Step,OBJPROP_TIME2,Time[H1]);
 ObjectSet("HL_"+Step,OBJPROP_PRICE1,High[H2]);ObjectSet("HL_"+Step,OBJPROP_PRICE2,High[H1]);
 ObjectSet("HL_"+Step,OBJPROP_COLOR,Col);
 if (Step==1)ObjectSet("HL_"+Step,OBJPROP_WIDTH,2);
 else ObjectSet("HL_"+Step,OBJPROP_WIDTH,1);
 return(0);
}
//--------------------------------------------------------------------
int TrendLineLowTD(int L1,int L2,int Step,int Col)
{
 ObjectSet("LL_"+Step,OBJPROP_TIME1,Time[L2]);ObjectSet("LL_"+Step,OBJPROP_TIME2,Time[L1]);
 ObjectSet("LL_"+Step,OBJPROP_PRICE1,Low[L2]);ObjectSet("LL_"+Step,OBJPROP_PRICE2,Low[L1]);
 ObjectSet("LL_"+Step,OBJPROP_COLOR,Col);
 if (Step==1)ObjectSet("LL_"+Step,OBJPROP_WIDTH,2);
 else ObjectSet("LL_"+Step,OBJPROP_WIDTH,1);
 return(0);
}
//--------------------------------------------------------------------
int HorizontLineHighTD(int H1,int H2,int Step,double St,int Col)
{
 ObjectSet("HHL_"+Step,OBJPROP_PRICE1,High[H2]-(High[H2]-High[H1])/(H2-H1)*H2);
 ObjectSet("HHL_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HHL_"+Step,OBJPROP_COLOR,Col);
 return(0);
}
//--------------------------------------------------------------------
int HorizontLineLowTD(int L1,int L2,int Step,double St,int Col)
{
 ObjectSet("HLL_"+Step,OBJPROP_PRICE1,Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2);
 ObjectSet("HLL_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HLL_"+Step,OBJPROP_COLOR,Col);
 return(0);
}
//--------------------------------------------------------------------
string TakeProfitHighTD(int H1,int H2,int Step,int Col)
{
 int i,ii,j=0;
 string Comm="";
 double kH,HC1,HC2,HC3,k,St;
 kH=(High[H2]-High[H1])/(H2-H1);
 while (NormalizeDouble(Point,j)==0)j++;
 k=0;
 for(i=H1;i>0;i--)if(Close[i]>High[H2]-kH*(H2-i)){k=High[H2]-kH*(H2-i);break;}
 if (k>0)
   {
    Comm=Comm+"UTD_Line ("+DoubleToStr(High[H2]-kH*H2,j)+") hit the point "+DoubleToStr(k,j)+", target above:\n";
    ii=Lowest(NULL,0,MODE_LOW,H2-i,i);
    HC1=High[H2]-kH*(H2-ii)-Low[ii];
    HC2=High[H2]-kH*(H2-ii)-Close[ii];
    ii=Lowest(NULL,0,MODE_CLOSE,H2-i,i);
    HC3=High[H2]-kH*(H2-ii)-Close[ii];
    St=STYLE_SOLID;
   }
 else
   {
    k=High[H2]-kH*H2;
    Comm=Comm+"UTD_Line ("+DoubleToStr(k,j)+"), estimated targets above if hit:\n";
    ii=Lowest(NULL,0,MODE_LOW,H2,0);
    HC1=High[H2]-kH*(H2-ii)-Low[ii];
    HC2=High[H2]-kH*(H2-ii)-Close[ii];
    ii=Lowest(NULL,0,MODE_CLOSE,H2,0);
    HC3=High[H2]-kH*(H2-ii)-Close[ii];
    St=STYLE_DASHDOT;
   }
 ObjectSet("HL_"+Step,OBJPROP_STYLE,St);
 Comm=Comm+"Target1="+DoubleToStr(HC1+k,j)+" ("+DoubleToStr(HC1/Point,0)+"p.)";
 Comm=Comm+" Target2="+DoubleToStr(HC2+k,j)+" ("+DoubleToStr(HC2/Point,0)+"p.)";
 Comm=Comm+" Target3="+DoubleToStr(HC3+k,j)+" ("+DoubleToStr(HC3/Point,0)+"p.)\n";
 ObjectSet("HC1_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC1_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("HC1_"+Step,OBJPROP_PRICE1,HC1+k);ObjectSet("HC1_"+Step,OBJPROP_PRICE2,HC1+k);
 ObjectSet("HC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC1_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HC2_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC2_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("HC2_"+Step,OBJPROP_PRICE1,HC2+k);ObjectSet("HC2_"+Step,OBJPROP_PRICE2,HC2+k);
 ObjectSet("HC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC2_"+Step,OBJPROP_STYLE,St);
 ObjectSet("HC3_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC3_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("HC3_"+Step,OBJPROP_PRICE1,HC3+k);ObjectSet("HC3_"+Step,OBJPROP_PRICE2,HC3+k);
 ObjectSet("HC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC3_"+Step,OBJPROP_STYLE,St);
 if (Step==1)
   {
    ObjectSet("HC1_"+Step,OBJPROP_WIDTH,2);
    ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
    ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
   }
 else
   {
    ObjectSet("HC1_"+Step,OBJPROP_WIDTH,1);
    ObjectSet("HC2_"+Step,OBJPROP_WIDTH,1);
    ObjectSet("HC3_"+Step,OBJPROP_WIDTH,1);
   }
 return(Comm);
}
//--------------------------------------------------------------------
string TakeProfitLowTD(int L1,int L2,int Step,int Col)
{
 int i,ii,j=0;
 string Comm="";
 double kL,LC1,LC2,LC3,k,St;
 kL=(Low[L1]-Low[L2])/(L2-L1);
 while (NormalizeDouble(Point,j)==0)j++;
 k=0;
 for(i=L1;i>0;i--)if(Close[i]<Low[L2]+kL*(L2-i)){k=Low[L2]+kL*(L2-i);break;}
 if (k>0)
   {
    Comm=Comm+"LTD_Line ("+DoubleToStr(Low[L2]+kL*L2,j)+") hit the point "+DoubleToStr(k,j)+", targets below:\n";
    ii=Highest(NULL,0,MODE_HIGH,L2-i,i);
    LC1=High[ii]-(Low[L2]+kL*(L2-ii));
    LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
    i=Highest(NULL,0,MODE_CLOSE,L2-i,i);
    LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
    St=STYLE_SOLID;
   }
 else
   {
    k=Low[L2]+kL*L2;
    Comm=Comm+"LTD_Line ("+DoubleToStr(k,j)+"), estimated targets below if hit:\n";
    ii=Highest(NULL,0,MODE_HIGH,L2,0);
    LC1=High[ii]-(Low[L2]+kL*(L2-ii));
    LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
    ii=Highest(NULL,0,MODE_CLOSE,L2,0);
    LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
    St=STYLE_DASHDOT;
   }
 ObjectSet("LL_"+Step,OBJPROP_STYLE,St);
 Comm=Comm+"Target1="+DoubleToStr(k-LC1,j)+" ("+DoubleToStr(LC1/Point,0)+"p.)";
 Comm=Comm+" Target2="+DoubleToStr(k-LC2,j)+" ("+DoubleToStr(LC2/Point,0)+"p.)";
 Comm=Comm+" Target3="+DoubleToStr(k-LC3,j)+" ("+DoubleToStr(LC3/Point,0)+"p.)\n";
 ObjectSet("LC1_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC1_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("LC1_"+Step,OBJPROP_PRICE1,k-LC1);ObjectSet("LC1_"+Step,OBJPROP_PRICE2,k-LC1);
 ObjectSet("LC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC1_"+Step,OBJPROP_STYLE,St);
 ObjectSet("LC2_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC2_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("LC2_"+Step,OBJPROP_PRICE1,k-LC2);ObjectSet("LC2_"+Step,OBJPROP_PRICE2,k-LC2);
 ObjectSet("LC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC2_"+Step,OBJPROP_STYLE,St);
 ObjectSet("LC3_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC3_"+Step,OBJPROP_TIME2,Time[0]);
 ObjectSet("LC3_"+Step,OBJPROP_PRICE1,k-LC3);ObjectSet("LC3_"+Step,OBJPROP_PRICE2,k-LC3);
 ObjectSet("LC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC3_"+Step,OBJPROP_STYLE,St);
 if (Step==1)
   {
    ObjectSet("LC1_"+Step,OBJPROP_WIDTH,2);
    ObjectSet("LC2_"+Step,OBJPROP_WIDTH,2);
    ObjectSet("LC3_"+Step,OBJPROP_WIDTH,2);
   }
 else
   {
    ObjectSet("LC1_"+Step,OBJPROP_WIDTH,1);
    ObjectSet("LC2_"+Step,OBJPROP_WIDTH,1);
    ObjectSet("LC3_"+Step,OBJPROP_WIDTH,1);
   }
 return(Comm);
}
//--------------------------------------------------------------------
string TDMain(int Step)
{
 int H1,H2,L1,L2;
 string Comm="---   STEP "+Step+"   --------------------\n";
 int i,j; while (NormalizeDouble(Point,j)==0)j++;
 double Style;
 double Col[20];Col[0]=Red;Col[2]=Magenta;Col[4]=Chocolate;Col[6]=Goldenrod;Col[8]=SlateBlue;
                Col[1]=Blue;Col[3]=DeepSkyBlue;Col[5]=Green;Col[7]=MediumOrchid;Col[9]=CornflowerBlue;
                Col[10]=Red;Col[12]=Magenta;Col[14]=Chocolate;Col[16]=Goldenrod;Col[18]=SlateBlue;
                Col[11]=Blue;Col[13]=DeepSkyBlue;Col[15]=Green;Col[17]=MediumOrchid;Col[19]=CornflowerBlue;
   Step=Step+BackSteps;
   H1=GetHighTD(Step);
   H2=GetNextHighTD(H1);
   L1=GetLowTD(Step);
   L2=GetNextLowTD(L1);
   if (H1<0)Comm=Comm+"UTD on the chart: no above TD point \n";
   else
     if (H2<0)Comm=Comm+"UTD on the chart: no TD point above the last one ("+DoubleToStr(High[H1],j)+")\n";
     else Comm=Comm+"UTD "+DoubleToStr(High[H2],j)+"  "+DoubleToStr(High[H1],j)+"\n";
   if (L1<0)Comm=Comm+"LTD on the chart: no below TD point \n";
   else
     if (L2<0)Comm=Comm+"LTD on the chart: no TD point below the last one ("+DoubleToStr(Low[L1],j)+")\n";
     else Comm=Comm+"LTD  "+DoubleToStr(Low[L2],j)+"  "+DoubleToStr(Low[L1],j)+"\n";
   //-----------------------------------------------------------------------------------
   if (Step==1)Style=STYLE_SOLID;
   else Style=STYLE_DOT;
   if (H1>0 && H2>0)
     {
      if (TrendLine==1)
        {
         ObjectCreate("HL_"+Step,OBJ_TREND,0,0,0,0,0);
         TrendLineHighTD(H1,H2,Step,Col[Step*2-2]);
        }
      else ObjectDelete("HL_"+Step);
      if (HorizontLine==1 && Step==1)
        {
         ObjectCreate("HHL_"+Step,OBJ_HLINE,0,0,0,0,0);
         HorizontLineHighTD(H1,H2,Step,Style,Col[Step*2-2]);
        }
      else ObjectDelete("HHL_"+Step);
      if (TakeProf==1)
        {
         ObjectCreate("HC1_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("HC2_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("HC3_"+Step,OBJ_TREND,0,0,0,0,0);
         Comm=Comm+TakeProfitHighTD(H1,H2,Step,Col[Step*2-2]);
        }
      else
        {
         ObjectDelete("HC1_"+Step);
         ObjectDelete("HC2_"+Step);
         ObjectDelete("HC3_"+Step);
        }
     }

   //-----------------------------------------------------------------------------------
   if (L1>0 && L2>0)
     {
      if (TrendLine==1)
        {
         ObjectCreate("LL_"+Step,OBJ_TREND,0,0,0,0,0);
         TrendLineLowTD(L1,L2,Step,Col[Step*2-1]);
        }
      else ObjectDelete("LL_"+Step);
      if (HorizontLine==1 && Step==1)
        {
         ObjectCreate("HLL_"+Step,OBJ_HLINE,0,0,0,0,0);
         HorizontLineLowTD(L1,L2,Step,Style,Col[Step*2-1]);
        }
      else ObjectDelete("HLL_"+Step);
      if (TakeProf==1)
        {
         ObjectCreate("LC1_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("LC2_"+Step,OBJ_TREND,0,0,0,0,0);
         ObjectCreate("LC3_"+Step,OBJ_TREND,0,0,0,0,0);
         Comm=Comm+TakeProfitLowTD(L1,L2,Step,Col[Step*2-1]);
        }
      else
        {
         ObjectDelete("LC1_"+Step);
         ObjectDelete("LC2_"+Step);
         ObjectDelete("LC3_"+Step);
        }
     }
 return(Comm);
}
//--------------------------------------------------------------------
int start()
{
 string Comm="";
   SetTDPoint(Bars-1);
   if (TD==1)
     {
      SetIndexArrow(0,217);
      SetIndexArrow(1,218);
     }
   else
     {
      SetIndexArrow(0,160);
      SetIndexArrow(1,160);
     }
   if (ShowingSteps>10)
    {
     Comment("ShowingSteps value 0 - 10");
     return(0);
    }
   for (int i=1;i<=ShowingSteps;i++)Comm=Comm+TDMain(i);
   Comm=Comm+"------------------------------------\nShowingSteps="+ShowingSteps+"\nBackSteps="+BackSteps;
   if (FractalAsTD==true)Comm=Comm+"\nFractals";
   else Comm=Comm+"\nTD point";
   if (Commen==1)Comment(Comm);
   else Comment("");
   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 

 Page 1 of 6  1  2  3  4  5 » ...  Last » 

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