Help - Add price offset
  #1 (permalink)  
Old 10-19-2007, 04:00 AM
Forex Trader
 
Join Date: Jul 2007
Location: Dallas
Posts: 6
cochran1 is on a distinguished road
Default Help - Add price offset

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 < price1 && ma0 >= 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];
}
}
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:38 AM.

Registered members gain free access to online FOREX currency trading tools, foreign exchange software, Metatrader MT4/MT5 expert advisors, MT4 indicators and EAs. Register now