Monday, 15 February 2010

Two Median Line tools ( Metatrader Indicator & Book)

Two bits that may help anyone out there who struggles with drawing Metatrader Median lines, Schiff, Mod Schiff, action-reaction lines, inner lines (Fib or quartiles), warning lines, trigger lines and lastly sliding parallel (i may have missed something out). This indicator does it all and is an invaluable tool for those using Metatrader. It's a well programmed Indicator as a MQ4 file and i will forward it on request to anyone interested. The only slightly amusing thing is that the talented programmer who created this is obviously not English as he refers to 'Medium lines' in the notes However this is a superb tool for anyone drawing alot of ML's and needing accuracy and flexibility.

Secondly, There are many excellent books for the beginner, intermediate and advanced user including Tim Morge's books (who is pretty much the gold standard for ML trading) and Greg Fisher's book(s) which are excellent. Dr Dolgoda books i find unnecessarily overcomplicated.
One book stands out for me and is available ( at the time of writing in feb 10) free on the Internet on SCRIBD, the freeshare publishing site. You could save yourself 50$. The book is:
'The Best Trendline Methods of Alan Andrews and Five New Trendline Methods' BY Patrick Mikula. It is and does exactly what the title says and i recommend this book to every & anyone at whatever level.
I am happy to forward the PDF file privately on request.

Update: 2012
Here is the MT4 script for the custom PF indicator used on this site. It has been slightly tweeked by me. Feel free to copy and paste into MetaEditor and then compile etc.
The custom indicator for Esignal 10.6 is not stable and still undergoing programming work. It uses too much CPU and you would need a mainframe computer such as the CIA have at Langley.Va. This is due to the construction of Esignals coding.  The program does work but needs tweeking. I am happy to share only if the cost is contributed towards.It is a powerful tool that draws reaction lines/reaction grids. The problem has been if either or all P0,P1,P2 are not contained in the data available ( ie limited 60 mn data viewed in the 5 min TF may not contain the historical pivots)  then it uses the CPU to try to scratch its head to work out where every point on each line should be and gets extremely hot and flustered....Ensign windows is a write off as far a reaction lines and historical PF's are concerned which is ironic as it has the best basic PF tool but suffers from the same problem as Esignal and R lines and forks disappear when the time frame is stepped up/down dramatically, again due to data probs so you can't view a monthly PF in the 5 min TF as the pivots dont exisit/go back far enough.



//+------------------------------------------------------------------+
//|                                                       AML_v1.mq4 |
//|                                        caveman @ Forex Factory   |
//+------------------------------------------------------------------+
#property copyright "CaveMan"
#property link      "http://www.forexfactory.com"

#property indicator_chart_window

//+----------------------------------------------------------------------------------------------------------+
//|
//| A simple indicator to draw Andrew's Median Lines with support for
//|
//| 1. Inner Lines (using fibonnaci levels and standard equal portions)
//| 2. Warning Lines
//| 3. Reaction Lines
//| 4. Trigger Lines
//| 5. Sliding Parallel Lines
//| 6. Andrew's, Schiff, Modified Schiff and Catalin
//|
//| To start using the indicator, start by plotting a Pitchfork onto the chart.
//| Next, rename the Pitchfork to the name you set in the indicator. Default is AL1.
//|
//| Then go to the indicator property for options to custom configure to your own preference.
//|
//| Instructions for using Sliding Parallel Lines
//| =============================================
//| 3 Sliding Parallel Lines are supported. To use Sliding Parallel Lines, just draw a trend line and rename
//| it to AL_Name + SP1 or SP2 or SP3.
//|
//| e.g.
//| if using default AL_Name of AL1, then rename your sliding paralell lines as AL1SP1, AL1SP2 and AL1SP3.
//|
//| Multiple instances of the indicator can be loaded to support multiple Andrew's Meridian Lines on a chart.
//| Be sure to allocate unique names to each of the ALs. The same applies for the sliding parallel lines.
//|
//| e.g. if using 2nd AL with AL_Name AL2, then sliding paralells for this AL is AL2SP1, AL2SP2 and AL3SP3.
//|
//|
//| That's it.
//|
//+----------------------------------------------------------------------------------------------------------+

