Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
VininI_HMA_sound_Alert
//+------------------------------------------------------------------+
//| ProjectName |
//| Copyright 2012, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
//---- input parameters
extern int period=16;
extern int method=3; // MODE_SMA
extern int price=0; // PRICE_CLOSE
extern int sdvig=0;
extern bool bPlaySound=true; // Âêëþ÷åíèå çâóêà ïðè ñìåíå öâåòà
extern bool bAllert=true; // Âêëþ÷åíèå çâóêà ïðè ñìåíå öâåòà
extern string SoundName="alert.wav"; // Çâóêîâîé ôàéë
extern int CheckBar=1;
//---- buffers
double Uptrend[];
double Dntrend[];
double ExtMapBuffer[];
double vect[];
static bool bs=false,ba=false;
static int bTime=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
SetIndexBuffer(0,ExtMapBuffer);
SetIndexBuffer(1,Uptrend);
SetIndexBuffer(2,Dntrend);
SetIndexBuffer(3,vect);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(0,1*period);
SetIndexDrawBegin(1,2*period);
SetIndexDrawBegin(2,3*period);
IndicatorShortName("Signal Line("+period+")");
SetIndexLabel(1,"UP");
SetIndexLabel(2,"DN");
bs=false;
ba=false;
bTime=0;
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| ?????????? ??????? |
//+------------------------------------------------------------------+
double WMA(int x,int p) { return(iMA(NULL,0,p,0,method,price,x+sdvig)); }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int p=MathSqrt(period);
int i,limit0,limit1,limit2;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit2 = Bars - counted_bars;
if(counted_bars==0) limit2--;
limit1=limit2;
limit0=limit1;
if(counted_bars==0)
{
limit1-=(period);
limit2-=(2*period);
}
for(i = limit0; i >= 0; i--) vect[i] = 2*WMA(i, period/2) - WMA(i, period);
for(i = limit1; i >= 0; i--) ExtMapBuffer[i] = iMAOnArray(vect, 0, p, 0, method, i);
for(i=limit2; i>=0; i--)
{
Uptrend[i] = EMPTY_VALUE; if(ExtMapBuffer[i]> ExtMapBuffer[i+1]) {Uptrend[i+1] = ExtMapBuffer[i+1]; Uptrend[i] = ExtMapBuffer[i]; }
Dntrend[i] = EMPTY_VALUE; if(ExtMapBuffer[i]< ExtMapBuffer[i+1]) {Dntrend[i+1] = ExtMapBuffer[i+1]; Dntrend[i] = ExtMapBuffer[i]; }
}
if(bTime!=Time[0])
{
bTime=Time[0];
bs=false;
ba=false;
}
if((ExtMapBuffer[CheckBar+2]-ExtMapBuffer[CheckBar+1])*(ExtMapBuffer[CheckBar+1]-ExtMapBuffer[CheckBar])<0)
{
if(bPlaySound && !bs) PlaySound(SoundName);
bs=true;
if(bAllert && !ba)
{
string mes="";
if(ExtMapBuffer[CheckBar]-ExtMapBuffer[CheckBar+1]>0) mes="Ñìåíà òðåíäà, âîñõîäÿùèé";
if(ExtMapBuffer[CheckBar]-ExtMapBuffer[CheckBar+1]<0) mes="Ñìåíà òðåíäà, íèñõîäÿùèé";
if(mes!="") Alert(mes+": "+Symbol()+"; "+Period_toStr()+"; "+DoubleToStr(Bid,Digits));
}
ba=true;
}
return(0);
}
//+------------------------------------------------------------------+
string Period_toStr()
{
switch(Period())
{
case PERIOD_M1: return("M1" );
case PERIOD_M5: return("M5" );
case PERIOD_M15: return("M15");
case PERIOD_M30: return("M30");
case PERIOD_H1: return("H1" );
case PERIOD_H4: return("H4" );
case PERIOD_D1: return("D1" );
case PERIOD_W1: return("W1" );
case PERIOD_MN1: return("MN1");
}
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---