SimpleRSI&amp_MA

Download script
Author: Copyright(c) 2010 Masaru Sasaki
SimpleRSI&amp_MA

This tool is designed as a visual aid for traders to better understand market momentum and identify potential price reversals. It functions by combining two popular technical analysis components—the Relative Strength Index (RSI) and the Simple Moving Average (SMA)—into a single, streamlined view.

How the Logic Works

The indicator operates through a three-step calculation process:

1. Monitoring Market Momentum (RSI) First, the script calculates the Relative Strength Index (RSI). The RSI is a standard tool used to measure how quickly and strongly a price is moving. It helps traders identify "overbought" conditions (where the price may be too high) or "oversold" conditions (where the price may be too low).

2. Smoothing the Data (Moving Average) Because the standard RSI can sometimes be volatile or "choppy," this script applies a second layer of logic. It takes the RSI values and runs them through a Simple Moving Average (SMA). Think of this as a smoothing filter; it averages out the recent RSI fluctuations to create a cleaner, more stable line that is easier for the human eye to follow.

3. Visualizing the Trends The script produces two distinct visual lines on your chart:

  • The RSI Line: Shows the raw momentum of the market.
  • The SMA Line: Shows the smoothed trend of that momentum.

Practical Application for Traders

By displaying these two lines together, the tool allows you to see the relationship between raw price energy and established trends. When the smoothed average line stays steady while the raw RSI line fluctuates, it provides a clearer picture of the market's underlying direction. This helps traders filter out "noise" and focus on the broader movements of the asset.

Indicators Used
Relative strength indexMoving average indicator
12 Views
0 Downloads
0 Favorites
SimpleRSI&amp_MA
//+------------------------------------------------------------------+
//|                                                 SimpleRSI&MA.mq4 |
//|                                  Copyright(c) 2010 Masaru Sasaki |
//|                                                                  |
//+------------------------------------------------------------------+
// 
// u–Ɛӎ–€v
//  *‚±‚̃vƒƒOƒ‰ƒ€‚ÉŠî‚­sˆ×‚ÌŒ‹‰Ê”­¶‚µ‚½áŠQA‘¹Ž¸‚Ȃǂɂ‚¢‚Ä
//    ’˜ìŽÒ‚ÍˆêØ‚̐ӔC‚𕉂¢‚Ü‚¹‚ñB
//
// uà–¾v
//  *RSI’l‚ÆRSI’l‚ðˆÚ“®•½‹Ï‚µ‚½’l‚ð•\ަ‚µ‚Ü‚·B
//   ŠúŠÔ‚Ì•W€Ý’è‚́A14‚ƂȂÁ‚Ä‚¨‚è‚Ü‚·B
//   “ñ‚‚̐ü‚̃NƒƒX‚ª”„”ƒ”»’f‚ƂȂÁ‚Ä‚¢‚Ü‚·B
//   –”AˆÚ“®•½‹Ïü‚ÌŽí—Þ‚ÍSMAA‰¿Ši‚͏I’l‚Å‚·B
//   ƒvƒƒOƒ‰ƒ~ƒ“ƒO‚Ì—ûK—p‚ɍ쐬‚µ‚½ˆ×A•s”õ‚ª‚ ‚邯Žv‚¢‚Ü‚·‚̂ŁA
//   Žg—p‚·‚éê‡‚͐ݒ蓙‚²’ˆÓ‰º‚³‚¢B
//
// ŽQl‘ÐFFXƒƒ^ƒgƒŒ[ƒ_[“ü–å PanRolling
//
#property copyright "Copyright(c) 2010 Masaru Sasaki"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Cyan
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 30
#property indicator_level2 70

// Žw•Wƒoƒbƒtƒ@
double RSI_Buf[];
double RSI_MA_Buf[];

// ŠúŠÔ
extern int RSI_period = 14;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  // Žw•Wƒoƒbƒtƒ@‚ÌŠ„‚è“–‚Ä
  SetIndexBuffer(0, RSI_Buf);
  SetIndexBuffer(1, RSI_MA_Buf);

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i;
   int limit = Bars - IndicatorCounted();
   
   if( counted_bars == 0 ) limit = limit - RSI_period - 1;     
   // RSI’l‚ÌŒvŽZ
   for( i = limit-1; i >= 0; i-- ){
      RSI_Buf[i] = iRSI(NULL, 0, RSI_period,PRICE_CLOSE, i);
   }
   
   if( counted_bars == 0 ) limit = limit - RSI_period - 1;
   // RSIˆÚ“®•½‹Ï’l‚ÌŒvŽZ
   for( i = limit-1; i >= 0; i-- ){
      RSI_MA_Buf[i] = iMAOnArray(RSI_Buf, 0, RSI_period, 0, MODE_SMA, i);
   }
   
   return(0);
  }
//+------------------------------------------------------------------+

Comments