XFisher_org_v2_Candle_Cloud_Alerts

Author: Copyright © 2005, TrendLaboratory Ltd.
Miscellaneous
It issuies visual alerts to the screenIt sends emails
0 Views
0 Downloads
0 Favorites
XFisher_org_v2_Candle_Cloud_Alerts
ÿþ//+---------------------------------------------------------------------+

//|                              XFisher_org_v2_Candle_Cloud_Alerts.mq5 |

//|                              Copyright © 2006, TrendLaboratory Ltd. |

//|               http://finance.groups.yahoo.com/group/TrendLaboratory |

//|                                          E-mail: igorad2004@list.ru |

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

//| ;O @01>BK  8=48:0B>@0  A;54C5B  ?>;>68BL D09; SmoothAlgorithms.mqh |

//| 2 ?0?:C (48@5:B>@8N): :0B0;>3_40==KE_B5@<8=0;0\\MQL5\Include        |

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

//---- 02B>@AB2> 8=48:0B>@0

#property copyright "Copyright © 2005, TrendLaboratory Ltd."

//---- 02B>@AB2> 8=48:0B>@0

#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

//---- =><5@ 25@A88 8=48:0B>@0

#property version   "1.00"

//---- >B@8A>2:0 8=48:0B>@0 2 >B45;L=>< >:=5

#property indicator_separate_window

//---- 4;O @0AG5B0 8 >B@8A>2:8 8=48:0B>@0 8A?>;L7>20=> B@8=04F0BL 1CD5@>2

#property indicator_buffers 13

//---- 8A?>;L7>20=> 2A53> ?OBL 3@0D8G5A:8E ?>AB@>5=89

#property indicator_plots   5

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

//| 0@0<5B@K >B@8A>2:8 25@E=53> >1;0:0 2        |

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

//---- >B@8A>2:0 8=48:0B>@0 2 2845 >1;0:0

#property indicator_type1   DRAW_FILLING

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= F25B C'151,255,219'

#property indicator_color1 C'151,255,219'

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label1  "Upper XFisher_org_v2_Candle_Cloud 2"

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

//| 0@0<5B@K >B@8A>2:8 25@E=53> >1;0:0 1        |

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

//---- >B@8A>2:0 8=48:0B>@0 2 2845 >1;0:0

#property indicator_type2   DRAW_FILLING

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= F25B C'202,255,237'

#property indicator_color2 C'202,255,237'

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label2  "Upper XFisher_org_v2_Candle_Cloud 1"

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

//| 0@0<5B@K >B@8A>2:8 =86=53> >1;0:0 1         |

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

//---- >B@8A>2:0 8=48:0B>@0 2 2845 >1;0:0

#property indicator_type3   DRAW_FILLING

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= F25B C'255,225,255'

#property indicator_color3 C'255,225,255'

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label3  "Lower XFisher_org_v2_Candle_Cloud 1"

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

//| 0@0<5B@K >B@8A>2:8 =86=53> >1;0:0 2         |

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

//---- >B@8A>2:0 8=48:0B>@0 2 2845 >1;0:0

#property indicator_type4   DRAW_FILLING

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= F25B C'255,185,255'

#property indicator_color4 C'255,185,255'

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label4  "Lower XFisher_org_v2_Candle_Cloud 2"

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

//| 0@0<5B@K >B@8A>2:8 8=48:0B>@0 Fisher_org_v2 |

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

//---- 2 :0G5AB25 8=48:0B>@0 8A?>;L7>20=K F25B=K5 A25G8

#property indicator_type5   DRAW_COLOR_CANDLES

#property indicator_color5   clrMagenta,clrPlum,clrGray,clrLightSkyBlue,clrBlue

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label5  "XFisher_org_v2 Open;XFisher_org_v2 High;XFisher_org_v2 Low;XFisher_org_v2 Close"

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

//|  1JO2;5=85 :>=AB0=B                         |

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

#define RESET 0       // :>=AB0=B0 4;O 2>72@0B0 B5@<8=0;C :><0=4K =0 ?5@5AG5B 8=48:0B>@0

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

//|  ?8A0=85 :;0AA0 CXMA                        |

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

#include <SmoothAlgorithms.mqh> 

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

//---- >1JO2;5=85 ?5@5<5==KE :;0AA0 CXMA 87 D09;0 SmoothAlgorithms.mqh

CXMA oXMA,hXMA,lXMA,cXMA;

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

