Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Alert_MA_v2
//+------------------------------------------------------------------+
//| Alert_MA.mq4 |
//| Kalenzo |
//| bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link "bartlomiej.gorski@gmail.com"
extern int range = 1;
extern int ma_period = 21;
extern int ma_shift = 0;
extern int ma_method = MODE_EMA;
extern int applied_price = PRICE_CLOSE;
extern bool usePriceTargetInsteadOfRange = true;
extern double priceTarget = 1.2001;
double pma = 0;
bool reached = false;
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----bb
double ma = iMA(Symbol(),0,ma_period,ma_shift,ma_method,applied_price,0);
if(!usePriceTargetInsteadOfRange)
{
if( (Bid <= ma+(range*Point)) && (Bid >= ma-(range*Point)))
Alert(Symbol()+" "+ma_period+" Moving Average range reached at ",Bid);
}
else
{
if(!reached && pma!=0 &&((pma < priceTarget && ma >= priceTarget) || (pma > priceTarget && ma <= priceTarget)))
{
Alert(Symbol()+" "+ma_period+" Moving Average price target ",priceTarget);
reached = true;
}
}
pma = ma;
//----
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
---