Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Alert
//+------------------------------------------------------------------+
//| Alert.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_chart_window
#define up " UP TREND "
#define down " DOWN TREND "
extern bool condittion_all = 0;
extern int shift_bar = 0;
extern bool one_alert = 0;
extern bool macd = 0;
extern int macdFastLWMA=12;
extern int macdSlowLWMA=26;
extern int macdSignalLWMA=9;
extern bool ma_cross = 0;
extern int FastLWMA_HLCC=5;
extern int SlowLWMA_OPEN=7;
extern bool stoch = 0;
extern int stochKperiod=5;
extern int stochDperiod=3;
extern int stochSlowing=3;
extern bool rsi = 0;
extern int rsiPeriod=14;
extern bool cci = 0;
extern int cciPeriod=14;
extern bool wpr = 0;
extern int wprPeriod=14;
extern bool rvi = 0;
extern int rviPeriod=10;
static int alert=-1;
int all_alert;
string signal;
double macdMacd, macdSignal, crossMA, stochSignal, rsiSignal,
cciSignal, wprSignal, rviSignal;
bool up_1, up_2, up_3, up_4, up_5, up_6, up_7,
down_1, down_2, down_3, down_4, down_5, down_6, down_7;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
all_alert = (macd == 1) + (ma_cross == 1) + (stoch == 1)
+ (rsi == 1) + (cci == 1) + (wpr == 1) + (rvi == 1);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
if(macd == 1) {
macdMacd =
iMA(NULL,0,macdFastLWMA,0,MODE_LWMA,PRICE_CLOSE,shift_bar)
- iMA(NULL,0,macdSlowLWMA,0,MODE_LWMA,PRICE_CLOSE,shift_bar);
macdSignal =
iMAOnArray(macdMacd,macdSlowLWMA,macdSignalLWMA,0,MODE_LWMA,shift_bar);
up_1 = macdMacd-macdSignal > 0.0;
down_1 = macdMacd-macdSignal < 0.0;}
//----
if(ma_cross == 1) {
crossMA =
iMA(NULL,0,FastLWMA_HLCC,0,MODE_LWMA,PRICE_WEIGHTED,shift_bar)
- iMA(NULL,0,SlowLWMA_OPEN,0,MODE_LWMA,PRICE_OPEN,shift_bar);
up_2 = crossMA > 0.0;
down_2 = crossMA < 0.0;}
//----
if(stoch == 1) {
stochSignal =
iStochastic(NULL,0,stochKperiod,stochDperiod,stochSlowing,
MODE_SMA,0,MODE_MAIN,shift_bar)
- iStochastic(NULL,0,stochKperiod,stochDperiod,stochSlowing,
MODE_SMA,0,MODE_SIGNAL,shift_bar);
up_3 = stochSignal > 0.0;
down_3 = stochSignal < 0.0;}
//----
if(rsi == 1) {
rsiSignal = iRSI(NULL,0,rsiPeriod,PRICE_CLOSE,shift_bar)
- iRSI(NULL,0,rsiPeriod,PRICE_CLOSE,shift_bar+1);
up_4 = rsiSignal > 0.0;
down_4 = rsiSignal < 0.0;}
//----
if(cci == 1) {
cciSignal = iCCI(NULL,0,cciPeriod,PRICE_TYPICAL,shift_bar)
- iCCI(NULL,0,cciPeriod,PRICE_TYPICAL,shift_bar+1);
up_5 = cciSignal > 0.0;
down_5 = cciSignal < 0.0;}
//----
if(wpr == 1) {
wprSignal = iWPR(NULL,0,wprPeriod,shift_bar)
- iWPR(NULL,0,wprPeriod,shift_bar+1);
up_6 = wprSignal > 0.0;
down_6 = wprSignal < 0.0;}
//----
if(rvi == 1) {
rviSignal = iRVI(NULL, 0, rviPeriod,MODE_MAIN,shift_bar)
- iRVI(NULL, 0, rviPeriod,MODE_SIGNAL,shift_bar);
up_7 = wprSignal > 0.0;
down_7 = wprSignal < 0.0;}
//----
if(condittion_all == 1 && all_alert > 0) {
if(
((macd == 1 && up_1 == 1) || macd == 0) &&
((ma_cross == 1 && up_2 == 1) || ma_cross == 0) &&
((stoch == 1 && up_3 == 1) || stoch == 0) &&
((rsi == 1 && up_4 == 1) || rsi == 0) &&
((cci == 1 && up_5 == 1) || cci == 0) &&
((wpr == 1 && up_6 == 1) || wpr == 0) &&
((rvi == 1 && up_7 == 1) || rvi == 0) )
signal = up;
if(
((macd == 1 && down_1 == 1) || macd == 0) &&
((ma_cross == 1 && down_2 == 1) || ma_cross == 0) &&
((stoch == 1 && down_3 == 1) || stoch == 0) &&
((rsi == 1 && down_4 == 1) || rsi == 0) &&
((cci == 1 && down_5 == 1) || cci == 0) &&
((wpr == 1 && down_6 == 1) || wpr == 0) &&
((rvi == 1 && down_7 == 1) || rvi == 0) )
signal = down;
}
//----
if(condittion_all == 0 && all_alert > 0) {
if(up_1 == 1 || up_2 == 1 || up_3 == 1 || up_4 == 1
|| up_5 == 1 || up_6 == 1 || up_7 == 1)
signal = up;
if(down_1 == 1 || down_2 == 1 || down_3 == 1 || down_4 == 1
|| down_5 == 1 || down_6 == 1 || down_7 == 1)
signal = down;
}
//----
if(one_alert == 1) {
if(alert != 0 && signal == up) {
alert = 0; Alert( signal, Symbol() ); }
if(alert != 1 && signal == down) {
alert = 1; Alert( signal, Symbol() ); }
}
else {
if(signal == up) Alert( signal, Symbol() );
if(signal == down) Alert( signal, Symbol() );
}
//----
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
---