//|  >1JO2;5=85 ?5@5G8A;5=89                     |

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

/*enum Smooth_Method - ?5@5G8A;5=85 >1JO2;5=> 2 D09;5 SmoothAlgorithms.mqh

  {

   MODE_SMA_,  // SMA

   MODE_EMA_,  // EMA

   MODE_SMMA_, // SMMA

   MODE_LWMA_, // LWMA

   MODE_JJMA,  // JJMA

   MODE_JurX,  // JurX

   MODE_ParMA, // ParMA

   MODE_T3,    // T3

   MODE_VIDYA, // VIDYA

   MODE_AMA    // AMA

  }; */

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

//| E>4=K5 ?0@0<5B@K 8=48:0B>@0                 |

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

input uint FLength=14;                            // 3;C18=0 CA@54=5=8O

input Smooth_Method MA_SMethod=MODE_JJMA;         // 5B>4 A3;06820=8O

input uint MA_Length=5;                           // ;C18=0 A3;06820=8O                    

input int MA_Phase=15;                            // ?0@0<5B@ A3;06820=8O,

//---- 4;O JJMA 87<5=ONI89AO 2 ?@545;0E -100 ... +100, 2;8O5B =0 :0G5AB2> ?5@5E>4=>3> ?@>F5AA0;

//---- ;O VIDIA MB> ?5@8>4 CMO, 4;O AMA MB> ?5@8>4 <54;5==>9 A:>;L7OI59                  

input uint Gap=10;                                // @07<5@ =5CG8BK205<>3> 3M?0 2 ?C=:B0E

input double HighLevel=+0.6;                      // C@>25=L ?5@570:C?0

input double LowLevel=-0.6;                       // C@>25=L ?5@5?@>40==>AB8

input int Shift=0;                                // !4283 8=48:0B>@0 ?> 3>@87>=B0;8 2 10@0E 

input uint NumberofBar=1;          // ><5@ 10@0 4;O ?>40G8 A83=0;0

input bool SoundON=true;           //  07@5H5=85 0;5@B0

input uint NumberofAlerts=2;       // >;8G5AB2> 0;5@B>2

input bool EMailON=false;          //  07@5H5=85 ?>GB>2>9 >B?@02:8 A83=0;0

input bool PushON=false;           //  07@5H5=85 >B?@02:8 A83=0;0 =0 <>18;L=K9

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

//---- >1JO2;5=85 48=0<8G5A:8E <0AA82>2, :>B>@K5 1C4CB 2 40;L=59H5< 8A?>;L7>20=K 2 :0G5AB25 8=48:0B>@=KE 1CD5@>2

double ExtOpenBuffer[],ExtHighBuffer[],ExtLowBuffer[],ExtCloseBuffer[],ExtColorBuffer[];

double UpUpBuffer1[],UpDnBuffer1[],DnUpBuffer1[],DnDnBuffer1[];

double UpUpBuffer2[],UpDnBuffer2[],DnUpBuffer2[],DnDnBuffer2[];

//---- >1JO2;5=85 F5;>G8A;5==KE ?5@5<5==KE =0G0;0 >BAG5B0 40==KE

int min_rates_total,min_rates_1;

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//---- 8=8F80;870F8O ?5@5<5==KE =0G0;0 >BAG5B0 40==KE

   min_rates_1=int(FLength)+1;

   min_rates_total=min_rates_1+GetStartBars(MA_SMethod,MA_Length,MA_Phase);



//--- 8=8F80;870F8O 8=48:0B>@=KE 1CD5@>2  

   IndInit(0,UpUpBuffer2,INDICATOR_DATA);

   IndInit(1,UpDnBuffer2,INDICATOR_DATA);

//--- 8=8F80;870F8O 8=48:0B>@>2

   PlotInit(0,EMPTY_VALUE,min_rates_total,Shift);

//--- 8=8F80;870F8O 8=48:0B>@=KE 1CD5@>2  

   IndInit(2,UpUpBuffer1,INDICATOR_DATA);

   IndInit(3,UpDnBuffer1,INDICATOR_DATA);

//--- 8=8F80;870F8O 8=48:0B>@>2

   PlotInit(1,EMPTY_VALUE,min_rates_total,Shift);

   

//--- 8=8F80;870F8O 8=48:0B>@=KE 1CD5@>2  

   IndInit(4,DnUpBuffer1,INDICATOR_DATA);

   IndInit(5,DnDnBuffer1,INDICATOR_DATA);

