Miscellaneous
0
Views
0
Downloads
0
Favorites
MomentumVT alert
//+--------------------------------------------------------------------+
//| MomentumVT.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//| Conversion from VT to MT4 by Skyline (glicci@yahoo.it) |
//+--------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern bool AlertsEnabled = false;
extern string AlertsSound = "alert.wav";
extern int MomPeriod = 10;
//---- buffers
double MomBuffer[];
void init()
{
//---- indicator line
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, MomBuffer);
//---- name for DataWindow and indicator subwindow label
string short_name="MomentumVT alert(" + MomPeriod + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, short_name);
//----
SetIndexDrawBegin(0, MomPeriod);
}
//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+
void start()
{
static datetime AlertTime = 0;
int counted_bars = IndicatorCounted();
if (Bars <= MomPeriod)
return;
//---- initial zero
if (counted_bars < 1)
for (int i = 1; i <= MomPeriod; i++)
MomBuffer[Bars - i] = 0.0;
//----
i = Bars - MomPeriod - 1;
if (counted_bars >= MomPeriod)
i = Bars - counted_bars - 1;
while (i >= 0) {
MomBuffer[i] = Close[i] - Close[i + MomPeriod];
i--;
if (AlertsEnabled && i == 0 && AlertTime != Time[0]) {
if ((MomBuffer[0] > 0 && MomBuffer[1] <= 0) || (MomBuffer[0] < 0 && MomBuffer[1] >= 0)) {
AlertTime = Time[0];
Alert("MomentumVT Indicator! ", Symbol(), " M", Period());
if (StringLen(AlertsSound) > 0)
PlaySound(AlertsSound);
}
}
}
}
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
---