Shooting star v1.0

Author: MaksimNeimeryk
Price Data Components
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Shooting star v1.0
ÿþ//+------------------------------------------------------------------+

//|                                           Shooting star v1.0.mq4 |

//|                                                   MaksimNeimeryk |

//|                                              deilyplanet@ukr.net |

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

#property copyright "MaksimNeimeryk"

#property link      "deilyplanet@ukr.net"

#property version   "1.04"

#property strict

#property indicator_chart_window

#property indicator_buffers 6

#property indicator_color1 Lime

#property indicator_color2 Lime

#property indicator_color3 Lime

#property indicator_color4 Tomato

#property indicator_color5 Tomato

#property indicator_color6 Tomato



extern int size=2; //Size of the indicator label 

extern int Position=2; //The position of the indicator label (in points)

extern bool Alerts=true; //Alert

extern int bar=5000;// Number of history bars



extern bool buy5=true;//5 bullish bars (on / off)

extern bool Shooting=true;//Shooting star (on / off)

extern bool Confirmation1=true;//Confirmation (on / off)



extern bool sell5=true;//5 bearish bars (on / off)

extern bool Hanging=true;//Hanging Man (on / off)

extern bool Confirmation2=true;//Confirmation (on / off)



static datetime prevtime=0;



double Buffer1[],Buffer2[],Buffer3[],Buffer4[],Buffer5[],Buffer6[],Positions;

bool   condition;

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//Buy Buffers--------------------------------------------------------

   SetIndexBuffer(0,Buffer1);SetIndexStyle(0,DRAW_ARROW,0,size);SetIndexArrow(0,133);

   SetIndexBuffer(1,Buffer2);SetIndexStyle(1,DRAW_ARROW,0,size);SetIndexArrow(1,181);

   SetIndexBuffer(2,Buffer3);SetIndexStyle(2,DRAW_ARROW,0,size);SetIndexArrow(2,252);