//--- 8=8F80;870F8O 8=48:0B>@>2

   PlotInit(2,EMPTY_VALUE,min_rates_total,Shift);

//--- 8=8F80;870F8O 8=48:0B>@=KE 1CD5@>2  

   IndInit(6,DnUpBuffer2,INDICATOR_DATA);

   IndInit(7,DnDnBuffer2,INDICATOR_DATA);

//--- 8=8F80;870F8O 8=48:0B>@>2

   PlotInit(3,EMPTY_VALUE,min_rates_total,Shift);



//---- ?@52@0I5=85 48=0<8G5A:8E <0AA82>2 2 8=48:0B>@=K5 1CD5@K

   SetIndexBuffer(8,ExtOpenBuffer,INDICATOR_DATA);

   SetIndexBuffer(9,ExtHighBuffer,INDICATOR_DATA);

   SetIndexBuffer(10,ExtLowBuffer,INDICATOR_DATA);

   SetIndexBuffer(11,ExtCloseBuffer,INDICATOR_DATA);

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 F25B>2>9, 8=45:A=K9 1CD5@   

   SetIndexBuffer(12,ExtColorBuffer,INDICATOR_COLOR_INDEX);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8 =0 Shift

   PlotIndexSetInteger(4,PLOT_SHIFT,Shift);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAG5B0 >B@8A>2:8 8=48:0B>@0 =0 min_rates_total

   PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,EMPTY_VALUE);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(4,PLOT_SHOW_DATA,false);



//---- 8=8F80;870F88 ?5@5<5==>9 4;O :>@>B:>3> 8<5=8 8=48:0B>@0

   string shortname;

   StringConcatenate(shortname,"XFisher_org_v2_Candle(",FLength,")");

//---- A>740=85 8<5=8 4;O >B>1@065=8O 2 >B45;L=>< ?>4>:=5 8 2> 2A?;K20NI59 ?>4A:07:5

   IndicatorSetString(INDICATOR_SHORTNAME,shortname);

//---- >?@545;5=85 B>G=>AB8 >B>1@065=8O 7=0G5=89 8=48:0B>@0

   IndicatorSetInteger(INDICATOR_DIGITS,4);

//---- :>;8G5AB2>  3>@87>=B0;L=KE C@>2=59 8=48:0B>@0 3   

   IndicatorSetInteger(INDICATOR_LEVELS,3);

//---- 7=0G5=8O 3>@87>=B0;L=KE C@>2=59 8=48:0B>@0   

   IndicatorSetDouble(INDICATOR_LEVELVALUE,0,HighLevel);

   IndicatorSetDouble(INDICATOR_LEVELVALUE,1,50);

   IndicatorSetDouble(INDICATOR_LEVELVALUE,2,LowLevel);

//---- 2 :0G5AB25 F25B>2 ;8=89 3>@87>=B0;L=KE C@>2=59 8A?>;L7>20=K

   IndicatorSetInteger(INDICATOR_LEVELCOLOR,0,clrTeal);

   IndicatorSetInteger(INDICATOR_LEVELCOLOR,1,clrGray);

   IndicatorSetInteger(INDICATOR_LEVELCOLOR,2,clrMagenta);

//---- 2 ;8=88 3>@87>=B0;L=>3> C@>2=O 8A?>;L7>20= :>@>B:89 HB@8E-?C=:B8@  

   IndicatorSetInteger(INDICATOR_LEVELSTYLE,0,STYLE_DASHDOTDOT);

   IndicatorSetInteger(INDICATOR_LEVELSTYLE,1,STYLE_DASHDOTDOT);

   IndicatorSetInteger(INDICATOR_LEVELSTYLE,2,STYLE_DASHDOTDOT);

//---- 7025@H5=85 8=8F80;870F88

   return(INIT_SUCCEEDED);

  }

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

//| =8F80;870F8O 8=48:0B>@=>3> 1CD5@0                               |

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

void IndInit(int Number,double &Buffer[],ENUM_INDEXBUFFER_TYPE Type)

  {

//--- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(Number,Buffer,Type);

//---

  }

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

//| =8F80;870F8O 8=48:0B>@0                                         |

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

