Special RSI ARROW
Download scriptThis script is a technical analysis tool designed to help traders identify potential momentum shifts and trend reversals by analyzing price action through three distinct layers of filtering. Instead of looking at the price directly, it processes data through a sequence of calculations to smooth out market "noise" and highlight significant movements.
How the Logic Works
1. Data Foundation (RSI Comparison) The core of the logic begins with two Relative Strength Index (RSI) values. The RSI is a standard momentum indicator. By calculating two different versions—one faster and one slower—the script determines the "gap" or difference between these two trends. This helps isolate the strength of the current move relative to the broader trend.
2. Smoothing Layers (Double EMA) To prevent the indicator from reacting to every minor price flicker, the script applies two layers of Exponential Moving Averages (EMA) to that data:
- First Layer: It takes the difference between the two RSIs and creates a moving average of that result.
- Second Layer: It then calculates a second moving average on top of that first smoothed line.
By layering these averages, the tool creates a very stable "signal line" that only moves when there is sustained momentum in the market.
3. Signal Detection (Threshold Trigger) The script does not just signal a change whenever the line moves up or down. It uses a specific mathematical threshold (a "difference" value). A signal is only triggered if the current movement exceeds this specific jump compared to the previous point. This ensures that the signals generated are significant rather than incidental.
4. Visual Execution (Arrows) Once the logic confirms a significant upward or downward momentum shift that meets the required threshold, it places visual markers on your chart:
- Upward Signals: These appear as blue arrows below the price candles when the smoothed momentum breaks upward significantly.
- Downward Signals: These appear as red arrows above the price candles when the smoothed momentum breaks downward significantly.
Summary for Traders
Think of this tool as a "momentum filter." It looks at the difference between two trends, smooths that data out multiple times to remove "jitter," and then watches for a large enough leap in that data to tell you when the market is likely shifting direction. The resulting arrows serve as visual alerts for these specific momentum breakouts.
//+------------------------------------------------------------------+
//| Special_RSI_ARROW.mq4 |
//| Copyright © 2009, leMai |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, leMai"
//----
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Green
#property indicator_color2 White
#property indicator_color3 Blue
#property indicator_color4 LimeGreen
#property indicator_color5 Red
//----
extern int RSIPeriod1 = 14;
extern int RSIPeriod2 = 28;
extern int Cross1 = 10;
extern double difference = 2.0;
extern int Magic = 1;
extern bool Draw_Arrow = true;
extern int WidthArrow = 1;
extern int ArrowUp = 233;
extern int ArrowDown = 234;
extern color colorup = DodgerBlue;
extern color colordown = Red;
double ind_buffer1[];
double MABuffer1[];
double Cross[];
double UpArrow[];
double DnArrow[];
double now=1,last=0;
int direction=0;
int count;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(3, DRAW_ARROW);
SetIndexArrow(3, 233);
SetIndexStyle(4, DRAW_ARROW);
SetIndexArrow(4, 234);
//----
SetIndexBuffer(0, ind_buffer1);
SetIndexBuffer(1, MABuffer1);
SetIndexBuffer(2, Cross);
SetIndexBuffer(3, UpArrow);
SetIndexBuffer(4, DnArrow);
//----
IndicatorShortName(WindowExpertName()+"("+Magic+")");
Comment("leMai");
return(0);
}
int deinit(){
DeleteObjects();
ObjectsDeleteAll(0,OBJ_ARROW);
return(0);}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
DeleteObjects();
double RSI1,RSI2;
int Limit, i, counted_bars = IndicatorCounted();
//----
if(counted_bars < 0)
return(-1);
//----
if(counted_bars > 0)
counted_bars--;
Limit=ArraySize(MABuffer1);
for(i=Limit; i>=0; i--)
{
RSI1 = iRSI(NULL, 0, RSIPeriod1, PRICE_CLOSE, i);
RSI2 = iRSI(NULL, 0, RSIPeriod2, PRICE_CLOSE, i);
MABuffer1[i] = (RSI1-RSI2);
}
for(i=Limit; i>=0; i--)
{
ind_buffer1[i] = iMAOnArray(MABuffer1,0,14,0,MODE_EMA,i);
}
for(i=Limit; i>=0; i--)
{
Cross[i]=iMAOnArray(ind_buffer1,Bars,Cross1,0,MODE_EMA,i);
now=Cross[i];
if(now>(last+(difference/1000)))
{
if(direction<1)
{
if (Draw_Arrow ){
DrawArrow(i,"Up" );
}
UpArrow[i]=Cross[i];
direction=1;
}
}
else
if(now<(last-(difference/1000)))
{
if(direction>-1)
{
if (Draw_Arrow ){
DrawArrow(i,"Down" );
}
DnArrow[i]=Cross[i];
direction=-1;
}
}
last=Cross[i];
}
for(i=Limit; i>=0; i--)
{
MABuffer1[i]=0;
}
return(0);
}
///////////////////////////////////////////////
// DrawArrowFunction //
/////////////////////////////////////////////
void DrawArrow(int i,string type)
{ count++;
string name = StringConcatenate(WindowExpertName(),count);
ObjectCreate(name+Magic,OBJ_ARROW,0,Time[i],0);
if (type=="Up")
{
ObjectSet(name+Magic,OBJPROP_PRICE1,Low[i]-iATR(NULL,0,20,i)/2.0);
ObjectSet(name+Magic,OBJPROP_ARROWCODE,ArrowUp);
ObjectSet(name+Magic,OBJPROP_COLOR,colorup);
ObjectSet(name+Magic,OBJPROP_WIDTH,WidthArrow);
}
else if (type=="Down")
{
ObjectSet(name+Magic,OBJPROP_PRICE1,High[i]+ iATR(NULL,0,20,i)/2.0);
ObjectSet(name+Magic,OBJPROP_ARROWCODE,ArrowDown);
ObjectSet(name+Magic,OBJPROP_WIDTH,WidthArrow);
ObjectSet(name+Magic,OBJPROP_COLOR,colordown);
}
}
///////////////////////////////////////////////
// DeleteFunction //
/////////////////////////////////////////////
void DeleteObjects()
{
while(count>0) {
ObjectDelete(StringConcatenate(WindowExpertName(),count));
count--; }
}
//+------------------------------------------------------------------+
Comments