Price Data Components
Series array that contains open prices of each bar
Indicators Used
Momentum indicatorMoving average indicatorBollinger bands indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt plays sound alertsIt sends emails
0 Views
0 Downloads
0 Favorites
Phoenix
ÿþ//--- setting the indicator name

#property description "Phoenix"

//--- set the strict mode of compilation

#property strict

//--- specify where to draw the indicator

#property indicator_chart_window

//--- specify the number of buffers

#property indicator_buffers 2

//--- setting the color of the indicator rendering

#property indicator_color1 clrGreenYellow

#property indicator_color2 clrRed

//--- we define the input parameters

extern string             S_I              = "0AB@>9:8 8=48:0B>@0";

extern int                count            = 10;                         //number of elements

extern int                hl_level         = 0;                          //level

extern int                distance         = 100;                        //minimum distance between the upper and lower line BB

extern ENUM_APPLIED_PRICE applied_price    = PRICE_OPEN;                 //apply to

extern string             S_M              = "0AB@>9:8 Momentum";

extern int                momentum_period  = 14;                         //period

extern double             momentum_level   = 100;                        //level

extern string             S_M_A            = "0AB@>9:8 Moving Average";

extern int                ma_period        = 14;                         //period

extern ENUM_MA_METHOD     ma_method        = MODE_SMA;                   //method MA

extern int                ma_shift         = 0;                          //shift

extern string             S_M_A_2          = "0AB@>9:8 Moving Average 2";

extern int                ma_period_2      = 28;                         //period 2

extern ENUM_MA_METHOD     ma_method_2      = MODE_SMA;                   //method MA 2

extern int                ma_shift_2       = 0;                          //shift 2

extern string             S_B_B            = "0AB@>9:8 Bollinger Bands";

extern int                bands_period     = 20;                         //period

extern double             bands_deviation  = 2;                          //deviations

extern int                bands_shift      = 0;                          //shift

extern string             S_G              = "0AB@>9:8 3@0D8:8";

extern int                indent_arrow     = 100;                        //arrow indent

extern int                counted_bars     = 1000;                       //counting bars

extern string             S_S              = "0AB@>9:8 72C:0";

extern string             sound_file       = "alert.wav";                //sound file

extern bool               use_sound        = true;                       //the use of sound

extern bool               use_notification = false;                      //phone usage

extern bool               use_mail         = false;                      //the use of email

//--- specify arrays of indicator buffers

double arrow_01[];

double arrow_02[];

//*********************************************//

bool sound_buy  = false;

bool sound_sell = false;

bool flag_buy   = false;

bool flag_sell  = false;

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

//| Custom indicator initialization function                         |

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

int OnInit(void)

  {

   string short_name;

//--- we specify two additional buffers for calculations

   IndicatorBuffers(2);

   SetIndexBuffer(0,arrow_01);

   SetIndexBuffer(1,arrow_02);

//--- setting the indicator to be drawn as a line

   SetIndexStyle(0,DRAW_ARROW,EMPTY,2,clrGreenYellow);

   SetIndexArrow(0,109);

   SetIndexBuffer(0,arrow_01);

   SetIndexStyle(1,DRAW_ARROW,EMPTY,2,clrRed);

   SetIndexArrow(1,109);

   SetIndexBuffer(1,arrow_02);

//--- setting a name in the DataWindow window and a label

   short_name="Mon$ter("+string(count)+")";

   IndicatorShortName(short_name);

   SetIndexLabel(0,short_name);

//--- check the input parameters

   if(count<2||hl_level>=count)

     {

      Alert("The value of the number of elements variable must not be less than 2,the level value must not be higher than or equal to the number of elements value");

      return(INIT_FAILED);

     }

//--- if there are no errors,initialization is completed successfully

   return(INIT_SUCCEEDED);

  }

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

