Author: Copyright � 2010, sxTed.
Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each bar
Indicators Used
Moving average indicator
Miscellaneous
It issuies visual alerts to the screen
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 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 ---