//Sell Buffers--------------------------------------------------------

   SetIndexBuffer(3,Buffer4);SetIndexStyle(3,DRAW_ARROW,0,size);SetIndexArrow(3,133);

   SetIndexBuffer(4,Buffer5);SetIndexStyle(4,DRAW_ARROW,0,size);SetIndexArrow(4,181);

   SetIndexBuffer(5,Buffer6);SetIndexStyle(5,DRAW_ARROW,0,size);SetIndexArrow(5,252);



   if(bar==0)

      bar=Bars;



   return(INIT_SUCCEEDED);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

   Positions=NormalizeDouble(Position*Point,Digits());

   if(Time[0] == prevtime)   return(-1);

   prevtime = Time[0];

   if(bar>Bars)bar=Bars;

   for(int i=0; i<=bar-9;i++)

     {

      //----------------BuyBars------------------------------------------------- 

      if(Close[i+1]>Open[i+1]&&Close[i+1]>=Close[i+2]&&Close[i+2]>Open[i+2]

         &&Close[i+2]>=Close[i+3]&&Close[i+3]>Open[i+3]&&Close[i+3]>=Close[i+4]

         &&Close[i+4]>Open[i+4]&&Close[i+4]>=Close[i+5]&&Close[i+5]>Open[i+5]

         &&Close[i+6]<=Open[i+6]&&buy5==true)

        {

         Buffer1[i+1]=High[i+1]+Positions;

         if(Alerts==true && i<=0)

            Alert("5 bullish Bars ",Symbol());

        } 

        

      if((High[i+1]-Open[i+1])>=((Open[i+1]-Close[i+1])*2)&&(Close[i+1]-Low[i+1])<=(Open[i+1]-Close[i+1])

         &&Close[i+1]<Open[i+1]&&Close[i+2]>Open[i+2]

         &&Close[i+2]>=Close[i+3]&&Close[i+3]>Open[i+3]&&Close[i+3]>=Close[i+4]

         &&Close[i+4]>Open[i+4]&&Close[i+4]>=Close[i+5]&&Close[i+5]>Open[i+5]

         &&Close[i+5]>=Close[i+6]&&Close[i+6]>Open[i+6]&&Close[i+7]<=Open[i+7]&&Shooting==true)

        {

         Buffer2[i+1]=High[i+1]+Positions;

         if(Alerts==true && i<=0)

            Alert("Shooting star! ",Symbol());

        } 

        

      if(Open[i+1]>Close[i+1]&&Open[i+2]>Close[i+1]

         &&(High[i+3]-Open[i+3])>=((Open[i+3]-Close[i+3])*2)&&(Close[i+3]-Low[i+3])<=(Open[i+3]-Close[i+3])

         &&Close[i+3]<Open[i+3]&&Close[i+4]>Open[i+4]

         &&Close[i+4]>=Close[i+5]&&Close[i+5]>Open[i+5]&&Close[i+5]>=Close[i+6]

         &&Close[i+6]>Open[i+6]&&Close[i+6]>=Close[i+7]&&Close[i+7]>Open[i+7]

         &&Close[i+7]>=Close[i+8]&&Close[i+8]>Open[i+8]&&Close[i+9]<=Open[i+9]&&Confirmation1==true)

      {

         Buffer3[i+1]=High[i+1]+Positions;

         if(Alerts==true && i<=0)

            Alert("Confirmation Shooting star! ",Symbol());

      }

      //--------SellBars-----------------------------------------------------------------           

      if(Close[i+1]<Open[i+1]&&Close[i+1]<=Close[i+2]&&Close[i+2]<Open[i+2]

         &&Close[i+2]<=Close[i+3]&&Close[i+3]<Open[i+3]&&Close[i+3]<=Close[i+4]

         &&Close[i+4]<Open[i+4]&&Close[i+4]<=Close[i+5]&&Close[i+5]<Open[i+5]

         &&Close[i+6]>=Open[i+6]&&sell5==true)

        {

         Buffer4[i+1]=Low[i+1]-Positions;

         if(Alerts==true && i<=0)

            Alert("5 bearish Bars ",Symbol());

        }

        

      if((Open[i+1]-Low[i+1])>=((Close[i+1]-Open[i+1])*2)&&(High[i+1]-Close[i+1])<=(Close[i+1]-Open[i+1])

         &&Close[i+1]>Open[i+1]&&Close[i+2]<Open[i+2]

         &&Close[i+2]<=Close[i+3]&&Close[i+3]<Open[i+3]&&Close[i+3]<=Close[i+4]

         &&Close[i+4]<Open[i+4]&&Close[i+4]<=Close[i+5]&&Close[i+5]<Open[i+5]

         &&Close[i+5]<=Close[i+6]&&Close[i+6]<Open[i+6]&&Close[i+7]>=Open[i+7]&&Hanging==true)

        {

         Buffer5[i+1]=Low[i+1]-Positions;

         if(Alerts==true && i<=0)

            Alert("Hanging Man! ",Symbol());

        }



      if(Open[i+1]<Close[i+1]&&Open[i+2]<Close[i+2]

         &&(Open[i+3]-Low[i+3])>=((Close[i+3]-Open[i+3])*2)&&(High[i+3]-Close[i+3])<=(Close[i+3]-Open[i+3])

         &&Close[i+3]>Open[i+3]&&Close[i+4]<Open[i+4]

         &&Close[i+4]<=Close[i+4]&&Close[i+5]<Open[i+5]&&Close[i+5]<=Close[i+6]

         &&Close[i+6]<Open[i+6]&&Close[i+6]<=Close[i+7]&&Close[i+7]<Open[i+7]

         &&Close[i+7]<=Close[i+8]&&Close[i+8]<Open[i+8]&&Close[i+9]>=Open[i+9]&&Confirmation2==true)

      {

         Buffer6[i+1]=Low[i+1]-Positions;

         if(Alerts==true && i<=0)

            Alert("Confirmation Hanging Man! ",Symbol());

      }

     }

   return(rates_total);

  }



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

Comments