//|                            Phoenix                               |

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

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[])

  {

   for(int shift=counted_bars; shift>=0; shift--)

     {

      double highest=iHighest(_Symbol,_Period,MODE_HIGH,count,shift);

      double lowest=iLowest(_Symbol,_Period,MODE_LOW,count,shift);

      double hl=iHighest(_Symbol,_Period,MODE_HIGH,count,shift)-iLowest(_Symbol,_Period,MODE_LOW,count,shift);

      double momentum=iMomentum(_Symbol,_Period,momentum_period,applied_price,shift);

      double ma=iMA(_Symbol,_Period,ma_period,ma_shift,ma_method,applied_price,shift)-iMA(_Symbol,_Period,ma_period_2,ma_shift_2,ma_method_2,applied_price,shift);

      double bands_upper=iBands(_Symbol,_Period,bands_period,bands_deviation,bands_shift,applied_price,MODE_UPPER,shift);

      double bands_main=iBands(_Symbol,_Period,bands_period,bands_deviation,bands_shift,applied_price,MODE_MAIN,shift);

      double bands_lower=iBands(_Symbol,_Period,bands_period,bands_deviation,bands_shift,applied_price,MODE_LOWER,shift);

      double o=iOpen(_Symbol,_Period,shift);

        {

         if(flag_buy==false)

            if(highest<lowest&&hl<-hl_level&&momentum>momentum_level&&ma>0&&o>bands_main&&bands_upper-bands_lower>distance*Point)

              {

               arrow_01[shift]=Low[shift]-indent_arrow*Point;

               flag_buy=true;

               flag_sell=false;

              }

         if(flag_sell==false)

            if(highest>lowest&&hl>hl_level&&momentum<momentum_level&&ma<0&&o<bands_main&&bands_upper-bands_lower>distance*Point)

              {

               arrow_02[shift]=High[shift]+indent_arrow*Point;

               flag_buy=false;

               flag_sell=true;

              }

         if(arrow_01[0]!=EMPTY_VALUE&&arrow_01[0]!=0&&sound_buy)

           {

            sound_buy=false;

            PlaySound(sound_file);

            if(use_sound)

               Alert("(Phoenix)" " Received a buy signal for the symbol " + Symbol() + ", on a timeframe " + (string)Period() + " min.," + " at the price " + (string)Bid);

            if(use_mail)

               SendMail("(Phoenix)" " Received a buy signal for the symbol.. ",  " Received a buy signal for the symbol " + Symbol()+ ", on a timeframe " + (string)Period() + " min" + ", at the price " + (string)Bid);

            if(use_notification)

               SendNotification("(Phoenix)" " Received a buy signal for the symbol " + Symbol() + ", on a timeframe " + (string)Period() + " min " + ", at the price " + (string)Bid);

           }

         if(!sound_buy&&(arrow_01[0]==EMPTY_VALUE||arrow_01[0]==0))

            sound_buy=true;

        }

      if(arrow_02[0]!=EMPTY_VALUE&&arrow_02[0]!=0&&sound_sell)

        {

         sound_sell=false;

         PlaySound(sound_file);

         if(use_sound)

            Alert("(Phoenix)" " Received a sell signal for the symbol " + Symbol()+ ", on a timeframe " + (string)Period() + " min.," + " at the price " + (string)Bid);

         if(use_mail)

            SendMail("(Phoenix)" " Received a sell signal for the symbol.. ",  " Received a sell signal for the symbol " + Symbol()+ ", on a timeframe " + (string)Period()+ " min" + ", at the price " + (string)Bid);

         if(use_notification)

            SendNotification("(Phoenix)" " Received a sell signal for the symbol " + Symbol() + ", on a timeframe " + (string)Period() + " min " + ", at the price " + (string)Bid);

        }

      if(!sound_sell&&(arrow_02[0]==EMPTY_VALUE||arrow_02[0]==0))

         sound_sell=true;

     }

   return(rates_total);

  }

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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---