extern string AL_Name = "AL1";
extern int Choose_Type_of_Meridian_Lines = 1;
extern string Option_1 = "Andrew ML";
extern string Option_2 = "Schiff ML (time same, price half P0 P1)";
extern string Option_3 = "Modified Schiff ML (price and time half P0 P1)";
extern string Option_4 = "Catalin ML (time same, price P0 = P2)";
extern string Hide_AL_Instruction1 = "Set same color as chart background to";
extern string Hide_AL_Instruction2 = "hide original AL when using modified MLs.";
extern color Original_AL_Color = DimGray;
extern color Chart_Bkgrd_Color = Black;

extern string Advance_Options = "Choose AL Extensions.";
extern bool Draw_Trigger_Lines = false;
extern bool Draw_Inner_Lines = false;
extern bool Use_Fib_Levels_4_Inner_Lines = true;
extern string Use_Fib_3_Inner_Lines_Note1 = "True means use Fibonacci Levels. 4 Inner Lines.";
extern string Use_Fib_3_Inner_Lines_Note2 = "False means equally divided. Set no. of lines.";
extern int Num_Of__Inner_Lines_2_or_6 = 2;
extern bool Draw_Warning_Lines = true;
extern int Num_Of_Warning_Lines = 26;
extern bool Draw_Reaction_Lines = true;
extern int Num_Of_Reaction_Lines = 26;
extern bool Extend_Reaction_Lines = true;

extern bool Draw_Sliding_Parallel = true;
extern string Sliding_Parallel_Instruction1 = "To automate sliding parallel lines,";
extern string Sliding_Parallel_Instruction2 = "draw up to 3 trend lines and name them";
extern string Sliding_Parallel_Instruction3 = "as such: AL_Name defined above + SP1 to SP3.";
extern string Sliding_Parallel_Instruction4 = "e.g AL1SP1, AL1SP2, AL1SP3 for 2 sliding parallels.";

extern string Look_and_Feel = "Set colors, width and styles";

extern string Settings_for_Meridian_Lines = "==========================================================";
extern color Main_AL_Color = Teal;
extern int Main_AL_Style = 0;
extern int Main_AL_Width = 0;
extern color Modified_AL_Color = Blue;
extern int Modified_AL_Style = 0;
extern int Modified_AL_Width = 0;
extern string Settings_for_Inner_Lines = "==========================================================";
extern color Upper_LN1_Color = Gray;
extern int Upper_LN1_Style = STYLE_DOT;
extern int Upper_LN1_Width = 0;
extern color Upper_LN2_Color = Gray;
extern int Upper_LN2_Style = STYLE_DASH;
extern int Upper_LN2_Width = 0;
extern color Upper_LN3_Color = Gray;
extern int Upper_LN3_Style = STYLE_DOT;
extern int Upper_LN3_Width = 0;
extern color Lower_LN1_Color = Gray;
extern int Lower_LN1_Style = STYLE_DOT;
extern int Lower_LN1_Width = 0;
extern color Lower_LN2_Color = Gray;
extern int Lower_LN2_Style = STYLE_DASH;
extern int Lower_LN2_Width = 0;
extern color Lower_LN3_Color = Gray;
extern int Lower_LN3_Style = STYLE_DOT;
extern int Lower_LN3_Width = 0;
extern string Settings_for_Warning_Lines = "==========================================================";
extern color Warning_LN_Color = Brown;
extern int Warning_LN_Style = STYLE_DASHDOT;
extern int Warning_LN_Width = 0;
extern string Settings_for_Reaction_Lines = "==========================================================";
extern color Reaction_LN_Color = Brown;
extern int Reaction_LN_Style = STYLE_DASHDOT;
extern int Reaction_LN_Width = 0;
extern string Settings_for_Sliding_Parallels = "==========================================================";
extern color Sliding_Parallel_Color = Yellow;
extern int Sliding_Parallel_Style = STYLE_SOLID;
extern int Sliding_Parallel_Width = 0;
extern string Settings_for_Trigger_Lines = "==========================================================";
extern color Trigger_Lines_Color = Gray;
extern int Trigger_Lines_Style = STYLE_DASHDOTDOT;
extern int Trigger_Lines_Width = 0;
extern string Settings_for_Info_Label = "==========================================================";
extern bool show_label = true;
extern color label_color = Red;
extern int label_window_corner = 0;
extern int label_x_shift = 5;
extern int label_y_shift = 20;
extern string label_font_type = "Arial";
extern int label_font_size = 10;

