Price Data Components
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Max
//+------------------------------------------------------------------+
//| Max.mq4 |
//| Copyright © 2010, sxTed. |
//| sxTed@gmx.com |
//| Purpose.: Alert when the Price crosses over EMA for any one of |
//| the Symbols provided by the Server and test function |
//| Symbols() in file Symbols.mqh |
//| Set up..: 1) Download file "Symbols.mqh" and place into the |
//| "\experts\include" subdirectory. |
//| 2) Place file "Max.mq4" into the "\experts\indicators" |
//| subdirectory. |
//| 3) Close and then re-start MetaTrader for it to find |
//| the new files. |
//| 4) Compile "Max" indicator. |
//| Start up: 1) Click on "Navigator", click on "Custom indicators", |
//| double click on "Max". |
//| 2) Window with header "Custom Indicator - Max" is |
//| displayed. |
//| 3) Click on the "Common" tab and ensure that a tick is |
//| showing in "Allow DLL imports" box by clicking it. |
//| 4) Click on the "Inputs" tab. |
//| For the value of input named "MA_Period" type in a |
//| moving average period or accept the default 100. |
//| Click on "OK". |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, sxTed."
#property link "sxTed@gmx.com"
#property indicator_chart_window
//---- input parameters
extern int MA_Period=100;
#include <Symbols.mqh> // #### must be stated here to pull in the functions
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start() {
static string sSymbols[1000];
static int iSymbols;
static datetime tPreviousTime;
double dMA;
int i;
string sPeriod=","+PeriodToStr();
// only load the Symbols once into the array "sSymbols"
if(iSymbols == 0) iSymbols=Symbols(sSymbols);
// only start analysis on complete bars
if(tPreviousTime == Time[0]) return;
for(i=0; i < iSymbols; i++) {
dMA=iMA(sSymbols[i],0,MA_Period,13,MODE_EMA,PRICE_CLOSE,0);
if(iOpen(sSymbols[i],0,1) > dMA && iClose(sSymbols[i],0,1) < dMA)
Alert("Price crossed below ",MA_Period," EMA on ",sSymbols[i],sPeriod);
if(iOpen(sSymbols[i],0,1) < dMA && iClose(sSymbols[i],0,1) > dMA)
Alert("Price crossed above ",MA_Period," EMA on ",sSymbols[i],sPeriod);
}
tPreviousTime=Time[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
---