Price Data Components
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
DeltaAlert
//+------------------------------------------------------------------+
//| SmWPR.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int sper=60;
extern int fper=13;
extern int test=0;
extern int nBars=100;
extern bool AlertON=true;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double shift, sdel, fdel, mas, maf, mBar;
double alertBar;
int flagval1 = 0;
int flagval2 = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,"sdel");
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexLabel(1,"fdel");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for(int shift=Bars-1; shift>0; shift--)
{
ExtMapBuffer1[shift]=0;
ExtMapBuffer2[shift]=0;
}
if (test==1) {mBar=nBars;} else {mBar=Bars;}
for(shift=Bars-1; shift>0; shift--)
{
mas=iMA(NULL, 0, sper, 0, MODE_EMA, PRICE_CLOSE,shift-1);
maf=iMA(NULL, 0, fper, 0, MODE_EMA, PRICE_CLOSE,shift-1);
sdel=MathRound((mas-Close[0])/Point);
fdel=MathRound((maf-Close[0])/Point);
if (sdel==0) {sdel=0.0001;}
if (fdel==0) {fdel=0.0001;}
if (sdel!=0) {ExtMapBuffer1[shift-1]=sdel;}
if (fdel!=0) {ExtMapBuffer2[shift-1]=fdel;}
if (fdel > sdel)
{
if (flagval1==0)
{
flagval1=1;
flagval2=0;
if (shift == 1 && AlertON && Bars>alertBar) {Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());alertBar = Bars;}
}
}
else if (fdel < sdel)
{
if ( flagval2==0)
{
flagval2=1;
flagval1=0;
if (shift == 1 && AlertON && Bars>alertBar) {Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());alertBar = Bars;}
}
}
}
return(0);
}
//+------------------------------------------------------------------+
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
---