RSI_2SigMA_mtf
Download scriptThis technical tool is designed to provide traders with a multi-dimensional view of market momentum by combining three distinct analytical layers: a Relative Strength Index (RSI), and two distinct Moving Averages that operate on top of that RSI data.
Core Logic Overview
Instead of looking at standard price action alone, this script analyzes the "momentum" of the price. It identifies whether an asset is being bought or sold aggressively and then applies smoothing filters to those momentum readings to help identify clearer trends and potential reversals.
Key Functional Components
1. Multi-Timeframe Analysis The tool possesses a unique "Multi-Timeframe" (MTF) capability. This allows the script to calculate data from higher timeframes (such as Daily, Weekly, or Hourly charts) while you are viewing a smaller, more immediate chart (like a 5-minute or 15-minute chart). This helps traders see the "big picture" of the market without having to constantly switch between different windows.
2. Momentum Tracking (RSI) At its foundation, the script uses the Relative Strength Index (RSI). This measures the speed and change of price movements. It determines if an asset is becoming "overbought" or "oversold."
3. Dual-Layer Smoothing (Moving Averages) What makes this specific script unique is that it doesn't just show you the RSI line; it applies two different Moving Averages to the RSI data itself:
- Primary Smoothing: The first layer calculates a moving average of the RSI values. This filters out "noise" or tiny, insignificant price fluctuations, making the momentum trend easier to follow visually.
- Secondary Smoothing: The second layer calculates a moving average of the previous moving average. By layering these calculations, the script creates a highly stabilized visual representation of momentum.
How the Logic Works Together
The script follows a sequential calculation process:
- It captures the RSI value based on your chosen timeframe.
- It takes that RSI result and calculates the first Moving Average (MA1).
- It then takes the result of MA1 and calculates the second Moving Average (MA2).
The Result: By the time the data reaches the final display, it has been processed through three distinct filters. This creates a "smoothed" momentum indicator where the interaction between the lines can signal shifts in market strength more reliably than a standard RSI alone. It is designed to help traders identify when momentum is gaining significant strength or beginning to lose steam by observing the convergence and divergence of these three distinct layers.
//+------------------------------------------------------------------+
//| RSI_2SigMA_mtf RSI.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//mtf2008fxtsd.com keris ki
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
//----
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 RoyalBlue
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_width1 1
#property indicator_width2 2
#property indicator_width3 1
#property indicator_level1 70
#property indicator_level2 50
#property indicator_level3 30
#property indicator_levelcolor DarkOliveGreen
//----
extern int RSI_Period=14;
extern int RSI_Price =0;
extern int MA1_Period=3;
extern int MA1_Mode =1;// MA_Price =0; - ma on array
extern int MA2_Period=5;
extern int MA2_Mode =1;
double RSI_Buffer[];
double MA1_Buffer[];
double MA2_Buffer[];
double ExBuffer1[];
double ExBuffer2[];
extern int TimeFrame=0;
extern string TimeFrames="M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string MA_Method_Price="SMA0 EMA1 SMMA2 LWMA3||0O,1C 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
//+----
int init()
{
IndicatorBuffers(5);
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
SetIndexStyle(2, DRAW_LINE);
//----
SetIndexBuffer(0, RSI_Buffer);
SetIndexBuffer(1, MA1_Buffer);
SetIndexBuffer(2, MA2_Buffer);
SetIndexBuffer(3, ExBuffer1);
SetIndexBuffer(4, ExBuffer2);
//----
switch(TimeFrame)
{
case 1 : string TimeFrameStr="M1"; break;
case 5 : TimeFrameStr="M5"; break;
case 15 : TimeFrameStr="M15"; break;
case 30 : TimeFrameStr="M30"; break;
case 60 : TimeFrameStr="H1"; break;
case 240 : TimeFrameStr="H4"; break;
case 1440 : TimeFrameStr="D1"; break;
case 10080 : TimeFrameStr="W1"; break;
case 43200 : TimeFrameStr="MN1"; break;
default : TimeFrameStr="TF0";
}
IndicatorShortName("RSI_2SigMA ("+RSI_Period+","+MA1_Period+","+MA2_Period+") ["+TimeFrameStr+"]");
TimeFrame=MathMax(TimeFrame,Period());
return(0);
}
//+----
int deinit()
{
//----
return(0);
}
//+----
int start()
{
datetime TimeArray[],TimeArray1[],TimeArray2[];
int limit,i,y=0,counted_bars = IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
//----
ArrayCopySeries(TimeArray, MODE_TIME,Symbol(),TimeFrame);
ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame);
ArrayCopySeries(TimeArray2,MODE_TIME,Symbol(),TimeFrame);
limit = Bars - counted_bars;
limit = MathMax(limit,TimeFrame/Period());
//----
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
RSI_Buffer[i] = iRSI(NULL, TimeFrame, RSI_Period, RSI_Price, y);
ExBuffer1[y] = RSI_Buffer[i];
}
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray1[y]) y++;
MA1_Buffer[i] = iMAOnArray(ExBuffer1,0,MA1_Period,0,MA1_Mode,y);
ExBuffer2[y] = MA1_Buffer[i];
}
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray1[y]) y++;
MA2_Buffer[i] = iMAOnArray(ExBuffer2,0,MA2_Period,0,MA2_Mode,y);
}
return(0);
}
//+---
Comments