//+------------------------------------------------------------------+ //| RSI-Cross50_Alert.mq4 | //| Copyright © 2006, Robert Hill | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, Robert Hill" #property link "" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red #property indicator_width1 1 extern int RSI_Period=14; double rsi[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_LINE, STYLE_SOLID); SetIndexBuffer(0, rsi); SetIndexLabel (0, "RSI" + "("+RSI_Period+")"); SetLevelStyle(STYLE_DASH, 1, Silver); SetLevelValue(0, 50); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i; double RSInow, RSIprevious; datetime alertTag; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i = 0; i <= limit; i++) { RSInow = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i); RSIprevious = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i+1); rsi[i] = RSInow; if (RSInow > 50 && RSIprevious < 50.0) { if ( alertTag!=Time[0]) { PlaySound("news.wav");// buy wav Alert(Symbol()," M",Period()," RSI cross above 50"); } alertTag = Time[0]; } else if (RSInow < 50.0 && RSIprevious > 50.0) { if ( alertTag!=Time[0]) { PlaySound("news.wav"); //sell wav Alert(Symbol()," M",Period()," RSI cross below 50"); } alertTag = Time[0]; } } return(0); }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Relative strength index
Custom Indicators Used:
Order Management characteristics:
Other Features:
It plays sound alerts
It issuies visual alerts to the screen