
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can someone help me to add a price offset to this alert ? Right now the alert works when the price crosses the upper MA and when the price crosses the lower MA. I would like the alert to occur 10pips above the upper MA and 10pips below the lower MA.
Need alert to function as follows:
Alert - when price +10 pips crosses the upper smma
Alert - when price -10 pips crosses the lower smma
Thank you very much..
----------------------------------------------------
#property indicator_chart_window
extern int MA1.period =5; //Period 5
extern int MA1.shift=0;
extern int MA1.method=2; //SMMA
extern int lMA1.price=2; //MA set to candle high
extern int sMA1.price=3; //MA set to candle low
extern int PriceMode = 6; //(high+low+close+close)/4
int cBar,pBarLong,pBarShort;
int start()
{
cBar = Time[0];
if(CheckMACross(1)== 1 && cBar!=pBarLong ) {EmailAlert(1); pBarLong=cBar;}
else
if(CheckMACross(2)==-1 && cBar!=pBarShort) {EmailAlert(2); pBarShort=cBar;}
return(0);
}
int CheckMACross(int mode)
{
if(mode==1) int price = lMA1.price;
else
if(mode==2) price = sMA1.price;
double price1 = iMA(Symbol(),0,1,0,1,PriceMode,1);
double ma1 = iMA(Symbol(),0,MA1.period,MA1.shift ,MA1.method, price,1);
double price0 = iMA(Symbol(),0,1,0,1,PriceMode,0);
double ma0 = iMA(Symbol(),0,MA1.period,MA1.shift ,MA1.method, price,0);
if(ma1 > price1 && ma0 <= price0) return( 1);
else
if(ma1 = price0) return(-1);
else
return(0);
}
{
if(mode == 1) SendMail("Signal for LONG",Symbol()+" Go Long"); //SendMail
else
if(mode == 2) SendMail("Signal for SHORT",Symbol()+" Go Short");//SendMail
}
int lastBAlert = 0;
int lastSAlert = 0;
void EmailAlert(int mode)
{
if(mode == 1 && lastBAlert < Time[0] )
{
SendMail("Go Long 1",Symbol()+" Go Long 1"); //SendMail
lastBAlert = Time[0];
}
else if(mode == 2 && lastSAlert < Time[0] )
{
SendMail("Go Short 1",Symbol()+" Go Short 1"); //SendMail
lastSAlert = Time[0];
}
}