Author: Copyright � 2010, Khlystov Vladimir
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
BEEP_v1_0
//+------------------------------------------------------------------+
//|                                                    BEEP_v1.0.mq4 |
//|                              Copyright © 2010, Khlystov Vladimir |
//|                                                cmillion@narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Khlystov Vladimir"
#property link      "cmillion@narod.ru"
//--------------------------------------------------------------------
#property indicator_separate_window
#property indicator_level1	0
#property indicator_levelcolor	Silver
#property indicator_levelwidth	0
#property indicator_levelstyle	2
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Aqua
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Gold
#property indicator_color6 DarkOrange
#property indicator_color7 DeepPink
#property indicator_color8 Red


extern int period_1   = 1;
extern int period_2   = 50;
extern int period_3   = 100;
extern int period_4   = 150;
extern int period_5   = 200;
extern int width      = 1;
extern int TF         = 0;

double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];

//+------------------------------------------------------------------+
int init()
{
   SetIndexStyle(0,DRAW_LINE,EMPTY,width);
   SetIndexBuffer(0,Buffer1);
   SetIndexLabel(0,DoubleToStr(period_1,0));   
   SetIndexStyle(1,DRAW_LINE,EMPTY,width);
   SetIndexBuffer(1,Buffer2);
   SetIndexLabel(1,DoubleToStr(period_2,0));   
   SetIndexStyle(2,DRAW_LINE,EMPTY,width);
   SetIndexBuffer(2,Buffer3);
   SetIndexLabel(2,DoubleToStr(period_3,0));   
   SetIndexStyle(3,DRAW_LINE,EMPTY,width);
   SetIndexBuffer(3,Buffer4);
   SetIndexLabel(3,DoubleToStr(period_4,0));   
   SetIndexStyle(4,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexBuffer(4,Buffer5);
   SetIndexLabel(4,"Âååð");   
   SetIndexStyle(5,DRAW_LINE,EMPTY,width);
   SetIndexBuffer(5,Buffer6);
   SetIndexLabel(5,"");   
   SetIndexStyle(6,DRAW_LINE,EMPTY,width);
   SetIndexBuffer(6,Buffer7);
   SetIndexLabel(6,"");   
   SetIndexStyle(7,DRAW_LINE,EMPTY,3);
   SetIndexBuffer(7,Buffer8);
   SetIndexLabel(7,"");   
   if (TF!=0) TF = next_period(TF);
   IndicatorShortName("Âååð "+string_per(TF));
   return(0);
}
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   int i,j,limit,counted_bars=IndicatorCounted();
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   double DeltaMA1,DeltaMA2,DeltaMA3,DeltaMA4;
   int bar;
   for(i=0; i<limit; i++)
   {
      bar = iBarShift(NULL,TF,Time[i],false);
      DeltaMA1=iMA(NULL,TF,period_1,0,MODE_EMA,PRICE_CLOSE,bar)-
      iMA(NULL,TF,period_2,0,MODE_EMA,PRICE_CLOSE,bar);
      DeltaMA2=iMA(NULL,TF,period_1,0,MODE_EMA,PRICE_CLOSE,bar)-
      iMA(NULL,TF,period_3,0,MODE_EMA,PRICE_CLOSE,bar);
      DeltaMA3=iMA(NULL,TF,period_1,0,MODE_EMA,PRICE_CLOSE,bar)-
      iMA(NULL,TF,period_4,0,MODE_EMA,PRICE_CLOSE,bar);
      DeltaMA4=iMA(NULL,TF,period_1,0,MODE_EMA,PRICE_CLOSE,bar)-
      iMA(NULL,TF,period_5,0,MODE_EMA,PRICE_CLOSE,bar);

      Buffer5[i]=(DeltaMA4-DeltaMA1);
      Buffer8[i]=(DeltaMA1+DeltaMA2+DeltaMA3+DeltaMA4)/4;
   }
   

   return(0);
  }
//+------------------------------------------------------------------+
string string_per(int per)
{
   if (per == 0) per=Period();
   if (per == 1)     return(" M1 ");
   if (per == 5)     return(" M5 ");
   if (per == 15)    return(" M15 ");
   if (per == 30)    return(" M30 ");
   if (per == 60)    return(" H1 ");
   if (per == 240)   return(" H4 ");
   if (per == 1440)  return(" D1 ");
   if (per == 10080) return(" W1 ");
   if (per == 43200) return(" MN1 ");
return("îøèáêà ïåðèîäà");
}
//+------------------------------------------------------------------+
int next_period(int per)
{
   if (per > 43200)  return(0); 
   if (per > 10080)  return(43200); 
   if (per > 1440)   return(10080); 
   if (per > 240)    return(1440); 
   if (per > 60)     return(240); 
   if (per > 30)     return(60);
   if (per > 15)     return(30); 
   if (per > 5)      return(15); 
   if (per > 1)      return(5);   
}
//+------------------------------------------------------------------+

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