SGMAR2_Alert
Download scriptThis tool is designed to help traders identify potential momentum shifts in the market by combining two well-known technical analysis methods: the Relative Strength Index (RSI) and Moving Averages. Instead of looking at price movements directly, this script analyzes the "momentum" of the RSI to generate specific visual signals and notifications.
How the Logic Works
1. The Foundation (RSI Analysis) The script first calculates the RSI, which is a standard momentum oscillator that measures the speed and change of price movements. By using the RSI as its base, the tool focuses on whether the market is becoming overextended or if there is a shift in trend strength.
2. The Overlay (Double Moving Average) The core "intelligence" of this script lies in how it treats the RSI data. It applies two different types of Moving Averages to the RSI values simultaneously:
- Simple Moving Average (SMA): This provides a smooth, stable average of recent RSI trends.
- Exponential Moving Average (EMA): This gives more weight to the most recent price data, making it more reactive to sudden changes.
3. Signal Detection (The "Cross") The script constantly monitors the relationship between these two moving averages (the SMA and the EMA) as they move along the RSI line. A trading signal is triggered specifically when these two lines cross over each other. This crossover indicates a change in the momentum's direction:
- Upward Signal: When the lines cross in a specific upward direction, the script places a visual arrow on the chart and, if enabled, sends an alert notification. This suggests that the underlying momentum is turning bullish.
- Downward Signal: When the lines cross in a downward direction, the script places a visual arrow and sends an alert, suggesting that the momentum is shifting toward a bearish trend.
Key Features for Users
- Visual Cues: The tool automatically plots arrows on your chart so you can see exactly where the momentum shifts occurred historically.
- Real-Time Alerts: It includes a notification system that "pings" you with an alert the moment a new signal appears, allowing you to react quickly without constantly staring at the screen.
- Filtered Noise: By requiring both a moving average crossover and a specific RSI context, the tool aims to filter out minor market fluctuations, focusing only on more significant shifts in trend energy.
//ShadowWz 03-11-2006, http://www.forex-tsd.com/13195-post2.html
//http://www.forex-tsd.com/metatrader-4/1270-signal-generator-show-mas-crossing-when-overlayed-rsi.html#post13195
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Maroon
#property indicator_color4 DarkTurquoise
#property indicator_color5 DarkViolet
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_level1 70
#property indicator_level2 50
#property indicator_level3 30
#property indicator_levelcolor DarkBlue
#property indicator_levelstyle STYLE_DOT
extern int Rsi = 14;
extern int Ma = 8;
extern bool alertOn = true;
double alertBar;
double RsiBuf[];
double MaP[];
double MaF[];
double Up[];
double Dn[];
void init() {
SetIndexStyle (0, DRAW_LINE);
SetIndexStyle (1, DRAW_LINE);
SetIndexStyle (2, DRAW_LINE);
SetIndexStyle (3, DRAW_ARROW);
SetIndexStyle (4, DRAW_ARROW);
SetIndexBuffer(0, RsiBuf);
SetIndexBuffer(1, MaP);
SetIndexBuffer(2, MaF);
SetIndexBuffer(3, Up);
SetIndexBuffer(4, Dn);
SetIndexEmptyValue(3,EMPTY_VALUE);
SetIndexEmptyValue(4,EMPTY_VALUE);
SetIndexArrow(3,108);//233 234
SetIndexArrow(4,108);
}
void deinit() {
}
int start()
{
int shift,limit,counted_bars=IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit = Bars-counted_bars;
for(shift=limit;shift>=0;shift--)
{
RsiBuf[shift] = iRSI(NULL,0,Rsi,PRICE_CLOSE,shift);
}
for(shift=limit;shift>=0;shift--)
{
Dn[shift] = EMPTY_VALUE; Up[shift] = EMPTY_VALUE;
// First Indicator Data
MaF[shift] = iMAOnArray(RsiBuf,0,Ma,0,MODE_SMA,shift);
// Previous Indicator Data//secondMA
MaP[shift] = iMAOnArray(RsiBuf,0,Ma,0,MODE_EMA,shift);
if((MaF[shift]-MaP[shift])*(MaF[shift+1]-MaP[shift+1])<0)
{
if(MaF[shift]-MaP[shift]<0)
{
Up[shift] = MaP[shift]-4; Dn[shift] = EMPTY_VALUE;
if(alertOn && Up[0] != EMPTY_VALUE && Bars>alertBar){
Alert("SGMAR Up signal on ", Symbol()," M", Period()," at ",Close[0]); alertBar = Bars;}//Bid tester Close[0]
}
else
{
Dn[shift] = MaF[shift]+2; Up[shift] = EMPTY_VALUE;
if( alertOn && Dn[0] != EMPTY_VALUE && Bars>alertBar) {
Alert("SGMAR Down Signal on ",Symbol()," M", Period()," at ",Close[0]); alertBar = Bars;}//Bid
}
}
}
return(0);
}
Comments