ARROW_RSI-8_CROSS-55 45_v2
Download scriptStrategy Overview
This script is a specialized trading indicator designed to identify potential momentum shifts in the market by monitoring the Relative Strength Index (RSI). Instead of using standard overbought or oversold levels, this tool focuses on specific "crossover" zones (specifically the 45 and 55 marks) to signal when price momentum is gaining strength in a particular direction.
How the Logic Works
1. Momentum Monitoring The indicator constantly calculates the RSI based on a user-defined period (defaulting to 8). It looks for two specific conditions:
- Bullish Momentum: When the RSI value climbs above 55.
- Bearish Momentum: When the RSI value drops below 45.
2. Visual Signaling (Arrows) To make these signals easy to see on your price chart, the script places visual arrows:
- Buy Signals: A green arrow appears below the candle when the momentum shifts into the bullish zone (above 55), provided it hasn't already signaled a buy recently.
- Sell Signals: A red arrow appears above the candle when the momentum shifts into the bearish zone (below 45), provided it hasn't already signaled a sell recently.
3. Intelligent Signal Filtering A key feature of this script is its "Cancel and Re-enter" logic. To prevent the chart from being cluttered with repetitive arrows, the script keeps track of the current active signal:
- If a Buy signal is active but the RSI momentum fails to stay in the "Buy zone," the script resets.
- This ensures that an arrow only appears when a definitive move into the target zone occurs, and it allows the indicator to "reset" itself to provide a fresh signal if the trend resumes.
4. Multi-Timeframe Compatibility The tool is built to be flexible. It includes logic to handle various timeframes (from 1-minute charts up to Monthly charts). It automatically adjusts its calculations based on the timeframe you are currently viewing, ensuring the data remains consistent regardless of your zoom level.
5. Real-Time Notifications Beyond just visual arrows, the script is equipped with an alert system. When a new Buy or Sell signal is confirmed:
- Pop-up Alerts: A text notification will appear on your screen identifying the specific currency pair and timeframe.
- Audio Feedback: The script will play a specific sound file (Buy or Sell) to provide immediate audible confirmation of the market move.
Summary for the User
This tool acts as a momentum filter. It ignores minor price fluctuations and only highlights significant movements where the RSI breaches the 45/55 thresholds. It is designed to give traders a clear, "at-a-glance" view of whether the current trend is leaning aggressively toward the upside or the downside.
//+------------------------------------------------------------------+
//| ARROW_RSI_CROSS50.mq4
//+------------------------------------------------------------------+
/* Modified by Zen_Leow
1. To ensure only one alert per cross
2. Tidied up the codes
*/
#property copyright "AHGduP"
#property link "ARROW_RSI_CROSS-70"
#property indicator_chart_window
#include <WinUser32.mqh>
#property indicator_buffers 2
#property indicator_color1 LimeGreen //LimeGreen
#property indicator_width1 1
#property indicator_color2 Red //Red
#property indicator_width2 1
//====================================================
extern int TF = 0 ;
extern string RSI = "== RSI ===";
extern int RSIPeriod = 8 ; //14
//====================================================
extern bool Alarm_On = True ;
extern int Move_Arrow = 10 ;
extern int CountBars = 500 ;//500
bool StepTF_Up = true;
double RSI1_up , RSI1_dn ;
double up1, down1 ;
double bBuffer1[];
double sBuffer1[];
datetime LastAlertTime = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW,0, 2);//LineSize);
SetIndexBuffer(0,bBuffer1);
SetIndexEmptyValue(0,0);
SetIndexArrow(0,233);// 233
SetIndexStyle(1,DRAW_ARROW,0, 2);//LineSize);
SetIndexBuffer(1,sBuffer1);
SetIndexEmptyValue(1,0);
SetIndexArrow(1,234);//234
up1 = 0 ;
down1 = 0 ;
//========================================================================================
switch(TF)
{
case 1 : string TimeFrameStr60="Period_M1"; break;
case 5 : TimeFrameStr60="Period_M5"; break;
case 15 : TimeFrameStr60="Period_M15"; break;
case 30 : TimeFrameStr60="Period_M30"; break;
case 60 : TimeFrameStr60="Period_H1"; break;
case 240 : TimeFrameStr60="Period_H4"; break;
case 1440 : TimeFrameStr60="Period_D1"; break;
case 10080 : TimeFrameStr60="Period_W1"; break;
case 43200 : TimeFrameStr60="Period_MN1"; break;
default : TimeFrameStr60="Current Timeframe";
SetStepTF_Up();
}
//=======================================================================================
string ThisName = "Rsi_55/45";// Rsi_246 ???
string Text=ThisName;
Text=Text+" ("+TF;
Text=Text+")";
Text=Text+"( ";
Text=Text+" "+DoubleToStr(RSIPeriod,0);
Text=Text+") ";
IndicatorShortName(Text);
return(0);
}
//+--------------------------------------------------------------------------------------+
int start()
{
static int last_bar = 0;
if(last_bar==Bars) return (0);
last_bar = Bars;
int limit,y=0,counted_bars=IndicatorCounted();
limit=Bars-counted_bars+TF/Period();
if(counted_bars>0) limit++; else if (limit>100) limit=CountBars;
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
for(int i=CountBars;i>0;i--)
{
int p1;
p1 = iBarShift( NULL, TF, Time[i], false );
bBuffer1[i] = EMPTY_VALUE;
sBuffer1[i] = EMPTY_VALUE;
//=================================================================================================
//===================== RSI 55 / 45 =============================================================
double RSI1_rsi = iRSI(NULL,TF,RSIPeriod,PRICE_CLOSE,p1);
if ((RSI1_rsi > 55))
{
RSI1_up = 1;
RSI1_dn = 0;
}// <<<<<<<<<< NB >>>>>>>>>>>>
if ((RSI1_rsi < 45))
{
RSI1_up = 0;
RSI1_dn = 1;
}// NB
//====================================================================================================
//======== ARROWS ARROWS ARROWS ARROWS ARROWS ARROWS ARROWS ==============================
if( up1 == 0 && RSI1_up == 1)
{
bBuffer1[i] = Low[i]- Move_Arrow*Point;
up1 = 1;
down1 = 0;
}
//-------------------------------------------------------------------------------------------------
if( down1 == 0 && RSI1_dn == 1)
{
sBuffer1[i] = High[i]+ Move_Arrow*Point;
down1 = 1;
up1 = 0;
}
//===========cancel signal and re enter in same direction===========================
if ( up1 == 1 && RSI1_up != 1 )
{
up1 = 0;
down1 = 0;
}
if ( down1 == 1 && RSI1_dn != 1 )
{
up1 = 0;
down1 = 0;
}
//=====================================================================================
}
if (Alarm_On)
{
ProcessAlert();
}
return(0);
}
//========================step timeframe up TF60====================================== ++
void SetValues60(int p1)
{
TF = p1;
}
void SetStepTF_Up()
{
switch (Period())
{
case PERIOD_M1 : SetValues60(PERIOD_M1); break;
case PERIOD_M5 : SetValues60(PERIOD_M5); break;
case PERIOD_M15 : SetValues60(PERIOD_M15); break;
case PERIOD_M30 : SetValues60(PERIOD_M30); break;
case PERIOD_H1 : SetValues60(PERIOD_H1); break;
case PERIOD_H4 : SetValues60(PERIOD_H4); break;
case PERIOD_D1 : SetValues60(PERIOD_D1); break;
case PERIOD_W1 : SetValues60(PERIOD_W1); break;
case PERIOD_MN1 : SetValues60(PERIOD_MN1); break;
}
}
void ProcessAlert()
{
if (bBuffer1[1] != EMPTY_VALUE && LastAlertTime != Time[0])
{
Alert(Symbol() + " M("+Period()+") - VM BUY");
PlaySound("RSI_CROSS+CCI+BUY.wav");
LastAlertTime = Time[0];
}
if (sBuffer1[1] != EMPTY_VALUE && LastAlertTime != Time[0])
{
Alert(Symbol() + " M("+Period()+") - VM SELL");
PlaySound("RSI_CROSS+CCI+SELL.wav");
LastAlertTime = Time[0];
}
}
//================================================================================== ++
Comments