SGMAR_v2
Download scriptThis custom trading indicator is designed to provide visual cues for market momentum and potential trend reversals by analyzing the Relative Strength Index (RSI) in a multi-layered way. Instead of simply looking at the price of an asset, it evaluates the "speed" and "strength" of price movements to help traders identify when a trend is losing steam or beginning to shift.
Core Analytical Logic
The tool functions by performing three distinct levels of analysis:
1. The Foundation: RSI Analysis First, the script calculates the Relative Strength Index (RSI), a standard market oscillator that measures whether an asset is overbought or oversold. This serves as the raw data for all subsequent calculations in the script.
2. The Smoothing Layer: Moving Averages Rather than plotting the raw RSI directly (which can be "noisy" or jump around too quickly), the script applies two different types of moving averages to that RSI data:
- Simple Moving Average (SMA): Used to smooth out price fluctuations to show the general direction.
- Exponential Moving Average (EMA): Used to give more weight to recent price action, making the indicator more responsive to sudden changes.
3. The Signal Logic: Cross-over Detection The primary "intelligence" of this script lies in how it compares these two moving averages against each other. It looks for specific mathematical "crosses":
- Trend Shift Identification: The script monitors the relationship between the SMA and the EMA. When the two lines cross each other, it signals a potential change in momentum.
- Visual Markers: When a crossover occurs, the script automatically places specific visual symbols (arrows) on the chart. These serve as immediate alerts for the trader, indicating where the momentum has flipped from upward to downward, or vice versa.
User Experience and Visuals
The indicator is designed to be displayed in a separate window below your main price chart. It includes predefined horizontal levels (30, 50, and 70) which are standard benchmarks for identifying high-pressure (overbought) and low-pressure (oversold) zones. By combining the smoothed moving averages with these dynamic arrow signals, the tool aims to filter out minor market noise and highlight significant shifts in market sentiment.
//+------------------------------------------------------------------+
//| |
//| Copyright © 1999-2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 5
//----
#property indicator_color1 Lime
#property indicator_color2 Aqua
#property indicator_color3 Red
#property indicator_color4 DarkTurquoise
#property indicator_color5 Red
//----
#property indicator_level1 70
#property indicator_level2 50
#property indicator_level3 30
#property indicator_levelcolor Gray
#property indicator_levelwidth 1
#property indicator_levelstyle STYLE_DASH
//----
extern int Rsi =14;
extern int Ma =8;
extern int cbars =0;
//----
double RsiBuf[];
double MaP[];
double MaF[];
double Up[];
double Dn[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void init()
{
SetIndexStyle (0, DRAW_LINE,0, 2);
SetIndexStyle (1, DRAW_LINE,0,2);
SetIndexStyle (2, DRAW_LINE,0,2);
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,0);
SetIndexEmptyValue(4,0);
SetIndexArrow(3,108);
SetIndexArrow(4,108);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void deinit()
{}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int shift,limit=cbars;
if(limit==0) limit=Bars;
for(shift=limit-1; shift>=0; shift--)
{
RsiBuf[shift]=iRSI(NULL,0,Rsi,PRICE_CLOSE,shift);
}
for(shift=limit-1; shift>=0; shift--)
{
// First Indicator Data
MaF[shift]=iMAOnArray(RsiBuf,0,Ma,0,MODE_SMA,shift);
// Previous Indicator Data
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];
else Dn[shift]=MaF[shift];
}
}
}
//+------------------------------------------------------------------+
Comments