RSIOMA_v2HLS22
Download scriptThe RSIOMAv2HLS22 is a sophisticated technical analysis tool designed to help traders visualize market momentum, trend strength, and potential reversal points. Rather than providing a single data point, it layers multiple mathematical filters onto the standard Relative Strength Index (RSI) to offer a multi-dimensional view of price action.
Here is a breakdown of how the logic functions:
Core Momentum Tracking
At its foundation, the script calculates the Relative Strength Index (RSI), which measures the speed and change of price movements. However, this specific version applies a smoothed moving average to the RSI calculation itself. This creates a "smoother" line that is less susceptible to erratic market noise while still reacting quickly enough to significant shifts in sentiment.
Trend Analysis Layers
The script distinguishes between short-term momentum and long-term trends through several visual components:
- Moving Average Overlay: It plots a secondary moving average over the RSI line. This helps traders see if the current momentum is accelerating or decelerating relative to its recent history.
- Main Trend Boundaries: The logic establishes specific zones for "Long" and "Short" trends (based on user-defined thresholds like 70 and 30). When the indicator enters these extremes, it visually flags whether the market is in a dominant bullish or bearish phase.
Signal Generation Logic
One of the most distinct features of this script is its automated signal logic, which identifies three specific types of price behavior:
- Trend Strength (Histogram): The script uses histograms to provide a visual "weight" to the trend. It assigns different heights to these bars depending on whether the RSI has crossed the 50-level midline or entered the deeper trend zones.
- Overbought/Oversold Signals: The logic monitors when the price moves into extreme territory (typically above 80 or below 20). It specifically looks for "hooks"—moments where the price reaches an extreme but then begins to turn back toward the center. These are highlighted as potential reversal points.
- Dynamic Trigger Points: There are specific "Trigger" levels that act as alerts. When the RSI crosses these thresholds while showing a change in direction (e.g., moving up from a low point or falling from a high point), the script highlights these areas to signal possible entry or exit opportunities.
Visual Summary for Traders
For the user, this logic translates into a clean, color-coded dashboard:
- Lines show the current smoothed momentum.
- Histograms provide a visual representation of trend strength and intensity.
- Horizontal Thresholds act as "fences," helping the trader stay disciplined by identifying when the market is stretched too far in one direction or is entering a confirmed trend state.
//+--------------------------------------------------------------------------------+
//| RSIOMAv2HLS22 Kalenzo fxtsd.com |
//| HistLevel/Sig mod Copyright © 2004, MetaQuotes Software Corp. |
//| FXtsd.com web: http://www.fxservice.eu |
//| email: bartlomiej.gorski@gmail.com |
//+--------------------------------------------------------------------------------+
/* The base for this indicator was orginal RSI attached with Metatrader.Hornet*/
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_minimum -15
#property indicator_maximum 105
#property indicator_buffers 6
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Magenta
#property indicator_color5 DodgerBlue
#property indicator_color6 BlueViolet
#property indicator_width1 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_level1 80
#property indicator_level2 50
#property indicator_level3 20
//---- input parameters
extern int RSIOMA = 14;
extern int RSIOMA_MODE = MODE_EMA;
extern int RSIOMA_PRICE = PRICE_CLOSE;
extern color RSIOMAColor = BlueViolet;
extern int Ma_RSIOMA = 21,
Ma_RSIOMA_MODE = MODE_EMA;
extern color Ma_RSIOMAColor = Blue;
extern int BuyTrigger = 80;
extern int SellTrigger = 20;
extern color BuyTriggerColor = DodgerBlue;
extern color SellTriggerColor = Magenta;
extern int MainTrendLong = 70;
extern int MainTrendShort = 30;
extern color MainTrendLongColor = Red;
extern color MainTrendShortColor = Green;
extern double MajorTrend = 50;
//---- buffers
double RSIBuffer[];
double PosBuffer[];
double NegBuffer[];
double bdn[],bup[];
double sdn[],sup[];
double marsioma[];
string short_name;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
short_name = StringConcatenate("RSIOMA(",RSIOMA,")");
IndicatorBuffers(8);
SetIndexBuffer(0,RSIBuffer);
SetIndexBuffer(2,bup); //trend lev up
SetIndexBuffer(1,bdn); //trend lev dn
SetIndexBuffer(3,sdn);
SetIndexBuffer(4,sup);
SetIndexBuffer(5,marsioma);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,0,RSIOMAColor);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,0,Ma_RSIOMAColor);
SetIndexBuffer(6,PosBuffer);
SetIndexBuffer(7,NegBuffer);
SetIndexLabel(0,"RSIOMA("+RSIOMA+")");
SetIndexLabel(1,"MainTrandDn");
SetIndexLabel(2,"MainTrandUp");
SetIndexLabel(3,"SigDn");
SetIndexLabel(4,"SigUp");
SetIndexLabel(5,"marsioma("+Ma_RSIOMA+")");
IndicatorShortName(short_name);
SetIndexDrawBegin(0,RSIOMA);
SetIndexDrawBegin(1,RSIOMA);
SetIndexDrawBegin(2,RSIOMA);
SetIndexDrawBegin(3,RSIOMA);
SetIndexDrawBegin(4,RSIOMA);
SetIndexDrawBegin(5,RSIOMA);
SetIndexDrawBegin(6,RSIOMA);
SetIndexDrawBegin(7,RSIOMA);
//----
drawLine(BuyTrigger,"BuyTrigger", BuyTriggerColor);
drawLine(SellTrigger,"SellTrigger", SellTriggerColor );
drawLine(MainTrendLong,"MainTrendLong", MainTrendLongColor );
drawLine(MainTrendShort,"MainTrendShort",MainTrendShortColor );
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive;
//----
if(Bars<=RSIOMA) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=RSIOMA;i++) RSIBuffer[Bars-i]=0.0;
//----
i=Bars-RSIOMA-1;
int ma = i;
if(counted_bars>=RSIOMA) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIOMA-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
double cma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,k);
double pma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,k+1);
rel=cma-pma;
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIOMA;
negative=sumn/RSIOMA;
}
else
{
//---- smoothed moving average
double ccma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i);
double ppma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i+1);
rel=ccma-ppma;
if(rel>0) sump=rel;
else sumn=-rel;
positive=(PosBuffer[i+1]*(RSIOMA-1)+sump)/RSIOMA;
negative=(NegBuffer[i+1]*(RSIOMA-1)+sumn)/RSIOMA;
}
PosBuffer[i]=positive;
NegBuffer[i]=negative;
if(negative==0.0) RSIBuffer[i]=0.0;
else
{
RSIBuffer[i]=100.0-100.0/(1+positive/negative);
bdn[i] = 0;
bup[i] = 0;
sdn[i] = 0;
sup[i] = 0;
if(RSIBuffer[i]>50)
bup[i] = 5;
if(RSIBuffer[i]>MainTrendLong)
bup[i] = 12;
if(RSIBuffer[i]<50)
bdn[i] = -5;
if(RSIBuffer[i]<MainTrendShort)
bdn[i] = -12;
if(RSIBuffer[i]<20 && RSIBuffer[i]>RSIBuffer[i+1])
sup[i] = -5;
if(RSIBuffer[i]>20 && RSIBuffer[i+1]<=20)
sup[i] = 4;
if(RSIBuffer[i+1]<=MainTrendShort && RSIBuffer[i]>MainTrendShort)
sup[i] = 9;
if(RSIBuffer[i]>80 && RSIBuffer[i]<RSIBuffer[i+1])
sdn[i] = 5;
if(RSIBuffer[i+1]>=80 && RSIBuffer[i]<80)
sdn[i] =-4 ;
if(RSIBuffer[i]<MainTrendLong && RSIBuffer[i+1]>=MainTrendLong)
sdn[i] =-9;
}
i--;
}
while(ma>=0)
{
marsioma[ma] = iMAOnArray(RSIBuffer,0,Ma_RSIOMA,0,Ma_RSIOMA_MODE,ma);
ma--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
void drawLine(double lvl,string name, color Col )
{
ObjectDelete(name);
ObjectCreate(name, OBJ_HLINE, WindowFind(short_name), Time[0], lvl,Time[0],lvl);
ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name, OBJPROP_COLOR, Col);
ObjectSet(name,OBJPROP_WIDTH,1);
}
Comments