string SP_Name1, SP_Name2, SP_Name3;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SP_Name1 = AL_Name+"SP1";
   SP_Name2 = AL_Name+"SP2";
   SP_Name3 = AL_Name+"SP3";
  
 
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete(AL_Name+"AL_Label");
   ObjectDelete(AL_Name+"Upper_ML1");
   ObjectDelete(AL_Name+"Upper_ML2");
   ObjectDelete(AL_Name+"Upper_ML3");
   ObjectDelete(AL_Name+"Lower_ML1");
   ObjectDelete(AL_Name+"Lower_ML2");
   ObjectDelete(AL_Name+"Lower_ML3");
   ObjectDelete(AL_Name+"Modified_AL");
   ObjectDelete(AL_Name+"Hidden_TL");
   ObjectDelete(AL_Name+"Trigger_Line1");
   ObjectDelete(AL_Name+"Trigger_Line2");
   ObjectDelete(SP_Name1+"1");
   ObjectDelete(SP_Name2+"1");
   ObjectDelete(SP_Name3+"1");
   for(int i=1; i <= Num_Of_Warning_Lines;i++)
      {
         string text = AL_Name+"Upper_Warning_LN"+i;
         ObjectDelete(text);
         text = AL_Name+"Lower_Warning_LN"+i;
         ObjectDelete(text);
      }
   for(i=1; i <= Num_Of_Reaction_Lines;i++)
      {
         text = AL_Name+"Reaction_LN1"+i;
         ObjectDelete(text);
         text = AL_Name+"Reaction_LN2"+i;
         ObjectDelete(text);
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
   if (ObjectFind(AL_Name)!= -1) // || ObjectFind(AL_Name+"Modified_AL") != -1)
      {
         double Price1 = ObjectGet(AL_Name, OBJPROP_PRICE1);
         double Price2 = ObjectGet(AL_Name, OBJPROP_PRICE2);
         double Price3 = ObjectGet(AL_Name, OBJPROP_PRICE3);
         datetime Time1 = ObjectGet(AL_Name, OBJPROP_TIME1);
         datetime Time2 = ObjectGet(AL_Name, OBJPROP_TIME2);
         datetime Time3  = ObjectGet(AL_Name, OBJPROP_TIME3);
  
         double PriceGap;    // Used to subdivide upper and lower ML into 8 portions
         double PriceShift;  // Used to calculate the next pair coorinates
         int TimeShift;      // for parallel lines
         double p1 = Price1, p2 = Price2, p3 = Price3;
         datetime t1 = Time1, t2 = Time2, t3 = Time3;

         if (ObjectGet(AL_Name, OBJPROP_COLOR) != Original_AL_Color)
            {
             ObjectSet(AL_Name, OBJPROP_COLOR, Main_AL_Color);
             ObjectSet(AL_Name, OBJPROP_STYLE, Main_AL_Style);
             ObjectSet(AL_Name, OBJPROP_WIDTH, Main_AL_Width);
             ObjectSet(AL_Name, OBJPROP_BACK, false);
            }
         if (ObjectFind(AL_Name+"AL_Label") == -1 && show_label)
            {
             ObjectCreate(AL_Name+"AL_Label",OBJ_LABEL,0,0,0);
             ObjectSet(AL_Name+"AL_Label", OBJPROP_CORNER, label_window_corner);
             ObjectSet(AL_Name+"AL_Label", OBJPROP_XDISTANCE, label_x_shift);
             ObjectSet(AL_Name+"AL_Label", OBJPROP_YDISTANCE, label_y_shift);
             ObjectSetText(AL_Name+"AL_Label", AL_Name+": Andrew ML", label_font_size, label_font_type, label_color);
             }
          else if (ObjectFind(AL_Name+"AL_Label") != -1 && !show_label)
            {
             ObjectDelete(AL_Name+"AL_Label");
            }
      // Types of ALs
      // 1 - Normal AL
      // 2 - Schiff
      // 3 - Modified Schiff (Catalin)
      // 4 - 50% Pitchfork (Austin Financial Group)
      // 5 - SuperPitchfork (Austin Financial Group)
         if (Choose_Type_of_Meridian_Lines == 2) { p1 = p1 + (p2 - p1)/2; if (show_label) ObjectSetText(AL_Name+"AL_Label", AL_Name+": Schiff ML", label_font_size, "Arial", label_color);}          
         if (Choose_Type_of_Meridian_Lines == 3) { p1 = p1 + (p2 - p1)/2; t1 = BarToTime(TimeToBar(t1) - (TimeToBar(t1) - TimeToBar(t2))/2) ; if (show_label) ObjectSetText(AL_Name+"AL_Label", AL_Name+": Modified Schiff ML", label_font_size, label_font_type, label_color);}        
         if (Choose_Type_of_Meridian_Lines == 4) { p1 = p3; if (show_label) ObjectSetText(AL_Name+"AL_Label", AL_Name+": Catalin ML", label_font_size, label_font_type, label_color);}          
         if (Choose_Type_of_Meridian_Lines > 1)
            {
             ObjectSet(AL_Name, OBJPROP_BACK, true);
             ObjectSet(AL_Name, OBJPROP_COLOR, Original_AL_Color);
             if (ObjectFind(AL_Name+"Modified_AL") == -1)
               {
                  ObjectCreate(AL_Name+"Modified_AL",OBJ_PITCHFORK,0, t1,p1,t2,p2,t3,p3);
                }
             else
               {
                  ObjectSet(AL_Name+"Modified_AL", OBJPROP_PRICE1, p1);
                  ObjectSet(AL_Name+"Modified_AL", OBJPROP_PRICE2, p2);
                  ObjectSet(AL_Name+"Modified_AL", OBJPROP_TIME1, t1);
                  ObjectSet(AL_Name+"Modified_AL", OBJPROP_TIME2, t2);
                  ObjectSet(AL_Name+"Modified_AL", OBJPROP_COLOR, Modified_AL_Color);
               }
             ObjectSet(AL_Name+"Modified_AL", OBJPROP_STYLE, Modified_AL_Style);
             ObjectSet(AL_Name+"Modified_AL", OBJPROP_COLOR, Modified_AL_Color);
             ObjectSet(AL_Name+"Modified_AL", OBJPROP_WIDTH, Modified_AL_Width);
             }
          else
          {
             ObjectSet(AL_Name, OBJPROP_BACK, false);
             ObjectSet(AL_Name, OBJPROP_COLOR, Main_AL_Color);
             ObjectSet(AL_Name, OBJPROP_STYLE, Main_AL_Style);
             ObjectSet(AL_Name, OBJPROP_WIDTH, Main_AL_Width);
          }
      //    
      // Price and Time Coordintes to draw parallel lines within MLs
      //
               double UpperP1, UpperP2, UpperP3, MiddleP0, LowerP1, LowerP2, LowerP3;
               int UT1Bar, UT2Bar, UT3Bar, MT0Bar, LT1Bar, LT2Bar, LT3Bar; // Time in bars for upper, mid and Lower inside lines

               int T1Bar, T2Bar, T3Bar, NumOfBars_T2T3, Bar_Gap, accuracy_factor = 10;
  
               T1Bar = TimeToBar(t1);
               T2Bar = TimeToBar(t2);
               T3Bar = TimeToBar(t3);

               NumOfBars_T2T3 = T2Bar - T3Bar;
               Bar_Gap = (NumOfBars_T2T3)/8;

               UT1Bar = T2Bar - Bar_Gap;
               UT2Bar = T2Bar - Bar_Gap*2;
               UT3Bar = T2Bar - Bar_Gap*3;
               MT0Bar = T2Bar - Bar_Gap*4;
               LT1Bar = T3Bar + Bar_Gap*3;
               LT2Bar = T3Bar + Bar_Gap*2;
               LT3Bar = T3Bar + Bar_Gap;

               PriceGap = (p2 - p3)/8.0;
      
               UpperP1 = p2 - PriceGap;
               UpperP2 = p2 - PriceGap*2;
               UpperP3 = p2 - PriceGap*3;
               MiddleP0 = p2 - (p2 - p3)/2.0;
               LowerP1 = p3 + PriceGap*3;
               LowerP2 = p3 + PriceGap*2;
               LowerP3 = p3 + PriceGap;

/*
There is a need here to multiple the shifts for both price and time by 2 as they are used for calculations of the 2nd
pivot point for drawing trendlines. If the 2 pivot points for drawing trendline are too close, there is a high chance
that the trendline drawn will not be totally parallel to the Meridian Lines. By increasing the distance between the
pivots by a factor of 2 will reduce the slight misalignment of all lines drawn parallel to the Andrew Meridian Lines.
This problem is less obvious when more bars are used for the ALs.
*/      
               PriceShift = (MiddleP0 - p1)*accuracy_factor;
               TimeShift = (T1Bar - MT0Bar)*accuracy_factor;  

         if (Draw_Inner_Lines)
            {
               if (Use_Fib_Levels_4_Inner_Lines)
                  {
                     SetLN(AL_Name+"Upper_ML1", BarToTime(T2Bar - (NumOfBars_T2T3*0.382)), p2 - (p2 - p3)*0.382, BarToTime(T2Bar - (NumOfBars_T2T3*0.382) - TimeShift), p2 - (p2 - p3)*0.382 + PriceShift, Upper_LN1_Color,Upper_LN1_Style,Upper_LN1_Width, true);
                     SetLN(AL_Name+"Lower_ML1", BarToTime(T3Bar + (NumOfBars_T2T3*0.382)), p3 + (p2 - p3)*0.382, BarToTime(T3Bar + (NumOfBars_T2T3*0.382) - TimeShift), p3 + (p2 - p3)*0.382 + PriceShift, Lower_LN1_Color,Lower_LN1_Style,Lower_LN1_Width, true);
                     SetLN(AL_Name+"Upper_ML2", BarToTime(T2Bar - (NumOfBars_T2T3*0.236)), p2 - (p2 - p3)*0.236, BarToTime(T2Bar - (NumOfBars_T2T3*0.236) - TimeShift), p2 - (p2 - p3)*0.236 + PriceShift, Upper_LN1_Color,Upper_LN1_Style,Upper_LN1_Width, true);
                     SetLN(AL_Name+"Lower_ML2", BarToTime(T3Bar + (NumOfBars_T2T3*0.236)), p3 + (p2 - p3)*0.236, BarToTime(T3Bar + (NumOfBars_T2T3*0.236) - TimeShift), p3 + (p2 - p3)*0.236 + PriceShift, Lower_LN1_Color,Lower_LN1_Style,Lower_LN1_Width, true);
                  }
               else if (Num_Of__Inner_Lines_2_or_6 == 2)
                  {
                     SetLN(AL_Name+"Upper_ML2", BarToTime(UT2Bar), UpperP2, BarToTime(UT2Bar - TimeShift), UpperP2 + PriceShift, Upper_LN2_Color,Upper_LN2_Style,Upper_LN2_Width, true);
                     SetLN(AL_Name+"Lower_ML2", BarToTime(LT2Bar), LowerP2, BarToTime(LT2Bar - TimeShift), LowerP2 + PriceShift, Lower_LN2_Color,Lower_LN2_Style,Lower_LN2_Width, true);
                  }
               else
                  {
                     SetLN(AL_Name+"Upper_ML1", BarToTime(UT1Bar), UpperP1, BarToTime(UT1Bar - TimeShift), UpperP1 + PriceShift, Upper_LN1_Color,Upper_LN1_Style,Upper_LN1_Width, true);
                     SetLN(AL_Name+"Upper_ML2", BarToTime(UT2Bar), UpperP2, BarToTime(UT2Bar - TimeShift), UpperP2 + PriceShift, Upper_LN2_Color,Upper_LN2_Style,Upper_LN2_Width, true);
                     SetLN(AL_Name+"Upper_ML3", BarToTime(UT3Bar), UpperP3, BarToTime(UT3Bar - TimeShift), UpperP3 + PriceShift, Upper_LN3_Color,Upper_LN3_Style,Upper_LN3_Width, true);
                     SetLN(AL_Name+"Lower_ML1", BarToTime(LT1Bar), LowerP1, BarToTime(LT1Bar - TimeShift), LowerP1 + PriceShift, Lower_LN1_Color,Lower_LN1_Style,Lower_LN1_Width, true);
                     SetLN(AL_Name+"Lower_ML2", BarToTime(LT2Bar), LowerP2, BarToTime(LT2Bar - TimeShift), LowerP2 + PriceShift, Lower_LN2_Color,Lower_LN2_Style,Lower_LN2_Width, true);
                     SetLN(AL_Name+"Lower_ML3", BarToTime(LT3Bar), LowerP3, BarToTime(LT3Bar - TimeShift), LowerP3 + PriceShift, Lower_LN3_Color,Lower_LN3_Style,Lower_LN3_Width, true);
                  }
            }
         if (Draw_Warning_Lines)
            {
               for(int x=1; x <= Num_Of_Warning_Lines;x++)
                  {
                     string txt = AL_Name+"Upper_Warning_LN"+x;
                     SetLN(txt,  BarToTime(T2Bar + (T2Bar - MT0Bar)*x), p2 + (p2-MiddleP0)*x, BarToTime((T2Bar + (T2Bar - MT0Bar)*x) - TimeShift), p2 + (p2-MiddleP0)*x + PriceShift, Warning_LN_Color,Warning_LN_Style,Warning_LN_Width, true);              
                     txt = AL_Name+"Lower_Warning_LN"+x;
                     SetLN(txt,  BarToTime(T3Bar - (T2Bar - MT0Bar)*x), p3 - (p2-MiddleP0)*x, BarToTime((T3Bar - (T2Bar - MT0Bar)*x) - TimeShift), p3 - (p2-MiddleP0)*x + PriceShift, Warning_LN_Color,Warning_LN_Style,Warning_LN_Width, true);              
                  }
            }
         if (Draw_Reaction_Lines)
            {
               for(x=1; x <= Num_Of_Reaction_Lines;x++)
                  {
                     txt = AL_Name+"Reaction_LN1"+x;
                     SetLN(txt, BarToTime(T2Bar - TimeShift/accuracy_factor*x), p2 + PriceShift/accuracy_factor*x , BarToTime(T3Bar - TimeShift/accuracy_factor*x), p3 + PriceShift/accuracy_factor*x,  Reaction_LN_Color,Reaction_LN_Style,Reaction_LN_Width, Extend_Reaction_Lines);              
                     txt = AL_Name+"Reaction_LN2"+x;
                     SetLN(txt,BarToTime(T3Bar - TimeShift/accuracy_factor*x), p3 + PriceShift/accuracy_factor*x ,   BarToTime(T2Bar - TimeShift/accuracy_factor*x), p2 + PriceShift/accuracy_factor*x, Reaction_LN_Color,Reaction_LN_Style,Reaction_LN_Width, Extend_Reaction_Lines);              
                  }           
            }
         if (Draw_Trigger_Lines)
            {
                  SetLN(AL_Name+"Trigger_Line1", t1, p1, t2, p2, Trigger_Lines_Color,Trigger_Lines_Style,Trigger_Lines_Width, true);              
                  SetLN(AL_Name+"Trigger_Line2", t1, p1, t3, p3, Trigger_Lines_Color,Trigger_Lines_Style,Trigger_Lines_Width, true);              
             }
         if (Draw_Sliding_Parallel)
            {
             if (ObjectFind(AL_Name+"Hidden_TL") == -1)
               {
                  ObjectCreate(AL_Name+"Hidden_TL", OBJ_TREND, 0,t1,p1, BarToTime(TimeToBar(t1)- TimeShift), p1 + PriceShift);
//                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_COLOR, Red);
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_COLOR, Chart_Bkgrd_Color);
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_BACK, true);
               }
             else
               {
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_PRICE1, p1);
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_PRICE2, p1 + PriceShift);
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_TIME1, t1);
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_TIME2, BarToTime(TimeToBar(t1)- TimeShift));
//                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_COLOR, Red);
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_COLOR, Chart_Bkgrd_Color);
                  ObjectSet(AL_Name+"Hidden_TL", OBJPROP_BACK, true);
               }
            for (x=1;x <=3;x++)
               {
               switch(x)
                  {
                     case 1: string line_name = SP_Name1;break;
                     case 2: line_name = SP_Name2;break;
                     case 3: line_name = SP_Name3;break;                    
                   }
               if (ObjectFind(line_name) != -1)
                  {
                     double sl_p; datetime sl_t;
                     sl_p = ObjectGet(line_name, OBJPROP_PRICE1);
                     sl_t = ObjectGet(line_name, OBJPROP_TIME1);
                 
                     ObjectSet(line_name, OBJPROP_TIME2, BarToTime(TimeToBar(sl_t) - TimeShift));
                     ObjectSet(line_name, OBJPROP_PRICE2, sl_p + PriceShift);
                     ObjectSet(line_name, OBJPROP_COLOR, Sliding_Parallel_Color);
                     ObjectSet(line_name, OBJPROP_STYLE, Sliding_Parallel_Style);
                     ObjectSet(line_name, OBJPROP_WIDTH, Sliding_Parallel_Width);
                     ObjectSet(line_name, OBJPROP_RAY, true);
                    
                     double check = ObjectGetValueByShift(AL_Name+"Hidden_TL", TimeToBar(sl_t)/10);

                     if (p2 > p3 && sl_p > check)
                        {
                          SetLN(line_name+1, BarToTime(TimeToBar(sl_t)-(T2Bar - T3Bar + 1)), sl_p - (p2 - p3), BarToTime(TimeToBar(sl_t)-(T2Bar - T3Bar + 1)- TimeShift),  sl_p - (p2 -p3) + PriceShift,  Sliding_Parallel_Color,Sliding_Parallel_Style,Sliding_Parallel_Width, true);              
                         }
                     else if (p2 > p3 && sl_p < check)
                        {
                          SetLN(line_name+1, BarToTime(TimeToBar(sl_t)+(T2Bar - T3Bar + 1)), sl_p + (p2 - p3), BarToTime(TimeToBar(sl_t)+(T2Bar - T3Bar + 1)- TimeShift),  sl_p + (p2 -p3) + PriceShift,  Sliding_Parallel_Color,Sliding_Parallel_Style,Sliding_Parallel_Width, true);              
                        }
                     else if (p3 > p2 && sl_p > check)
                        {
                          SetLN(line_name+1, BarToTime(TimeToBar(sl_t)+(T2Bar - T3Bar + 1)), sl_p + (p2 - p3), BarToTime(TimeToBar(sl_t)+(T2Bar - T3Bar + 1)- TimeShift),  sl_p + (p2 -p3) + PriceShift,  Sliding_Parallel_Color,Sliding_Parallel_Style,Sliding_Parallel_Width, true);              
                         }
                     else if (p3 > p2 && sl_p < check)
                        {
                          SetLN(line_name+1, BarToTime(TimeToBar(sl_t)-(T2Bar - T3Bar + 1)), sl_p - (p2 - p3), BarToTime(TimeToBar(sl_t)-(T2Bar - T3Bar + 1)- TimeShift),  sl_p - (p2 -p3) + PriceShift,  Sliding_Parallel_Color,Sliding_Parallel_Style,Sliding_Parallel_Width, true);              
                        }
                  }
                else if (ObjectFind(line_name) == -1) if (ObjectFind(line_name+1)!= -1) ObjectDelete(line_name+1);
                }
             }
   }
   return(0);
  }
