rsi_ts
Download scriptThis tool is designed to assist traders in identifying specific momentum shifts and potential reversal points in the financial markets by analyzing price action history. It focuses on a well-known technical analysis concept that measures the speed and magnitude of price changes, helping you visualize whether an asset is being traded too aggressively in one direction.
Core Functionality
The script works by continuously calculating a momentum value based on a user-defined period (the default is 14 units). It plots this data as a visual histogram in a separate window, allowing you to see the "pulse" of the market clearly.
Key Technical Logic:
- Momentum Tracking: The tool constantly monitors the current market strength. By looking at the history of price movements, it determines if the asset is currently experiencing a surge or a decline.
- Boundary Identification: The script utilizes two critical thresholds: an "Overbought" level (set at 70) and an "Oversold" level (set at 30). These act as boundaries to help identify when a market move might be becoming exhausted.
- Visual Signaling: Instead of just showing a line, the script features an automated alerting system. When the momentum value crosses into either the Overbought or Oversold territory, the tool places a specific visual marker (an arrow) on the chart.
How It Helps the User
The primary goal of this script is to filter out the "noise" of the market. By highlighting moments where the price reaches extreme highs or lows relative to its recent history, it provides a clear visual cue for traders who are looking for potential turning points. Rather than manually watching every price tick, you can rely on the script to highlight these specific zones of interest automatically, making it easier to spot opportunities where the market might be ready to shift direction.
//+------------------------------------------------------------------+
//| RSI_TS.mq4 |
//| Yuriy Tokman (YTG) |
//| http://ytg.com.ua/ |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link "http://ytg.com.ua/"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_level1 30.0
#property indicator_level2 70.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
#property indicator_color2 clrRed
//--- input parameters
input int InpRSIPeriod=14; // RSI Period
input int OverboughtLevels=70;
input int OversoldLevels=30;
//--- buffers
double ExtRSIBuffer[];
double ExtARWBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
string short_name;
//--- 2 additional buffers are used for counting.
SetIndexBuffer(0,ExtRSIBuffer);
SetIndexBuffer(1,ExtARWBuffer);
//--- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,116);
//--- name for DataWindow and indicator subwindow label
short_name="RSI_TS("+string(InpRSIPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//--- check for input
if(InpRSIPeriod<2)
{
Print("Incorrect value for input variable InpRSIPeriod = ",InpRSIPeriod);
return(INIT_FAILED);
}
//---
SetIndexDrawBegin(0,InpRSIPeriod);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
double rsi_0,rsi_1;
int limit=rates_total-prev_calculated-1;
if(prev_calculated==0)limit--;
else limit++;
for(int i=limit; i>=0 && !IsStopped(); i--)
{
rsi_0 = iRSI(Symbol(),0,InpRSIPeriod,0,i);
rsi_1 = iRSI(Symbol(),0,InpRSIPeriod,0,i+1);
ExtRSIBuffer[i]=rsi_0;
if(rsi_1>OverboughtLevels || rsi_1<OversoldLevels)ExtARWBuffer[i+1]=rsi_1+5;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Comments