void PlotInit(int Number,double Empty_Value,int Draw_Begin,int nShift)

  {

//--- >ACI5AB2;5=85 A42830 =0G0;0 >BAG5B0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(Number,PLOT_DRAW_BEGIN,Draw_Begin);

//--- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(Number,PLOT_EMPTY_VALUE,Empty_Value);

//--- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8 =0 Shift

   PlotIndexSetInteger(Number,PLOT_SHIFT,nShift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(Number,PLOT_SHOW_DATA,false);

//---

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,    // :>;8G5AB2> 8AB>@88 2 10@0E =0 B5:CI5< B8:5

                const int prev_calculated,// :>;8G5AB2> 8AB>@88 2 10@0E =0 ?@54K4CI5< B8:5

                const datetime &time[],

                const double &open[],

                const double& high[],     // F5=>2>9 <0AA82 <0:A8<C<>2 F5=K 4;O @0AG5B0 8=48:0B>@0

                const double& low[],      // F5=>2>9 <0AA82 <8=8<C<>2 F5=K  4;O @0AG5B0 8=48:0B>@0

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

//---- ?@>25@:0 :>;8G5AB20 10@>2 =0 4>AB0B>G=>ABL 4;O @0AG5B0

   if(rates_total<min_rates_total) return(RESET);



//---- >1JO2;5=8O ;>:0;L=KE ?5@5<5==KE 

   int first,bar;

   double smax,smin,price,wpr,ovalue,hvalue,lvalue,cvalue,res1,res2,ofish,hfish,lfish,cfish,O,H,L,C;

   static double ovalue_prev,ofish_prev,hvalue_prev,hfish_prev,lvalue_prev,lfish_prev,cvalue_prev,cfish_prev;



//---- @0AG5B AB0@B>2>3> =><5@0 first 4;O F8:;0 ?5@5AG5B0 10@>2

   if(prev_calculated>rates_total || prev_calculated<=0) // ?@>25@:0 =0 ?5@2K9 AB0@B @0AG5B0 8=48:0B>@0

     {

      first=min_rates_1;                           // AB0@B>2K9 =><5@ 4;O @0AG5B0 2A5E 10@>2

      ovalue_prev=hvalue_prev=lvalue_prev=cvalue_prev=NULL;

      ofish_prev=hfish_prev=lfish_prev=cfish_prev=0.0;

     }

   else first=prev_calculated-1; // AB0@B>2K9 =><5@ 4;O @0AG5B0 =>2KE 10@>2



//---- >A=>2=>9 F8:; @0AG5B0 8=48:0B>@0

   for(bar=first; bar<rates_total && !IsStopped(); bar++)

     {

      UpUpBuffer2[bar]=+3.5;     

      UpDnBuffer2[bar]=HighLevel;

      UpUpBuffer1[bar]=HighLevel;     

      UpDnBuffer1[bar]=0;  

      //----      

      DnUpBuffer1[bar]=0;

      DnDnBuffer1[bar]=LowLevel;

      DnUpBuffer2[bar]=LowLevel;

      DnDnBuffer2[bar]=-3.5;

      //----      

      smax=DBL_MIN;

      smin=DBL_MAX;

      //----

      for(int iii=0; iii<int(FLength); iii++)

        {

         int barx=bar-iii;

         smax=MathMax(smax,high[barx]);

         smin=MathMin(smin,low[barx]);

        }

      if(smax==smin) smax+=_Point;

      //----

      price=open[bar];

      wpr=(price-smin)/(smax-smin);

      ovalue=(wpr-0.5)+0.67*ovalue_prev;

      ovalue=MathMin(ovalue,+DBL_MAX);

      ovalue=MathMax(ovalue,-DBL_MAX);

      res1=1.0-ovalue;

      if(!res1) res1=1.0;

      res2=(1.0+ovalue)/(1.0-ovalue);

      if(res2<0.0000001) res2=1.0;

      ofish=0.5*MathLog(res2)+0.5*ofish_prev;

      O=oXMA.XMASeries(min_rates_1,prev_calculated,rates_total,MA_SMethod,MA_Phase,MA_Length,ofish,bar,false);

      //----

      price=high[bar];

      wpr=(price-smin)/(smax-smin);

      hvalue=(wpr-0.5)+0.67*hvalue_prev;

      hvalue=MathMin(hvalue,+DBL_MAX);

      hvalue=MathMax(hvalue,-DBL_MAX);

      res1=1.0-hvalue;

      if(!res1) res1=1.0;

      res2=(1.0+hvalue)/(1.0-hvalue);

      if(res2<0.0000001) res2=1.0;

      hfish=0.5*MathLog(res2)+0.5*hfish_prev;

      H=hXMA.XMASeries(min_rates_1,prev_calculated,rates_total,MA_SMethod,MA_Phase,MA_Length,hfish,bar,false);

      //----

      price=low[bar];

      wpr=(price-smin)/(smax-smin);

      lvalue=(wpr-0.5)+0.67*lvalue_prev;

      lvalue=MathMin(lvalue,+DBL_MAX);

      lvalue=MathMax(lvalue,-DBL_MAX);

      res1=1.0-lvalue;

      if(!res1) res1=1.0;

      res2=(1.0+lvalue)/(1.0-lvalue);

      if(res2<0.0000001) res2=1.0;

      lfish=0.5*MathLog(res2)+0.5*lfish_prev;

      L=lXMA.XMASeries(min_rates_1,prev_calculated,rates_total,MA_SMethod,MA_Phase,MA_Length,lfish,bar,false);

      //----

      price=close[bar];

      wpr=(price-smin)/(smax-smin);

      cvalue=(wpr-0.5)+0.67*cvalue_prev;

      cvalue=MathMin(cvalue,+DBL_MAX);

      cvalue=MathMax(cvalue,-DBL_MAX);

      res1=1.0-cvalue;

      if(!res1) res1=1.0;

      res2=(1.0+cvalue)/(1.0-cvalue);

      if(res2<0.0000001) res2=1.0;

      cfish=0.5*MathLog(res2)+0.5*cfish_prev;

      C=cXMA.XMASeries(min_rates_1,prev_calculated,rates_total,MA_SMethod,MA_Phase,MA_Length,cfish,bar,false);

      //---- 8A?@02;O5< 7=0G5=8O ?>;CG5==KE A25G5:

      double Max=MathMax(O,C);

      Max=MathMax(Max,L);

      Max=MathMax(Max,H);

      double Min=MathMin(O,C);

      Min=MathMin(Min,L);

      Min=MathMin(Min,H);

      ExtOpenBuffer[bar]=O;

      ExtHighBuffer[bar]=Max;

      ExtLowBuffer[bar]=Min;

      ExtCloseBuffer[bar]=C;

      //---- C40;O5< =5ACI5AB2CNI85 35?K

      if(MathAbs(open[bar]-close[bar])<=Gap) ExtOpenBuffer[bar]=ExtCloseBuffer[MathMax(bar-1,0)];

      //---- :@0A8< A25G8

      int clr=2;

      double trend=ExtCloseBuffer[bar]-ExtOpenBuffer[bar];



      if(ExtCloseBuffer[bar]>HighLevel  || ExtCloseBuffer[bar]<LowLevel)

        {

         if(trend>0) clr=4.0;

         else if(trend<0) clr=0.0;

        }       

      else

        {

         if(trend>0) clr=3.0;

         else if(trend<0) clr=1.0;

        }

      ExtColorBuffer[bar]=clr;



      if(bar<rates_total-1)

        {

         ovalue_prev=ovalue;

         ofish_prev=ofish;

         hvalue_prev=hvalue;

         hfish_prev=hfish;

         lvalue_prev=lvalue;

         lfish_prev=lfish;

         cvalue_prev=cvalue;

         cfish_prev=cfish;

        }

     }

//---     

   BuySignal("XFisher_org_v2_Candle_Alerts",rates_total,prev_calculated,close,spread);

   SellSignal("XFisher_org_v2_Candle_Alerts",rates_total,prev_calculated,close,spread);

//---     

   return(rates_total);

  }

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

//| Buy signal function                                              |

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

void BuySignal(string SignalSirname,      // B5:AB 8<5=8 8=48:0B>@0 4;O ?>GB>2KE 8 ?CH-A83=0;>2

               const int Rates_total,     // B5:CI55 :>;8G5AB2> 10@>2

               const int Prev_calculated, // :>;8G5AB2> 10@>2 =0 ?@54K4CI5< B8:5

               const double &Close[],     // F5=0 70:@KB8O

               const int &Spread[])       // A?@54

  {

//---

   static uint counter=0;

   if(Rates_total!=Prev_calculated) counter=0;



   string SignalText="";

   bool BuySignal=false;

   int index=int(Rates_total-1-NumberofBar);

   int index1=int(Rates_total-1-NumberofBar)-1;

   //--- 

   if(ExtCloseBuffer[index1]<=0 && ExtCloseBuffer[index]>0)  

     {

      BuySignal=true;

      SignalText=SignalText+"@>1>9 =C;O! ";

     } 

    //--- 

    if(ExtColorBuffer[index1]<3 && ExtColorBuffer[index]>2)

     {

      BuySignal=true;

      SignalText=SignalText+"7<5=5=85 =0?@02;5=8O 42865=8O A25G8! ";

     } 

    //--- 

    if(ExtCloseBuffer[index1]<=HighLevel && ExtCloseBuffer[index]>HighLevel)

     {

      BuySignal=true;

      SignalText=SignalText+"@>1>9 C@>2=O ?5@5:C?;5==>AB8! ";

     }  

    //--- 

    if(ExtCloseBuffer[index1]<LowLevel && ExtCloseBuffer[index]>=LowLevel)

     {

      BuySignal=true;

      SignalText=SignalText+"KE>4 87 7>=K ?5@5?@>40==>AB8! ";

     }

        

   //---              

   if(BuySignal && counter<=NumberofAlerts)

     {

      counter++;

      MqlDateTime tm;

      TimeToStruct(TimeCurrent(),tm);

      string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);

      double Ask=Close[index];

      double Bid=Close[index];

      Bid+=Spread[index]*_Point;

      string sAsk=DoubleToString(Ask,_Digits);

      string sBid=DoubleToString(Bid,_Digits);

      string sPeriod=GetStringTimeframe(ChartPeriod());

      if(SoundON) Alert("BUY signal "+SignalText+"\n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);

      if(EMailON) SendMail(SignalSirname+": BUY signal "+SignalText," at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);

      if(PushON) SendNotification(SignalSirname+": BUY signal "+SignalText+" at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);

     }



//---

  }

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

//| Sell signal function                                             |

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

void SellSignal(string SignalSirname,      // B5:AB 8<5=8 8=48:0B>@0 4;O ?>GB>2KE 8 ?CH-A83=0;>2

                const int Rates_total,     // B5:CI55 :>;8G5AB2> 10@>2

                const int Prev_calculated, // :>;8G5AB2> 10@>2 =0 ?@54K4CI5< B8:5

                const double &Close[],     // F5=0 70:@KB8O

                const int &Spread[])       // A?@54

  {

//---

   static uint counter=0;

   if(Rates_total!=Prev_calculated) counter=0;

   string SignalText="";

   bool SellSignal=false;

   int index=int(Rates_total-1-NumberofBar);

   int index1=int(Rates_total-1-NumberofBar)-1;

   //---   

   if(ExtCloseBuffer[index1]>=0 && ExtCloseBuffer[index]<0)

     {

      SellSignal=true;

      SignalText=SignalText+"@>1>9 =C;O! ";

     } 

    //--- 

    if(ExtColorBuffer[index1]>1 && ExtColorBuffer[index]<2)

     {

      SellSignal=true;

      SignalText=SignalText+"7<5=5=85 =0?@02;5=8O 42865=8O A25G8! ";

     } 

    //--- 

    if(ExtCloseBuffer[index1]>=LowLevel && ExtCloseBuffer[index]<LowLevel)

     {

      SellSignal=true;

      SignalText=SignalText+"@>1>9 C@>2=O ?5?@>40==>AB8! ";

     } 

    //--- 

    if(ExtCloseBuffer[index1]>HighLevel && ExtCloseBuffer[index]<=HighLevel)

     {

      SellSignal=true;

      SignalText=SignalText+"KE>4 87 7>=K ?5@5:C?;5==>AB8! ";

     }

   //--- 

   if(SellSignal && counter<=NumberofAlerts)

     {

      counter++;

      MqlDateTime tm;

      TimeToStruct(TimeCurrent(),tm);

      string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);

      double Ask=Close[index];

      double Bid=Close[index];

      Bid+=Spread[index]*_Point;

      string sAsk=DoubleToString(Ask,_Digits);

      string sBid=DoubleToString(Bid,_Digits);

      string sPeriod=GetStringTimeframe(ChartPeriod());

      if(SoundON) Alert("SELL signal "+SignalText+"\n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);

      if(EMailON) SendMail(SignalSirname+": SELL signal "+SignalText," at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);

      if(PushON) SendNotification(SignalSirname+": SELL signal "+SignalText+" at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);

     }

//---

  }

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

//|  >;CG5=85 B09<D@59<0 2 2845 AB@>:8                              |

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

string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)

  {

//----

   return(StringSubstr(EnumToString(timeframe),7,-1));

//----

  }

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

Comments