//+------------------------------------------------------------------+

void SetLN(string text, datetime t1, double p1,datetime t2, double p2, color col, int style, int width, bool extend_ray) {
   string linename=text;
   // create or move the object
   if (ObjectFind(linename) < 0) {
      ObjectCreate(linename, OBJ_TREND, 0, t1, p1, t2, p2);
      ObjectSet(linename, OBJPROP_RAY, extend_ray);
      ObjectSet(linename, OBJPROP_STYLE, style);
      ObjectSet(linename, OBJPROP_COLOR, col);
      ObjectSet(linename, OBJPROP_WIDTH, width);
   } else {
      ObjectSet(linename, OBJPROP_TIME1, t1);
      ObjectSet(linename, OBJPROP_TIME2, t2);
      ObjectSet(linename, OBJPROP_PRICE1, p1);
      ObjectSet(linename, OBJPROP_PRICE2, p2);
   }
}

datetime BarToTime(int bar)
  {
    bar /= 10;
   
    if (bar >= 0)
      return(Time[bar]);
    else
      {
        return(Time[0] + (-bar * Period() * 60));
      }
  }
 
int TimeToBar(datetime d) 
  {
    if (d > Time[0])
      return(((Time[0] - d) / (Period() * 60)) * 10);
    else
      return(10 * iBarShift(NULL, 0, d, false));
  }


9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi, could you please forward me the book (pdf file) you mentioned. Many thanks. Mike mistycloud2@yahoo.com

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. Thx Cordially Yours. Pls forward the pdf to eropico@yahoo.com. many thanks.

    ReplyDelete
  5. Hi, Could you please send the Mikula PDF to me at email: arnov@fea.st. Thanks!

    ReplyDelete
  6. Hi there, can I have the pdf? My email is okky.djatmiko@gmail.com

    Thanks

    ReplyDelete
  7. Hi, Appreciate the pdf - my email is andrewflanagan7@gmail.com

    Thanks

    ReplyDelete